diff --git a/core/src/main/java/org/bitcoinj/script/Script.java b/core/src/main/java/org/bitcoinj/script/Script.java index 616c6b36a..c64a4f314 100644 --- a/core/src/main/java/org/bitcoinj/script/Script.java +++ b/core/src/main/java/org/bitcoinj/script/Script.java @@ -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)}. diff --git a/core/src/main/java/org/bitcoinj/store/DatabaseFullPrunedBlockStore.java b/core/src/main/java/org/bitcoinj/store/DatabaseFullPrunedBlockStore.java index 2b0018594..025b516c5 100644 --- a/core/src/main/java/org/bitcoinj/store/DatabaseFullPrunedBlockStore.java +++ b/core/src/main/java/org/bitcoinj/store/DatabaseFullPrunedBlockStore.java @@ -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();