Script.ScriptType: Use stable id for persistence, rather than ordinal().

This commit is contained in:
Andreas Schildbach 2018-03-05 22:04:00 +01:00
parent c337970ca8
commit d231bade1f
2 changed files with 13 additions and 8 deletions

View File

@ -56,13 +56,18 @@ public class Script {
/** Enumeration to encapsulate the type of this script. */
public enum ScriptType {
// Do NOT change the ordering of the following definitions because their ordinals are stored in databases.
NO_TYPE,
P2PKH, // pay to pubkey hash (aka pay to address)
P2PK, // pay to pubkey
P2SH, // pay to script hash
P2WPKH, // pay to witness pubkey hash
P2WSH, // pay to witness script hash
NO_TYPE(0),
P2PKH(1), // pay to pubkey hash (aka pay to address)
P2PK(2), // pay to pubkey
P2SH(3), // pay to script hash
P2WPKH(4), // pay to witness pubkey hash
P2WSH(5); // pay to witness script hash
public final int id;
private ScriptType(int id) {
this.id = id;
}
}
/** Flags to pass to {@link Script#correctlySpends(Transaction, long, Script, Set)}.

View File

@ -959,7 +959,7 @@ public abstract class DatabaseFullPrunedBlockStore implements FullPrunedBlockSto
s.setLong(4, out.getValue().value);
s.setBytes(5, out.getScript().getProgram());
s.setString(6, out.getAddress());
s.setInt(7, out.getScript().getScriptType().ordinal());
s.setInt(7, out.getScript().getScriptType().id);
s.setBoolean(8, out.isCoinbase());
s.executeUpdate();
s.close();