@Test public void testScriptShouldReturnTrue () throws Exception { byte[] script = Tools.hexStringToByteArray ("A905AABBCCDDEE87630C04928400827100743892481767040879668868527C1D0987093827AA980083A9FF89113947892811990283990428406678096552AE"); byte[] p1 = Tools.hexStringToByteArray("aa bb cc dd ee"); byte[] p2 = Tools.hexStringToByteArray("04 92 84 00 82 71 00 74 38 92 48 17"); byte[] p3 = Tools.hexStringToByteArray("08 79 66 88"); byte[] p4 = Tools.hexStringToByteArray("09 87 09 38 27 aa 98 00 83 a9 ff 89 11 39 47 89 28 11 99 02 83 99 04 28 40 66 78 09 65"); assertTrue(ScriptTools.testScript(script, ScriptTools.ANCHOR_OUTPUT_SCRIPT, p1, p2, p3, p4)); }
public static boolean testScript (byte[] script, byte[] template, byte[]... parameters) { Script s = new Script(script); List<ScriptChunk> chunks = s.getChunks(); int parameter = 0; for (int i = 0; i < chunks.size(); i++) { boolean correct = false; ScriptChunk chunk = chunks.get(i); byte templateChunk = template[i]; int op = templateChunk; if (op < 0) { op = op + 256; } if (op == 255) { if (chunk.isPushData()) { if (Arrays.equals(chunk.data, parameters[parameter])) { parameter++; correct = true; } } } else { if (chunk.opcode == op) { correct = true; } } if (!correct) { return false; } } return true; }
ScriptTools { public static boolean testScript (byte[] script, byte[] template, byte[]... parameters) { Script s = new Script(script); List<ScriptChunk> chunks = s.getChunks(); int parameter = 0; for (int i = 0; i < chunks.size(); i++) { boolean correct = false; ScriptChunk chunk = chunks.get(i); byte templateChunk = template[i]; int op = templateChunk; if (op < 0) { op = op + 256; } if (op == 255) { if (chunk.isPushData()) { if (Arrays.equals(chunk.data, parameters[parameter])) { parameter++; correct = true; } } } else { if (chunk.opcode == op) { correct = true; } } if (!correct) { return false; } } return true; } }
ScriptTools { public static boolean testScript (byte[] script, byte[] template, byte[]... parameters) { Script s = new Script(script); List<ScriptChunk> chunks = s.getChunks(); int parameter = 0; for (int i = 0; i < chunks.size(); i++) { boolean correct = false; ScriptChunk chunk = chunks.get(i); byte templateChunk = template[i]; int op = templateChunk; if (op < 0) { op = op + 256; } if (op == 255) { if (chunk.isPushData()) { if (Arrays.equals(chunk.data, parameters[parameter])) { parameter++; correct = true; } } } else { if (chunk.opcode == op) { correct = true; } } if (!correct) { return false; } } return true; }  }
ScriptTools { public static boolean testScript (byte[] script, byte[] template, byte[]... parameters) { Script s = new Script(script); List<ScriptChunk> chunks = s.getChunks(); int parameter = 0; for (int i = 0; i < chunks.size(); i++) { boolean correct = false; ScriptChunk chunk = chunks.get(i); byte templateChunk = template[i]; int op = templateChunk; if (op < 0) { op = op + 256; } if (op == 255) { if (chunk.isPushData()) { if (Arrays.equals(chunk.data, parameters[parameter])) { parameter++; correct = true; } } } else { if (chunk.opcode == op) { correct = true; } } if (!correct) { return false; } } return true; }  static Script getChannelTxOutputPaymentSending(ECKey keyServer, ECKey keyClient,
                                                           RevocationHash revocationHash, PaymentSecret secret, int refundTimeout); static Script getChannelTxOutputPaymentReceiving(ECKey keyServer, ECKey keyClient,
                                                             RevocationHash revocationHash, PaymentSecret secret, int refundTimeout); static Script getPaymentTxOutput(ECKey keyReceiver, ECKey keyRevocation, RevocationHash revocationHash, int revocationTimeout); static Script getAnchorOutputScript(byte[] secretServerHash, ECKey keyClient, ECKey keyClientA, ECKey keyServer); static Script getEscapeInputScript(byte[] signatureClientA, byte[] signatureServer, byte[] secretServer, byte[] secretServerHash, ECKey
            keyClient, ECKey keyClientA, ECKey keyServer); static Script getCommitInputScript(byte[] signatureClient, byte[] signatureServer, byte[] secretServerHash, ECKey
            keyClient, ECKey keyClientA, ECKey keyServer); static Script getEscapeOutputScript(byte[] revocationHashServer, ECKey keyServer, ECKey keyClient, int revocationDelay); static Script getEscapeInputRevocationScript(byte[] revocationHashServer, ECKey keyServer, ECKey keyClient, int revocationDelay, byte[]
            signatureClient, byte[] revocationClient); static Script getEscapeInputTimeoutScript(byte[] revocationHashServer, ECKey keyServer, ECKey keyClient, int revocationDelay, byte[]
            signatureServer); static Script getFastEscapeOutputScript(byte[] secretHashClient, ECKey keyServer, ECKey keyClient, int revocationDelay); static Script getFastEscapeInputSecretScript(byte[] secretClientHash, ECKey keyServer, ECKey keyClient, int revocationDelay, byte[]
            signatureServer, byte[] secretClient); static Script getFastEscapeInputTimeoutScript(byte[] secretClientHash, ECKey keyServer, ECKey keyClient, int revocationDelay, byte[]
            signatureClient); static Script getChannelTxOutputRevocation(RevocationHash revocationHash, ECKey keyServer, ECKey keyClient, int revocationDelay); static Script getChannelTxOutputPlain(ECKey keyClient); static Script getChannelTxOutputSending(RevocationHash revocationHash, PaymentData paymentData, ECKey keyServer, ECKey keyClient); static Script getChannelTxOutputReceiving(RevocationHash revocationHash, PaymentData paymentData, ECKey keyServer, ECKey keyClient); static Script produceScript(byte[] template, byte[]... parameters); static boolean testScript(byte[] script, byte[] template, byte[]... parameters); static byte[] integerToByteArray(int i); }
