@Test public void testIsSentToMultisigFailure() { Script evil = new ScriptBuilder() .op(0xff) .op(0xff) .op(0xff) .op(OP_CHECKMULTISIG) .build(); assertFalse(ScriptPattern.isSentToMultisig(evil)); }
public static boolean isSentToMultisig(Script script) { List<ScriptChunk> chunks = script.chunks; if (chunks.size() < 4) return false; ScriptChunk chunk = chunks.get(chunks.size() - 1); if (!(chunk.equalsOpCode(OP_CHECKMULTISIG) || chunk.equalsOpCode(OP_CHECKMULTISIGVERIFY))) return false; int nOpCode = chunks.get(chunks.size() - 2).opcode; if (nOpCode < OP_1 || nOpCode > OP_16) return false; int numKeys = decodeFromOpN(nOpCode); if (numKeys < 1 || chunks.size() != 3 + numKeys) return false; for (int i = 1; i < chunks.size() - 2; i++) { if (chunks.get(i).isOpCode()) return false; } int mOpCode = chunks.get(0).opcode; return mOpCode >= OP_1 && mOpCode <= OP_16; }
ScriptPattern { public static boolean isSentToMultisig(Script script) { List<ScriptChunk> chunks = script.chunks; if (chunks.size() < 4) return false; ScriptChunk chunk = chunks.get(chunks.size() - 1); if (!(chunk.equalsOpCode(OP_CHECKMULTISIG) || chunk.equalsOpCode(OP_CHECKMULTISIGVERIFY))) return false; int nOpCode = chunks.get(chunks.size() - 2).opcode; if (nOpCode < OP_1 || nOpCode > OP_16) return false; int numKeys = decodeFromOpN(nOpCode); if (numKeys < 1 || chunks.size() != 3 + numKeys) return false; for (int i = 1; i < chunks.size() - 2; i++) { if (chunks.get(i).isOpCode()) return false; } int mOpCode = chunks.get(0).opcode; return mOpCode >= OP_1 && mOpCode <= OP_16; } }
ScriptPattern { public static boolean isSentToMultisig(Script script) { List<ScriptChunk> chunks = script.chunks; if (chunks.size() < 4) return false; ScriptChunk chunk = chunks.get(chunks.size() - 1); if (!(chunk.equalsOpCode(OP_CHECKMULTISIG) || chunk.equalsOpCode(OP_CHECKMULTISIGVERIFY))) return false; int nOpCode = chunks.get(chunks.size() - 2).opcode; if (nOpCode < OP_1 || nOpCode > OP_16) return false; int numKeys = decodeFromOpN(nOpCode); if (numKeys < 1 || chunks.size() != 3 + numKeys) return false; for (int i = 1; i < chunks.size() - 2; i++) { if (chunks.get(i).isOpCode()) return false; } int mOpCode = chunks.get(0).opcode; return mOpCode >= OP_1 && mOpCode <= OP_16; }  }
ScriptPattern { public static boolean isSentToMultisig(Script script) { List<ScriptChunk> chunks = script.chunks; if (chunks.size() < 4) return false; ScriptChunk chunk = chunks.get(chunks.size() - 1); if (!(chunk.equalsOpCode(OP_CHECKMULTISIG) || chunk.equalsOpCode(OP_CHECKMULTISIGVERIFY))) return false; int nOpCode = chunks.get(chunks.size() - 2).opcode; if (nOpCode < OP_1 || nOpCode > OP_16) return false; int numKeys = decodeFromOpN(nOpCode); if (numKeys < 1 || chunks.size() != 3 + numKeys) return false; for (int i = 1; i < chunks.size() - 2; i++) { if (chunks.get(i).isOpCode()) return false; } int mOpCode = chunks.get(0).opcode; return mOpCode >= OP_1 && mOpCode <= OP_16; }  static boolean isP2PKH(Script script); static byte[] extractHashFromP2PKH(Script script); static boolean isP2SH(Script script); static byte[] extractHashFromP2SH(Script script); static boolean isP2PK(Script script); static byte[] extractKeyFromP2PK(Script script); static boolean isP2WH(Script script); static boolean isP2WPKH(Script script); static boolean isP2WSH(Script script); static byte[] extractHashFromP2WH(Script script); static boolean isSentToMultisig(Script script); static boolean isOpReturn(Script script); static boolean isWitnessCommitment(Script script); static Sha256Hash extractWitnessCommitmentHash(Script script); }
ScriptPattern { public static boolean isSentToMultisig(Script script) { List<ScriptChunk> chunks = script.chunks; if (chunks.size() < 4) return false; ScriptChunk chunk = chunks.get(chunks.size() - 1); if (!(chunk.equalsOpCode(OP_CHECKMULTISIG) || chunk.equalsOpCode(OP_CHECKMULTISIGVERIFY))) return false; int nOpCode = chunks.get(chunks.size() - 2).opcode; if (nOpCode < OP_1 || nOpCode > OP_16) return false; int numKeys = decodeFromOpN(nOpCode); if (numKeys < 1 || chunks.size() != 3 + numKeys) return false; for (int i = 1; i < chunks.size() - 2; i++) { if (chunks.get(i).isOpCode()) return false; } int mOpCode = chunks.get(0).opcode; return mOpCode >= OP_1 && mOpCode <= OP_16; }  static boolean isP2PKH(Script script); static byte[] extractHashFromP2PKH(Script script); static boolean isP2SH(Script script); static byte[] extractHashFromP2SH(Script script); static boolean isP2PK(Script script); static byte[] extractKeyFromP2PK(Script script); static boolean isP2WH(Script script); static boolean isP2WPKH(Script script); static boolean isP2WSH(Script script); static byte[] extractHashFromP2WH(Script script); static boolean isSentToMultisig(Script script); static boolean isOpReturn(Script script); static boolean isWitnessCommitment(Script script); static Sha256Hash extractWitnessCommitmentHash(Script script);  }