From ff68116ee9e8501561d951d87f15198a4bad3f19 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Thu, 15 Dec 2016 11:12:26 +1100 Subject: [PATCH] tests: separate templates and script tests --- test/fixtures/script.json | 512 ++++++----------------------------- test/fixtures/templates.json | 499 ++++++++++++++++++++++++++++++++++ test/script.js | 134 +++------ test/templates.js | 178 ++++++------ 4 files changed, 718 insertions(+), 605 deletions(-) create mode 100644 test/fixtures/templates.json diff --git a/test/fixtures/script.json b/test/fixtures/script.json index 2335b1b..89456c9 100644 --- a/test/fixtures/script.json +++ b/test/fixtures/script.json @@ -1,75 +1,45 @@ { "valid": [ { - "type": "pubkey", - "pubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1", - "signature": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", - "scriptPubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 OP_CHECKSIG", - "scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", - "scriptSigHex": "47304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", - "scriptPubKeyHex": "2102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1ac", - "pushOnly": false, - "pushOnlySig": true, - "scriptSigStack": [ + "asm": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", + "script": "47304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", + "stack": [ "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801" ] }, { - "type": "pubkeyhash", - "pubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1", - "signature": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", - "scriptPubKey": "OP_DUP OP_HASH160 aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5 OP_EQUALVERIFY OP_CHECKSIG", - "scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1", - "scriptSigHex": "47304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca28012102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1", - "scriptPubKeyHex": "76a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac", - "pushOnly": false, - "pushOnlySig": true, - "scriptSigStack": [ + "asm": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 OP_CHECKSIG", + "script": "2102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1ac" + }, + { + "asm": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1", + "script": "47304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca28012102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1", + "stack": [ "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1" ] }, { - "type": "multisig", - "pubKeys": [ - "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1", - "0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a" - ], - "signatures": [ - "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", - "3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501" - ], - "scriptPubKey": "OP_2 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a OP_2 OP_CHECKMULTISIG", - "scriptSig": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501", - "scriptSigHex": "0047304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801483045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501", - "scriptPubKeyHex": "522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae", - "pushOnly": false, - "pushOnlySig": true, - "scriptSigStack": [ + "asm": "OP_DUP OP_HASH160 aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5 OP_EQUALVERIFY OP_CHECKSIG", + "script": "76a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac" + }, + { + "asm": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501", + "script": "0047304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801483045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501", + "stack": [ "", "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", "3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501" ] }, { - "type": "multisig", - "pubKeys": [ - "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", - "02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340", - "024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34" - ], - "signatures": [ - "3045022100fe324541215798b2df68cbd44039615e23c506d4ec1a05572064392a98196b82022068c849fa6699206da2fc6d7848efc1d3804a5816d6293615fe34c1a7f34e1c2f01", - "3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901", - "3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01" - ], - "scriptPubKey": "OP_3 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34 OP_3 OP_CHECKMULTISIG", - "scriptSig": "OP_0 3045022100fe324541215798b2df68cbd44039615e23c506d4ec1a05572064392a98196b82022068c849fa6699206da2fc6d7848efc1d3804a5816d6293615fe34c1a7f34e1c2f01 3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901 3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01", - "scriptSigHex": "00483045022100fe324541215798b2df68cbd44039615e23c506d4ec1a05572064392a98196b82022068c849fa6699206da2fc6d7848efc1d3804a5816d6293615fe34c1a7f34e1c2f01473044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901483045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01", - "scriptPubKeyHex": "53210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f817982102b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f84834021024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a3453ae", - "pushOnly": false, - "pushOnlySig": true, - "scriptSigStack": [ + "asm": "OP_2 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a OP_2 OP_CHECKMULTISIG", + "script": "522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae" + }, + { + "asm": "OP_0 3045022100fe324541215798b2df68cbd44039615e23c506d4ec1a05572064392a98196b82022068c849fa6699206da2fc6d7848efc1d3804a5816d6293615fe34c1a7f34e1c2f01 3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901 3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01", + "script": "00483045022100fe324541215798b2df68cbd44039615e23c506d4ec1a05572064392a98196b82022068c849fa6699206da2fc6d7848efc1d3804a5816d6293615fe34c1a7f34e1c2f01473044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901483045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01", + "stack": [ "", "3045022100fe324541215798b2df68cbd44039615e23c506d4ec1a05572064392a98196b82022068c849fa6699206da2fc6d7848efc1d3804a5816d6293615fe34c1a7f34e1c2f01", "3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901", @@ -77,16 +47,13 @@ ] }, { - "type": "scripthash", - "redeemScript": "OP_2 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a OP_2 OP_CHECKMULTISIG", - "redeemScriptSig": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501", - "scriptSig": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501 522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae", - "scriptPubKey": "OP_HASH160 722ff0bc2c3f47b35c20df646c395594da24e90e OP_EQUAL", - "scriptSigHex": "0047304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801483045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d14050147522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae", - "scriptPubKeyHex": "a914722ff0bc2c3f47b35c20df646c395594da24e90e87", - "pushOnly": false, - "pushOnlySig": true, - "scriptSigStack": [ + "asm": "OP_3 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34 OP_3 OP_CHECKMULTISIG", + "script": "53210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f817982102b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f84834021024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a3453ae" + }, + { + "asm": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501 522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae", + "script": "0047304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801483045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d14050147522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae", + "stack": [ "", "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", "3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501", @@ -94,52 +61,37 @@ ] }, { - "type": "witnesspubkeyhash", - "pubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1", - "scriptPubKey": "OP_0 aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5", - "scriptPubKeyHex": "0014aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5", - "pushOnly": true + "asm": "OP_HASH160 722ff0bc2c3f47b35c20df646c395594da24e90e OP_EQUAL", + "script": "a914722ff0bc2c3f47b35c20df646c395594da24e90e87" }, { - "type": "witnessscripthash", - "witnessScriptPubKey": "OP_2 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a OP_2 OP_CHECKMULTISIG", - "witnessScriptSig": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501", - "scriptPubKey": "OP_0 32447752937d355ca2defddcd1f6b4fc53d182f8901cebbcff42f5e381bf0b80", - "scriptPubKeyHex": "002032447752937d355ca2defddcd1f6b4fc53d182f8901cebbcff42f5e381bf0b80", - "witness": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501 522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae", - "pushOnly": true + "asm": "OP_0 aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5", + "script": "0014aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5", + "stack": [ + "", + "aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5" + ] }, { - "type": "nulldata", - "data": "06deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474", - "scriptPubKey": "OP_RETURN 06deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474", - "scriptPubKeyHex": "6a2606deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474", - "pushOnly": false + "asm": "OP_0 32447752937d355ca2defddcd1f6b4fc53d182f8901cebbcff42f5e381bf0b80", + "script": "002032447752937d355ca2defddcd1f6b4fc53d182f8901cebbcff42f5e381bf0b80", + "stack": [ + "", + "32447752937d355ca2defddcd1f6b4fc53d182f8901cebbcff42f5e381bf0b80" + ] }, { - "type": "nulldata", - "data": "deadffffffffffffffffffffffffffffffffbeef", - "scriptPubKey": "OP_RETURN deadffffffffffffffffffffffffffffffffbeef", - "scriptPubKeyHex": "6a14deadffffffffffffffffffffffffffffffffbeef", - "pushOnly": false + "asm": "OP_RETURN 06deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474", + "script": "6a2606deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474" }, { - "type": "nonstandard", - "typeIncomplete": "multisig", - "pubKeys": [ - "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", - "02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340", - "024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34" - ], - "signatures": [ - null, - "3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901", - "3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01" - ], - "scriptSig": "OP_0 OP_0 3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901 3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01", - "scriptSigHex": "0000473044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901483045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01", - "pushOnlySig": true, - "scriptSigStack": [ + "asm": "OP_RETURN deadffffffffffffffffffffffffffffffffbeef", + "script": "6a14deadffffffffffffffffffffffffffffffffbeef" + }, + { + "asm": "OP_0 OP_0 3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901 3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01", + "script": "0000473044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901483045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01", + "stack": [ "", "", "3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901", @@ -147,22 +99,9 @@ ] }, { - "type": "nonstandard", - "typeIncomplete": "multisig", - "pubKeys": [ - "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", - "02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340", - "024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34" - ], - "signatures": [ - null, - null, - null - ], - "scriptSig": "OP_0 OP_0 OP_0 OP_0", - "scriptSigHex": "00000000", - "pushOnlySig": true, - "scriptSigStack": [ + "asm": "OP_0 OP_0 OP_0 OP_0", + "script": "00000000", + "stack": [ "", "", "", @@ -170,22 +109,9 @@ ] }, { - "type": "nonstandard", - "typeIncomplete": "scripthash", - "pubKeys": [ - "0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", - "04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a" - ], - "signatures": [ - null, - "30450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a801" - ], - "redeemScript": "OP_2 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a OP_2 OP_CHECKMULTISIG", - "redeemScriptSig": "OP_0 OP_0 30450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a801", - "scriptSig": "OP_0 OP_0 30450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a801 52410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a52ae", - "scriptSigHex": "00004830450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a8014c8752410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a52ae", - "pushOnlySig": true, - "scriptSigStack": [ + "asm": "OP_0 OP_0 30450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a801 52410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a52ae", + "script": "00004830450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a8014c8752410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a52ae", + "stack": [ "", "", "30450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a801", @@ -193,57 +119,43 @@ ] }, { - "type": "nonstandard", - "scriptPubKey": "OP_HASH256 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 OP_EQUAL", - "scriptPubKeyHex": "aa206fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d619000000000087", - "pushOnly": false + "asm": "OP_HASH256 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 OP_EQUAL", + "script": "aa206fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d619000000000087" }, { - "type": "nonstandard", - "scriptPubKey": "OP_0 OP_0 OP_0 OP_CHECKMULTISIG", - "scriptPubKeyHex": "000000ae", - "pushOnly": false + "asm": "OP_0 OP_0 OP_0 OP_CHECKMULTISIG", + "script": "000000ae" }, { - "type": "nonstandard", - "scriptPubKey": "OP_0", - "scriptPubKeyHex": "00", - "pushOnly": true + "asm": "OP_0", + "script": "00", + "stack": [ + "" + ] }, { - "type": "scripthash", - "redeemScript": "OP_0", - "redeemScriptSig": "OP_0", - "scriptSig": "OP_0 00", - "scriptSigHex": "000100", - "pushOnly": true, - "pushOnlySig": true, - "scriptSigStack": [ + "asm": "OP_0 00", + "script": "000100", + "stack": [ "", "00" ] }, { - "type": "nonstandard", - "scriptSig": "OP_6", - "scriptSigHex": "56", + "asm": "OP_6", + "script": "56", + "stack": [ + "06" + ], "nonstandard": { "scriptSig": "06", "scriptSigHex": "0106" - }, - "pushOnly": true, - "pushOnlySig": true, - "scriptSigStack": [ - "06" - ] + } }, { - "type": "nonstandard", - "scriptSig": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "scriptSigHex": "4cff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "pushOnly": true, - "pushOnlySig": true, - "scriptSigStack": [ + "asm": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "script": "4cff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "stack": [ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ] } @@ -252,272 +164,24 @@ "decompile": [ { "description": "Not enough data: OP_1", - "hex": "01" + "script": "01" }, { "description": "Not enough data: OP_2", - "hex": "0201" + "script": "0201" }, { "description": "Not enough data: OP_PUSHDATA1 0x02", - "hex": "4c0201" + "script": "4c0201" }, { "description": "Not enough data: OP_PUSHDATA2 0xffff", - "hex": "4dffff01" + "script": "4dffff01" }, { "description": "Not enough data: OP_PUSHDATA4 0xffffffff", - "hex": "4effffffff01" + "script": "4effffffff01" } - ], - "pubKey": { - "inputs": [ - { - "description": "non-canonical signature (too short)", - "scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf7593" - }, - { - "description": "non-canonical signature (too long)", - "scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca28ffffffff01" - }, - { - "description": "non-canonical signature (invalid hashType)", - "scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca28ff" - } - ], - "outputs": [ - { - "description": "non-canonical pubkey (too short)", - "scriptPubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce OP_CHECKSIG" - }, - { - "description": "non-canonical pubkey (too long)", - "scriptPubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1ffffff OP_CHECKSIG" - }, - { - "description": "last operator is wrong for pubkey-output", - "scriptPubKeyHex": "21027a71801ab59336de37785c50005b6abd8ea859eecce1edbe8e81afa74ee5c752ae" - }, - { - "description": "missing OP_CHECKSIG", - "scriptPubKeyHex": "21027a71801ab59336de37785c50005b6abd8ea859eecce1edbe8e81afa74ee5c752" - }, - { - "description": "non-canonical pubkey (bad prefix)", - "scriptPubKey": "427a71801ab59336de37785c50005b6abd8ea859eecce1edbe8e81afa74ee5c752 OP_CHECKSIG" - }, - { - "description": "has extra opcode at the end isPubKeyOutput", - "scriptPubKey": "027a71801ab59336de37785c50005b6abd8ea859eecce1edbe8e81afa74ee5c752 OP_CHECKSIG OP_0" - } - ] - }, - "pubKeyHash": { - "inputs": [ - { - "description": "pubKeyHash input : extraneous data", - "scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 ffffffff" - } - ], - "outputs": [ - { - "description": "non-minimal encoded isPubKeyHashOutput (non BIP62 compliant)", - "scriptPubKeyHex": "76a94c14aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac" - }, - { - "description": "bad OP_DUP isPubKeyHashOutput", - "scriptPubKeyHex": "aca914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac" - }, - { - "description": "bad OP_HASH160 isPubKeyHashOutput", - "scriptPubKeyHex": "76ac14aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac" - }, - { - "description": "bad OP_EQUALVERIFY isPubKeyHashOutput", - "scriptPubKeyHex": "76a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5acac" - }, - { - "description": "bad OP_CHECKSIG isPubKeyHashOutput", - "scriptPubKeyHex": "76a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c58888" - }, - { - "description": "bad length isPubKeyHashOutput", - "scriptPubKeyHex": "76a920aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac" - }, - { - "description": "has something at the end isPubKeyHashOutput", - "scriptPubKeyHex": "76a920aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac00" - }, - { - "exception": "Expected Buffer\\(Length: 20\\), got Buffer\\(Length: 2\\)", - "hash": "ffff" - } - ] - }, - "scriptHash": { - "inputs": [ - { - "description": "redeemScript not data", - "scriptSig": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501 OP_RESERVED" - }, - { - "description": "redeemScript is a signature, therefore not a valid script", - "scriptSig": "OP_0 3045022100e12b17b3a4c80c401a1687487bd2bafee9e5f1f8f1ffc6180ce186672ad7b43a02205e316d1e5e71822f5ef301b694e578fa9c94af4f5f098c952c833f4691307f4e01" - } - ], - "outputs": [ - { - "description": "non-minimal encoded isScriptHashOutput (non BIP62 compliant)", - "scriptPubKeyHex": "a94c14c286a1af0947f58d1ad787385b1c2c4a976f9e7187" - }, - { - "description": "wrong OP_HASH160 opcode", - "scriptPubKeyHex": "ac4c14c286a1af0947f58d1ad787385b1c2c4a976f9e7187" - }, - { - "description": "wrong length marker", - "scriptPubKeyHex": "a916c286a1af0947f58d1ad787385b1c2c4a976f9e7187" - }, - { - "description": "wrong OP_EQUAL opcode", - "scriptPubKeyHex": "a914c286a1af0947f58d1ad787385b1c2c4a976f9e7188" - }, - { - "exception": "Expected Buffer\\(Length: 20\\), got Buffer\\(Length: 3\\)", - "hash": "ffffff" - } - ] - }, - "multisig": { - "inputs": [ - { - "description": "Not enough signatures provided", - "type": "multisig", - "scriptPubKey": "OP_2 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_2 OP_CHECKMULTISIG", - "signatures": [] - }, - { - "exception": "Not enough signatures provided", - "scriptPubKey": "OP_2 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a OP_2 OP_CHECKMULTISIG", - "signatures": [ - "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801" - ] - }, - { - "exception": "Too many signatures provided", - "scriptPubKey": "OP_2 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a OP_2 OP_CHECKMULTISIG", - "signatures": [ - "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", - "3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501", - "3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501" - ] - } - ], - "outputs": [ - { - "description": "OP_CHECKMULTISIG not found", - "scriptPubKey": "OP_0 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_2 OP_HASH160" - }, - { - "description": "less than 4 chunks", - "scriptPubKey": "OP_0 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 OP_HASH160" - }, - { - "description": "m === 0", - "scriptPubKey": "OP_0 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_2 OP_CHECKMULTISIG" - }, - { - "description": "m < OP_1", - "scriptPubKey": "OP_1NEGATE 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_2 OP_CHECKMULTISIG" - }, - { - "description": "m > OP_16", - "scriptPubKey": "OP_NOP 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_2 OP_CHECKMULTISIG" - }, - { - "description": "n === 0", - "scriptPubKey": "OP_1 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_0 OP_CHECKMULTISIG" - }, - { - "description": "n < OP_1", - "scriptPubKey": "OP_1 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_1NEGATE OP_CHECKMULTISIG" - }, - { - "description": "n > OP_16", - "scriptPubKey": "OP_1 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_NOP OP_CHECKMULTISIG" - }, - { - "description": "n < m", - "scriptPubKey": "OP_2 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_1 OP_CHECKMULTISIG" - }, - { - "description": "n < len(pubKeys)", - "scriptPubKey": "OP_2 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34 OP_2 OP_CHECKMULTISIG" - }, - { - "description": "n > len(pubKeys)", - "scriptPubKey": "OP_1 024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34 OP_2 OP_CHECKMULTISIG" - }, - { - "description": "m is data", - "scriptPubKey": "ffff 024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34 OP_1 OP_CHECKMULTISIG" - }, - { - "description": "n is data", - "scriptPubKey": "OP_1 024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34 ffff OP_CHECKMULTISIG" - }, - { - "description": "non-canonical pubKey (bad length)", - "scriptPubKey": "OP_1 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ffff OP_1 OP_CHECKMULTISIG" - }, - { - "exception": "Not enough pubKeys provided", - "m": 4, - "pubKeys": [ - "02ea1297665dd733d444f31ec2581020004892cdaaf3dd6c0107c615afb839785f", - "02fab2dea1458990793f56f42e4a47dbf35a12a351f26fa5d7e0cc7447eaafa21f", - "036c6802ce7e8113723dd92cdb852e492ebb157a871ca532c3cb9ed08248ff0e19" - ], - "signatures": [ - "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801" - ] - } - ] - }, - "witnessPubKeyHash": { - "inputs": [], - "outputs": [ - { - "description": "wrong version", - "scriptPubKeyHex": "51149090909090909090909090909090909090909090" - }, - { - "description": "wrong length marker", - "scriptPubKeyHex": "00209090909090909090909090909090909090909090" - }, - { - "exception": "Expected Buffer\\(Length: 20\\), got Buffer\\(Length: 3\\)", - "hash": "ffffff" - } - ] - }, - "witnessScriptHash": { - "inputs": [], - "outputs": [ - { - "description": "wrong version", - "scriptPubKeyHex": "51209090909090909090909090909090909090909090909090909090909090909090" - }, - { - "description": "wrong length marker", - "scriptPubKeyHex": "00219090909090909090909090909090909090909090909090909090909090909090" - }, - { - "exception": "Expected Buffer\\(Length: 32\\), got Buffer\\(Length: 3\\)", - "hash": "ffffff" - } - ] - } + ] } -} \ No newline at end of file +} diff --git a/test/fixtures/templates.json b/test/fixtures/templates.json new file mode 100644 index 0000000..1756821 --- /dev/null +++ b/test/fixtures/templates.json @@ -0,0 +1,499 @@ +{ + "valid": [ + { + "type": "pubkey", + "pubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1", + "signature": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", + "output": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 OP_CHECKSIG", + "input": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", + "inputHex": "47304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", + "outputHex": "2102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1ac", + "inputStack": [ + "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801" + ] + }, + { + "type": "pubkeyhash", + "pubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1", + "signature": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", + "output": "OP_DUP OP_HASH160 aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5 OP_EQUALVERIFY OP_CHECKSIG", + "input": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1", + "inputHex": "47304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca28012102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1", + "outputHex": "76a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac", + "pushOnly": false, + "pushOnlySig": true, + "inputStack": [ + "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", + "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1" + ] + }, + { + "type": "multisig", + "pubKeys": [ + "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1", + "0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a" + ], + "signatures": [ + "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", + "3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501" + ], + "output": "OP_2 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a OP_2 OP_CHECKMULTISIG", + "input": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501", + "inputHex": "0047304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801483045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501", + "outputHex": "522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae", + "pushOnly": false, + "pushOnlySig": true, + "inputStack": [ + "", + "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", + "3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501" + ] + }, + { + "type": "multisig", + "pubKeys": [ + "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", + "02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340", + "024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34" + ], + "signatures": [ + "3045022100fe324541215798b2df68cbd44039615e23c506d4ec1a05572064392a98196b82022068c849fa6699206da2fc6d7848efc1d3804a5816d6293615fe34c1a7f34e1c2f01", + "3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901", + "3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01" + ], + "output": "OP_3 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34 OP_3 OP_CHECKMULTISIG", + "input": "OP_0 3045022100fe324541215798b2df68cbd44039615e23c506d4ec1a05572064392a98196b82022068c849fa6699206da2fc6d7848efc1d3804a5816d6293615fe34c1a7f34e1c2f01 3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901 3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01", + "inputHex": "00483045022100fe324541215798b2df68cbd44039615e23c506d4ec1a05572064392a98196b82022068c849fa6699206da2fc6d7848efc1d3804a5816d6293615fe34c1a7f34e1c2f01473044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901483045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01", + "outputHex": "53210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f817982102b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f84834021024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a3453ae", + "pushOnly": false, + "pushOnlySig": true, + "inputStack": [ + "", + "3045022100fe324541215798b2df68cbd44039615e23c506d4ec1a05572064392a98196b82022068c849fa6699206da2fc6d7848efc1d3804a5816d6293615fe34c1a7f34e1c2f01", + "3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901", + "3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01" + ] + }, + { + "type": "scripthash", + "redeemScript": "OP_2 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a OP_2 OP_CHECKMULTISIG", + "redeemScriptSig": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501", + "input": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501 522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae", + "output": "OP_HASH160 722ff0bc2c3f47b35c20df646c395594da24e90e OP_EQUAL", + "inputHex": "0047304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801483045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d14050147522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae", + "outputHex": "a914722ff0bc2c3f47b35c20df646c395594da24e90e87", + "pushOnly": false, + "pushOnlySig": true, + "inputStack": [ + "", + "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", + "3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501", + "522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae" + ] + }, + { + "type": "witnesspubkeyhash", + "pubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1", + "output": "OP_0 aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5", + "outputHex": "0014aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5", + "pushOnly": true + }, + { + "type": "witnessscripthash", + "witnessScriptPubKey": "OP_2 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a OP_2 OP_CHECKMULTISIG", + "witnessScriptSig": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501", + "output": "OP_0 32447752937d355ca2defddcd1f6b4fc53d182f8901cebbcff42f5e381bf0b80", + "outputHex": "002032447752937d355ca2defddcd1f6b4fc53d182f8901cebbcff42f5e381bf0b80", + "witness": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501 522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae", + "pushOnly": true + }, + { + "type": "nulldata", + "data": "06deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474", + "output": "OP_RETURN 06deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474", + "outputHex": "6a2606deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474", + "pushOnly": false + }, + { + "type": "nulldata", + "data": "deadffffffffffffffffffffffffffffffffbeef", + "output": "OP_RETURN deadffffffffffffffffffffffffffffffffbeef", + "outputHex": "6a14deadffffffffffffffffffffffffffffffffbeef", + "pushOnly": false + }, + { + "type": "nonstandard", + "typeIncomplete": "multisig", + "pubKeys": [ + "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", + "02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340", + "024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34" + ], + "signatures": [ + null, + "3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901", + "3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01" + ], + "input": "OP_0 OP_0 3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901 3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01", + "inputHex": "0000473044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901483045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01", + "pushOnlySig": true, + "inputStack": [ + "", + "", + "3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901", + "3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01" + ] + }, + { + "type": "nonstandard", + "typeIncomplete": "multisig", + "pubKeys": [ + "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", + "02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340", + "024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34" + ], + "signatures": [ + null, + null, + null + ], + "input": "OP_0 OP_0 OP_0 OP_0", + "inputHex": "00000000", + "pushOnlySig": true, + "inputStack": [ + "", + "", + "", + "" + ] + }, + { + "type": "nonstandard", + "typeIncomplete": "scripthash", + "pubKeys": [ + "0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", + "04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a" + ], + "signatures": [ + null, + "30450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a801" + ], + "redeemScript": "OP_2 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a OP_2 OP_CHECKMULTISIG", + "redeemScriptSig": "OP_0 OP_0 30450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a801", + "input": "OP_0 OP_0 30450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a801 52410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a52ae", + "inputHex": "00004830450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a8014c8752410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a52ae", + "pushOnlySig": true, + "inputStack": [ + "", + "", + "30450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a801", + "52410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a52ae" + ] + }, + { + "type": "nonstandard", + "output": "OP_HASH256 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 OP_EQUAL", + "outputHex": "aa206fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d619000000000087", + "pushOnly": false + }, + { + "type": "nonstandard", + "output": "OP_0 OP_0 OP_0 OP_CHECKMULTISIG", + "outputHex": "000000ae", + "pushOnly": false + }, + { + "type": "nonstandard", + "output": "OP_0", + "outputHex": "00", + "pushOnly": true + }, + { + "type": "scripthash", + "redeemScript": "OP_0", + "redeemScriptSig": "OP_0", + "input": "OP_0 00", + "inputHex": "000100", + "pushOnly": true, + "pushOnlySig": true, + "inputStack": [ + "", + "00" + ] + }, + { + "type": "nonstandard", + "input": "OP_6", + "inputHex": "56", + "nonstandard": { + "input": "06", + "inputHex": "0106" + }, + "pushOnly": true, + "pushOnlySig": true, + "inputStack": [ + "06" + ] + }, + { + "type": "nonstandard", + "input": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "inputHex": "4cff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "pushOnly": true, + "pushOnlySig": true, + "inputStack": [ + "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "invalid": { + "pubKey": { + "inputs": [ + { + "description": "non-canonical signature (too short)", + "input": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf7593" + }, + { + "description": "non-canonical signature (too long)", + "input": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca28ffffffff01" + }, + { + "description": "non-canonical signature (invalid hashType)", + "input": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca28ff" + } + ], + "outputs": [ + { + "description": "non-canonical pubkey (too short)", + "output": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce OP_CHECKSIG" + }, + { + "description": "non-canonical pubkey (too long)", + "output": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1ffffff OP_CHECKSIG" + }, + { + "description": "last operator is wrong for pubkey-output", + "outputHex": "21027a71801ab59336de37785c50005b6abd8ea859eecce1edbe8e81afa74ee5c752ae" + }, + { + "description": "missing OP_CHECKSIG", + "outputHex": "21027a71801ab59336de37785c50005b6abd8ea859eecce1edbe8e81afa74ee5c752" + }, + { + "description": "non-canonical pubkey (bad prefix)", + "output": "427a71801ab59336de37785c50005b6abd8ea859eecce1edbe8e81afa74ee5c752 OP_CHECKSIG" + }, + { + "description": "has extra opcode at the end isPubKeyOutput", + "output": "027a71801ab59336de37785c50005b6abd8ea859eecce1edbe8e81afa74ee5c752 OP_CHECKSIG OP_0" + } + ] + }, + "pubKeyHash": { + "inputs": [ + { + "description": "pubKeyHash input : extraneous data", + "input": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 ffffffff" + } + ], + "outputs": [ + { + "description": "non-minimal encoded isPubKeyHashOutput (non BIP62 compliant)", + "outputHex": "76a94c14aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac" + }, + { + "description": "bad OP_DUP isPubKeyHashOutput", + "outputHex": "aca914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac" + }, + { + "description": "bad OP_HASH160 isPubKeyHashOutput", + "outputHex": "76ac14aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac" + }, + { + "description": "bad OP_EQUALVERIFY isPubKeyHashOutput", + "outputHex": "76a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5acac" + }, + { + "description": "bad OP_CHECKSIG isPubKeyHashOutput", + "outputHex": "76a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c58888" + }, + { + "description": "bad length isPubKeyHashOutput", + "outputHex": "76a920aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac" + }, + { + "description": "has something at the end isPubKeyHashOutput", + "outputHex": "76a920aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac00" + }, + { + "exception": "Expected Buffer\\(Length: 20\\), got Buffer\\(Length: 2\\)", + "hash": "ffff" + } + ] + }, + "scriptHash": { + "inputs": [ + { + "description": "redeemScript not data", + "input": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501 OP_RESERVED" + }, + { + "description": "redeemScript is a signature, therefore not a valid script", + "input": "OP_0 3045022100e12b17b3a4c80c401a1687487bd2bafee9e5f1f8f1ffc6180ce186672ad7b43a02205e316d1e5e71822f5ef301b694e578fa9c94af4f5f098c952c833f4691307f4e01" + } + ], + "outputs": [ + { + "description": "non-minimal encoded isScriptHashOutput (non BIP62 compliant)", + "outputHex": "a94c14c286a1af0947f58d1ad787385b1c2c4a976f9e7187" + }, + { + "description": "wrong OP_HASH160 opcode", + "outputHex": "ac4c14c286a1af0947f58d1ad787385b1c2c4a976f9e7187" + }, + { + "description": "wrong length marker", + "outputHex": "a916c286a1af0947f58d1ad787385b1c2c4a976f9e7187" + }, + { + "description": "wrong OP_EQUAL opcode", + "outputHex": "a914c286a1af0947f58d1ad787385b1c2c4a976f9e7188" + }, + { + "exception": "Expected Buffer\\(Length: 20\\), got Buffer\\(Length: 3\\)", + "hash": "ffffff" + } + ] + }, + "multisig": { + "inputs": [ + { + "description": "Not enough signatures provided", + "type": "multisig", + "output": "OP_2 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_2 OP_CHECKMULTISIG", + "signatures": [] + }, + { + "exception": "Not enough signatures provided", + "output": "OP_2 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a OP_2 OP_CHECKMULTISIG", + "signatures": [ + "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801" + ] + }, + { + "exception": "Too many signatures provided", + "output": "OP_2 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a OP_2 OP_CHECKMULTISIG", + "signatures": [ + "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801", + "3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501", + "3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501" + ] + } + ], + "outputs": [ + { + "description": "OP_CHECKMULTISIG not found", + "output": "OP_0 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_2 OP_HASH160" + }, + { + "description": "less than 4 chunks", + "output": "OP_0 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 OP_HASH160" + }, + { + "description": "m === 0", + "output": "OP_0 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_2 OP_CHECKMULTISIG" + }, + { + "description": "m < OP_1", + "output": "OP_1NEGATE 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_2 OP_CHECKMULTISIG" + }, + { + "description": "m > OP_16", + "output": "OP_NOP 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_2 OP_CHECKMULTISIG" + }, + { + "description": "n === 0", + "output": "OP_1 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_0 OP_CHECKMULTISIG" + }, + { + "description": "n < OP_1", + "output": "OP_1 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_1NEGATE OP_CHECKMULTISIG" + }, + { + "description": "n > OP_16", + "output": "OP_1 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_NOP OP_CHECKMULTISIG" + }, + { + "description": "n < m", + "output": "OP_2 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_1 OP_CHECKMULTISIG" + }, + { + "description": "n < len(pubKeys)", + "output": "OP_2 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34 OP_2 OP_CHECKMULTISIG" + }, + { + "description": "n > len(pubKeys)", + "output": "OP_1 024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34 OP_2 OP_CHECKMULTISIG" + }, + { + "description": "m is data", + "output": "ffff 024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34 OP_1 OP_CHECKMULTISIG" + }, + { + "description": "n is data", + "output": "OP_1 024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34 ffff OP_CHECKMULTISIG" + }, + { + "description": "non-canonical pubKey (bad length)", + "output": "OP_1 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ffff OP_1 OP_CHECKMULTISIG" + }, + { + "exception": "Not enough pubKeys provided", + "m": 4, + "pubKeys": [ + "02ea1297665dd733d444f31ec2581020004892cdaaf3dd6c0107c615afb839785f", + "02fab2dea1458990793f56f42e4a47dbf35a12a351f26fa5d7e0cc7447eaafa21f", + "036c6802ce7e8113723dd92cdb852e492ebb157a871ca532c3cb9ed08248ff0e19" + ], + "signatures": [ + "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801" + ] + } + ] + }, + "witnessPubKeyHash": { + "inputs": [], + "outputs": [ + { + "description": "wrong version", + "outputHex": "51149090909090909090909090909090909090909090" + }, + { + "description": "wrong length marker", + "outputHex": "00209090909090909090909090909090909090909090" + }, + { + "exception": "Expected Buffer\\(Length: 20\\), got Buffer\\(Length: 3\\)", + "hash": "ffffff" + } + ] + }, + "witnessScriptHash": { + "inputs": [], + "outputs": [ + { + "description": "wrong version", + "outputHex": "51209090909090909090909090909090909090909090909090909090909090909090" + }, + { + "description": "wrong length marker", + "outputHex": "00219090909090909090909090909090909090909090909090909090909090909090" + }, + { + "exception": "Expected Buffer\\(Length: 32\\), got Buffer\\(Length: 3\\)", + "hash": "ffffff" + } + ] + } + } +} diff --git a/test/script.js b/test/script.js index 8e4e3ad..438e3cf 100644 --- a/test/script.js +++ b/test/script.js @@ -22,119 +22,79 @@ describe('script', function () { describe('fromASM/toASM', function () { fixtures.valid.forEach(function (f) { - if (f.scriptSig) { - it('encodes/decodes ' + f.scriptSig, function () { - var scriptSig = bscript.fromASM(f.scriptSig) + it('encodes/decodes ' + f.asm, function () { + var scriptSig = bscript.fromASM(f.asm) - assert.strictEqual(bscript.toASM(scriptSig), f.scriptSig) - }) - } - - if (f.scriptPubKey) { - it('encodes/decodes ' + f.scriptPubKey, function () { - var scriptPubKey = bscript.fromASM(f.scriptPubKey) - - assert.strictEqual(bscript.toASM(scriptPubKey), f.scriptPubKey) - }) - } + assert.strictEqual(bscript.toASM(scriptSig), f.asm) + }) }) }) describe('isPushOnly', function () { fixtures.valid.forEach(function (f) { - if (f.scriptSig) { - it('returns ' + f.pushOnlySig + ' for ' + f.scriptSig, function () { - var script = bscript.fromASM(f.scriptSig) - var chunks = bscript.decompile(script) + it('returns ' + !!f.stack + ' for ' + f.asm, function () { + var script = bscript.fromASM(f.asm) + var chunks = bscript.decompile(script) - assert.strictEqual(bscript.isPushOnly(chunks), f.pushOnlySig) - }) - } - - if (f.scriptPubKey) { - it('returns ' + f.pushOnly + ' for ' + f.scriptPubKey, function () { - var script = bscript.fromASM(f.scriptPubKey) - var chunks = bscript.decompile(script) - - assert.strictEqual(bscript.isPushOnly(chunks), f.pushOnly) - }) - } + assert.strictEqual(bscript.isPushOnly(chunks), !!f.stack) + }) }) }) describe('toStack', function () { fixtures.valid.forEach(function (f) { - if (!f.scriptSig) return - - it('returns ' + f.pushOnlySig + ' for ' + f.scriptSig, function () { - var script = bscript.fromASM(f.scriptSig) + it('returns ' + !!f.stack + ' for ' + f.asm, function () { + var script = bscript.fromASM(f.asm) var chunks = bscript.decompile(script) - var stack = bscript.toStack(chunks).map(x => x.toString('hex')) - assert.deepEqual(stack, f.scriptSigStack) + try { + var stack = bscript.toStack(chunks).map(function (x) { return x.toString('hex') }) + assert.deepEqual(stack, f.stack) + } catch (e) { + assert.strictEqual(f.stack, undefined) + } }) }) }) describe('compile (via fromASM)', function () { fixtures.valid.forEach(function (f) { - if (f.scriptSig) { - it('(' + f.type + ') compiles ' + f.scriptSig, function () { - var scriptSig = bscript.fromASM(f.scriptSig) + it('(' + f.type + ') compiles ' + f.asm, function () { + var scriptSig = bscript.fromASM(f.asm) - assert.strictEqual(scriptSig.toString('hex'), f.scriptSigHex) + assert.strictEqual(scriptSig.toString('hex'), f.script) - if (f.nonstandard) { - var scriptSigNS = bscript.fromASM(f.nonstandard.scriptSig) + if (f.nonstandard) { + var scriptSigNS = bscript.fromASM(f.nonstandard.scriptSig) - assert.strictEqual(scriptSigNS.toString('hex'), f.scriptSigHex) - } - }) - } - - if (f.scriptPubKey) { - it('(' + f.type + ') compiles ' + f.scriptPubKey, function () { - var scriptPubKey = bscript.fromASM(f.scriptPubKey) - - assert.strictEqual(scriptPubKey.toString('hex'), f.scriptPubKeyHex) - }) - } + assert.strictEqual(scriptSigNS.toString('hex'), f.script) + } + }) }) }) describe('decompile', function () { fixtures.valid.forEach(function (f) { - if (f.scriptSigHex) { - it('decompiles ' + f.scriptSig, function () { - var chunks = bscript.decompile(new Buffer(f.scriptSigHex, 'hex')) + it('decompiles ' + f.asm, function () { + var chunks = bscript.decompile(new Buffer(f.script, 'hex')) - assert.strictEqual(bscript.compile(chunks).toString('hex'), f.scriptSigHex) - assert.strictEqual(bscript.toASM(chunks), f.scriptSig) + assert.strictEqual(bscript.compile(chunks).toString('hex'), f.script) + assert.strictEqual(bscript.toASM(chunks), f.asm) - if (f.nonstandard) { - var chunksNS = bscript.decompile(new Buffer(f.nonstandard.scriptSigHex, 'hex')) + if (f.nonstandard) { + var chunksNS = bscript.decompile(new Buffer(f.nonstandard.scriptSigHex, 'hex')) - assert.strictEqual(bscript.compile(chunksNS).toString('hex'), f.scriptSigHex) + assert.strictEqual(bscript.compile(chunksNS).toString('hex'), f.script) - // toASM converts verbatim, only `compile` transforms the script to a minimalpush compliant script - assert.strictEqual(bscript.toASM(chunksNS), f.nonstandard.scriptSig) - } - }) - } - - if (f.scriptPubKeyHex) { - it('decompiles ' + f.scriptPubKey, function () { - var chunks = bscript.decompile(new Buffer(f.scriptPubKeyHex, 'hex')) - - assert.strictEqual(bscript.compile(chunks).toString('hex'), f.scriptPubKeyHex) - assert.strictEqual(bscript.toASM(chunks), f.scriptPubKey) - }) - } + // toASM converts verbatim, only `compile` transforms the script to a minimalpush compliant script + assert.strictEqual(bscript.toASM(chunksNS), f.nonstandard.scriptSig) + } + }) }) fixtures.invalid.decompile.forEach(function (f) { - it('decompiles ' + f.hex + ' to [] because of "' + f.description + '"', function () { - var chunks = bscript.decompile(new Buffer(f.hex, 'hex')) + it('decompiles ' + f.script + ' to [] because of "' + f.description + '"', function () { + var chunks = bscript.decompile(new Buffer(f.script, 'hex')) assert.strictEqual(chunks.length, 0) }) @@ -143,21 +103,11 @@ describe('script', function () { describe('SCRIPT_VERIFY_MINIMALDATA policy', function () { fixtures.valid.forEach(function (f) { - if (f.scriptSigHex) { - it('compliant for ' + f.type + ' scriptSig ' + f.scriptSig, function () { - var script = new Buffer(f.scriptSigHex, 'hex') + it('compliant for ' + f.type + ' scriptSig ' + f.asm, function () { + var script = new Buffer(f.script, 'hex') - assert(minimalData(script)) - }) - } - - if (f.scriptPubKeyHex) { - it('compliant for ' + f.type + ' scriptPubKey ' + f.scriptPubKey, function () { - var script = new Buffer(f.scriptPubKeyHex, 'hex') - - assert(minimalData(script)) - }) - } + assert(minimalData(script)) + }) }) function testEncodingForSize (i) { diff --git a/test/templates.js b/test/templates.js index ad32558..613d4d7 100644 --- a/test/templates.js +++ b/test/templates.js @@ -5,28 +5,28 @@ var bcrypto = require('../src/crypto') var bscript = require('../src/script') var ops = require('../src/opcodes') -var fixtures = require('./fixtures/script.json') +var fixtures = require('./fixtures/templates.json') describe('script-templates', function () { describe('classifyInput', function () { fixtures.valid.forEach(function (f) { - if (!f.scriptSig) return + if (!f.input) return - it('classifies ' + f.scriptSig + ' as ' + f.type, function () { - var scriptSig = bscript.fromASM(f.scriptSig) - var type = bscript.classifyInput(scriptSig) + it('classifies ' + f.input + ' as ' + f.type, function () { + var input = bscript.fromASM(f.input) + var type = bscript.classifyInput(input) assert.strictEqual(type, f.type) }) }) fixtures.valid.forEach(function (f) { - if (!f.scriptSig) return + if (!f.input) return if (!f.typeIncomplete) return - it('classifies incomplete ' + f.scriptSig + ' as ' + f.typeIncomplete, function () { - var scriptSig = bscript.fromASM(f.scriptSig) - var type = bscript.classifyInput(scriptSig, true) + it('classifies incomplete ' + f.input + ' as ' + f.typeIncomplete, function () { + var input = bscript.fromASM(f.input) + var type = bscript.classifyInput(input, true) assert.strictEqual(type, f.typeIncomplete) }) @@ -35,11 +35,11 @@ describe('script-templates', function () { describe('classifyOutput', function () { fixtures.valid.forEach(function (f) { - if (!f.scriptPubKey) return + if (!f.output) return - it('classifies ' + f.scriptPubKey + ' as ' + f.type, function () { - var scriptPubKey = bscript.fromASM(f.scriptPubKey) - var type = bscript.classifyOutput(scriptPubKey) + it('classifies ' + f.output + ' as ' + f.type, function () { + var output = bscript.fromASM(f.output) + var type = bscript.classifyOutput(output) assert.strictEqual(type, f.type) }) @@ -62,18 +62,18 @@ describe('script-templates', function () { fixtures.valid.forEach(function (f) { var expected = name.toLowerCase() === f.type - if (inputType && f.scriptSig) { - var scriptSig = bscript.fromASM(f.scriptSig) + if (inputType && f.input) { + var input = bscript.fromASM(f.input) - it('returns ' + expected + ' for ' + f.scriptSig, function () { - assert.strictEqual(inputType.check(scriptSig), expected) + it('returns ' + expected + ' for ' + f.input, function () { + assert.strictEqual(inputType.check(input), expected) }) if (f.typeIncomplete) { var expectedIncomplete = name.toLowerCase() === f.typeIncomplete - it('returns ' + expected + ' for ' + f.scriptSig, function () { - assert.strictEqual(inputType.check(scriptSig, true), expectedIncomplete) + it('returns ' + expected + ' for ' + f.input, function () { + assert.strictEqual(inputType.check(input, true), expectedIncomplete) }) } } @@ -82,18 +82,18 @@ describe('script-templates', function () { if (!(fixtures.invalid[name])) return fixtures.invalid[name].inputs.forEach(function (f) { - if (!f.scriptSig && !f.scriptSigHex) return + if (!f.input && !f.inputHex) return - it('returns false for ' + f.description + ' (' + (f.scriptSig || f.scriptSigHex) + ')', function () { - var scriptSig + it('returns false for ' + f.description + ' (' + (f.input || f.inputHex) + ')', function () { + var input - if (f.scriptSig) { - scriptSig = bscript.fromASM(f.scriptSig) + if (f.input) { + input = bscript.fromASM(f.input) } else { - scriptSig = new Buffer(f.scriptSigHex, 'hex') + input = new Buffer(f.inputHex, 'hex') } - assert.strictEqual(inputType.check(scriptSig), false) + assert.strictEqual(inputType.check(input), false) }) }) }) @@ -102,11 +102,11 @@ describe('script-templates', function () { fixtures.valid.forEach(function (f) { var expected = name.toLowerCase() === f.type - if (outputType && f.scriptPubKey) { - it('returns ' + expected + ' for ' + f.scriptPubKey, function () { - var scriptPubKey = bscript.fromASM(f.scriptPubKey) + if (outputType && f.output) { + it('returns ' + expected + ' for ' + f.output, function () { + var output = bscript.fromASM(f.output) - assert.strictEqual(outputType.check(scriptPubKey), expected) + assert.strictEqual(outputType.check(output), expected) }) } }) @@ -114,18 +114,18 @@ describe('script-templates', function () { if (!(fixtures.invalid[name])) return fixtures.invalid[name].outputs.forEach(function (f) { - if (!f.scriptPubKey && !f.scriptPubKeyHex) return + if (!f.output && !f.outputHex) return - it('returns false for ' + f.description + ' (' + (f.scriptPubKey || f.scriptPubKeyHex) + ')', function () { - var scriptPubKey + it('returns false for ' + f.description + ' (' + (f.output || f.outputHex) + ')', function () { + var output - if (f.scriptPubKey) { - scriptPubKey = bscript.fromASM(f.scriptPubKey) + if (f.output) { + output = bscript.fromASM(f.output) } else { - scriptPubKey = new Buffer(f.scriptPubKeyHex, 'hex') + output = new Buffer(f.outputHex, 'hex') } - assert.strictEqual(outputType.check(scriptPubKey), false) + assert.strictEqual(outputType.check(output), false) }) }) }) @@ -136,14 +136,14 @@ describe('script-templates', function () { if (f.type !== 'pubkey') return var signature = new Buffer(f.signature, 'hex') - var scriptSig = bscript.pubKey.input.encode(signature) + var input = bscript.pubKey.input.encode(signature) - it('encodes to ' + f.scriptSig, function () { - assert.strictEqual(bscript.toASM(scriptSig), f.scriptSig) + it('encodes to ' + f.input, function () { + assert.strictEqual(bscript.toASM(input), f.input) }) it('decodes to ' + f.signature, function () { - assert.deepEqual(bscript.pubKey.input.decode(scriptSig), signature) + assert.deepEqual(bscript.pubKey.input.decode(input), signature) }) }) }) @@ -153,14 +153,14 @@ describe('script-templates', function () { if (f.type !== 'pubkey') return var pubKey = new Buffer(f.pubKey, 'hex') - var scriptPubKey = bscript.pubKey.output.encode(pubKey) + var output = bscript.pubKey.output.encode(pubKey) - it('encodes to ' + f.scriptPubKey, function () { - assert.strictEqual(bscript.toASM(scriptPubKey), f.scriptPubKey) + it('encodes to ' + f.output, function () { + assert.strictEqual(bscript.toASM(output), f.output) }) it('decodes to ' + f.pubKey, function () { - assert.deepEqual(bscript.pubKey.output.decode(scriptPubKey), pubKey) + assert.deepEqual(bscript.pubKey.output.decode(output), pubKey) }) }) }) @@ -171,14 +171,14 @@ describe('script-templates', function () { var pubKey = new Buffer(f.pubKey, 'hex') var signature = new Buffer(f.signature, 'hex') - var scriptSig = bscript.pubKeyHash.input.encode(signature, pubKey) + var input = bscript.pubKeyHash.input.encode(signature, pubKey) - it('encodes to ' + f.scriptSig, function () { - assert.strictEqual(bscript.toASM(scriptSig), f.scriptSig) + it('encodes to ' + f.input, function () { + assert.strictEqual(bscript.toASM(input), f.input) }) it('decodes to original arguments', function () { - assert.deepEqual(bscript.pubKeyHash.input.decode(scriptSig), { + assert.deepEqual(bscript.pubKeyHash.input.decode(input), { signature: signature, pubKey: pubKey }) @@ -192,14 +192,14 @@ describe('script-templates', function () { var pubKey = new Buffer(f.pubKey, 'hex') var pubKeyHash = bcrypto.hash160(pubKey) - var scriptPubKey = bscript.pubKeyHash.output.encode(pubKeyHash) + var output = bscript.pubKeyHash.output.encode(pubKeyHash) - it('encodes to ' + f.scriptPubKey, function () { - assert.strictEqual(bscript.toASM(scriptPubKey), f.scriptPubKey) + it('encodes to ' + f.output, function () { + assert.strictEqual(bscript.toASM(output), f.output) }) it('decodes to ' + pubKeyHash.toString('hex'), function () { - assert.deepEqual(bscript.pubKeyHash.output.decode(scriptPubKey), pubKeyHash) + assert.deepEqual(bscript.pubKeyHash.output.decode(output), pubKeyHash) }) }) @@ -224,20 +224,20 @@ describe('script-templates', function () { return signature ? new Buffer(signature, 'hex') : ops.OP_0 }) - var scriptSig = bscript.multisig.input.encode(signatures) + var input = bscript.multisig.input.encode(signatures) - it('encodes to ' + f.scriptSig, function () { - assert.strictEqual(bscript.toASM(scriptSig), f.scriptSig) + it('encodes to ' + f.input, function () { + assert.strictEqual(bscript.toASM(input), f.input) }) it('decodes to ' + signatures.map(function (x) { return x === ops.OP_0 ? 'OP_0' : x.toString('hex') }), function () { - assert.deepEqual(bscript.multisig.input.decode(scriptSig, allowIncomplete), signatures) + assert.deepEqual(bscript.multisig.input.decode(input, allowIncomplete), signatures) }) }) fixtures.invalid.multisig.inputs.forEach(function (f) { - if (!f.scriptPubKey) return - var scriptPubKey = bscript.fromASM(f.scriptPubKey) + if (!f.output) return + var output = bscript.fromASM(f.output) it('throws on ' + f.exception, function () { var signatures = f.signatures.map(function (signature) { @@ -245,7 +245,7 @@ describe('script-templates', function () { }) assert.throws(function () { - bscript.multisig.input.encode(signatures, scriptPubKey) + bscript.multisig.input.encode(signatures, output) }, new RegExp(f.exception)) }) }) @@ -258,14 +258,14 @@ describe('script-templates', function () { var pubKeys = f.pubKeys.map(function (p) { return new Buffer(p, 'hex') }) var m = pubKeys.length - var scriptPubKey = bscript.multisig.output.encode(m, pubKeys) + var output = bscript.multisig.output.encode(m, pubKeys) - it('encodes ' + f.scriptPubKey, function () { - assert.strictEqual(bscript.toASM(scriptPubKey), f.scriptPubKey) + it('encodes ' + f.output, function () { + assert.strictEqual(bscript.toASM(output), f.output) }) it('decodes to original arguments', function () { - assert.deepEqual(bscript.multisig.output.decode(scriptPubKey), { + assert.deepEqual(bscript.multisig.output.decode(output), { m: m, pubKeys: pubKeys }) @@ -292,18 +292,18 @@ describe('script-templates', function () { var redeemScript = bscript.fromASM(f.redeemScript) var redeemScriptSig = bscript.fromASM(f.redeemScriptSig) - var scriptSig = bscript.scriptHash.input.encode(redeemScriptSig, redeemScript) + var input = bscript.scriptHash.input.encode(redeemScriptSig, redeemScript) - it('encodes to ' + f.scriptPubKey, function () { - if (f.scriptSig) { - assert.strictEqual(bscript.toASM(scriptSig), f.scriptSig) + it('encodes to ' + f.output, function () { + if (f.input) { + assert.strictEqual(bscript.toASM(input), f.input) } else { - assert.strictEqual(scriptSig.toString('hex'), f.scriptSigHex) + assert.strictEqual(input.toString('hex'), f.inputHex) } }) it('decodes to original arguments', function () { - assert.deepEqual(bscript.scriptHash.input.decode(scriptSig), { + assert.deepEqual(bscript.scriptHash.input.decode(input), { redeemScriptSig: redeemScriptSig, redeemScript: redeemScript }) @@ -314,18 +314,18 @@ describe('script-templates', function () { describe('scriptHash.output', function () { fixtures.valid.forEach(function (f) { if (f.type !== 'scripthash') return - if (!f.scriptPubKey) return + if (!f.output) return var redeemScript = bscript.fromASM(f.redeemScript) var scriptHash = bcrypto.hash160(redeemScript) - var scriptPubKey = bscript.scriptHash.output.encode(scriptHash) + var output = bscript.scriptHash.output.encode(scriptHash) - it('encodes to ' + f.scriptPubKey, function () { - assert.strictEqual(bscript.toASM(scriptPubKey), f.scriptPubKey) + it('encodes to ' + f.output, function () { + assert.strictEqual(bscript.toASM(output), f.output) }) it('decodes to ' + scriptHash.toString('hex'), function () { - assert.deepEqual(bscript.scriptHash.output.decode(scriptPubKey), scriptHash) + assert.deepEqual(bscript.scriptHash.output.decode(output), scriptHash) }) }) @@ -344,18 +344,18 @@ describe('script-templates', function () { describe('witnessPubKeyHash.output', function () { fixtures.valid.forEach(function (f) { if (f.type !== 'witnesspubkeyhash') return - if (!f.scriptPubKey) return + if (!f.output) return var pubKey = new Buffer(f.pubKey, 'hex') var pubKeyHash = bcrypto.hash160(pubKey) - var scriptPubKey = bscript.witnessPubKeyHash.output.encode(pubKeyHash) + var output = bscript.witnessPubKeyHash.output.encode(pubKeyHash) - it('encodes to ' + f.scriptPubKey, function () { - assert.strictEqual(bscript.toASM(scriptPubKey), f.scriptPubKey) + it('encodes to ' + f.output, function () { + assert.strictEqual(bscript.toASM(output), f.output) }) it('decodes to ' + pubKeyHash.toString('hex'), function () { - assert.deepEqual(bscript.witnessPubKeyHash.output.decode(scriptPubKey), pubKeyHash) + assert.deepEqual(bscript.witnessPubKeyHash.output.decode(output), pubKeyHash) }) }) @@ -374,18 +374,18 @@ describe('script-templates', function () { describe('witnessScriptHash.output', function () { fixtures.valid.forEach(function (f) { if (f.type !== 'witnessscripthash') return - if (!f.scriptPubKey) return + if (!f.output) return var witnessScriptPubKey = bscript.fromASM(f.witnessScriptPubKey) var scriptHash = bcrypto.hash256(witnessScriptPubKey) - var scriptPubKey = bscript.witnessScriptHash.output.encode(scriptHash) + var output = bscript.witnessScriptHash.output.encode(scriptHash) - it('encodes to ' + f.scriptPubKey, function () { - assert.strictEqual(bscript.toASM(scriptPubKey), f.scriptPubKey) + it('encodes to ' + f.output, function () { + assert.strictEqual(bscript.toASM(output), f.output) }) it('decodes to ' + scriptHash.toString('hex'), function () { - assert.deepEqual(bscript.witnessScriptHash.output.decode(scriptPubKey), scriptHash) + assert.deepEqual(bscript.witnessScriptHash.output.decode(output), scriptHash) }) }) @@ -406,14 +406,14 @@ describe('script-templates', function () { if (f.type !== 'nulldata') return var data = new Buffer(f.data, 'hex') - var scriptPubKey = bscript.nullData.output.encode(data) + var output = bscript.nullData.output.encode(data) - it('encodes to ' + f.scriptPubKey, function () { - assert.strictEqual(bscript.toASM(scriptPubKey), f.scriptPubKey) + it('encodes to ' + f.output, function () { + assert.strictEqual(bscript.toASM(output), f.output) }) it('decodes to ' + f.data, function () { - assert.deepEqual(bscript.nullData.output.decode(scriptPubKey), data) + assert.deepEqual(bscript.nullData.output.decode(output), data) }) }) })