ScriptTools { public static boolean testScript (byte[] script, byte[] template, byte[]... parameters) { Script s = new Script(script); List<ScriptChunk> chunks = s.getChunks(); int parameter = 0; for (int i = 0; i < chunks.size(); i++) { boolean correct = false; ScriptChunk chunk = chunks.get(i); byte templateChunk = template[i]; int op = templateChunk; if (op < 0) { op = op + 256; } if (op == 255) { if (chunk.isPushData()) { if (Arrays.equals(chunk.data, parameters[parameter])) { parameter++; correct = true; } } } else { if (chunk.opcode == op) { correct = true; } } if (!correct) { return false; } } return true; }  static Script getChannelTxOutputPaymentSending(ECKey keyServer, ECKey keyClient,
                                                           RevocationHash revocationHash, PaymentSecret secret, int refundTimeout); static Script getChannelTxOutputPaymentReceiving(ECKey keyServer, ECKey keyClient,
                                                             RevocationHash revocationHash, PaymentSecret secret, int refundTimeout); static Script getPaymentTxOutput(ECKey keyReceiver, ECKey keyRevocation, RevocationHash revocationHash, int revocationTimeout); static Script getAnchorOutputScript(byte[] secretServerHash, ECKey keyClient, ECKey keyClientA, ECKey keyServer); static Script getEscapeInputScript(byte[] signatureClientA, byte[] signatureServer, byte[] secretServer, byte[] secretServerHash, ECKey
            keyClient, ECKey keyClientA, ECKey keyServer); static Script getCommitInputScript(byte[] signatureClient, byte[] signatureServer, byte[] secretServerHash, ECKey
            keyClient, ECKey keyClientA, ECKey keyServer); static Script getEscapeOutputScript(byte[] revocationHashServer, ECKey keyServer, ECKey keyClient, int revocationDelay); static Script getEscapeInputRevocationScript(byte[] revocationHashServer, ECKey keyServer, ECKey keyClient, int revocationDelay, byte[]
            signatureClient, byte[] revocationClient); static Script getEscapeInputTimeoutScript(byte[] revocationHashServer, ECKey keyServer, ECKey keyClient, int revocationDelay, byte[]
            signatureServer); static Script getFastEscapeOutputScript(byte[] secretHashClient, ECKey keyServer, ECKey keyClient, int revocationDelay); static Script getFastEscapeInputSecretScript(byte[] secretClientHash, ECKey keyServer, ECKey keyClient, int revocationDelay, byte[]
            signatureServer, byte[] secretClient); static Script getFastEscapeInputTimeoutScript(byte[] secretClientHash, ECKey keyServer, ECKey keyClient, int revocationDelay, byte[]
            signatureClient); static Script getChannelTxOutputRevocation(RevocationHash revocationHash, ECKey keyServer, ECKey keyClient, int revocationDelay); static Script getChannelTxOutputPlain(ECKey keyClient); static Script getChannelTxOutputSending(RevocationHash revocationHash, PaymentData paymentData, ECKey keyServer, ECKey keyClient); static Script getChannelTxOutputReceiving(RevocationHash revocationHash, PaymentData paymentData, ECKey keyServer, ECKey keyClient); static Script produceScript(byte[] template, byte[]... parameters); static boolean testScript(byte[] script, byte[] template, byte[]... parameters); static byte[] integerToByteArray(int i); static final boolean CLTV_CSV_ENABLED; static final byte[] ANCHOR_OUTPUT_SCRIPT; static final byte[] ESCAPE_INPUT_SCRIPT; static final byte[] COMMIT_INPUT_SCRIPT; static final byte[] ESCAPE_OUTPUT_SCRIPT; static final byte[] ESCAPE_OUTPUT_SCRIPT_WITHOUT_CSV; static final byte[] ESCAPE_INPUT_REVOCATION_SCRIPT; static final byte[] ESCAPE_INPUT_TIMEOUT_SCRIPT; static final byte[] FAST_ESCAPE_OUTPUT_SCRIPT; static final byte[] FAST_ESCAPE_OUTPUT_SCRIPT_WITHOUT_CSV; static final byte[] FAST_ESCAPE_INPUT_SECRET_SCRIPT; static final byte[] FAST_ESCAPE_INPUT_TIMEOUT_SCRIPT; static final byte[] CHANNEL_TX_OUTPUT_REVOCATION; static final byte[] CHANNEL_TX_OUTPUT_PLAIN; static final byte[] CHANNEL_TX_OUTPUT_PAYMENT_SENDING_ONE; static final byte[] CHANNEL_TX_OUTPUT_PAYMENT_RECEIVING_ONE; static final byte[] CHANNEL_TX_INPUT_PAYMENT_SENDING_TIMEOUT; static final byte[] CHANNEL_TX_INPUT_PAYMENT_SENDING_REDEEM; static final byte[] CHANNEL_TX_INPUT_PAYMENT_SENDING_STEAL; static final byte[] CHANNEL_TX_INPUT_PAYMENT_RECEIVING_TIMEOUT; static final byte[] CHANNEL_TX_INPUT_PAYMENT_RECEIVING_REDEEM; static final byte[] CHANNEL_TX_INPUT_PAYMENT_RECEIVING_STEAL; static final byte[] CHANNEL_TX_OUTPUT_PAYMENT_TWO; static final byte[] CHANNEL_TX_OUTPUT_PAYMENT_SENDING_ONEa; static final byte[] CHANNEL_TX_OUTPUT_MULTISIG1; static final byte[] CHANNEL_TX_OUTPUT_PAYMENT_SENDING; static final byte[] CHANNEL_TX_OUTPUT_PAYMENT_RECEIVING; }