Merge pull request from bitcoinjs/noscript

No Script
This commit is contained in:
Daniel Cousens 2015-08-19 15:03:40 +10:00
commit bfb7289cf2
19 changed files with 509 additions and 571 deletions

View file

@ -2,9 +2,9 @@
var assert = require('assert')
var networks = require('../src/networks')
var scripts = require('../src/scripts')
var Address = require('../src/address')
var Script = require('../src/script')
var fixtures = require('./fixtures/address.json')
@ -31,7 +31,7 @@ describe('Address', function () {
describe('fromOutputScript', function () {
fixtures.valid.forEach(function (f) {
it('parses ' + f.script.slice(0, 30) + '... (' + f.network + ')', function () {
var script = Script.fromASM(f.script)
var script = scripts.fromASM(f.script)
var address = Address.fromOutputScript(script, networks[f.network])
assert.strictEqual(address, f.base58check)
@ -40,7 +40,7 @@ describe('Address', function () {
fixtures.invalid.fromOutputScript.forEach(function (f) {
it('throws when ' + f.script.slice(0, 30) + '... ' + f.exception, function () {
var script = Script.fromASM(f.script)
var script = scripts.fromASM(f.script)
assert.throws(function () {
Address.fromOutputScript(script)
@ -66,7 +66,7 @@ describe('Address', function () {
it('exports ' + f.script.slice(0, 30) + '... (' + f.network + ')', function () {
var script = Address.toOutputScript(f.base58check, network)
assert.strictEqual(script.toASM(), f.script)
assert.strictEqual(scripts.toASM(script), f.script)
})
})

View file

@ -9,10 +9,10 @@ var Block = Bitcoin.Block
var ECPair = Bitcoin.ECPair
var ECSignature = Bitcoin.ECSignature
var Transaction = Bitcoin.Transaction
var Script = Bitcoin.Script
var bufferutils = Bitcoin.bufferutils
var networks = Bitcoin.networks
var scripts = Bitcoin.scripts
var base58_encode_decode = require('./fixtures/core/base58_encode_decode.json')
var base58_keys_invalid = require('./fixtures/core/base58_keys_invalid.json')
@ -172,7 +172,7 @@ describe('Bitcoin-core', function () {
})
})
describe('Script.fromASM', function () {
describe('scripts.fromASM', function () {
tx_valid.forEach(function (f) {
// Objects that are only a single string are ignored
if (f.length === 1) return
@ -195,7 +195,7 @@ describe('Bitcoin-core', function () {
it('can parse ' + prevOutScriptPubKey, function () {
// TODO: we can probably do better validation than this
Script.fromASM(prevOutScriptPubKey)
scripts.fromASM(prevOutScriptPubKey)
})
})
})
@ -227,8 +227,9 @@ describe('Bitcoin-core', function () {
var transaction = Transaction.fromHex(txHex)
assert.strictEqual(transaction.toHex(), txHex)
var script = Script.fromHex(scriptHex)
assert.strictEqual(script.toHex(), scriptHex)
var script = new Buffer(scriptHex, 'hex')
var scriptChunks = scripts.decompile(script)
assert.strictEqual(scripts.compile(scriptChunks).toString('hex'), scriptHex)
var hash = transaction.hashForSignature(inIndex, script, hashType)
assert.deepEqual(hash, expectedHash)

View file

@ -1,96 +0,0 @@
{
"valid": [
{
"asm": "031f1e68f82112b373f0fe980b3a89d212d2b5c01fb51eb25acb8b4c4b4299ce95 OP_CHECKSIG",
"description": "pay-to-PubKey",
"hash": "26e645ab170255f2a0a82d29e48f35b14ae7c826",
"hex": "21031f1e68f82112b373f0fe980b3a89d212d2b5c01fb51eb25acb8b4c4b4299ce95ac",
"pubKey": "031f1e68f82112b373f0fe980b3a89d212d2b5c01fb51eb25acb8b4c4b4299ce95"
},
{
"asm": "OP_HASH160 e8c300c87986efa84c37c0519929019ef86eb5b4 OP_EQUAL",
"description": "P2SH ScriptPubKey",
"hash": "0ba47b56a573bab4b430ad6ed3ec79270e04b066",
"hex": "a914e8c300c87986efa84c37c0519929019ef86eb5b487"
},
{
"asm": "OP_DUP OP_HASH160 5a3acbc7bbcc97c5ff16f5909c9d7d3fadb293a8 OP_EQUALVERIFY OP_CHECKSIG",
"description": "PubKeyHash ScriptPubKey",
"hash": "a5313f33d5c7b81674b35f7f3febc3522ef234db",
"hex": "76a9145a3acbc7bbcc97c5ff16f5909c9d7d3fadb293a888ac"
},
{
"asm": "304502206becda98cecf7a545d1a640221438ff8912d9b505ede67e0138485111099f696022100ccd616072501310acba10feb97cecc918e21c8e92760cd35144efec7622938f301 040cd2d2ce17a1e9b2b3b2cb294d40eecf305a25b7e7bfdafae6bb2639f4ee399b3637706c3d377ec4ab781355add443ae864b134c5e523001c442186ea60f0eb8",
"description": "pubKeyHash scriptSig",
"hash": "b9bac2a5c5c29bb27c382d41fa3d179c646c78fd",
"hex": "48304502206becda98cecf7a545d1a640221438ff8912d9b505ede67e0138485111099f696022100ccd616072501310acba10feb97cecc918e21c8e92760cd35144efec7622938f30141040cd2d2ce17a1e9b2b3b2cb294d40eecf305a25b7e7bfdafae6bb2639f4ee399b3637706c3d377ec4ab781355add443ae864b134c5e523001c442186ea60f0eb8"
},
{
"asm": "304502206becda98cecf7a545d1a640221438ff8912d9b505ede67e0138485111099f696022100ccd616072501310acba10feb97cecc918e21c8e92760cd35144efec7622938f301",
"description": "pubKey scriptSig",
"hash": "44d9982c3e79452e02ef5816976a0e20a0ec1cba",
"hex": "48304502206becda98cecf7a545d1a640221438ff8912d9b505ede67e0138485111099f696022100ccd616072501310acba10feb97cecc918e21c8e92760cd35144efec7622938f301",
"signature": "304502206becda98cecf7a545d1a640221438ff8912d9b505ede67e0138485111099f696022100ccd616072501310acba10feb97cecc918e21c8e92760cd35144efec7622938f301"
},
{
"asm": "OP_TRUE 032487c2a32f7c8d57d2a93906a6457afd00697925b0e6e145d89af6d3bca33016 02308673d16987eaa010e540901cc6fe3695e758c19f46ce604e174dac315e685a OP_2 OP_CHECKMULTISIG",
"description": "Valid multisig script",
"hash": "f1c98f0b74ecabcf78ae20dfa224bb6666051fbe",
"hex": "5121032487c2a32f7c8d57d2a93906a6457afd00697925b0e6e145d89af6d3bca330162102308673d16987eaa010e540901cc6fe3695e758c19f46ce604e174dac315e685a52ae"
},
{
"asm": "OP_0 304402202b29881db1b4cc128442d955e906d41c77365ed9a8392b584be12d980b236459022009da4bc60d09280aa26f4f981bfbed94eb7263d92920961e48a7f3f0991895b101 3045022100871708a7597c1dbebff2a5527a56a1f2b49d73e35cd825a07285f5f29f5766d8022003bd7ac25334e9a6d6020cc8ba1be67a8c70dca8e7063ea0547d79c45b9bc12601",
"description": "mutisig scriptSig",
"hash": "b1ef3ae2c77b356eff81049aad7dfd2eeb34c6f5",
"hex": "0047304402202b29881db1b4cc128442d955e906d41c77365ed9a8392b584be12d980b236459022009da4bc60d09280aa26f4f981bfbed94eb7263d92920961e48a7f3f0991895b101483045022100871708a7597c1dbebff2a5527a56a1f2b49d73e35cd825a07285f5f29f5766d8022003bd7ac25334e9a6d6020cc8ba1be67a8c70dca8e7063ea0547d79c45b9bc12601"
},
{
"asm": "OP_RETURN 06deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474",
"description": "OP_RETURN script",
"hash": "ec88f016655477663455fe6a8e83508c348ea145",
"hex": "6a2606deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474"
},
{
"asm": "OP_HASH256 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 OP_EQUAL",
"description": "Non standard script",
"hash": "3823382e70d1930989813d3459988e0d7c2861d8",
"hex": "aa206fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d619000000000087"
},
{
"asm": "OP_0 OP_0 OP_0 OP_CHECKMULTISIG",
"description": "Invalid multisig script",
"hash": "62ede8963f9387544935f168745262f703dab1fb",
"hex": "000000ae"
},
{
"asm": "",
"description": "Not enough data: OP_1",
"hash": "c51b66bced5e4491001bd702669770dccf440982",
"hex": "01"
},
{
"asm": "",
"description": "Not enough data: OP_2",
"hash": "d48ce86c698f246829921ba9fb2a844ae2adba67",
"hex": "0201"
},
{
"asm": "",
"description": "Not enough data: OP_PUSHDATA1 0x02",
"hash": "b663ef01a96ff65bec84a3fb14688d6ff7fc617c",
"hex": "4c0201"
},
{
"asm": "",
"description": "Not enough data: OP_PUSHDATA2 0xffff",
"hash": "b4d2fac2836232e59d7b1628f64f24bce3cb4478",
"hex": "4dffff01"
},
{
"asm": "",
"description": "Not enough data: OP_PUSHDATA4 0xffffffff",
"hash": "941db1ca32faf29e1338fb966bb56d98fbce4823",
"hex": "4effffffff01"
}
]
}

View file

@ -5,14 +5,18 @@
"pubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1",
"signature": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801",
"scriptPubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 OP_CHECKSIG",
"scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801"
"scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801",
"scriptSigHex": "47304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801",
"scriptPubKeyHex": "2102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1ac"
},
{
"type": "pubkeyhash",
"pubKey": "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1",
"signature": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801",
"scriptPubKey": "OP_DUP OP_HASH160 aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5 OP_EQUALVERIFY OP_CHECKSIG",
"scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1"
"scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1",
"scriptSigHex": "47304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca28012102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1",
"scriptPubKeyHex": "76a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac"
},
{
"type": "multisig",
@ -25,7 +29,9 @@
"3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501"
],
"scriptPubKey": "OP_2 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a OP_2 OP_CHECKMULTISIG",
"scriptSig": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501"
"scriptSig": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501",
"scriptSigHex": "0047304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801483045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501",
"scriptPubKeyHex": "522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae"
},
{
"type": "multisig",
@ -40,19 +46,30 @@
"3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01"
],
"scriptPubKey": "OP_3 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34 OP_3 OP_CHECKMULTISIG",
"scriptSig": "OP_0 3045022100fe324541215798b2df68cbd44039615e23c506d4ec1a05572064392a98196b82022068c849fa6699206da2fc6d7848efc1d3804a5816d6293615fe34c1a7f34e1c2f01 3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901 3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01"
"scriptSig": "OP_0 3045022100fe324541215798b2df68cbd44039615e23c506d4ec1a05572064392a98196b82022068c849fa6699206da2fc6d7848efc1d3804a5816d6293615fe34c1a7f34e1c2f01 3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901 3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01",
"scriptSigHex": "00483045022100fe324541215798b2df68cbd44039615e23c506d4ec1a05572064392a98196b82022068c849fa6699206da2fc6d7848efc1d3804a5816d6293615fe34c1a7f34e1c2f01473044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901483045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01",
"scriptPubKeyHex": "53210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f817982102b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f84834021024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a3453ae"
},
{
"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"
"scriptPubKey": "OP_HASH160 722ff0bc2c3f47b35c20df646c395594da24e90e OP_EQUAL",
"scriptSigHex": "0047304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801483045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d14050147522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae",
"scriptPubKeyHex": "a914722ff0bc2c3f47b35c20df646c395594da24e90e87"
},
{
"type": "nulldata",
"data": "06deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474",
"scriptPubKey": "OP_RETURN 06deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474",
"scriptPubKeyHex": "6a2606deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474"
},
{
"type": "nulldata",
"data": "deadffffffffffffffffffffffffffffffffbeef",
"scriptPubKey": "OP_RETURN deadffffffffffffffffffffffffffffffffbeef"
"scriptPubKey": "OP_RETURN deadffffffffffffffffffffffffffffffffbeef",
"scriptPubKeyHex": "6a14deadffffffffffffffffffffffffffffffffbeef"
},
{
"type": "nonstandard",
@ -67,7 +84,8 @@
"3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901",
"3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01"
],
"scriptSig": "OP_0 OP_0 3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901 3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01"
"scriptSig": "OP_0 OP_0 3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901 3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01",
"scriptSigHex": "0000473044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901483045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01"
},
{
"type": "nonstandard",
@ -82,7 +100,8 @@
null,
null
],
"scriptSig": "OP_0 OP_0 OP_0 OP_0"
"scriptSig": "OP_0 OP_0 OP_0 OP_0",
"scriptSigHex": "00000000"
},
{
"type": "nonstandard",
@ -97,16 +116,50 @@
],
"redeemScript": "OP_2 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a OP_2 OP_CHECKMULTISIG",
"redeemScriptSig": "OP_0 OP_0 30450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a801",
"scriptSig": "OP_0 OP_0 30450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a801 52410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a52ae"
"scriptSig": "OP_0 OP_0 30450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a801 52410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a52ae",
"scriptSigHex": "00004830450221009c92c1ae1767ac04e424da7f6db045d979b08cde86b1ddba48621d59a109d818022004f5bb21ad72255177270abaeb2d7940ac18f1e5ca1f53db4f3fd1045647a8a8014c8752410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a52ae"
},
{
"type": "nonstandard",
"scriptPubKey": "OP_HASH256 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 OP_EQUAL",
"scriptPubKeyHex": "aa206fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d619000000000087"
},
{
"type": "nonstandard",
"scriptPubKey": "OP_0 OP_0 OP_0 OP_CHECKMULTISIG",
"scriptPubKeyHex": "000000ae"
},
{
"type": "scripthash",
"redeemScript": "OP_0",
"redeemScriptSig": "OP_0",
"scriptSig": "OP_0 00",
"scriptSigHex": "000100"
}
],
"invalid": {
"decompile": [
{
"description": "Not enough data: OP_1",
"hex": "01"
},
{
"description": "Not enough data: OP_2",
"hex": "0201"
},
{
"description": "Not enough data: OP_PUSHDATA1 0x02",
"hex": "4c0201"
},
{
"description": "Not enough data: OP_PUSHDATA2 0xffff",
"hex": "4dffff01"
},
{
"description": "Not enough data: OP_PUSHDATA4 0xffffffff",
"hex": "4effffffff01"
}
],
"isPubKeyHashInput": [
{
"description": "pubKeyHash input : extraneous data",
@ -212,6 +265,18 @@
"304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801"
]
}
],
"pubKeyHashOutput": [
{
"exception": "Expected 160-bit Buffer, got 16-bit Buffer",
"hash": "ffff"
}
],
"scriptHashOutput": [
{
"exception": "Expected 160-bit Buffer, got 24-bit Buffer",
"hash": "ffffff"
}
]
}
}

View file

@ -229,12 +229,12 @@
"invalid": {
"addInput": [
{
"exception": "Expected 256-bit Buffer, got 240-bit",
"exception": "Expected 256-bit Buffer, got 240-bit Buffer",
"hash": "0aed1366a73b6057ee7800d737bff1bdf8c448e98d86bc0998f2b009816d",
"index": 0
},
{
"exception": "Expected 256-bit Buffer, got 272-bit",
"exception": "Expected 256-bit Buffer, got 272-bit Buffer",
"hash": "0aed1366a73b6057ee7800d737bff1bdf8c448e98d86bc0998f2b009816da9b0ffff",
"index": 0
}

View file

@ -55,7 +55,7 @@ describe('bitcoinjs-lib (advanced)', function () {
var actual = bitcoin.Transaction.fromHex(transaction.txHex)
var dataScript2 = actual.outs[0].script
var data2 = dataScript2.chunks[1]
var data2 = bitcoin.scripts.decompile(dataScript2)[1]
assert.deepEqual(dataScript, dataScript2)
assert.deepEqual(data, data2)

View file

@ -129,7 +129,9 @@ describe('bitcoinjs-lib (crypto)', function () {
inputs.forEach(function (input) {
var transaction = transactions[input.txId]
var script = transaction.ins[input.vout].script
assert(bitcoin.scripts.isPubKeyHashInput(script), 'Expected pubKeyHash script')
var scriptChunks = bitcoin.scripts.decompile(script)
assert(bitcoin.scripts.isPubKeyHashInput(scriptChunks), 'Expected pubKeyHash script')
var prevOutTxId = bitcoin.bufferutils.reverse(transaction.ins[input.vout].hash).toString('hex')
var prevVout = transaction.ins[input.vout].index
@ -141,8 +143,8 @@ describe('bitcoinjs-lib (crypto)', function () {
var prevOut = bitcoin.Transaction.fromHex(result.txHex)
var prevOutScript = prevOut.outs[prevVout].script
var scriptSignature = bitcoin.ECSignature.parseScriptSignature(script.chunks[0])
var publicKey = bitcoin.ECPair.fromPublicKeyBuffer(script.chunks[1])
var scriptSignature = bitcoin.ECSignature.parseScriptSignature(scriptChunks[0])
var publicKey = bitcoin.ECPair.fromPublicKeyBuffer(scriptChunks[1])
var m = transaction.hashForSignature(input.vout, prevOutScript, scriptSignature.hashType)
assert(publicKey.verify(m, scriptSignature.signature), 'Invalid m')

View file

@ -15,7 +15,7 @@ describe('bitcoinjs-lib (multisig)', function () {
})
var redeemScript = bitcoin.scripts.multisigOutput(2, pubKeys) // 2 of 3
var scriptPubKey = bitcoin.scripts.scriptHashOutput(redeemScript.getHash())
var scriptPubKey = bitcoin.scripts.scriptHashOutput(bitcoin.crypto.hash160(redeemScript))
var address = bitcoin.Address.fromOutputScript(scriptPubKey)
assert.strictEqual(address, '36NUkt6FWUi3LAWBqWRdDmdTWbt91Yvfu7')
@ -33,7 +33,7 @@ describe('bitcoinjs-lib (multisig)', function () {
var pubKeys = keyPairs.map(function (x) { return x.getPublicKeyBuffer() })
var redeemScript = bitcoin.scripts.multisigOutput(2, pubKeys) // 2 of 4
var scriptPubKey = bitcoin.scripts.scriptHashOutput(redeemScript.getHash())
var scriptPubKey = bitcoin.scripts.scriptHashOutput(bitcoin.crypto.hash160(redeemScript))
var address = bitcoin.Address.fromOutputScript(scriptPubKey, bitcoin.networks.testnet)
// attempt to send funds to the source address

View file

@ -1,95 +0,0 @@
/* global describe, it */
/* eslint-disable no-new */
var assert = require('assert')
var opcodes = require('../src/opcodes')
var Script = require('../src/script')
var fixtures = require('./fixtures/script.json')
describe('Script', function () {
describe('constructor', function () {
it('accepts valid parameters', function () {
var buffer = new Buffer([1])
var chunks = [1]
var script = new Script(buffer, chunks)
assert.strictEqual(script.buffer, buffer)
assert.strictEqual(script.chunks, chunks)
})
it('throws an error when input is not an array', function () {
assert.throws(function () {
new Script({})
}, /Expected Buffer, got/)
})
})
describe('fromASM/toASM', function () {
fixtures.valid.forEach(function (f) {
if (!f.asm) return
it('decodes/encodes ' + f.description, function () {
var script = Script.fromASM(f.asm)
assert.strictEqual(script.toASM(), f.asm)
assert.strictEqual(script.toHex(), f.hex)
})
})
})
describe('fromHex/toHex', function () {
fixtures.valid.forEach(function (f) {
it('decodes/encodes ' + f.description, function () {
var script = Script.fromHex(f.hex)
assert.strictEqual(script.toASM(), f.asm)
assert.strictEqual(script.toHex(), f.hex)
})
})
})
describe('getHash', function () {
fixtures.valid.forEach(function (f) {
it('produces a HASH160 of ' + f.description, function () {
var script = Script.fromHex(f.hex)
assert.strictEqual(script.getHash().toString('hex'), f.hash)
})
})
})
describe('fromChunks', function () {
it('should match expected behaviour', function () {
var hash = new Buffer(32)
hash.fill(0)
var script = Script.fromChunks([
opcodes.OP_HASH160,
hash,
opcodes.OP_EQUAL
])
assert.strictEqual(script.toHex(), 'a920000000000000000000000000000000000000000000000000000000000000000087')
})
})
describe('without', function () {
var hex = 'a914e8c300c87986efa94c37c0519929019ef86eb5b487'
var script = Script.fromHex(hex)
it('should return a script without the given value', function () {
var subScript = script.without(opcodes.OP_HASH160)
assert.strictEqual(subScript.toHex(), '14e8c300c87986efa94c37c0519929019ef86eb5b487')
})
it('shouldnt mutate the original script', function () {
var subScript = script.without(opcodes.OP_EQUAL)
assert.notEqual(subScript.toHex(), hex)
assert.strictEqual(script.toHex(), hex)
})
})
})

View file

@ -5,21 +5,87 @@ var bcrypto = require('../src/crypto')
var ops = require('../src/opcodes')
var scripts = require('../src/scripts')
var Script = require('../src/script')
var fixtures = require('./fixtures/scripts.json')
describe('Scripts', function () {
describe('scripts', function () {
// TODO
describe.skip('isCanonicalPubKey', function () {})
describe.skip('isCanonicalSignature', function () {})
describe('fromASM/toASM', function () {
fixtures.valid.forEach(function (f) {
if (f.scriptSig) {
it('encodes/decodes ' + f.scriptSig, function () {
var script = scripts.fromASM(f.scriptSig)
assert.strictEqual(scripts.toASM(script), f.scriptSig)
})
}
if (f.scriptPubKey) {
it('encodes/decodes ' + f.scriptPubKey, function () {
var script = scripts.fromASM(f.scriptPubKey)
assert.strictEqual(scripts.toASM(script), f.scriptPubKey)
})
}
})
})
describe('compile', function () {
fixtures.valid.forEach(function (f) {
if (f.scriptSig) {
it('compiles ' + f.scriptSig, function () {
var script = scripts.fromASM(f.scriptSig)
assert.strictEqual(scripts.compile(script).toString('hex'), f.scriptSigHex)
})
}
if (f.scriptPubKey) {
it('compiles ' + f.scriptPubKey, function () {
var script = scripts.fromASM(f.scriptPubKey)
assert.strictEqual(scripts.compile(script).toString('hex'), f.scriptPubKeyHex)
})
}
})
})
describe('decompile', function () {
fixtures.valid.forEach(function (f) {
if (f.scriptSigHex) {
it('decompiles ' + f.scriptSig, function () {
var chunks = scripts.decompile(new Buffer(f.scriptSigHex, 'hex'))
assert.strictEqual(scripts.toASM(chunks), f.scriptSig)
})
}
if (f.scriptPubKeyHex) {
it('decompiles ' + f.scriptPubKey, function () {
var chunks = scripts.decompile(new Buffer(f.scriptPubKeyHex, 'hex'))
assert.strictEqual(scripts.toASM(chunks), f.scriptPubKey)
})
}
})
fixtures.invalid.decompile.forEach(function (f) {
it('decompiles ' + f.hex + ' to [] because of "' + f.description + '"', function () {
var chunks = scripts.decompile(new Buffer(f.hex, 'hex'))
assert.strictEqual(chunks.length, 0)
})
})
})
describe('classifyInput', function () {
fixtures.valid.forEach(function (f) {
if (!f.scriptSig) return
it('classifies ' + f.scriptSig + ' as ' + f.type, function () {
var script = Script.fromASM(f.scriptSig)
var script = scripts.fromASM(f.scriptSig)
var type = scripts.classifyInput(script)
assert.strictEqual(type, f.type)
@ -31,7 +97,7 @@ describe('Scripts', function () {
if (!f.typeIncomplete) return
it('classifies incomplete ' + f.scriptSig + ' as ' + f.typeIncomplete, function () {
var script = Script.fromASM(f.scriptSig)
var script = scripts.fromASM(f.scriptSig)
var type = scripts.classifyInput(script, true)
assert.strictEqual(type, f.typeIncomplete)
@ -44,7 +110,7 @@ describe('Scripts', function () {
if (!f.scriptPubKey) return
it('classifies ' + f.scriptPubKey + ' as ' + f.type, function () {
var script = Script.fromASM(f.scriptPubKey)
var script = scripts.fromASM(f.scriptPubKey)
var type = scripts.classifyOutput(script)
assert.strictEqual(type, f.type)
@ -64,13 +130,7 @@ describe('Scripts', function () {
var expected = type.toLowerCase() === f.type
if (inputFn && f.scriptSig) {
var script
if (f.scriptSig) {
script = Script.fromASM(f.scriptSig)
} else {
script = Script.fromHex(f.scriptSigHex)
}
var script = scripts.fromASM(f.scriptSig)
it('returns ' + expected + ' for ' + f.scriptSig, function () {
assert.strictEqual(inputFn(script), expected)
@ -94,9 +154,9 @@ describe('Scripts', function () {
var script
if (f.scriptSig) {
script = Script.fromASM(f.scriptSig)
script = scripts.fromASM(f.scriptSig)
} else {
script = Script.fromHex(f.scriptSigHex)
script = scripts.fromHex(f.scriptSigHex)
}
assert.strictEqual(inputFn(script), false)
@ -111,7 +171,7 @@ describe('Scripts', function () {
if (outputFn && f.scriptPubKey) {
it('returns ' + expected + ' for ' + f.scriptPubKey, function () {
var script = Script.fromASM(f.scriptPubKey)
var script = scripts.fromASM(f.scriptPubKey)
assert.strictEqual(outputFn(script), expected)
})
@ -123,7 +183,7 @@ describe('Scripts', function () {
fixtures.invalid[outputFnName].forEach(function (f) {
if (outputFn && f.scriptPubKey) {
it('returns false for ' + f.description + ' (' + f.scriptPubKey + ')', function () {
var script = Script.fromASM(f.scriptPubKey)
var script = scripts.fromASM(f.scriptPubKey)
assert.strictEqual(outputFn(script), false)
})
@ -140,7 +200,7 @@ describe('Scripts', function () {
var signature = new Buffer(f.signature, 'hex')
var scriptSig = scripts.pubKeyInput(signature)
assert.strictEqual(scriptSig.toASM(), f.scriptSig)
assert.strictEqual(scripts.toASM(scriptSig), f.scriptSig)
})
})
})
@ -152,7 +212,8 @@ describe('Scripts', function () {
it('returns ' + f.scriptPubKey, function () {
var pubKey = new Buffer(f.pubKey, 'hex')
var scriptPubKey = scripts.pubKeyOutput(pubKey)
assert.strictEqual(scriptPubKey.toASM(), f.scriptPubKey)
assert.strictEqual(scripts.toASM(scriptPubKey), f.scriptPubKey)
})
})
})
@ -167,7 +228,7 @@ describe('Scripts', function () {
var signature = new Buffer(f.signature, 'hex')
var scriptSig = scripts.pubKeyHashInput(signature, pubKey)
assert.strictEqual(scriptSig.toASM(), f.scriptSig)
assert.strictEqual(scripts.toASM(scriptSig), f.scriptSig)
})
})
})
@ -181,7 +242,17 @@ describe('Scripts', function () {
it('returns ' + f.scriptPubKey, function () {
var scriptPubKey = scripts.pubKeyHashOutput(pubKeyHash)
assert.strictEqual(scriptPubKey.toASM(), f.scriptPubKey)
assert.strictEqual(scripts.toASM(scriptPubKey), f.scriptPubKey)
})
})
fixtures.invalid.pubKeyHashOutput.forEach(function (f) {
var hash = new Buffer(f.hash, 'hex')
it('throws on ' + f.exception, function () {
assert.throws(function () {
scripts.pubKeyHashOutput(hash)
}, new RegExp(f.exception))
})
})
})
@ -196,12 +267,12 @@ describe('Scripts', function () {
})
var scriptSig = scripts.multisigInput(signatures)
assert.strictEqual(scriptSig.toASM(), f.scriptSig)
assert.strictEqual(scripts.toASM(scriptSig), f.scriptSig)
})
})
fixtures.invalid.multisigInput.forEach(function (f) {
var scriptPubKey = Script.fromASM(f.scriptPubKey)
var scriptPubKey = scripts.fromASM(f.scriptPubKey)
it('throws on ' + f.exception, function () {
var signatures = f.signatures.map(function (signature) {
@ -223,7 +294,7 @@ describe('Scripts', function () {
var scriptPubKey = scripts.multisigOutput(pubKeys.length, pubKeys)
it('returns ' + f.scriptPubKey, function () {
assert.strictEqual(scriptPubKey.toASM(), f.scriptPubKey)
assert.strictEqual(scripts.toASM(scriptPubKey), f.scriptPubKey)
})
})
@ -244,16 +315,17 @@ describe('Scripts', function () {
fixtures.valid.forEach(function (f) {
if (f.type !== 'scripthash') return
var redeemScript = Script.fromASM(f.redeemScript)
var redeemScriptSig = Script.fromASM(f.redeemScriptSig)
var redeemScript = scripts.fromASM(f.redeemScript)
var redeemScriptSig = scripts.fromASM(f.redeemScriptSig)
it('returns ' + f.scriptSig, function () {
var scriptSig = scripts.scriptHashInput(redeemScriptSig, redeemScript)
if (f.scriptSig) {
assert.strictEqual(scriptSig.toASM(), f.scriptSig)
assert.strictEqual(scripts.toASM(scriptSig), f.scriptSig)
} else {
assert.strictEqual(scriptSig.toHex(), f.scriptSigHex)
assert.strictEqual(scriptSig.toString('hex'), f.scriptSigHex)
}
})
})
@ -265,10 +337,20 @@ describe('Scripts', function () {
if (!f.scriptPubKey) return
it('returns ' + f.scriptPubKey, function () {
var redeemScript = Script.fromASM(f.redeemScript)
var scriptPubKey = scripts.scriptHashOutput(redeemScript.getHash())
var redeemScript = scripts.fromASM(f.redeemScript)
var scriptPubKey = scripts.scriptHashOutput(bcrypto.hash160(redeemScript))
assert.strictEqual(scriptPubKey.toASM(), f.scriptPubKey)
assert.strictEqual(scripts.toASM(scriptPubKey), f.scriptPubKey)
})
})
fixtures.invalid.scriptHashOutput.forEach(function (f) {
var hash = new Buffer(f.hash, 'hex')
it('throws on ' + f.exception, function () {
assert.throws(function () {
scripts.scriptHashOutput(hash)
}, new RegExp(f.exception))
})
})
})
@ -281,7 +363,7 @@ describe('Scripts', function () {
var scriptPubKey = scripts.nullDataOutput(data)
it('returns ' + f.scriptPubKey, function () {
assert.strictEqual(scriptPubKey.toASM(), f.scriptPubKey)
assert.strictEqual(scripts.toASM(scriptPubKey), f.scriptPubKey)
})
})
})

View file

@ -1,9 +1,9 @@
/* global describe, it, beforeEach */
var assert = require('assert')
var scripts = require('../src/scripts')
var Transaction = require('../src/transaction')
var Script = require('../src/script')
var fixtures = require('./fixtures/transaction')
@ -19,9 +19,10 @@ describe('Transaction', function () {
if (txIn.data) {
var data = new Buffer(txIn.data, 'hex')
script = new Script(data, [])
script = data
} else if (txIn.script) {
script = Script.fromASM(txIn.script)
script = scripts.fromASM(txIn.script)
}
tx.addInput(txHash, txIn.index, txIn.sequence, script)
@ -32,9 +33,10 @@ describe('Transaction', function () {
if (txOut.data) {
var data = new Buffer(txOut.data, 'hex')
script = new Script(data, [])
script = data
} else if (txOut.script) {
script = Script.fromASM(txOut.script)
script = scripts.fromASM(txOut.script)
}
tx.addOutput(script, txOut.value)
@ -102,7 +104,7 @@ describe('Transaction', function () {
var tx = new Transaction()
tx.addInput(prevTxHash, 0)
assert.strictEqual(tx.ins[0].script, Script.EMPTY)
assert.strictEqual(tx.ins[0].script.length, 0)
})
fixtures.invalid.addInput.forEach(function (f) {
@ -120,8 +122,8 @@ describe('Transaction', function () {
describe('addOutput', function () {
it('returns an index', function () {
var tx = new Transaction()
assert.strictEqual(tx.addOutput(Script.EMPTY, 0), 0)
assert.strictEqual(tx.addOutput(Script.EMPTY, 0), 1)
assert.strictEqual(tx.addOutput(new Buffer(0), 0), 0)
assert.strictEqual(tx.addOutput(new Buffer(0), 0), 1)
})
})

View file

@ -7,7 +7,6 @@ var scripts = require('../src/scripts')
var Address = require('../src/address')
var BigInteger = require('bigi')
var ECPair = require('../src/ecpair')
var Script = require('../src/script')
var Transaction = require('../src/transaction')
var TransactionBuilder = require('../src/transaction_builder')
var NETWORKS = require('../src/networks')
@ -22,14 +21,14 @@ function construct (f, sign) {
var prevTxScript
if (input.prevTxScript) {
prevTxScript = Script.fromASM(input.prevTxScript)
prevTxScript = scripts.fromASM(input.prevTxScript)
}
txb.addInput(input.txId, input.vout, input.sequence, prevTxScript)
})
f.outputs.forEach(function (output) {
var script = Script.fromASM(output.script)
var script = scripts.fromASM(output.script)
txb.addOutput(script, output.value)
})
@ -41,7 +40,7 @@ function construct (f, sign) {
var redeemScript
if (sign.redeemScript) {
redeemScript = Script.fromASM(sign.redeemScript)
redeemScript = scripts.fromASM(sign.redeemScript)
}
txb.sign(index, keyPair, redeemScript, sign.hashType)
@ -200,7 +199,7 @@ describe('TransactionBuilder', function () {
var redeemScript
if (sign.redeemScript) {
redeemScript = Script.fromASM(sign.redeemScript)
redeemScript = scripts.fromASM(sign.redeemScript)
}
if (!sign.throws) {
@ -262,7 +261,7 @@ describe('TransactionBuilder', function () {
var network = NETWORKS[f.network]
f.inputs.forEach(function (input, i) {
var redeemScript = Script.fromASM(input.redeemScript)
var redeemScript = scripts.fromASM(input.redeemScript)
input.signs.forEach(function (sign) {
// rebuild the transaction each-time after the first
@ -272,11 +271,11 @@ describe('TransactionBuilder', function () {
var scriptSig = tx.ins[i].script
// ignore OP_0 on the front, ignore redeemScript
var signatures = scriptSig.chunks.slice(1, -1).filter(function (x) { return x !== ops.OP_0 })
var signatures = scripts.decompile(scriptSig).slice(1, -1).filter(function (x) { return x !== ops.OP_0 })
// rebuild/replace the scriptSig without them
var replacement = scripts.scriptHashInput(scripts.multisigInput(signatures), redeemScript)
assert.strictEqual(replacement.toASM(), sign.scriptSigFiltered)
assert.strictEqual(scripts.toASM(replacement), sign.scriptSigFiltered)
tx.ins[i].script = replacement
}
@ -292,7 +291,7 @@ describe('TransactionBuilder', function () {
tx = txb.buildIncomplete()
// now verify the serialized scriptSig is as expected
assert.strictEqual(tx.ins[i].script.toASM(), sign.scriptSig)
assert.strictEqual(scripts.toASM(tx.ins[i].script), sign.scriptSig)
})
})
@ -309,7 +308,7 @@ describe('TransactionBuilder', function () {
txb = TransactionBuilder.fromTransaction(lameTx, network)
var redeemScript = Script.fromASM('OP_2 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a 04f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672 OP_3 OP_CHECKMULTISIG')
var redeemScript = scripts.fromASM('OP_2 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a 04f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672 OP_3 OP_CHECKMULTISIG')
var keyPair = ECPair.fromWIF('91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgx3cTMqe', network)
txb.sign(0, keyPair, redeemScript)