diff --git a/src/ecpair.js b/src/ecpair.js index c629835..25c1bc6 100644 --- a/src/ecpair.js +++ b/src/ecpair.js @@ -3,27 +3,17 @@ var bs58check = require('bs58check') var bcrypto = require('./crypto') var ecdsa = require('./ecdsa') var ecurve = require('ecurve') -var networks = require('./networks') +var NETWORKS = require('./networks') var randomBytes = require('randombytes') var typeForce = require('typeforce') var BigInteger = require('bigi') -function findNetworkByWIFVersion (version) { - for (var networkName in networks) { - var network = networks[networkName] - - if (network.wif === version) return network - } - - throw new Error('Unknown network') -} - function ECPair (d, Q, options) { options = options || {} var compressed = options.compressed === undefined ? true : options.compressed - var network = options.network === undefined ? networks.bitcoin : options.network + var network = options.network === undefined ? NETWORKS.bitcoin : options.network typeForce('Boolean', compressed) assert('pubKeyHash' in network, 'Unknown pubKeyHash constants for network') @@ -67,7 +57,7 @@ ECPair.fromPublicKeyBuffer = function (buffer, network) { }) } -ECPair.fromWIF = function (string) { +ECPair.fromWIF = function (string, networks) { var payload = bs58check.decode(string) var version = payload.readUInt8(0) var compressed @@ -88,7 +78,23 @@ ECPair.fromWIF = function (string) { compressed = false } - var network = findNetworkByWIFVersion(version) + var network + + // list of networks? + if (Array.isArray(networks)) { + network = networks.filter(function (network) { + return network.wif === version + }).pop() || {} + + // otherwise, assume a network object (or default to bitcoin) + } else { + network = networks || NETWORKS.bitcoin + } + + if (network.wif !== version) { + throw new Error('Invalid network') + } + var d = BigInteger.fromBuffer(payload) return new ECPair(d, null, { diff --git a/test/bitcoin.core.js b/test/bitcoin.core.js index 2c058b5..38bd439 100644 --- a/test/bitcoin.core.js +++ b/test/bitcoin.core.js @@ -57,13 +57,10 @@ describe('Bitcoin-core', function () { var expected = f[0] var hash = new Buffer(f[1], 'hex') var params = f[2] - var network = networks.bitcoin if (params.isPrivkey) return - if (params.isTestnet) { - network = networks.testnet - } + var network = params.isTestnet ? networks.testnet : networks.bitcoin var version = network[typeMap[params.addrType]] it('can export ' + expected, function () { @@ -102,7 +99,9 @@ describe('Bitcoin-core', function () { var params = f[2] if (!params.isPrivkey) return - var keyPair = ECPair.fromWIF(string) + + var network = params.isTestnet ? networks.testnet : networks.bitcoin + var keyPair = ECPair.fromWIF(string, network) it('fromWIF imports ' + string, function () { assert.strictEqual(keyPair.d.toHex(), hex) @@ -127,9 +126,7 @@ describe('Bitcoin-core', function () { it('throws on ' + string, function () { assert.throws(function () { - var keyPair = ECPair.fromWIF(string) - - assert(allowedNetworks.indexOf(keyPair.network) > -1, 'Invalid network') + ECPair.fromWIF(string, allowedNetworks) }, /(Invalid|Unknown) (checksum|compression flag|network|WIF payload)/) }) }) diff --git a/test/ecpair.js b/test/ecpair.js index 4408ca1..a86bf5e 100644 --- a/test/ecpair.js +++ b/test/ecpair.js @@ -4,7 +4,7 @@ var assert = require('assert') var ecdsa = require('../src/ecdsa') var ecurve = require('ecurve') -var networks = require('../src/networks') +var NETWORKS = require('../src/networks') var proxyquire = require('proxyquire') var sinon = require('sinon') @@ -13,6 +13,11 @@ var ECPair = require('../src/ecpair') var fixtures = require('./fixtures/ecpair.json') +var NETWORKS_LIST = [] // Object.values(NETWORKS) +for (var networkName in NETWORKS) { + NETWORKS_LIST.push(NETWORKS[networkName]) +} + describe('ECPair', function () { describe('constructor', function () { it('defaults to compressed', function () { @@ -32,10 +37,10 @@ describe('ECPair', function () { it('supports the network option', function () { var keyPair = new ECPair(BigInteger.ONE, null, { compressed: false, - network: networks.testnet + network: NETWORKS.testnet }) - assert.strictEqual(keyPair.network, networks.testnet) + assert.strictEqual(keyPair.network, NETWORKS.testnet) }) it('throws if compressed option is not a bool', function () { @@ -102,12 +107,23 @@ describe('ECPair', function () { describe('fromWIF', function () { fixtures.valid.forEach(function (f) { - it('imports ' + f.WIF + ' correctly', function () { - var keyPair = ECPair.fromWIF(f.WIF) + it('imports ' + f.WIF + ' (' + f.network + ')', function () { + var network = NETWORKS[f.network] + var keyPair = ECPair.fromWIF(f.WIF, network) + + assert.strictEqual(keyPair.d.toString(), f.d) + assert.strictEqual(keyPair.compressed, f.compressed) + assert.strictEqual(keyPair.network, network) + }) + }) + + fixtures.valid.forEach(function (f) { + it('imports ' + f.WIF + ' (via list of networks)', function () { + var keyPair = ECPair.fromWIF(f.WIF, NETWORKS_LIST) assert.strictEqual(keyPair.d.toString(), f.d) assert.strictEqual(keyPair.compressed, f.compressed) - assert.strictEqual(keyPair.network, networks[f.network]) + assert.strictEqual(keyPair.network, NETWORKS[f.network]) }) }) @@ -122,8 +138,8 @@ describe('ECPair', function () { describe('toWIF', function () { fixtures.valid.forEach(function (f) { - it('exports ' + f.WIF + ' correctly', function () { - var keyPair = ECPair.fromWIF(f.WIF) + it('exports ' + f.WIF, function () { + var keyPair = ECPair.fromWIF(f.WIF, NETWORKS_LIST) var result = keyPair.toWIF() assert.strictEqual(result, f.WIF) @@ -169,7 +185,7 @@ describe('ECPair', function () { describe('getAddress', function () { fixtures.valid.forEach(function (f) { it('returns ' + f.address + ' for ' + f.WIF, function () { - var keyPair = ECPair.fromWIF(f.WIF) + var keyPair = ECPair.fromWIF(f.WIF, NETWORKS_LIST) assert.strictEqual(keyPair.getAddress(), f.address) }) diff --git a/test/fixtures/transaction_builder.json b/test/fixtures/transaction_builder.json index 9fd03f3..aee7e90 100644 --- a/test/fixtures/transaction_builder.json +++ b/test/fixtures/transaction_builder.json @@ -68,6 +68,7 @@ }, { "description": "Transaction w/ scriptHash(multisig 2-of-2) -> pubKeyHash", + "network": "testnet", "txHex": "0100000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000fd1b0100483045022100b7a9bab60c4307349de9571ce0bd26ebb9d68d4e9ab3f9173e1f736f1390a04a022020931ff70e87033cdd94bdf434e865993b2258065c5c222a53f29d077bcfa4480147304402206d79ad83f1ab12fc9feee9e66412de842fcbf8de0632beb4433d469f24f0fb4e022079e6df186582f2686a3292bde8e50dac36cb9bec3991995fe331e1daef7df8a4014c8752410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a52aeffffffff0110270000000000001976a914faf1d99bf040ea9c7f8cc9f14ac6733ad75ce24688ac00000000", "inputs": [ { @@ -93,6 +94,7 @@ }, { "description": "Transaction w/ multisig 2-of-2 -> pubKeyHash", + "network": "testnet", "txHex": "0100000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000009200483045022100b7a9bab60c4307349de9571ce0bd26ebb9d68d4e9ab3f9173e1f736f1390a04a022020931ff70e87033cdd94bdf434e865993b2258065c5c222a53f29d077bcfa4480147304402206d79ad83f1ab12fc9feee9e66412de842fcbf8de0632beb4433d469f24f0fb4e022079e6df186582f2686a3292bde8e50dac36cb9bec3991995fe331e1daef7df8a401ffffffff0110270000000000001976a914faf1d99bf040ea9c7f8cc9f14ac6733ad75ce24688ac00000000", "inputs": [ { @@ -118,6 +120,7 @@ }, { "description": "Transaction w/ multisig 2-of-2 (reverse order) -> pubKeyHash", + "network": "testnet", "txHex": "0100000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000009200483045022100b7a9bab60c4307349de9571ce0bd26ebb9d68d4e9ab3f9173e1f736f1390a04a022020931ff70e87033cdd94bdf434e865993b2258065c5c222a53f29d077bcfa4480147304402206d79ad83f1ab12fc9feee9e66412de842fcbf8de0632beb4433d469f24f0fb4e022079e6df186582f2686a3292bde8e50dac36cb9bec3991995fe331e1daef7df8a401ffffffff0110270000000000001976a914faf1d99bf040ea9c7f8cc9f14ac6733ad75ce24688ac00000000", "inputs": [ { @@ -143,6 +146,7 @@ }, { "description": "Transaction w/ scriptHash(multisig 2-of-3)", + "network": "testnet", "txHex": "0100000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000fd5e0100483045022100eec19e061cad41610f9b42d2b06638b6b0fec3da0de9c6858e7f8c06053979900220622936dd47e202b2ad17639cda680e52334d407149252959936bb1f38e4acc52014830450221009aac215157a74a18234fd06be27448dccee809986bbf93be457a9262f0c69a9402203ff41d7c757f0e8951e4471f205087ecff499f986400ab18210eaad9a628e33c014cc952410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a4104f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e67253aeffffffff01e8030000000000001976a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac00000000", "inputs": [ { @@ -237,7 +241,8 @@ ], "multisig": [ { - "description": "P2SH 2of2 multisig, signed in correct order", + "description": "P2SH 2-of-2 multisig, signed in correct order", + "network": "testnet", "inputs": [ { "txId": "4971f016798a167331bcbc67248313fbc444c6e92e4416efd06964425588f5cf", @@ -266,7 +271,8 @@ "txHex": "0100000001cff58855426469d0ef16442ee9c644c4fb13832467bcbc3173168a7916f0714900000000fd1c0100483045022100e37e33a4fe5fccfb87afb0e951e83fcea4820d73b327d21edc1adec3b916c437022061c5786908b674e323a1863cc2feeb60e1679f1892c10ee08ac21e51fd50ba9001483045022100aa0c323bc639d3d71591be98ccaf7b8cb8c86aa95f060aef5e36fc3f04c4d029022010e2b18de17e307a12ae7e0e88518fe814f18a0ca1ee4510ba23a65628b06576014c8752410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a52aeffffffff01e8030000000000001976a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac00000000" }, { - "description": "P2SH 2of2 multisig, signed in shuffled order", + "description": "P2SH 2-of-2 multisig, signed in shuffled order", + "network": "testnet", "inputs": [ { "txId": "4971f016798a167331bcbc67248313fbc444c6e92e4416efd06964425588f5cf", @@ -295,7 +301,8 @@ "txHex": "0100000001cff58855426469d0ef16442ee9c644c4fb13832467bcbc3173168a7916f0714900000000fd1c0100483045022100e37e33a4fe5fccfb87afb0e951e83fcea4820d73b327d21edc1adec3b916c437022061c5786908b674e323a1863cc2feeb60e1679f1892c10ee08ac21e51fd50ba9001483045022100aa0c323bc639d3d71591be98ccaf7b8cb8c86aa95f060aef5e36fc3f04c4d029022010e2b18de17e307a12ae7e0e88518fe814f18a0ca1ee4510ba23a65628b06576014c8752410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a52aeffffffff01e8030000000000001976a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac00000000" }, { - "description": "P2SH 2of2 multisig, manually messed up order of signatures", + "description": "P2SH 2-of-2 multisig, manually messed up order of signatures", + "network": "testnet", "inputs": [ { "txId": "4971f016798a167331bcbc67248313fbc444c6e92e4416efd06964425588f5cf", @@ -324,7 +331,8 @@ "txHex": "0100000001cff58855426469d0ef16442ee9c644c4fb13832467bcbc3173168a7916f0714900000000fd1c0100483045022100e37e33a4fe5fccfb87afb0e951e83fcea4820d73b327d21edc1adec3b916c437022061c5786908b674e323a1863cc2feeb60e1679f1892c10ee08ac21e51fd50ba9001483045022100aa0c323bc639d3d71591be98ccaf7b8cb8c86aa95f060aef5e36fc3f04c4d029022010e2b18de17e307a12ae7e0e88518fe814f18a0ca1ee4510ba23a65628b06576014c8752410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a52aeffffffff01e8030000000000001976a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac00000000" }, { - "description": "P2SH 2of3 multisig, signed by key 1 and 2", + "description": "P2SH 2-of-3 multisig, signed by key 1 and 2", + "network": "testnet", "inputs": [ { "txId": "4971f016798a167331bcbc67248313fbc444c6e92e4416efd06964425588f5cf", @@ -353,7 +361,8 @@ "txHex": "0100000001cff58855426469d0ef16442ee9c644c4fb13832467bcbc3173168a7916f0714900000000fd5e0100483045022100daf0f4f3339d9fbab42b098045c1e4958ee3b308f4ae17be80b63808558d0adb02202f07e3d1f79dc8da285ae0d7f68083d769c11f5621ebd9691d6b48c0d4283d7d01483045022100ae06d8269b79b5cfa0297d1d88261b0061e52fc2814948c3aa05fa78ee76894302206e0c79a5c90569d8c72a542ef9a06471cbbcd2c651b312339983dfba4f8ff463014cc952410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a4104f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e67253aeffffffff01e8030000000000001976a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac00000000" }, { - "description": "P2SH 2of3 multisig, signed by key 1 and 3", + "description": "P2SH 2-of-3 multisig, signed by key 1 and 3", + "network": "testnet", "inputs": [ { "txId": "4971f016798a167331bcbc67248313fbc444c6e92e4416efd06964425588f5cf", @@ -382,7 +391,8 @@ "txHex": "0100000001cff58855426469d0ef16442ee9c644c4fb13832467bcbc3173168a7916f0714900000000fd5e0100483045022100daf0f4f3339d9fbab42b098045c1e4958ee3b308f4ae17be80b63808558d0adb02202f07e3d1f79dc8da285ae0d7f68083d769c11f5621ebd9691d6b48c0d4283d7d01483045022100a346c61738304eac5e7702188764d19cdf68f4466196729db096d6c87ce18cdd022018c0e8ad03054b0e7e235cda6bedecf35881d7aa7d94ff425a8ace7220f38af0014cc952410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a4104f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e67253aeffffffff01e8030000000000001976a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac00000000" }, { - "description": "P2SH 2of3 multisig, signed by key 3 and 1", + "description": "P2SH 2-of-3 multisig, signed by key 3 and 1", + "network": "testnet", "inputs": [ { "txId": "4971f016798a167331bcbc67248313fbc444c6e92e4416efd06964425588f5cf", @@ -411,7 +421,8 @@ "txHex": "0100000001cff58855426469d0ef16442ee9c644c4fb13832467bcbc3173168a7916f0714900000000fd5e0100483045022100daf0f4f3339d9fbab42b098045c1e4958ee3b308f4ae17be80b63808558d0adb02202f07e3d1f79dc8da285ae0d7f68083d769c11f5621ebd9691d6b48c0d4283d7d01483045022100a346c61738304eac5e7702188764d19cdf68f4466196729db096d6c87ce18cdd022018c0e8ad03054b0e7e235cda6bedecf35881d7aa7d94ff425a8ace7220f38af0014cc952410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a4104f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e67253aeffffffff01e8030000000000001976a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac00000000" }, { - "description": "P2SH 2of3 multisig, signed by key 1 and 3, manually messed up order of signatures", + "description": "P2SH 2-of-3 multisig, signed by key 1 and 3, manually messed up order of signatures", + "network": "testnet", "inputs": [ { "txId": "4971f016798a167331bcbc67248313fbc444c6e92e4416efd06964425588f5cf", @@ -440,7 +451,8 @@ "txHex": "0100000001cff58855426469d0ef16442ee9c644c4fb13832467bcbc3173168a7916f0714900000000fd5e0100483045022100daf0f4f3339d9fbab42b098045c1e4958ee3b308f4ae17be80b63808558d0adb02202f07e3d1f79dc8da285ae0d7f68083d769c11f5621ebd9691d6b48c0d4283d7d01483045022100a346c61738304eac5e7702188764d19cdf68f4466196729db096d6c87ce18cdd022018c0e8ad03054b0e7e235cda6bedecf35881d7aa7d94ff425a8ace7220f38af0014cc952410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a4104f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e67253aeffffffff01e8030000000000001976a914aa4d7985c57e011a8b3dd8e0e5a73aaef41629c588ac00000000" }, { - "description": "P2SH 2of3 multisig, signed by key 3 and 1, manually removing OP_0s", + "description": "P2SH 2-of-3 multisig, signed by key 3 and 1, manually removing OP_0s", + "network": "testnet", "inputs": [ { "txId": "4971f016798a167331bcbc67248313fbc444c6e92e4416efd06964425588f5cf", @@ -618,6 +630,7 @@ }, { "exception": "Inconsistent redeemScript", + "network": "testnet", "inputs": [ { "txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", @@ -644,6 +657,7 @@ }, { "exception": "Inconsistent hashType", + "network": "testnet", "inputs": [ { "txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", diff --git a/test/transaction_builder.js b/test/transaction_builder.js index ba1ea6c..9ef3214 100644 --- a/test/transaction_builder.js +++ b/test/transaction_builder.js @@ -10,10 +10,13 @@ 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') var fixtures = require('./fixtures/transaction_builder') function construct (txb, f, sign) { + var network = NETWORKS[f.network] + f.inputs.forEach(function (input) { var prevTxScript @@ -33,7 +36,7 @@ function construct (txb, f, sign) { if (sign === undefined || sign) { f.inputs.forEach(function (input, index) { input.signs.forEach(function (sign) { - var keyPair = ECPair.fromWIF(sign.keyPair) + var keyPair = ECPair.fromWIF(sign.keyPair, network) var redeemScript if (sign.redeemScript) { @@ -161,12 +164,12 @@ describe('TransactionBuilder', function () { describe('sign', function () { fixtures.invalid.sign.forEach(function (f) { - it('throws on ' + f.exception + ' (' + f.description + ')', function () { + it('throws on ' + f.exception + (f.description ? ' (' + f.description + ')' : ''), function () { construct(txb, f, false) f.inputs.forEach(function (input, index) { input.signs.forEach(function (sign) { - var keyPair = ECPair.fromWIF(sign.keyPair) + var keyPair = ECPair.fromWIF(sign.keyPair, NETWORKS[f.network]) var redeemScript if (sign.redeemScript) { @@ -254,7 +257,7 @@ describe('TransactionBuilder', function () { txb = TransactionBuilder.fromTransaction(tx) } - var keyPair = ECPair.fromWIF(sign.keyPair) + var keyPair = ECPair.fromWIF(sign.keyPair, NETWORKS[f.network]) txb.sign(i, keyPair, redeemScript, sign.hashType) // update the tx @@ -277,7 +280,7 @@ describe('TransactionBuilder', function () { var redeemScript = Script.fromASM('OP_2 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a 04f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672 OP_3 OP_CHECKMULTISIG') - var keyPair = ECPair.fromWIF('91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgx3cTMqe') + var keyPair = ECPair.fromWIF('91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgx3cTMqe', NETWORKS.testnet) txb.sign(0, keyPair, redeemScript) var tx = txb.build()