Compare commits
27 Commits
master
...
solve-witn
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3734cdefd5 | ||
|
|
b27b72d775 | ||
|
|
b0bda2e3f2 | ||
|
|
244c3d4f18 | ||
|
|
fdcd277ba9 | ||
|
|
155c9afe05 | ||
|
|
3a03691b7d | ||
|
|
b09cf89f97 | ||
|
|
c215f350fc | ||
|
|
c3ed014488 | ||
|
|
09bdc1deee | ||
|
|
c60a6418b5 | ||
|
|
9d766df519 | ||
|
|
c0bbd76ad0 | ||
|
|
78faaddf4d | ||
|
|
ffca5afcff | ||
|
|
dd649867f6 | ||
|
|
fe5be931a4 | ||
|
|
8ae194ab9c | ||
|
|
bdf6a9d458 | ||
|
|
20577d42f2 | ||
|
|
4c68cd9a5a | ||
|
|
b00d26d557 | ||
|
|
dfae2be165 | ||
|
|
239e632912 | ||
|
|
4521f3d4c1 | ||
|
|
7fb5259233 |
30
latest/fund_p2sh_p2wpkh.js
Normal file
30
latest/fund_p2sh_p2wpkh.js
Normal file
@ -0,0 +1,30 @@
|
||||
var bitcoin = require('../src/index.js')
|
||||
var bscript = bitcoin.script
|
||||
var crypto = bitcoin.crypto
|
||||
var networks = bitcoin.networks
|
||||
var TransactionBuilder = bitcoin.TransactionBuilder
|
||||
var TxSigner = bitcoin.TxSigner
|
||||
|
||||
var network = networks.testnet
|
||||
var entropy = new Buffer('14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac')
|
||||
var root = bitcoin.HDNode.fromSeedBuffer(entropy, network)
|
||||
|
||||
var txid = '06fc7b675a31bfe3f05dab40d0cd8c044a9b2e890c696a53449d970a4adc6d52'
|
||||
var vout = 0
|
||||
var receivePK = bscript.pubKeyHash.output.encode(crypto.hash160(root.keyPair.getPublicKeyBuffer()))
|
||||
var receiveAmount = 22000
|
||||
|
||||
var fundP2shScript = bscript.witnessPubKeyHash.output.encode(crypto.hash160(root.keyPair.getPublicKeyBuffer()))
|
||||
var fundScriptPubKey = bscript.scriptHash.output.encode(crypto.hash160(fundP2shScript))
|
||||
|
||||
var txb = new TransactionBuilder(network)
|
||||
txb.addInput(txid, vout, 0xffffffff)
|
||||
txb.addOutput(fundScriptPubKey, receiveAmount - 5000)
|
||||
|
||||
var unsigned = txb.buildIncomplete()
|
||||
var signer = new TxSigner(unsigned)
|
||||
signer.sign(0, root.keyPair, {
|
||||
scriptPubKey: receivePK
|
||||
})
|
||||
var tx = signer.done()
|
||||
console.log(tx.toBuffer().toString('hex'))
|
||||
32
latest/fund_p2sh_p2wsh.js
Normal file
32
latest/fund_p2sh_p2wsh.js
Normal file
@ -0,0 +1,32 @@
|
||||
var bitcoin = require('../src/index.js')
|
||||
var bscript = bitcoin.script
|
||||
var crypto = bitcoin.crypto
|
||||
var networks = bitcoin.networks
|
||||
var TransactionBuilder = bitcoin.TransactionBuilder
|
||||
var TxSigner = bitcoin.TxSigner
|
||||
|
||||
var network = networks.testnet
|
||||
var entropy = new Buffer('14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac')
|
||||
var root = bitcoin.HDNode.fromSeedBuffer(entropy, network)
|
||||
|
||||
var pubkeyhash = crypto.hash160(root.keyPair.getPublicKeyBuffer())
|
||||
|
||||
var txid = 'beb647db98bda750f8202e6bc3441781ea5cfc6e3630c9d0ae47b0bfb111c249'
|
||||
var vout = 1
|
||||
var receiveAmount = 10000
|
||||
var receivePK = bscript.pubKeyHash.output.encode(pubkeyhash)
|
||||
|
||||
var witnessScript = bscript.pubKeyHash.output.encode(pubkeyhash)
|
||||
var p2shScript = bscript.witnessScriptHash.output.encode(crypto.sha256(witnessScript))
|
||||
var scriptPubKey = bscript.scriptHash.output.encode(crypto.hash160(p2shScript))
|
||||
|
||||
var txb = new TransactionBuilder(network)
|
||||
txb.addInput(txid, vout, 0xffffffff)
|
||||
txb.addOutput(scriptPubKey, receiveAmount - 10000)
|
||||
|
||||
var txs = new TxSigner(txb.buildIncomplete())
|
||||
txs.sign(0, root.keyPair, {
|
||||
scriptPubKey: receivePK
|
||||
})
|
||||
var tx = txs.done()
|
||||
console.log(tx.toBuffer().toString('hex'))
|
||||
33
latest/fund_p2sh_p2wsh_multisig.js
Normal file
33
latest/fund_p2sh_p2wsh_multisig.js
Normal file
@ -0,0 +1,33 @@
|
||||
var bitcoin = require('../src/index.js')
|
||||
var bscript = bitcoin.script
|
||||
var crypto = bitcoin.crypto
|
||||
var networks = bitcoin.networks
|
||||
var TransactionBuilder = bitcoin.TransactionBuilder
|
||||
var TxSigner = bitcoin.TxSigner
|
||||
|
||||
var network = networks.testnet
|
||||
var entropy = new Buffer('14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac')
|
||||
var root = bitcoin.HDNode.fromSeedBuffer(entropy, network)
|
||||
var root2 = root.derive(1)
|
||||
|
||||
var pubkeyhash = crypto.hash160(root.keyPair.getPublicKeyBuffer())
|
||||
|
||||
var txid = 'aed14f8e918c6e7cc9347391b790f765030b07e6985fbb146bf3f6b25ddc0043'
|
||||
var vout = 0
|
||||
var receivePK = bscript.pubKeyHash.output.encode(pubkeyhash)
|
||||
var receiveAmount = 22000
|
||||
|
||||
var multisig = bscript.multisig.output.encode(2, [root.getPublicKeyBuffer(), root2.getPublicKeyBuffer()])
|
||||
var p2shScript = bscript.witnessScriptHash.output.encode(crypto.sha256(multisig))
|
||||
var scriptPubKey = bscript.scriptHash.output.encode(crypto.hash160(p2shScript))
|
||||
|
||||
var txb = new TransactionBuilder(network)
|
||||
txb.addInput(txid, vout, 0xffffffff)
|
||||
txb.addOutput(scriptPubKey, receiveAmount - 5000)
|
||||
|
||||
var txs = new TxSigner(txb.buildIncomplete())
|
||||
txs.sign(0, root.keyPair, {
|
||||
scriptPubKey: receivePK
|
||||
})
|
||||
var tx = txs.done()
|
||||
console.log(tx.toBuffer().toString('hex'))
|
||||
31
latest/fund_p2wpkh.js
Normal file
31
latest/fund_p2wpkh.js
Normal file
@ -0,0 +1,31 @@
|
||||
var bitcoin = require('../src/index.js')
|
||||
var bscript = bitcoin.script
|
||||
var crypto = bitcoin.crypto
|
||||
var networks = bitcoin.networks
|
||||
var TransactionBuilder = bitcoin.TransactionBuilder
|
||||
var TxSigner = bitcoin.TxSigner
|
||||
|
||||
var network = networks.testnet
|
||||
var entropy = new Buffer('14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac')
|
||||
var root = bitcoin.HDNode.fromSeedBuffer(entropy, network)
|
||||
|
||||
var pubkeyhash = crypto.hash160(root.keyPair.getPublicKeyBuffer())
|
||||
|
||||
var txid = '9aa8d1a1c5df0afccf76e84df1029062b65a98dad68e13cc765aef88ab378dd0'
|
||||
var vout = 0
|
||||
var receivePK = bscript.pubKeyHash.output.encode(pubkeyhash)
|
||||
var receiveAmount = 22000
|
||||
|
||||
var toSegwitPubkey = bscript.witnessPubKeyHash.output.encode(pubkeyhash)
|
||||
|
||||
var txb = new TransactionBuilder(network)
|
||||
txb.addInput(txid, vout, 0xffffffff)
|
||||
txb.addOutput(toSegwitPubkey, receiveAmount - 5000)
|
||||
|
||||
var txs = new TxSigner(txb.buildIncomplete())
|
||||
txs.sign(0, root.keyPair, {
|
||||
scriptPubKey: receivePK
|
||||
})
|
||||
|
||||
var tx = txs.done()
|
||||
console.log(tx.toBuffer().toString('hex'))
|
||||
30
latest/fund_p2wsh.js
Normal file
30
latest/fund_p2wsh.js
Normal file
@ -0,0 +1,30 @@
|
||||
var bitcoin = require('../src/index.js')
|
||||
var bscript = bitcoin.script
|
||||
var crypto = bitcoin.crypto
|
||||
var networks = bitcoin.networks
|
||||
var TransactionBuilder = bitcoin.TransactionBuilder
|
||||
var TxSigner = bitcoin.TxSigner
|
||||
|
||||
var network = networks.testnet
|
||||
var entropy = new Buffer('14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac')
|
||||
var root = bitcoin.HDNode.fromSeedBuffer(entropy, network)
|
||||
var pubkeyhash = crypto.hash160(root.keyPair.getPublicKeyBuffer())
|
||||
|
||||
var txid = '79f560d078eacf4cf9381544b15c400773fddd6bbfb1064956e0c345d39be260'
|
||||
var vout = 0
|
||||
var receivePK = bscript.pubKeyHash.output.encode(pubkeyhash)
|
||||
var receiveAmount = 70000
|
||||
|
||||
var witnessScript = bscript.pubKeyHash.output.encode(pubkeyhash)
|
||||
var toP2WSH = bscript.witnessScriptHash.output.encode(crypto.sha256(witnessScript))
|
||||
|
||||
var txb = new TransactionBuilder(network)
|
||||
txb.addInput(txid, vout, 0xffffffff)
|
||||
txb.addOutput(toP2WSH, receiveAmount - 5000)
|
||||
|
||||
var txs = new TxSigner(txb.buildIncomplete())
|
||||
txs.sign(0, root.keyPair, {
|
||||
scriptPubKey: receivePK
|
||||
})
|
||||
var tx = txs.done()
|
||||
console.log(tx.toBuffer().toString('hex'))
|
||||
53
latest/spend_p2sh_p2wpkh.js
Normal file
53
latest/spend_p2sh_p2wpkh.js
Normal file
@ -0,0 +1,53 @@
|
||||
var bitcoin = require('../src/index.js')
|
||||
|
||||
var bscript = bitcoin.script
|
||||
var crypto = bitcoin.crypto
|
||||
var networks = bitcoin.networks
|
||||
// var baddress = bitcoin.address
|
||||
var TransactionBuilder = bitcoin.TransactionBuilder
|
||||
var TxSigner = bitcoin.TxSigner
|
||||
var network = networks.testnet
|
||||
|
||||
var entropy = new Buffer('14bdfeac14bdfeac14bdfeac1100feac14bdfeac14bdfeac14bdfeac14bdfeac') // my entropy
|
||||
var root = bitcoin.HDNode.fromSeedBuffer(entropy, network)
|
||||
|
||||
var pubkeyhash = crypto.hash160(root.keyPair.getPublicKeyBuffer())
|
||||
// redeem script
|
||||
var toSegwitPubkey = bscript.witnessPubKeyHash.output.encode(pubkeyhash)
|
||||
// aixo es l-envoltori del p2sh crec
|
||||
var p2sh = bscript.scriptHash.output.encode(crypto.hash160(toSegwitPubkey))
|
||||
// on hem rebut la pasta inicial
|
||||
// var receiveAddress = baddress.toBase58Check(crypto.hash160(toSegwitPubkey), network.scriptHash)
|
||||
|
||||
// txhash de la tx que estem gastant
|
||||
var txhashUnspent = 'b085099291d44edecfb3a98384f4266282964fe7b0a12d6db9169698cb7e6487'
|
||||
var vout = 0
|
||||
// on gastarem la pasta despres
|
||||
|
||||
var myaddress = '2N6stcWuMpLgt4nkiaEFXP6p9J9VKRHCwDJ'
|
||||
|
||||
var txOut = {
|
||||
script: p2sh,
|
||||
value: 30000
|
||||
}
|
||||
|
||||
var txb = new TransactionBuilder(network)
|
||||
txb.addInput(txhashUnspent, vout, 0xffffffff, p2sh)
|
||||
txb.addOutput(myaddress, txOut.value - 5000)
|
||||
|
||||
var unsigned = txb.buildIncomplete()
|
||||
var signer = new TxSigner(unsigned)
|
||||
|
||||
var opts = {
|
||||
scriptPubKey: txOut.script,
|
||||
redeemScript: toSegwitPubkey,
|
||||
value: txOut.value
|
||||
}
|
||||
signer.sign(0, root.keyPair, opts)
|
||||
var txd = signer.done()
|
||||
console.log(txd.toBuffer().toString('hex'))
|
||||
|
||||
var testSigner = new TxSigner(txd)
|
||||
|
||||
console.log(testSigner.signer(0, opts).isFullySigned());
|
||||
console.log(testSigner.done().toBuffer().equals(txd.toBuffer()))
|
||||
44
latest/spend_p2sh_p2wsh.js
Normal file
44
latest/spend_p2sh_p2wsh.js
Normal file
@ -0,0 +1,44 @@
|
||||
var bitcoin = require('../src/index.js')
|
||||
|
||||
var bscript = bitcoin.script
|
||||
var crypto = bitcoin.crypto
|
||||
var networks = bitcoin.networks
|
||||
var TransactionBuilder = bitcoin.TransactionBuilder
|
||||
var TxSigner = bitcoin.TxSigner
|
||||
|
||||
var network = networks.testnet
|
||||
var entropy = new Buffer('14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac')
|
||||
var root = bitcoin.HDNode.fromSeedBuffer(entropy, network)
|
||||
|
||||
var pubkeyhash = crypto.hash160(root.keyPair.getPublicKeyBuffer())
|
||||
var witnessScript = bscript.pubKeyHash.output.encode(pubkeyhash)
|
||||
var p2shScript = bscript.witnessScriptHash.output.encode(crypto.sha256(witnessScript))
|
||||
var scriptPubKey = bscript.scriptHash.output.encode(crypto.hash160(p2shScript))
|
||||
|
||||
var txid = '2f789c63bb88c0ca844cf9ab5c59e1d6e935fa9ae6d6b5bc2c5251fca549f09d'
|
||||
var vout = 0
|
||||
var txOut = {
|
||||
script: scriptPubKey,
|
||||
value: 90000
|
||||
}
|
||||
|
||||
var builder = new TransactionBuilder(network)
|
||||
builder.addInput(txid, vout, 0xffffffff, txOut.script)
|
||||
builder.addOutput('2N6stcWuMpLgt4nkiaEFXP6p9J9VKRHCwDJ', 10000)
|
||||
|
||||
var unsigned = builder.buildIncomplete()
|
||||
var signer = new TxSigner(unsigned)
|
||||
var opts = {
|
||||
scriptPubKey: txOut.script,
|
||||
redeemScript: p2shScript,
|
||||
witnessScript: witnessScript,
|
||||
value: txOut.value
|
||||
}
|
||||
signer.sign(0, root.keyPair, opts)
|
||||
|
||||
var txd = signer.done()
|
||||
console.log(txd.toBuffer().toString('hex'))
|
||||
var testSigner = new TxSigner(txd)
|
||||
|
||||
console.log(testSigner.signer(0, opts).isFullySigned());
|
||||
console.log(testSigner.done().toBuffer().equals(txd.toBuffer()))
|
||||
51
latest/spend_p2sh_p2wsh_multisig.js
Normal file
51
latest/spend_p2sh_p2wsh_multisig.js
Normal file
@ -0,0 +1,51 @@
|
||||
var bitcoin = require('../src/index.js')
|
||||
var bscript = bitcoin.script
|
||||
var crypto = bitcoin.crypto
|
||||
var networks = bitcoin.networks
|
||||
var TransactionBuilder = bitcoin.TransactionBuilder
|
||||
var TxSigner = bitcoin.TxSigner
|
||||
|
||||
var network = networks.testnet
|
||||
var entropy = new Buffer('14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac')
|
||||
var root = bitcoin.HDNode.fromSeedBuffer(entropy, network)
|
||||
var root2 = root.derive(1)
|
||||
|
||||
// var address = root.keyPair.getAddress()
|
||||
// var wif = root.keyPair.toWIF()
|
||||
// console.log(address)
|
||||
// console.log(wif)
|
||||
|
||||
var multisig = bscript.multisig.output.encode(2, [root.getPublicKeyBuffer(), root2.getPublicKeyBuffer()])
|
||||
var p2shScript = bscript.witnessScriptHash.output.encode(crypto.sha256(multisig))
|
||||
var scriptPubKey = bscript.scriptHash.output.encode(crypto.hash160(p2shScript))
|
||||
|
||||
var txid = '5d614b47c75ca29a16086e7866de7522e59a09491bbd7e914923f5aabc62616a'
|
||||
var vout = 0
|
||||
var txOut = {
|
||||
script: scriptPubKey,
|
||||
value: 15000
|
||||
}
|
||||
|
||||
var builder = new TransactionBuilder(network)
|
||||
builder.addInput(txid, vout, 0xffffffff, txOut.script)
|
||||
builder.addOutput('2N6stcWuMpLgt4nkiaEFXP6p9J9VKRHCwDJ', 10000)
|
||||
|
||||
var unsigned = builder.buildIncomplete()
|
||||
var signer = new TxSigner(unsigned)
|
||||
|
||||
var opts = {
|
||||
scriptPubKey: txOut.script,
|
||||
value: txOut.value,
|
||||
redeemScript: p2shScript,
|
||||
witnessScript: multisig
|
||||
}
|
||||
|
||||
signer.sign(0, root.keyPair, opts)
|
||||
signer.sign(0, root2.keyPair, opts)
|
||||
|
||||
var txd = signer.done()
|
||||
console.log(txd.toBuffer().toString('hex'))
|
||||
var testSigner = new TxSigner(txd)
|
||||
|
||||
console.log(testSigner.signer(0, opts).isFullySigned())
|
||||
console.log(testSigner.done().toBuffer().equals(txd.toBuffer()))
|
||||
43
latest/spend_p2wpkh.js
Normal file
43
latest/spend_p2wpkh.js
Normal file
@ -0,0 +1,43 @@
|
||||
var bitcoin = require('../src/index.js')
|
||||
var bscript = bitcoin.script
|
||||
var crypto = bitcoin.crypto
|
||||
var networks = bitcoin.networks
|
||||
var TransactionBuilder = bitcoin.TransactionBuilder
|
||||
var TxSigner = bitcoin.TxSigner
|
||||
|
||||
var network = networks.testnet
|
||||
var entropy = new Buffer('14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac')
|
||||
var root = bitcoin.HDNode.fromSeedBuffer(entropy, network)
|
||||
var address = root.keyPair.getAddress()
|
||||
var wif = root.keyPair.toWIF()
|
||||
console.log(address)
|
||||
console.log(wif)
|
||||
|
||||
var pubkeyhash = crypto.hash160(root.keyPair.getPublicKeyBuffer())
|
||||
var txid = 'cca0f194d0ca770737121532497f82b3b4eb861df462bbb26978e53acfec7de8'
|
||||
var vout = 0
|
||||
|
||||
var txOut = {
|
||||
script: bscript.witnessPubKeyHash.output.encode(pubkeyhash),
|
||||
value: 17000
|
||||
}
|
||||
|
||||
var builder = new TransactionBuilder(network)
|
||||
builder.addInput(txid, vout, 0xffffffff, txOut.script)
|
||||
builder.addOutput('2N6stcWuMpLgt4nkiaEFXP6p9J9VKRHCwDJ', txOut.value - 5000)
|
||||
|
||||
var unsigned = builder.buildIncomplete()
|
||||
var signer = new TxSigner(unsigned)
|
||||
var opts = {
|
||||
scriptPubKey: txOut.script,
|
||||
value: txOut.value
|
||||
}
|
||||
signer.sign(0, root.keyPair, opts)
|
||||
|
||||
var txd = signer.done()
|
||||
|
||||
console.log(txd.toBuffer().toString('hex'))
|
||||
var testSigner = new TxSigner(txd)
|
||||
|
||||
console.log(testSigner.signer(0, opts).isFullySigned());
|
||||
console.log(testSigner.done().toBuffer().equals(txd.toBuffer()))
|
||||
47
latest/spend_p2wsh.js
Normal file
47
latest/spend_p2wsh.js
Normal file
@ -0,0 +1,47 @@
|
||||
var bitcoin = require('../src/index.js')
|
||||
var bscript = bitcoin.script
|
||||
var crypto = bitcoin.crypto
|
||||
var networks = bitcoin.networks
|
||||
var TransactionBuilder = bitcoin.TransactionBuilder
|
||||
var TxSigner = bitcoin.TxSigner
|
||||
|
||||
var network = networks.testnet
|
||||
var entropy = new Buffer('14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac14bdfeac')
|
||||
var root = bitcoin.HDNode.fromSeedBuffer(entropy, network)
|
||||
// var address = root.keyPair.getAddress()
|
||||
// var wif = root.keyPair.toWIF()
|
||||
// console.log(address)
|
||||
// console.log(wif)
|
||||
|
||||
var pubkeyhash = crypto.hash160(root.keyPair.getPublicKeyBuffer())
|
||||
var witnessScript = bscript.pubKeyHash.output.encode(pubkeyhash)
|
||||
var scriptHash = crypto.sha256(witnessScript)
|
||||
var scriptPubKey = bscript.witnessScriptHash.output.encode(scriptHash)
|
||||
var txid = '6d1c2682f553889e3887762fcf4669ab3844c6803d6c5c366bc2909bbe33cbf9'
|
||||
var vout = 0
|
||||
|
||||
var txOut = {
|
||||
script: scriptPubKey,
|
||||
value: 65000
|
||||
}
|
||||
|
||||
var builder = new TransactionBuilder(network)
|
||||
builder.addInput(txid, vout, 0xffffffff, txOut.script)
|
||||
builder.addOutput('2N6stcWuMpLgt4nkiaEFXP6p9J9VKRHCwDJ', 10000)
|
||||
|
||||
var unsigned = builder.buildIncomplete()
|
||||
var signer = new TxSigner(unsigned)
|
||||
var opts = {
|
||||
scriptPubKey: scriptPubKey,
|
||||
witnessScript: witnessScript,
|
||||
value: txOut.value
|
||||
}
|
||||
signer.sign(0, root.keyPair, opts)
|
||||
|
||||
var txd = signer.done()
|
||||
console.log(txd.toBuffer().toString('hex'))
|
||||
|
||||
var testSigner = new TxSigner(txd)
|
||||
|
||||
console.log(testSigner.signer(0, opts).isFullySigned())
|
||||
console.log(testSigner.done().toBuffer().equals(txd.toBuffer()))
|
||||
@ -5,7 +5,7 @@ module.exports = {
|
||||
HDNode: require('./hdnode'),
|
||||
Transaction: require('./transaction'),
|
||||
TransactionBuilder: require('./transaction_builder'),
|
||||
|
||||
TxSigner: require('./transaction_signer'),
|
||||
address: require('./address'),
|
||||
bufferutils: require('./bufferutils'),
|
||||
crypto: require('./crypto'),
|
||||
|
||||
@ -54,10 +54,60 @@ function classifyWitness (script, allowIncomplete) {
|
||||
return types.NONSTANDARD
|
||||
}
|
||||
|
||||
function solveOutput (scriptCode) {
|
||||
if (!(scriptCode instanceof Buffer)) {
|
||||
throw new Error('Argument 0 for solveScript must be a Buffer')
|
||||
}
|
||||
|
||||
var outputType = classifyOutput(scriptCode)
|
||||
var solvedBy = null
|
||||
var requiredSigs = null
|
||||
|
||||
switch (outputType) {
|
||||
// We can only determine the relevant hash from these, not if it's signable
|
||||
case types.P2SH:
|
||||
solvedBy = scriptHash.output.decode(scriptCode)
|
||||
break
|
||||
case types.P2WSH:
|
||||
solvedBy = witnessScriptHash.output.decode(scriptCode)
|
||||
break
|
||||
|
||||
// P2WPKH is separate from other signable types, it's best viewed as a special case for P2PKH
|
||||
// Not included in canSign.
|
||||
case types.P2WPKH:
|
||||
solvedBy = witnessPubKeyHash.output.decode(scriptCode)
|
||||
requiredSigs = 1
|
||||
break
|
||||
|
||||
// We can immediately solve signatures for these
|
||||
// When adding a new script type, edit here
|
||||
case types.P2PK:
|
||||
solvedBy = pubKey.output.decode(scriptCode)
|
||||
requiredSigs = 1
|
||||
break
|
||||
case types.P2PKH:
|
||||
solvedBy = pubKeyHash.output.decode(scriptCode)
|
||||
requiredSigs = 1
|
||||
break
|
||||
case types.MULTISIG:
|
||||
solvedBy = multisig.output.decode(scriptCode)
|
||||
requiredSigs = solvedBy.m
|
||||
break
|
||||
}
|
||||
|
||||
return {
|
||||
type: outputType,
|
||||
script: scriptCode,
|
||||
solvedBy: solvedBy,
|
||||
requiredSigs: requiredSigs
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
classifyInput: classifyInput,
|
||||
classifyOutput: classifyOutput,
|
||||
classifyWitness: classifyWitness,
|
||||
solveOutput: solveOutput,
|
||||
multisig: multisig,
|
||||
nullData: nullData,
|
||||
pubKey: pubKey,
|
||||
|
||||
@ -5,7 +5,7 @@ var typeforce = require('typeforce')
|
||||
|
||||
function check (script, allowIncomplete) {
|
||||
var chunks = bscript.decompile(script)
|
||||
if (chunks.length < 2) return false
|
||||
if (chunks.length < 1) return false
|
||||
|
||||
var lastChunk = chunks[chunks.length - 1]
|
||||
if (!Buffer.isBuffer(lastChunk)) return false
|
||||
@ -13,11 +13,12 @@ function check (script, allowIncomplete) {
|
||||
var scriptSigChunks = chunks.slice(0, -1)
|
||||
var redeemScriptChunks = bscript.decompile(lastChunk)
|
||||
|
||||
// is redeemScript a valid script?
|
||||
if (redeemScriptChunks.length === 0) return false
|
||||
var outputType = bscript.classifyOutput(redeemScriptChunks)
|
||||
if (outputType === bscript.types.P2WSH || outputType === bscript.types.P2WPKH) {
|
||||
return true
|
||||
}
|
||||
|
||||
var inputType = bscript.classifyInput(scriptSigChunks, allowIncomplete)
|
||||
var outputType = bscript.classifyOutput(redeemScriptChunks)
|
||||
return inputType === outputType
|
||||
}
|
||||
check.toJSON = function () { return 'scriptHash input' }
|
||||
|
||||
@ -6,6 +6,20 @@ var opcodes = require('./opcodes.json')
|
||||
var typeforce = require('typeforce')
|
||||
var types = require('./types')
|
||||
|
||||
function varSliceSize (someScript) {
|
||||
var length = someScript.length
|
||||
|
||||
return bufferutils.varIntSize(length) + length
|
||||
}
|
||||
|
||||
function vectorSize (someVector) {
|
||||
var length = someVector.length
|
||||
|
||||
return bufferutils.varIntSize(length) + someVector.reduce(function (sum, witness) {
|
||||
return sum + varSliceSize(witness)
|
||||
}, 0)
|
||||
}
|
||||
|
||||
function Transaction () {
|
||||
this.version = 1
|
||||
this.locktime = 0
|
||||
@ -18,6 +32,19 @@ Transaction.SIGHASH_ALL = 0x01
|
||||
Transaction.SIGHASH_NONE = 0x02
|
||||
Transaction.SIGHASH_SINGLE = 0x03
|
||||
Transaction.SIGHASH_ANYONECANPAY = 0x80
|
||||
Transaction.ADVANCED_TRANSACTION_MARKER = 0x00
|
||||
Transaction.ADVANCED_TRANSACTION_FLAG = 0x01
|
||||
Transaction.SIG_V0 = 0
|
||||
Transaction.SIG_V1 = 1
|
||||
var EMPTY_SCRIPT = new Buffer(0)
|
||||
var EMPTY_WITNESS = []
|
||||
var ZERO = new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
|
||||
var ONE = new Buffer('0000000000000000000000000000000000000000000000000000000000000001', 'hex')
|
||||
var VALUE_UINT64_MAX = new Buffer('ffffffffffffffff', 'hex')
|
||||
var BLANK_OUTPUT = {
|
||||
script: EMPTY_SCRIPT,
|
||||
valueBuffer: VALUE_UINT64_MAX
|
||||
}
|
||||
|
||||
Transaction.fromBuffer = function (buffer, __noStrict) {
|
||||
var offset = 0
|
||||
@ -50,20 +77,38 @@ Transaction.fromBuffer = function (buffer, __noStrict) {
|
||||
return vi.number
|
||||
}
|
||||
|
||||
function readScript () {
|
||||
function readVarSlice () {
|
||||
return readSlice(readVarInt())
|
||||
}
|
||||
|
||||
function readVector () {
|
||||
var count = readVarInt()
|
||||
var vector = []
|
||||
for (var i = 0; i < count; i++) vector.push(readVarSlice())
|
||||
return vector
|
||||
}
|
||||
|
||||
var tx = new Transaction()
|
||||
tx.version = readInt32()
|
||||
|
||||
var marker = buffer.readUInt8(offset)
|
||||
var flag = buffer.readUInt8(offset + 1)
|
||||
|
||||
var hasWitnesses = false
|
||||
if (marker === Transaction.ADVANCED_TRANSACTION_MARKER &&
|
||||
flag === Transaction.ADVANCED_TRANSACTION_FLAG) {
|
||||
offset += 2
|
||||
hasWitnesses = true
|
||||
}
|
||||
|
||||
var vinLen = readVarInt()
|
||||
for (var i = 0; i < vinLen; ++i) {
|
||||
tx.ins.push({
|
||||
hash: readSlice(32),
|
||||
index: readUInt32(),
|
||||
script: readScript(),
|
||||
sequence: readUInt32()
|
||||
script: readVarSlice(),
|
||||
sequence: readUInt32(),
|
||||
witness: EMPTY_WITNESS
|
||||
})
|
||||
}
|
||||
|
||||
@ -71,10 +116,21 @@ Transaction.fromBuffer = function (buffer, __noStrict) {
|
||||
for (i = 0; i < voutLen; ++i) {
|
||||
tx.outs.push({
|
||||
value: readUInt64(),
|
||||
script: readScript()
|
||||
script: readVarSlice()
|
||||
})
|
||||
}
|
||||
|
||||
if (hasWitnesses) {
|
||||
var isNull = true
|
||||
for (i = 0; i < vinLen; ++i) {
|
||||
tx.ins[i].witness = readVector()
|
||||
isNull = isNull && tx.ins[i].witness.length === 0
|
||||
}
|
||||
if (isNull) {
|
||||
throw new Error('Transaction has superfluous witness data')
|
||||
}
|
||||
}
|
||||
|
||||
tx.locktime = readUInt32()
|
||||
|
||||
if (__noStrict) return tx
|
||||
@ -99,8 +155,6 @@ Transaction.prototype.isCoinbase = function () {
|
||||
return this.ins.length === 1 && Transaction.isCoinbaseHash(this.ins[0].hash)
|
||||
}
|
||||
|
||||
var EMPTY_SCRIPT = new Buffer(0)
|
||||
|
||||
Transaction.prototype.addInput = function (hash, index, sequence, scriptSig) {
|
||||
typeforce(types.tuple(
|
||||
types.Hash256bit,
|
||||
@ -118,7 +172,8 @@ Transaction.prototype.addInput = function (hash, index, sequence, scriptSig) {
|
||||
hash: hash,
|
||||
index: index,
|
||||
script: scriptSig || EMPTY_SCRIPT,
|
||||
sequence: sequence
|
||||
sequence: sequence,
|
||||
witness: EMPTY_WITNESS
|
||||
}) - 1)
|
||||
}
|
||||
|
||||
@ -132,19 +187,22 @@ Transaction.prototype.addOutput = function (scriptPubKey, value) {
|
||||
}) - 1)
|
||||
}
|
||||
|
||||
Transaction.prototype.byteLength = function () {
|
||||
function scriptSize (someScript) {
|
||||
var length = someScript.length
|
||||
Transaction.prototype._hasWitnesses = function () {
|
||||
return this.ins.some(function (x) {
|
||||
return x.witness.length > 0
|
||||
})
|
||||
}
|
||||
|
||||
return bufferutils.varIntSize(length) + length
|
||||
}
|
||||
Transaction.prototype.byteLength = function () {
|
||||
var hasWitnesses = this._hasWitnesses()
|
||||
|
||||
return (
|
||||
8 +
|
||||
(hasWitnesses ? 10 : 8) +
|
||||
bufferutils.varIntSize(this.ins.length) +
|
||||
bufferutils.varIntSize(this.outs.length) +
|
||||
this.ins.reduce(function (sum, input) { return sum + 40 + scriptSize(input.script) }, 0) +
|
||||
this.outs.reduce(function (sum, output) { return sum + 8 + scriptSize(output.script) }, 0)
|
||||
this.ins.reduce(function (sum, input) { return sum + 40 + varSliceSize(input.script) }, 0) +
|
||||
this.outs.reduce(function (sum, output) { return sum + 8 + varSliceSize(output.script) }, 0) +
|
||||
(hasWitnesses ? this.ins.reduce(function (sum, input) { return sum + vectorSize(input.witness) }, 0) : 0)
|
||||
)
|
||||
}
|
||||
|
||||
@ -158,7 +216,8 @@ Transaction.prototype.clone = function () {
|
||||
hash: txIn.hash,
|
||||
index: txIn.index,
|
||||
script: txIn.script,
|
||||
sequence: txIn.sequence
|
||||
sequence: txIn.sequence,
|
||||
witness: txIn.witness
|
||||
}
|
||||
})
|
||||
|
||||
@ -172,13 +231,6 @@ Transaction.prototype.clone = function () {
|
||||
return newTx
|
||||
}
|
||||
|
||||
var ONE = new Buffer('0000000000000000000000000000000000000000000000000000000000000001', 'hex')
|
||||
var VALUE_UINT64_MAX = new Buffer('ffffffffffffffff', 'hex')
|
||||
var BLANK_OUTPUT = {
|
||||
script: EMPTY_SCRIPT,
|
||||
valueBuffer: VALUE_UINT64_MAX
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash transaction for signing a specific input.
|
||||
*
|
||||
@ -252,6 +304,90 @@ Transaction.prototype.hashForSignature = function (inIndex, prevOutScript, hashT
|
||||
return bcrypto.hash256(buffer)
|
||||
}
|
||||
|
||||
Transaction.prototype.hashForWitnessV0 = function (inIndex, prevOutScript, value, hashType) {
|
||||
typeforce(types.tuple(types.UInt32, types.Buffer, types.Satoshi, types.UInt32), arguments)
|
||||
|
||||
var tbuffer, toffset
|
||||
function writeSlice (slice) { toffset += slice.copy(tbuffer, toffset) }
|
||||
function writeUInt32 (i) { toffset = tbuffer.writeUInt32LE(i, toffset) }
|
||||
function writeUInt64 (i) { toffset = bufferutils.writeUInt64LE(tbuffer, i, toffset) }
|
||||
function writeVarInt (i) { toffset += bufferutils.writeVarInt(tbuffer, i, toffset) }
|
||||
function writeVarSlice (slice) { writeVarInt(slice.length); writeSlice(slice) }
|
||||
|
||||
var hashOutputs = ZERO
|
||||
var hashPrevouts = ZERO
|
||||
var hashSequence = ZERO
|
||||
|
||||
if (!(hashType & Transaction.SIGHASH_ANYONECANPAY)) {
|
||||
tbuffer = new Buffer(36 * this.ins.length)
|
||||
toffset = 0
|
||||
|
||||
this.ins.forEach(function (txIn) {
|
||||
writeSlice(txIn.hash)
|
||||
writeUInt32(txIn.index)
|
||||
})
|
||||
|
||||
hashPrevouts = bcrypto.hash256(tbuffer)
|
||||
}
|
||||
|
||||
if (!(hashType & Transaction.SIGHASH_ANYONECANPAY) &&
|
||||
(hashType & 0x1f) !== Transaction.SIGHASH_SINGLE &&
|
||||
(hashType & 0x1f) !== Transaction.SIGHASH_NONE) {
|
||||
tbuffer = new Buffer(4 * this.ins.length)
|
||||
toffset = 0
|
||||
|
||||
this.ins.forEach(function (txIn) {
|
||||
writeUInt32(txIn.sequence)
|
||||
})
|
||||
|
||||
hashSequence = bcrypto.hash256(tbuffer)
|
||||
}
|
||||
|
||||
if ((hashType & 0x1f) !== Transaction.SIGHASH_SINGLE &&
|
||||
(hashType & 0x1f) !== Transaction.SIGHASH_NONE) {
|
||||
var txOutsSize = this.outs.reduce(function (sum, output) {
|
||||
return sum + 8 + varSliceSize(output.script)
|
||||
}, 0)
|
||||
|
||||
tbuffer = new Buffer(txOutsSize)
|
||||
toffset = 0
|
||||
|
||||
this.outs.forEach(function (out) {
|
||||
writeUInt64(out.value)
|
||||
writeVarSlice(out.script)
|
||||
})
|
||||
|
||||
hashOutputs = bcrypto.hash256(tbuffer)
|
||||
} else if ((hashType & 0x1f) === Transaction.SIGHASH_SINGLE && inIndex < this.outs.length) {
|
||||
var output = this.outs[inIndex]
|
||||
|
||||
tbuffer = new Buffer(8 + varSliceSize(output.script))
|
||||
toffset = 0
|
||||
writeUInt64(output.value)
|
||||
writeVarSlice(output.script)
|
||||
|
||||
hashOutputs = bcrypto.hash256(tbuffer)
|
||||
}
|
||||
|
||||
tbuffer = new Buffer(156 + varSliceSize(prevOutScript))
|
||||
toffset = 0
|
||||
|
||||
var input = this.ins[inIndex]
|
||||
writeUInt32(this.version)
|
||||
writeSlice(hashPrevouts)
|
||||
writeSlice(hashSequence)
|
||||
writeSlice(input.hash)
|
||||
writeUInt32(input.index)
|
||||
writeVarSlice(prevOutScript)
|
||||
writeUInt64(value)
|
||||
writeUInt32(input.sequence)
|
||||
writeSlice(hashOutputs)
|
||||
writeUInt32(this.locktime)
|
||||
writeUInt32(hashType)
|
||||
|
||||
return bcrypto.hash256(tbuffer)
|
||||
}
|
||||
|
||||
Transaction.prototype.getHash = function () {
|
||||
return bcrypto.hash256(this.toBuffer())
|
||||
}
|
||||
@ -266,19 +402,30 @@ Transaction.prototype.toBuffer = function (buffer, initialOffset) {
|
||||
|
||||
var offset = initialOffset || 0
|
||||
function writeSlice (slice) { offset += slice.copy(buffer, offset) }
|
||||
function writeUInt8 (i) { offset = buffer.writeUInt8(i, offset) }
|
||||
function writeUInt32 (i) { offset = buffer.writeUInt32LE(i, offset) }
|
||||
function writeInt32 (i) { offset = buffer.writeInt32LE(i, offset) }
|
||||
function writeUInt64 (i) { offset = bufferutils.writeUInt64LE(buffer, i, offset) }
|
||||
function writeVarInt (i) { offset += bufferutils.writeVarInt(buffer, i, offset) }
|
||||
function writeVarSlice (slice) { writeVarInt(slice.length); writeSlice(slice) }
|
||||
function writeVector (vector) { writeVarInt(vector.length); vector.forEach(writeVarSlice) }
|
||||
|
||||
writeInt32(this.version)
|
||||
|
||||
var hasWitnesses = this._hasWitnesses()
|
||||
var serializeWitnesses = hasWitnesses // TODO: remove this, temporary
|
||||
|
||||
if (hasWitnesses) {
|
||||
writeUInt8(Transaction.ADVANCED_TRANSACTION_MARKER)
|
||||
writeUInt8(Transaction.ADVANCED_TRANSACTION_FLAG)
|
||||
}
|
||||
|
||||
writeVarInt(this.ins.length)
|
||||
|
||||
this.ins.forEach(function (txIn) {
|
||||
writeSlice(txIn.hash)
|
||||
writeUInt32(txIn.index)
|
||||
writeVarInt(txIn.script.length)
|
||||
writeSlice(txIn.script)
|
||||
writeVarSlice(txIn.script)
|
||||
writeUInt32(txIn.sequence)
|
||||
})
|
||||
|
||||
@ -290,15 +437,24 @@ Transaction.prototype.toBuffer = function (buffer, initialOffset) {
|
||||
writeSlice(txOut.valueBuffer)
|
||||
}
|
||||
|
||||
writeVarInt(txOut.script.length)
|
||||
writeSlice(txOut.script)
|
||||
writeVarSlice(txOut.script)
|
||||
})
|
||||
|
||||
if (serializeWitnesses) {
|
||||
var isNull = true
|
||||
this.ins.forEach(function (input) {
|
||||
writeVector(input.witness)
|
||||
isNull = isNull && input.witness.length === 0
|
||||
})
|
||||
if (isNull) {
|
||||
throw new Error('Transaction has superfluous witness data')
|
||||
}
|
||||
}
|
||||
|
||||
writeUInt32(this.locktime)
|
||||
|
||||
// avoid slicing unless necessary
|
||||
if (initialOffset !== undefined) return buffer.slice(initialOffset, offset)
|
||||
|
||||
return buffer
|
||||
}
|
||||
|
||||
@ -312,4 +468,10 @@ Transaction.prototype.setInputScript = function (index, scriptSig) {
|
||||
this.ins[index].script = scriptSig
|
||||
}
|
||||
|
||||
Transaction.prototype.setWitness = function (index, witness) {
|
||||
typeforce(types.tuple(types.Number, types.Buffer), arguments)
|
||||
|
||||
this.ins[index].witness = witness
|
||||
}
|
||||
|
||||
module.exports = Transaction
|
||||
|
||||
492
src/transaction_signer.js
Normal file
492
src/transaction_signer.js
Normal file
@ -0,0 +1,492 @@
|
||||
var bscript = require('./script')
|
||||
var OPS = require('./opcodes.json')
|
||||
var bscriptNumber = require('./script_number')
|
||||
var bcrypto = require('./crypto')
|
||||
var bufferEquals = require('buffer-equals')
|
||||
var typeforce = require('typeforce')
|
||||
var types = require('./types')
|
||||
var ECPair = require('./ecpair')
|
||||
var ECSignature = require('./ecsignature')
|
||||
var Transaction = require('./transaction')
|
||||
var SIGNABLE_SCRIPTS = [
|
||||
bscript.types.MULTISIG,
|
||||
bscript.types.P2PKH,
|
||||
bscript.types.P2PK
|
||||
]
|
||||
|
||||
var ALLOWED_P2SH_SCRIPTS = [
|
||||
bscript.types.MULTISIG,
|
||||
bscript.types.P2PKH,
|
||||
bscript.types.P2PK,
|
||||
bscript.types.P2WSH,
|
||||
bscript.types.P2WPKH
|
||||
]
|
||||
|
||||
function calculateSigHash (tx, nIn, scriptCode, sigHashType, sigVersion, txOutAmount) {
|
||||
return sigVersion === 1
|
||||
? tx.hashForWitnessV0(nIn, scriptCode, txOutAmount, sigHashType)
|
||||
: tx.hashForSignature(nIn, scriptCode, sigHashType)
|
||||
}
|
||||
|
||||
function sortMultisigs (tx, nIn, txOutValue, ecsigs, publicKeys, scriptCode, sigVersion) {
|
||||
var results = []
|
||||
var hash
|
||||
var ikey = 0
|
||||
var isig = 0
|
||||
var sig, key
|
||||
var success = true
|
||||
var sigsCount = ecsigs.length
|
||||
var keysCount = publicKeys.length
|
||||
|
||||
while (success && ecsigs.length > isig) {
|
||||
sig = ECSignature.parseScriptSignature(ecsigs[isig])
|
||||
key = ECPair.fromPublicKeyBuffer(publicKeys[ikey])
|
||||
hash = calculateSigHash(tx, nIn, scriptCode, sig.hashType, sigVersion, txOutValue)
|
||||
if (key.verify(hash, sig.signature)) {
|
||||
isig++
|
||||
results[key.getPublicKeyBuffer().toString('binary')] = sig
|
||||
}
|
||||
ikey++
|
||||
if (sigsCount > keysCount) {
|
||||
success = false
|
||||
}
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
function calculateSignature (tx, nIn, key, scriptCode, sigHashType, sigVersion, txOutValue) {
|
||||
var hash = calculateSigHash(tx, nIn, scriptCode, sigHashType, sigVersion, txOutValue)
|
||||
return key.sign(hash).toScriptSignature(sigHashType)
|
||||
}
|
||||
|
||||
function pushOnlyRead (op) {
|
||||
if (op === OPS.OP_0) {
|
||||
return new Buffer()
|
||||
} else if (op instanceof Buffer) {
|
||||
return op
|
||||
} else if (op === OPS.OP_1NEGATE || op >= OPS.OP_1 && op <= OPS.OP_16) {
|
||||
return bscriptNumber.encode(op - 0x50)
|
||||
} else {
|
||||
throw new Error('Should only be run on a push-only script')
|
||||
}
|
||||
}
|
||||
|
||||
function pushOnlyWrite (buffer) {
|
||||
if (!(buffer instanceof Buffer)) {
|
||||
throw new Error('Non-buffer passed to pushOnlyWrite')
|
||||
}
|
||||
|
||||
if (buffer.length === 0) {
|
||||
return OPS.OP_0
|
||||
} else if (buffer.length === 1 && (buffer[0] === 0x81 || buffer[0] >= 1 && buffer[0] <= 16)) {
|
||||
return bscriptNumber.decode(buffer)
|
||||
} else {
|
||||
return buffer
|
||||
}
|
||||
}
|
||||
|
||||
function evalPushOnly (script) {
|
||||
return bscript.decompile(script).map(pushOnlyRead)
|
||||
}
|
||||
|
||||
function pushAll (chunks) {
|
||||
return bscript.compile(chunks.map(pushOnlyWrite))
|
||||
}
|
||||
|
||||
/**
|
||||
* Design goals
|
||||
*
|
||||
* - tolerate arbitrary sigHashType's on signatures
|
||||
* - given tx, nIn, txOut, we can reliably check a redeemScript and eventual witnessScript at signing
|
||||
* - reliably extract signatures from a signed input
|
||||
* - create, and re-serialize given minimal state
|
||||
* - clear separation of 'standard scripts' and the various script-hash scripts
|
||||
*
|
||||
* @param tx - the transaction we want to sign
|
||||
* @param nIn - the input we will sign here
|
||||
* @param opts
|
||||
*/
|
||||
function InSigner (tx, nIn, opts) {
|
||||
if ((tx instanceof Transaction) === false) {
|
||||
throw new Error('A transaction is required for InSigner')
|
||||
}
|
||||
if (tx.ins[nIn] === undefined) {
|
||||
throw new Error('No transaction input at this index')
|
||||
}
|
||||
if (opts.scriptPubKey === undefined) {
|
||||
throw new Error('A value for scriptPubKey is required')
|
||||
}
|
||||
|
||||
this.tx = tx
|
||||
this.nIn = nIn
|
||||
this.publicKeys = []
|
||||
this.signatures = []
|
||||
this.requiredSigs = 0
|
||||
this.solve(opts)
|
||||
this.extractSig()
|
||||
}
|
||||
|
||||
InSigner.prototype.solve = function (opts) {
|
||||
// Link scriptPubKey, and check that redeemScript/witnessScript/amount are provided
|
||||
// Sets sigVersion, signScript, scriptPubKey (solution), redeemScript (solution), and witnessScript (solution)
|
||||
|
||||
// Determine scriptPubKey is solvable
|
||||
var scriptPubKey = bscript.solveOutput(opts.scriptPubKey)
|
||||
if (scriptPubKey.type !== bscript.types.P2SH && ALLOWED_P2SH_SCRIPTS.indexOf(scriptPubKey.type) === -1) {
|
||||
throw new Error('txOut script is non-standard')
|
||||
}
|
||||
|
||||
var solution = scriptPubKey
|
||||
var redeemScript
|
||||
var witnessScript
|
||||
var sigVersion = Transaction.SIG_V0
|
||||
var value = 0
|
||||
|
||||
if (solution.type === bscript.types.P2SH) {
|
||||
var scriptHash = solution.solvedBy
|
||||
// Redeem script must be provided by opts
|
||||
if (!(opts.redeemScript instanceof Buffer)) {
|
||||
throw new Error('Redeem script required to solve utxo')
|
||||
}
|
||||
// Check redeemScript against script-hash
|
||||
if (!scriptHash.equals(bcrypto.hash160(opts.redeemScript))) {
|
||||
throw new Error('Redeem script does not match txOut script hash')
|
||||
}
|
||||
// Prevent non-standard P2SH scripts
|
||||
solution = bscript.solveOutput(opts.redeemScript)
|
||||
if (!ALLOWED_P2SH_SCRIPTS.indexOf(solution.type)) {
|
||||
throw new Error('Unsupported P2SH script')
|
||||
}
|
||||
redeemScript = solution
|
||||
}
|
||||
|
||||
if (solution.type === bscript.types.P2WPKH) {
|
||||
// txOutValue is required here
|
||||
if (!types.Satoshi(opts.value)) {
|
||||
throw new Error('Value is required for witness-key-hash')
|
||||
}
|
||||
// We set solution to this to avoid work later, since P2WPKH is a special case of P2PKH
|
||||
solution = bscript.solveOutput(bscript.pubKeyHash.output.encode(solution.solvedBy))
|
||||
sigVersion = Transaction.SIG_V1
|
||||
value = opts.value
|
||||
} else if (solution.type === bscript.types.P2WSH) {
|
||||
var witnessScriptHash = solution.solvedBy
|
||||
// Witness script must be provided by opts
|
||||
if (!(opts.witnessScript instanceof Buffer)) {
|
||||
throw new Error('P2WSH script required to solve utxo')
|
||||
}
|
||||
// txOutValue is required here
|
||||
if (!types.Satoshi(opts.value)) {
|
||||
throw new Error('Value is required for witness-script-hash')
|
||||
}
|
||||
// Check witnessScript against script hash
|
||||
if (!bcrypto.sha256(opts.witnessScript).equals(witnessScriptHash)) {
|
||||
throw new Error('Witness script does not match txOut script hash')
|
||||
}
|
||||
// Prevent non-standard P2WSH scripts
|
||||
solution = bscript.solveOutput(opts.witnessScript)
|
||||
if (SIGNABLE_SCRIPTS.indexOf(solution.type) === -1) {
|
||||
throw new Error('Witness script is not supported')
|
||||
}
|
||||
witnessScript = solution
|
||||
sigVersion = Transaction.SIG_V1
|
||||
value = opts.value
|
||||
}
|
||||
|
||||
this.requiredSigs = solution.requiredSigs
|
||||
this.scriptPubKey = scriptPubKey
|
||||
this.redeemScript = redeemScript
|
||||
this.witnessScript = witnessScript
|
||||
this.value = value
|
||||
this.sigVersion = sigVersion
|
||||
this.signScript = solution
|
||||
}
|
||||
|
||||
InSigner.prototype.isFullySigned = function () {
|
||||
return this.requiredSigs !== null && this.signatures.length === this.requiredSigs
|
||||
}
|
||||
|
||||
InSigner.prototype.extractSignableChunks = function (solution, chunks, sigVersion) {
|
||||
// Only SIGNABLE_SCRIPTS can be extracted here
|
||||
var signatures = []
|
||||
var publicKeys = []
|
||||
var decoded
|
||||
|
||||
// only SIGNABLE_SCRIPTS can be extracted here
|
||||
if (solution.type === bscript.types.P2PK) {
|
||||
if (bscript.pubKey.input.check(chunks)) {
|
||||
decoded = bscript.pubKey.input.decode(chunks)
|
||||
if (!decoded.pubKey.equals(solution.solvedBy)) {
|
||||
throw new Error('Key in scriptSig does not match output script key')
|
||||
}
|
||||
|
||||
signatures[0] = decoded.signature
|
||||
publicKeys[0] = solution.solvedBy
|
||||
}
|
||||
} else if (solution.type === bscript.types.P2PKH) {
|
||||
if (bscript.pubKeyHash.input.check(chunks)) {
|
||||
decoded = bscript.pubKeyHash.input.decode(chunks)
|
||||
if (!bcrypto.hash160(decoded.pubKey).equals(solution.solvedBy)) {
|
||||
throw new Error('Key in scriptSig does not match output script key-hash')
|
||||
}
|
||||
signatures[0] = decoded.signature
|
||||
publicKeys[0] = decoded.pubKey
|
||||
}
|
||||
} else if (solution.type === bscript.types.MULTISIG) {
|
||||
if (bscript.multisig.input.check(pushAll(chunks))) {
|
||||
publicKeys = solution.solvedBy.pubKeys
|
||||
signatures = bscript.multisig.input.decode(pushAll(chunks), true)
|
||||
|
||||
// We need to map signature to the pubkey index in order to re-serialize
|
||||
var sigs = sortMultisigs(this.tx, this.nIn, this.value, signatures, publicKeys, solution.script, sigVersion)
|
||||
for (var i = 0, l = publicKeys.length; i < l; i++) {
|
||||
var str = publicKeys[ i ].toString('binary')
|
||||
if (sigs[ str ] !== undefined && bscript.isCanonicalSignature(sigs[str])) {
|
||||
signatures[ i ] = sigs[ str ]
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Error('Never call extractStandardFromChunks on a non-SIGNABLE script')
|
||||
}
|
||||
|
||||
return [signatures, publicKeys]
|
||||
}
|
||||
|
||||
InSigner.prototype.extractSig = function () {
|
||||
// Attempt decoding of the input scriptSig and witness
|
||||
var input = this.tx.ins[this.nIn]
|
||||
var solution = this.scriptPubKey
|
||||
var extractChunks = []
|
||||
if (SIGNABLE_SCRIPTS.indexOf(solution.type) !== -1) {
|
||||
extractChunks = evalPushOnly(input.script)
|
||||
}
|
||||
|
||||
if (solution.type === bscript.types.P2SH) {
|
||||
extractChunks = bscript.decompile(input.script)
|
||||
if (extractChunks.length > 0) {
|
||||
// If we go to extract a P2SH scriptSig, verify the provided redeemScript
|
||||
var p2sh = bscript.scriptHash.input.decode(input.script)
|
||||
if (!p2sh.redeemScript.equals(this.redeemScript.script)) {
|
||||
throw new Error('Redeem script from scriptSig does not match')
|
||||
}
|
||||
solution = this.redeemScript
|
||||
if (SIGNABLE_SCRIPTS.indexOf(solution.type) !== -1) {
|
||||
// only do this if we can sign, otherwise we waste CPU
|
||||
extractChunks = evalPushOnly(p2sh.redeemScriptSig)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (solution.type === bscript.types.P2WPKH) {
|
||||
if (input.witness.length === 2) {
|
||||
var witnessKeyHash = solution.solvedBy
|
||||
if (!witnessKeyHash.equals(bcrypto.hash160(input.witness[1]))) {
|
||||
throw new Error('Public key does not match key-hash')
|
||||
}
|
||||
extractChunks = input.witness
|
||||
}
|
||||
} else if (solution.type === bscript.types.P2WSH) {
|
||||
if (input.witness.length > 0) {
|
||||
if (!this.witnessScript.script.equals(input.witness[ input.witness.length - 1 ])) {
|
||||
throw new Error('Witness script does not match')
|
||||
}
|
||||
extractChunks = input.witness.slice(0, -1)
|
||||
}
|
||||
}
|
||||
if (extractChunks.length > 0) {
|
||||
[this.signatures, this.publicKeys] = this.extractSignableChunks(this.signScript, extractChunks, this.sigVersion)
|
||||
}
|
||||
}
|
||||
|
||||
function signSignable (tx, nIn, txOutValue, signatures, publicKeys, key, solution, sigHashType, sigVersion) {
|
||||
// Todo, skip if already signed
|
||||
// Only SIGNABLE_SCRIPTS can be signed here
|
||||
var keyBuffer = key.getPublicKeyBuffer()
|
||||
if (solution.type === bscript.types.P2PK) {
|
||||
if (bufferEquals(keyBuffer, solution.solvedBy)) {
|
||||
signatures = [calculateSignature(tx, nIn, key, solution.script, sigHashType, sigVersion, txOutValue)]
|
||||
publicKeys = [keyBuffer]
|
||||
} else {
|
||||
throw new Error('Signing input with wrong private key')
|
||||
}
|
||||
} else if (solution.type === bscript.types.P2PKH) {
|
||||
if (bufferEquals(bcrypto.hash160(keyBuffer), solution.solvedBy)) {
|
||||
signatures = [calculateSignature(tx, nIn, key, solution.script, sigHashType, sigVersion, txOutValue)]
|
||||
publicKeys = [keyBuffer]
|
||||
} else {
|
||||
throw new Error('Signing input with wrong private key')
|
||||
}
|
||||
} else if (solution.type === bscript.types.MULTISIG) {
|
||||
var match = false
|
||||
for (var i = 0, keyLen = solution.solvedBy.pubKeys.length; i < keyLen; i++) {
|
||||
publicKeys[i] = solution.solvedBy.pubKeys[i]
|
||||
if (bufferEquals(keyBuffer, publicKeys[i])) {
|
||||
match = true
|
||||
signatures[i] = calculateSignature(tx, nIn, key, solution.script, sigHashType, sigVersion, txOutValue)
|
||||
}
|
||||
}
|
||||
if (!match) {
|
||||
throw new Error('Signing input with wrong private key')
|
||||
}
|
||||
} else {
|
||||
throw new Error('signStandard can only sign SIGNABLE_SCRIPTS')
|
||||
}
|
||||
|
||||
return [signatures, publicKeys]
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs the input given a key/sigHashType
|
||||
* @param key
|
||||
* @param sigHashType
|
||||
* @returns {boolean}
|
||||
*/
|
||||
InSigner.prototype.sign = function (key, sigHashType) {
|
||||
sigHashType = sigHashType || Transaction.SIGHASH_ALL;
|
||||
[this.signatures, this.publicKeys] = signSignable(this.tx, this.nIn, this.value, this.signatures, this.publicKeys, key, this.signScript, sigHashType, this.sigVersion)
|
||||
this.requiredSigs = this.publicKeys.length
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array of chunks for the scriptSig or witness
|
||||
* Future signable types go here (CSV, HTLC)
|
||||
*
|
||||
* @param outputType
|
||||
* @param signatures
|
||||
* @param publicKeys
|
||||
* @returns {Array}
|
||||
*/
|
||||
function serializeSignableChunks (outputType, signatures, publicKeys) {
|
||||
// Only SIGNABLE_SCRIPTS can be serialized here
|
||||
var chunks = []
|
||||
switch (outputType) {
|
||||
case bscript.types.P2PK:
|
||||
if (signatures.length === 1) {
|
||||
chunks = [signatures[ 0 ]]
|
||||
}
|
||||
break
|
||||
case bscript.types.P2PKH:
|
||||
if (signatures.length === 1) {
|
||||
chunks = [signatures[ 0 ], publicKeys[ 0 ]]
|
||||
}
|
||||
break
|
||||
case bscript.types.MULTISIG:
|
||||
chunks.push(new Buffer(0))
|
||||
chunks = chunks.concat(signatures.map(function (signature) {
|
||||
if (signature instanceof Buffer === false) {
|
||||
throw new Error('debugging probably required')
|
||||
}
|
||||
return signature
|
||||
}))
|
||||
break
|
||||
default:
|
||||
throw new Error('serializeStandardChunks only works with a SIGNABLE_SCRIPT')
|
||||
}
|
||||
|
||||
return chunks
|
||||
}
|
||||
|
||||
InSigner.prototype.serializeSigData = function () {
|
||||
var scriptChunks = []
|
||||
var witnessChunks = []
|
||||
var type = this.scriptPubKey.type
|
||||
if (SIGNABLE_SCRIPTS.indexOf(this.scriptPubKey.type) !== -1) {
|
||||
scriptChunks = serializeSignableChunks(type, this.signatures, this.publicKeys)
|
||||
}
|
||||
|
||||
var p2sh = false
|
||||
if (type === bscript.types.P2SH) {
|
||||
p2sh = true
|
||||
type = this.redeemScript.type
|
||||
if (SIGNABLE_SCRIPTS.indexOf(this.redeemScript.type) !== -1) {
|
||||
scriptChunks = serializeSignableChunks(type, this.signatures, this.publicKeys)
|
||||
}
|
||||
}
|
||||
|
||||
if (type === bscript.types.P2WPKH) {
|
||||
witnessChunks = serializeSignableChunks(bscript.types.P2PKH, this.signatures, this.publicKeys)
|
||||
} else if (type === bscript.types.P2WSH) {
|
||||
type = this.witnessScript.type
|
||||
if (SIGNABLE_SCRIPTS.indexOf(this.witnessScript.type) !== -1) {
|
||||
scriptChunks = []
|
||||
witnessChunks = serializeSignableChunks(type, this.signatures, this.publicKeys)
|
||||
witnessChunks.push(this.witnessScript.script)
|
||||
}
|
||||
}
|
||||
|
||||
if (p2sh) {
|
||||
scriptChunks.push(this.redeemScript.script)
|
||||
}
|
||||
|
||||
return {
|
||||
scriptSig: pushAll(scriptChunks),
|
||||
witness: witnessChunks
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a TxSigner for this transaction instance
|
||||
* @param tx
|
||||
* @constructor
|
||||
*/
|
||||
function TxSigner (tx) {
|
||||
if (tx === undefined || (tx instanceof Transaction) === false) {
|
||||
throw new Error('A transaction is required for TxSigner')
|
||||
}
|
||||
|
||||
this.tx = tx.clone()
|
||||
this.states = []
|
||||
}
|
||||
|
||||
TxSigner.prototype.signer = function (nIn, opts) {
|
||||
if (this.states[nIn] === undefined) {
|
||||
this.states[nIn] = new InSigner(this.tx, nIn, opts)
|
||||
}
|
||||
return this.states[nIn]
|
||||
}
|
||||
/**
|
||||
* Sign a transaction.
|
||||
*
|
||||
* @param nIn - the input to sign
|
||||
* @param key - the private key to sign with
|
||||
* @param sigHashType - SIGHASH type to sign with
|
||||
* @param opts - optional data required to solve UTXO
|
||||
*/
|
||||
TxSigner.prototype.sign = function (nIn, key, opts, sigHashType) {
|
||||
typeforce(types.Number, nIn)
|
||||
typeforce(types.maybe(Number), sigHashType)
|
||||
if (sigHashType === undefined) {
|
||||
sigHashType = Transaction.SIGHASH_ALL
|
||||
}
|
||||
// You can probably make this work with the current library, if you can work out the witnessScript above!
|
||||
// generate opts for the internal signer based off older way of positional arguments to TxSigner.sign
|
||||
|
||||
if (!this.signer(nIn, opts).sign(key, sigHashType)) {
|
||||
throw new Error('Unsignable input: ', nIn)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Produce a Transaction with our changes.
|
||||
*/
|
||||
TxSigner.prototype.done = function () {
|
||||
var tx = this.tx.clone()
|
||||
|
||||
var states = this.states
|
||||
for (var i = 0, l = tx.ins.length; i < l; i++) {
|
||||
if (this.states[i] !== undefined) {
|
||||
var sigData = states[i].serializeSigData()
|
||||
tx.ins[i].script = sigData.scriptSig
|
||||
tx.ins[i].witness = sigData.witness
|
||||
}
|
||||
}
|
||||
return tx
|
||||
}
|
||||
|
||||
module.exports = TxSigner
|
||||
@ -162,35 +162,6 @@ describe('Bitcoin-core', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('script.fromASM', function () {
|
||||
txValid.forEach(function (f) {
|
||||
// Objects that are only a single string are ignored
|
||||
if (f.length === 1) return
|
||||
|
||||
var inputs = f[0]
|
||||
|
||||
inputs.forEach(function (input) {
|
||||
var prevOutScriptPubKey = input[2]
|
||||
.replace(/(^| )([0-9])( |$)/g, 'OP_$2 ')
|
||||
.replace(/0x[a-f0-9]+ 0x([a-f0-9]+)/, '$1')
|
||||
.replace(/DUP/g, 'OP_DUP')
|
||||
.replace(/NOT/g, 'OP_NOT')
|
||||
.replace(/HASH160/g, 'OP_HASH160')
|
||||
.replace(/EQUALVERIFY/g, 'OP_EQUALVERIFY')
|
||||
.replace(/EQUAL( |$)/g, 'OP_EQUAL ')
|
||||
.replace(/CHECKSIG/g, 'OP_CHECKSIG')
|
||||
.replace(/ CHECKMULTISIG/g, ' OP_CHECKMULTISIG')
|
||||
.replace(/CODESEPARATOR/g, 'OP_CODESEPARATOR')
|
||||
.replace(/CHECKSIGVERIFY/g, 'OP_CHECKSIGVERIFY')
|
||||
|
||||
it('can parse ' + prevOutScriptPubKey, function () {
|
||||
// TODO: we can probably do better validation than this
|
||||
bitcoin.script.fromASM(prevOutScriptPubKey)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
// sighash
|
||||
describe('Transaction', function () {
|
||||
sigHash.forEach(function (f) {
|
||||
|
||||
334
test/fixtures/core/tx_valid.json
vendored
334
test/fixtures/core/tx_valid.json
vendored
@ -16,7 +16,7 @@
|
||||
["It is an OP_CHECKMULTISIG with an arbitrary extra byte stuffed into the signature at pos length - 2"],
|
||||
["The dummy byte is fine however, so the NULLDUMMY flag should be happy"],
|
||||
[[["60a20bd93aa49ab4b28d514ec10b06e1829ce6818ec06cd3aabd013ebcdc4bb1", 0, "1 0x41 0x04cc71eb30d653c0c3163990c47b976f3fb3f37cccdcbedb169a1dfef58bbfbfaff7d8a473e7e2e6d317b87bafe8bde97e3cf8f065dec022b51d11fcdd0d348ac4 0x41 0x0461cbdcc5409fb4b4d42b51d33381354d80e550078cb532a34bfa2fcfdeb7d76519aecc62770f5b0e4ef8551946d8a540911abe3e7854a26f39f58b25c15342af 2 OP_CHECKMULTISIG"]],
|
||||
"0100000001b14bdcbc3e01bdaad36cc08e81e69c82e1060bc14e518db2b49aa43ad90ba260000000004A0048304402203f16c6f40162ab686621ef3000b04e75418a0c0cb2d8aebeac894ae360ac1e780220ddc15ecdfc3507ac48e1681a33eb60996631bf6bf5bc0a0682c4db743ce7ca2bab01ffffffff0140420f00000000001976a914660d4ef3a743e3e696ad990364e555c271ad504b88ac00000000", "P2SH,NULLDUMMY"],
|
||||
"0100000001b14bdcbc3e01bdaad36cc08e81e69c82e1060bc14e518db2b49aa43ad90ba260000000004a0048304402203f16c6f40162ab686621ef3000b04e75418a0c0cb2d8aebeac894ae360ac1e780220ddc15ecdfc3507ac48e1681a33eb60996631bf6bf5bc0a0682c4db743ce7ca2bab01ffffffff0140420f00000000001976a914660d4ef3a743e3e696ad990364e555c271ad504b88ac00000000", "P2SH,NULLDUMMY"],
|
||||
|
||||
["The following is a tweaked form of 23b397edccd3740a74adb603c9756370fafcde9bcc4483eb271ecad09a94dd63"],
|
||||
["It is an OP_CHECKMULTISIG with the dummy value set to something other than an empty string"],
|
||||
@ -150,6 +150,15 @@
|
||||
[[["a955032f4d6b0c9bfe8cad8f00a8933790b9c1dc28c82e0f48e75b35da0e4944", 0, "0x21 0x038479a0fa998cd35259a2ef0a7a5c68662c1474f88ccb6d08a7677bbec7f22041 CHECKSIGVERIFY CODESEPARATOR 0x21 0x038479a0fa998cd35259a2ef0a7a5c68662c1474f88ccb6d08a7677bbec7f22041 CHECKSIGVERIFY CODESEPARATOR 1"]],
|
||||
"010000000144490eda355be7480f2ec828dcc1b9903793a8008fad8cfe9b0c6b4d2f0355a900000000924830450221009c0a27f886a1d8cb87f6f595fbc3163d28f7a81ec3c4b252ee7f3ac77fd13ffa02203caa8dfa09713c8c4d7ef575c75ed97812072405d932bd11e6a1593a98b679370148304502201e3861ef39a526406bad1e20ecad06be7375ad40ddb582c9be42d26c3a0d7b240221009d0a3985e96522e59635d19cc4448547477396ce0ef17a58e7d74c3ef464292301ffffffff010000000000000000016a00000000", "P2SH"],
|
||||
|
||||
["CODESEPARATOR in an unexecuted IF block does not change what is hashed"],
|
||||
[[["a955032f4d6b0c9bfe8cad8f00a8933790b9c1dc28c82e0f48e75b35da0e4944", 0, "IF CODESEPARATOR ENDIF 0x21 0x0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71 CHECKSIGVERIFY CODESEPARATOR 1"]],
|
||||
"010000000144490eda355be7480f2ec828dcc1b9903793a8008fad8cfe9b0c6b4d2f0355a9000000004a48304502207a6974a77c591fa13dff60cabbb85a0de9e025c09c65a4b2285e47ce8e22f761022100f0efaac9ff8ac36b10721e0aae1fb975c90500b50c56e8a0cc52b0403f0425dd0100ffffffff010000000000000000016a00000000", "P2SH"],
|
||||
|
||||
["As above, with the IF block executed"],
|
||||
[[["a955032f4d6b0c9bfe8cad8f00a8933790b9c1dc28c82e0f48e75b35da0e4944", 0, "IF CODESEPARATOR ENDIF 0x21 0x0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71 CHECKSIGVERIFY CODESEPARATOR 1"]],
|
||||
"010000000144490eda355be7480f2ec828dcc1b9903793a8008fad8cfe9b0c6b4d2f0355a9000000004a483045022100fa4a74ba9fd59c59f46c3960cf90cbe0d2b743c471d24a3d5d6db6002af5eebb02204d70ec490fd0f7055a7c45f86514336e3a7f03503dacecabb247fc23f15c83510151ffffffff010000000000000000016a00000000", "P2SH"],
|
||||
|
||||
|
||||
["CHECKSIG is legal in scriptSigs"],
|
||||
[[["ccf7f4053a02e653c36ac75c891b7496d0dc5ce5214f6c913d9cf8f1329ebee0", 0, "DUP HASH160 0x14 0xee5a6aa40facefb2655ac23c0c28c57c65c41f9b EQUALVERIFY CHECKSIG"]],
|
||||
"0100000001e0be9e32f1f89c3d916c4f21e55cdcd096741b895cc76ac353e6023a05f4f7cc00000000d86149304602210086e5f736a2c3622ebb62bd9d93d8e5d76508b98be922b97160edc3dcca6d8c47022100b23c312ac232a4473f19d2aeb95ab7bdf2b65518911a0d72d50e38b5dd31dc820121038479a0fa998cd35259a2ef0a7a5c68662c1474f88ccb6d08a7677bbec7f22041ac4730440220508fa761865c8abd81244a168392876ee1d94e8ed83897066b5e2df2400dad24022043f5ee7538e87e9c6aef7ef55133d3e51da7cc522830a9c4d736977a76ef755c0121038479a0fa998cd35259a2ef0a7a5c68662c1474f88ccb6d08a7677bbec7f22041ffffffff010000000000000000016a00000000", "P2SH"],
|
||||
@ -179,5 +188,328 @@
|
||||
"0100000002dbb33bdf185b17f758af243c5d3c6e164cc873f6bb9f40c0677d6e0f8ee5afce000000006b4830450221009627444320dc5ef8d7f68f35010b4c050a6ed0d96b67a84db99fda9c9de58b1e02203e4b4aaa019e012e65d69b487fdf8719df72f488fa91506a80c49a33929f1fd50121022b78b756e2258af13779c1a1f37ea6800259716ca4b7f0b87610e0bf3ab52a01ffffffffdbb33bdf185b17f758af243c5d3c6e164cc873f6bb9f40c0677d6e0f8ee5afce010000009300483045022015bd0139bcccf990a6af6ec5c1c52ed8222e03a0d51c334df139968525d2fcd20221009f9efe325476eb64c3958e4713e9eefe49bf1d820ed58d2112721b134e2a1a5303483045022015bd0139bcccf990a6af6ec5c1c52ed8222e03a0d51c334df139968525d2fcd20221009f9efe325476eb64c3958e4713e9eefe49bf1d820ed58d2112721b134e2a1a5303ffffffff01a0860100000000001976a9149bc0bbdd3024da4d0c38ed1aecf5c68dd1d3fa1288ac00000000", "P2SH"],
|
||||
|
||||
|
||||
["CHECKLOCKTIMEVERIFY tests"],
|
||||
|
||||
["By-height locks, with argument == 0 and == tx nLockTime"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "499999999 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ff64cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ff64cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
|
||||
["By-time locks, with argument just beyond tx nLockTime (but within numerical boundaries)"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "500000000 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000065cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4294967295 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ffffffff", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "500000000 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ffffffff", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
|
||||
["Any non-maxint nSequence is fine"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000feffffff0100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
|
||||
["The argument can be calculated rather than created directly by a PUSHDATA"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "499999999 1ADD CHECKLOCKTIMEVERIFY 1"]],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000065cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
|
||||
["Perhaps even by an ADD producing a 5-byte result that is out of bounds for other opcodes"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483647 2147483647 ADD CHECKLOCKTIMEVERIFY 1"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000feffffff", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
|
||||
["5 byte non-minimally-encoded arguments are valid"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x05 0x0000000000 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
|
||||
["Valid CHECKLOCKTIMEVERIFY in scriptSig"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "1"]],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000251b1000000000100000000000000000001000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
|
||||
["Valid CHECKLOCKTIMEVERIFY in redeemScript"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0xc5b93064159b3b2d6ab506a41b1f50463771b988 EQUAL"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000030251b1000000000100000000000000000001000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
|
||||
["A transaction with a non-standard DER signature."],
|
||||
[[["b1dbc81696c8a9c0fccd0693ab66d7c368dbc38c0def4e800685560ddd1b2132", 0, "DUP HASH160 0x14 0x4b3bd7eba3bc0284fd3007be7f3be275e94f5826 EQUALVERIFY CHECKSIG"]],
|
||||
"010000000132211bdd0d568506804eef0d8cc3db68c3d766ab9306cdfcc0a9c89616c8dbb1000000006c493045022100c7bb0faea0522e74ff220c20c022d2cb6033f8d167fb89e75a50e237a35fd6d202203064713491b1f8ad5f79e623d0219ad32510bfaa1009ab30cbee77b59317d6e30001210237af13eb2d84e4545af287b919c2282019c9691cc509e78e196a9d8274ed1be0ffffffff0100000000000000001976a914f1b3ed2eda9a2ebe5a9374f692877cdf87c0f95b88ac00000000", "P2SH"],
|
||||
|
||||
["CHECKSEQUENCEVERIFY tests"],
|
||||
|
||||
["By-height locks, with argument == 0 and == txin.nSequence"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "65535 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffff00000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "65535 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffbf7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffbf7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
|
||||
["By-time locks, with argument == 0 and == txin.nSequence"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4194304 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4259839 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffff40000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4259839 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffff7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4194304 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffff7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
|
||||
["Upper sequence with upper sequence is fine"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483648 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000800100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4294967295 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000800100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483648 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000feffffff0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4294967295 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000feffffff0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483648 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4294967295 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
|
||||
["Argument 2^31 with various nSequence"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483648 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffbf7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483648 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffff7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483648 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
|
||||
["Argument 2^32-1 with various nSequence"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4294967295 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffbf7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4294967295 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffff7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4294967295 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
|
||||
["Argument 3<<31 with various nSequence"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "6442450944 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffbf7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "6442450944 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffff7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "6442450944 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
|
||||
["5 byte non-minimally-encoded operandss are valid"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x05 0x0000000000 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
|
||||
["The argument can be calculated rather than created directly by a PUSHDATA"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4194303 1ADD CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4194304 1SUB CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffff00000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
|
||||
["An ADD producing a 5-byte result that sets CTxIn::SEQUENCE_LOCKTIME_DISABLE_FLAG"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483647 65536 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483647 4259840 ADD CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
|
||||
["Valid CHECKSEQUENCEVERIFY in scriptSig"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "1"]],
|
||||
"02000000010001000000000000000000000000000000000000000000000000000000000000000000000251b2010000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
|
||||
["Valid CHECKSEQUENCEVERIFY in redeemScript"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x7c17aff532f22beb54069942f9bf567a66133eaf EQUAL"]],
|
||||
"0200000001000100000000000000000000000000000000000000000000000000000000000000000000030251b2010000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
|
||||
["Valid P2WPKH (Private key of segwit tests is L5AQtV2HDm4xGsseLokK2VAT2EtYKcTm3c7HwqnJBFt9LdaQULsM)"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 1000]],
|
||||
"0100000000010100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff01e8030000000000001976a9144c9c3dfac4207d5d8cb89df5722cb3d712385e3f88ac02483045022100cfb07164b36ba64c1b1e8c7720a56ad64d96f6ef332d3d37f9cb3c96477dc44502200a464cd7a9cf94cd70f66ce4f4f0625ef650052c7afcfe29d7d7e01830ff91ed012103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc7100000000", "P2SH,WITNESS"],
|
||||
|
||||
["Valid P2WSH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x00 0x20 0xff25429251b5a84f452230a3c75fd886b7fc5a7865ce4a7bb7a9d7c5be6da3db", 1000]],
|
||||
"0100000000010100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff01e8030000000000001976a9144c9c3dfac4207d5d8cb89df5722cb3d712385e3f88ac02483045022100aa5d8aa40a90f23ce2c3d11bc845ca4a12acd99cbea37de6b9f6d86edebba8cb022022dedc2aa0a255f74d04c0b76ece2d7c691f9dd11a64a8ac49f62a99c3a05f9d01232103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc71ac00000000", "P2SH,WITNESS"],
|
||||
|
||||
["Valid P2SH(P2WPKH)"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0xfe9c7dacc9fcfbf7e3b7d5ad06aa2b28c5a7b7e3 EQUAL", 1000]],
|
||||
"01000000000101000100000000000000000000000000000000000000000000000000000000000000000000171600144c9c3dfac4207d5d8cb89df5722cb3d712385e3fffffffff01e8030000000000001976a9144c9c3dfac4207d5d8cb89df5722cb3d712385e3f88ac02483045022100cfb07164b36ba64c1b1e8c7720a56ad64d96f6ef332d3d37f9cb3c96477dc44502200a464cd7a9cf94cd70f66ce4f4f0625ef650052c7afcfe29d7d7e01830ff91ed012103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc7100000000", "P2SH,WITNESS"],
|
||||
|
||||
["Valid P2SH(P2WSH)"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x2135ab4f0981830311e35600eebc7376dce3a914 EQUAL", 1000]],
|
||||
"0100000000010100010000000000000000000000000000000000000000000000000000000000000000000023220020ff25429251b5a84f452230a3c75fd886b7fc5a7865ce4a7bb7a9d7c5be6da3dbffffffff01e8030000000000001976a9144c9c3dfac4207d5d8cb89df5722cb3d712385e3f88ac02483045022100aa5d8aa40a90f23ce2c3d11bc845ca4a12acd99cbea37de6b9f6d86edebba8cb022022dedc2aa0a255f74d04c0b76ece2d7c691f9dd11a64a8ac49f62a99c3a05f9d01232103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc71ac00000000", "P2SH,WITNESS"],
|
||||
|
||||
["Witness with SigHash Single|AnyoneCanPay"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 2, "0x51", 3100],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 1, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 2000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x51", 1100],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 3, "0x51", 4100]],
|
||||
"0100000000010400010000000000000000000000000000000000000000000000000000000000000200000000ffffffff00010000000000000000000000000000000000000000000000000000000000000100000000ffffffff00010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00010000000000000000000000000000000000000000000000000000000000000300000000ffffffff05540b0000000000000151d0070000000000000151840300000000000001513c0f00000000000001512c010000000000000151000248304502210092f4777a0f17bf5aeb8ae768dec5f2c14feabf9d1fe2c89c78dfed0f13fdb86902206da90a86042e252bcd1e80a168c719e4a1ddcc3cebea24b9812c5453c79107e9832103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc71000000000000", "P2SH,WITNESS"],
|
||||
|
||||
["Witness with SigHash Single|AnyoneCanPay (same signature as previous)"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x51", 1000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 1, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 2000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 2, "0x51", 3000]],
|
||||
"0100000000010300010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00010000000000000000000000000000000000000000000000000000000000000100000000ffffffff00010000000000000000000000000000000000000000000000000000000000000200000000ffffffff03e8030000000000000151d0070000000000000151b80b0000000000000151000248304502210092f4777a0f17bf5aeb8ae768dec5f2c14feabf9d1fe2c89c78dfed0f13fdb86902206da90a86042e252bcd1e80a168c719e4a1ddcc3cebea24b9812c5453c79107e9832103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc710000000000", "P2SH,WITNESS"],
|
||||
|
||||
["Witness with SigHash Single"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x51", 1000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 1, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 2000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 2, "0x51", 3000]],
|
||||
"0100000000010300010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00010000000000000000000000000000000000000000000000000000000000000100000000ffffffff00010000000000000000000000000000000000000000000000000000000000000200000000ffffffff0484030000000000000151d0070000000000000151540b0000000000000151c800000000000000015100024730440220699e6b0cfe015b64ca3283e6551440a34f901ba62dd4c72fe1cb815afb2e6761022021cc5e84db498b1479de14efda49093219441adc6c543e5534979605e273d80b032103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc710000000000", "P2SH,WITNESS"],
|
||||
|
||||
["Witness with SigHash Single (same signature as previous)"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x51", 1000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 1, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 2000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 2, "0x51", 3000]],
|
||||
"0100000000010300010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00010000000000000000000000000000000000000000000000000000000000000100000000ffffffff00010000000000000000000000000000000000000000000000000000000000000200000000ffffffff03e8030000000000000151d0070000000000000151b80b000000000000015100024730440220699e6b0cfe015b64ca3283e6551440a34f901ba62dd4c72fe1cb815afb2e6761022021cc5e84db498b1479de14efda49093219441adc6c543e5534979605e273d80b032103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc710000000000", "P2SH,WITNESS"],
|
||||
|
||||
["Witness with SigHash None|AnyoneCanPay"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 2, "0x51", 3100],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x51", 1100],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 1, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 2000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 3, "0x51", 4100]],
|
||||
"0100000000010400010000000000000000000000000000000000000000000000000000000000000200000000ffffffff00010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00010000000000000000000000000000000000000000000000000000000000000100000000ffffffff00010000000000000000000000000000000000000000000000000000000000000300000000ffffffff04b60300000000000001519e070000000000000151860b00000000000001009600000000000000015100000248304502210091b32274295c2a3fa02f5bce92fb2789e3fc6ea947fbe1a76e52ea3f4ef2381a022079ad72aefa3837a2e0c033a8652a59731da05fa4a813f4fc48e87c075037256b822103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc710000000000", "P2SH,WITNESS"],
|
||||
|
||||
["Witness with SigHash None|AnyoneCanPay (same signature as previous)"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x51", 1000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 1, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 2000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 2, "0x51", 3000]],
|
||||
"0100000000010300010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00010000000000000000000000000000000000000000000000000000000000000100000000ffffffff00010000000000000000000000000000000000000000000000000000000000000200000000ffffffff03e8030000000000000151d0070000000000000151b80b0000000000000151000248304502210091b32274295c2a3fa02f5bce92fb2789e3fc6ea947fbe1a76e52ea3f4ef2381a022079ad72aefa3837a2e0c033a8652a59731da05fa4a813f4fc48e87c075037256b822103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc710000000000", "P2SH,WITNESS"],
|
||||
|
||||
["Witness with SigHash None"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x51", 1000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 1, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 2000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 2, "0x51", 3000]],
|
||||
"0100000000010300010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00010000000000000000000000000000000000000000000000000000000000000100000000ffffffff00010000000000000000000000000000000000000000000000000000000000000200000000ffffffff04b60300000000000001519e070000000000000151860b0000000000000100960000000000000001510002473044022022fceb54f62f8feea77faac7083c3b56c4676a78f93745adc8a35800bc36adfa022026927df9abcf0a8777829bcfcce3ff0a385fa54c3f9df577405e3ef24ee56479022103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc710000000000", "P2SH,WITNESS"],
|
||||
|
||||
["Witness with SigHash None (same signature as previous)"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x51", 1000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 1, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 2000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 2, "0x51", 3000]],
|
||||
"0100000000010300010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00010000000000000000000000000000000000000000000000000000000000000100000000ffffffff00010000000000000000000000000000000000000000000000000000000000000200000000ffffffff03e8030000000000000151d0070000000000000151b80b00000000000001510002473044022022fceb54f62f8feea77faac7083c3b56c4676a78f93745adc8a35800bc36adfa022026927df9abcf0a8777829bcfcce3ff0a385fa54c3f9df577405e3ef24ee56479022103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc710000000000", "P2SH,WITNESS"],
|
||||
|
||||
["Witness with SigHash None (same signature, only sequences changed)"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x51", 1000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 1, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 2000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 2, "0x51", 3000]],
|
||||
"01000000000103000100000000000000000000000000000000000000000000000000000000000000000000000200000000010000000000000000000000000000000000000000000000000000000000000100000000ffffffff000100000000000000000000000000000000000000000000000000000000000002000000000200000003e8030000000000000151d0070000000000000151b80b00000000000001510002473044022022fceb54f62f8feea77faac7083c3b56c4676a78f93745adc8a35800bc36adfa022026927df9abcf0a8777829bcfcce3ff0a385fa54c3f9df577405e3ef24ee56479022103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc710000000000", "P2SH,WITNESS"],
|
||||
|
||||
["Witness with SigHash All|AnyoneCanPay"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 2, "0x51", 3100],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x51", 1100],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 1, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 2000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 3, "0x51", 4100]],
|
||||
"0100000000010400010000000000000000000000000000000000000000000000000000000000000200000000ffffffff00010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00010000000000000000000000000000000000000000000000000000000000000100000000ffffffff00010000000000000000000000000000000000000000000000000000000000000300000000ffffffff03e8030000000000000151d0070000000000000151b80b0000000000000151000002483045022100a3cec69b52cba2d2de623eeef89e0ba1606184ea55476c0f8189fda231bc9cbb022003181ad597f7c380a7d1c740286b1d022b8b04ded028b833282e055e03b8efef812103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc710000000000", "P2SH,WITNESS"],
|
||||
|
||||
["Witness with SigHash All|AnyoneCanPay (same signature as previous)"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x51", 1000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 1, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 2000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 2, "0x51", 3000]],
|
||||
"0100000000010300010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00010000000000000000000000000000000000000000000000000000000000000100000000ffffffff00010000000000000000000000000000000000000000000000000000000000000200000000ffffffff03e8030000000000000151d0070000000000000151b80b00000000000001510002483045022100a3cec69b52cba2d2de623eeef89e0ba1606184ea55476c0f8189fda231bc9cbb022003181ad597f7c380a7d1c740286b1d022b8b04ded028b833282e055e03b8efef812103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc710000000000", "P2SH,WITNESS"],
|
||||
|
||||
["Unknown witness program version (without DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM)"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x51", 1000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 1, "0x60 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 2000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 2, "0x51", 3000]],
|
||||
"0100000000010300010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00010000000000000000000000000000000000000000000000000000000000000100000000ffffffff00010000000000000000000000000000000000000000000000000000000000000200000000ffffffff03e8030000000000000151d0070000000000000151b80b00000000000001510002483045022100a3cec69b52cba2d2de623ffffffffff1606184ea55476c0f8189fda231bc9cbb022003181ad597f7c380a7d1c740286b1d022b8b04ded028b833282e055e03b8efef812103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc710000000000", "P2SH,WITNESS"],
|
||||
|
||||
["Witness with a push of 520 bytes"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x00 0x20 0x33198a9bfef674ebddb9ffaa52928017b8472791e54c609cb95f278ac6b1e349", 1000]],
|
||||
"0100000000010100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff010000000000000000015102fd08020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002755100000000", "P2SH,WITNESS"],
|
||||
|
||||
["Transaction mixing all SigHash, segwit and normal inputs"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 1000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 1, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 1001],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 2, "DUP HASH160 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f EQUALVERIFY CHECKSIG", 1002],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 3, "DUP HASH160 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f EQUALVERIFY CHECKSIG", 1003],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 4, "DUP HASH160 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f EQUALVERIFY CHECKSIG", 1004],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 5, "DUP HASH160 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f EQUALVERIFY CHECKSIG", 1005],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 6, "DUP HASH160 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f EQUALVERIFY CHECKSIG", 1006],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 7, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 1007],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 8, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 1008],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 9, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 1009],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 10, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 1010],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 11, "DUP HASH160 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f EQUALVERIFY CHECKSIG", 1011]],
|
||||
"0100000000010c00010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00010000000000000000000000000000000000000000000000000000000000000100000000ffffffff0001000000000000000000000000000000000000000000000000000000000000020000006a473044022026c2e65b33fcd03b2a3b0f25030f0244bd23cc45ae4dec0f48ae62255b1998a00220463aa3982b718d593a6b9e0044513fd67a5009c2fdccc59992cffc2b167889f4012103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc71ffffffff0001000000000000000000000000000000000000000000000000000000000000030000006a4730440220008bd8382911218dcb4c9f2e75bf5c5c3635f2f2df49b36994fde85b0be21a1a02205a539ef10fb4c778b522c1be852352ea06c67ab74200977c722b0bc68972575a012103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc71ffffffff0001000000000000000000000000000000000000000000000000000000000000040000006b483045022100d9436c32ff065127d71e1a20e319e4fe0a103ba0272743dbd8580be4659ab5d302203fd62571ee1fe790b182d078ecfd092a509eac112bea558d122974ef9cc012c7012103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc71ffffffff0001000000000000000000000000000000000000000000000000000000000000050000006a47304402200e2c149b114ec546015c13b2b464bbcb0cdc5872e6775787527af6cbc4830b6c02207e9396c6979fb15a9a2b96ca08a633866eaf20dc0ff3c03e512c1d5a1654f148012103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc71ffffffff0001000000000000000000000000000000000000000000000000000000000000060000006b483045022100b20e70d897dc15420bccb5e0d3e208d27bdd676af109abbd3f88dbdb7721e6d6022005836e663173fbdfe069f54cde3c2decd3d0ea84378092a5d9d85ec8642e8a41012103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc71ffffffff00010000000000000000000000000000000000000000000000000000000000000700000000ffffffff00010000000000000000000000000000000000000000000000000000000000000800000000ffffffff00010000000000000000000000000000000000000000000000000000000000000900000000ffffffff00010000000000000000000000000000000000000000000000000000000000000a00000000ffffffff00010000000000000000000000000000000000000000000000000000000000000b0000006a47304402206639c6e05e3b9d2675a7f3876286bdf7584fe2bbd15e0ce52dd4e02c0092cdc60220757d60b0a61fc95ada79d23746744c72bac1545a75ff6c2c7cdb6ae04e7e9592012103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc71ffffffff0ce8030000000000000151e9030000000000000151ea030000000000000151eb030000000000000151ec030000000000000151ed030000000000000151ee030000000000000151ef030000000000000151f0030000000000000151f1030000000000000151f2030000000000000151f30300000000000001510248304502210082219a54f61bf126bfc3fa068c6e33831222d1d7138c6faa9d33ca87fd4202d6022063f9902519624254d7c2c8ea7ba2d66ae975e4e229ae38043973ec707d5d4a83012103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc7102473044022017fb58502475848c1b09f162cb1688d0920ff7f142bed0ef904da2ccc88b168f02201798afa61850c65e77889cbcd648a5703b487895517c88f85cdd18b021ee246a012103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc7100000000000247304402202830b7926e488da75782c81a54cd281720890d1af064629ebf2e31bf9f5435f30220089afaa8b455bbeb7d9b9c3fe1ed37d07685ade8455c76472cda424d93e4074a012103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc7102473044022026326fcdae9207b596c2b05921dbac11d81040c4d40378513670f19d9f4af893022034ecd7a282c0163b89aaa62c22ec202cef4736c58cd251649bad0d8139bcbf55012103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc71024730440220214978daeb2f38cd426ee6e2f44131a33d6b191af1c216247f1dd7d74c16d84a02205fdc05529b0bc0c430b4d5987264d9d075351c4f4484c16e91662e90a72aab24012103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc710247304402204a6e9f199dc9672cf2ff8094aaa784363be1eb62b679f7ff2df361124f1dca3302205eeb11f70fab5355c9c8ad1a0700ea355d315e334822fa182227e9815308ee8f012103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc710000000000", "P2SH,WITNESS"],
|
||||
|
||||
["Unknown version witness program with empty witness"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x60 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 1000]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff01e803000000000000015100000000", "P2SH,WITNESS"],
|
||||
|
||||
["Witness SIGHASH_SINGLE with output out of bound"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x51", 1000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 1, "0x00 0x20 0x4d6c2a32c87821d68fc016fca70797abdb80df6cd84651d40a9300c6bad79e62", 1000]],
|
||||
"0100000000010200010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00010000000000000000000000000000000000000000000000000000000000000100000000ffffffff01d00700000000000001510003483045022100e078de4e96a0e05dcdc0a414124dd8475782b5f3f0ed3f607919e9a5eeeb22bf02201de309b3a3109adb3de8074b3610d4cf454c49b61247a2779a0bcbf31c889333032103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc711976a9144c9c3dfac4207d5d8cb89df5722cb3d712385e3f88ac00000000", "P2SH,WITNESS"],
|
||||
|
||||
["1 byte push should not be considered a witness scriptPubKey"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x60 0x01 0x01", 1000]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff01e803000000000000015100000000", "P2SH,WITNESS,DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM"],
|
||||
|
||||
["41 bytes push should not be considered a witness scriptPubKey"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x60 0x29 0xff25429251b5a84f452230a3c75fd886b7fc5a7865ce4a7bb7a9d7c5be6da3dbff0000000000000000", 1000]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff01e803000000000000015100000000", "P2SH,WITNESS,DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM"],
|
||||
|
||||
["The witness version must use OP_1 to OP_16 only"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x01 0x10 0x02 0x0001", 1000]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff01e803000000000000015100000000", "P2SH,WITNESS,DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM"],
|
||||
|
||||
["The witness program push must be canonical"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x60 0x4c02 0x0001", 1000]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff01e803000000000000015100000000", "P2SH,WITNESS,DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM"],
|
||||
|
||||
["Witness Single|AnyoneCanPay does not hash input's position"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 1000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 1, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 1001]],
|
||||
"0100000000010200010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00010000000000000000000000000000000000000000000000000000000000000100000000ffffffff02e8030000000000000151e90300000000000001510247304402206d59682663faab5e4cb733c562e22cdae59294895929ec38d7c016621ff90da0022063ef0af5f970afe8a45ea836e3509b8847ed39463253106ac17d19c437d3d56b832103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc710248304502210085001a820bfcbc9f9de0298af714493f8a37b3b354bfd21a7097c3e009f2018c022050a8b4dbc8155d4d04da2f5cdd575dcf8dd0108de8bec759bd897ea01ecb3af7832103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc7100000000", "P2SH,WITNESS"],
|
||||
|
||||
["Witness Single|AnyoneCanPay does not hash input's position (permutation)"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 1, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 1001],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x00 0x14 0x4c9c3dfac4207d5d8cb89df5722cb3d712385e3f", 1000]],
|
||||
"0100000000010200010000000000000000000000000000000000000000000000000000000000000100000000ffffffff00010000000000000000000000000000000000000000000000000000000000000000000000ffffffff02e9030000000000000151e80300000000000001510248304502210085001a820bfcbc9f9de0298af714493f8a37b3b354bfd21a7097c3e009f2018c022050a8b4dbc8155d4d04da2f5cdd575dcf8dd0108de8bec759bd897ea01ecb3af7832103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc710247304402206d59682663faab5e4cb733c562e22cdae59294895929ec38d7c016621ff90da0022063ef0af5f970afe8a45ea836e3509b8847ed39463253106ac17d19c437d3d56b832103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc7100000000", "P2SH,WITNESS"],
|
||||
|
||||
["Non witness Single|AnyoneCanPay hash input's position"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x21 0x03596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc71 CHECKSIG", 1000],
|
||||
["0000000000000000000000000000000000000000000000000000000000000100", 1, "0x21 0x03596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc71 CHECKSIG", 1001]],
|
||||
"01000000020001000000000000000000000000000000000000000000000000000000000000000000004847304402202a0b4b1294d70540235ae033d78e64b4897ec859c7b6f1b2b1d8a02e1d46006702201445e756d2254b0f1dfda9ab8e1e1bc26df9668077403204f32d16a49a36eb6983ffffffff00010000000000000000000000000000000000000000000000000000000000000100000049483045022100acb96cfdbda6dc94b489fd06f2d720983b5f350e31ba906cdbd800773e80b21c02200d74ea5bdf114212b4bbe9ed82c36d2e369e302dff57cb60d01c428f0bd3daab83ffffffff02e8030000000000000151e903000000000000015100000000", "P2SH,WITNESS"],
|
||||
|
||||
["BIP143 examples: details and private keys are available in BIP143"],
|
||||
["BIP143 example: P2WSH with OP_CODESEPARATOR and out-of-range SIGHASH_SINGLE."],
|
||||
[[["6eb316926b1c5d567cd6f5e6a84fec606fc53d7b474526d1fff3948020c93dfe", 0, "0x21 0x036d5c20fa14fb2f635474c1dc4ef5909d4568e5569b79fc94d3448486e14685f8 CHECKSIG", 156250000],
|
||||
["f825690aee1b3dc247da796cacb12687a5e802429fd291cfd63e010f02cf1508", 0, "0x00 0x20 0x5d1b56b63d714eebe542309525f484b7e9d6f686b3781b6f61ef925d66d6f6a0", 4900000000]],
|
||||
"01000000000102fe3dc9208094f3ffd12645477b3dc56f60ec4fa8e6f5d67c565d1c6b9216b36e000000004847304402200af4e47c9b9629dbecc21f73af989bdaa911f7e6f6c2e9394588a3aa68f81e9902204f3fcf6ade7e5abb1295b6774c8e0abd94ae62217367096bc02ee5e435b67da201ffffffff0815cf020f013ed6cf91d29f4202e8a58726b1ac6c79da47c23d1bee0a6925f80000000000ffffffff0100f2052a010000001976a914a30741f8145e5acadf23f751864167f32e0963f788ac000347304402200de66acf4527789bfda55fc5459e214fa6083f936b430a762c629656216805ac0220396f550692cd347171cbc1ef1f51e15282e837bb2b30860dc77c8f78bc8501e503473044022027dc95ad6b740fe5129e7e62a75dd00f291a2aeb1200b84b09d9e3789406b6c002201a9ecd315dd6a0e632ab20bbb98948bc0c6fb204f2c286963bb48517a7058e27034721026dccc749adc2a9d0d89497ac511f760f45c47dc5ed9cf352a58ac706453880aeadab210255a9626aebf5e29c0e6538428ba0d1dcf6ca98ffdf086aa8ced5e0d0215ea465ac00000000", "P2SH,WITNESS"],
|
||||
|
||||
["BIP143 example: P2WSH with unexecuted OP_CODESEPARATOR and SINGLE|ANYONECANPAY"],
|
||||
[[["01c0cf7fba650638e55eb91261b183251fbb466f90dff17f10086817c542b5e9", 0, "0x00 0x20 0xba468eea561b26301e4cf69fa34bde4ad60c81e70f059f045ca9a79931004a4d", 16777215],
|
||||
["1b2a9a426ba603ba357ce7773cb5805cb9c7c2b386d100d1fc9263513188e680", 0, "0x00 0x20 0xd9bbfbe56af7c4b7f960a70d7ea107156913d9e5a26b0a71429df5e097ca6537", 16777215]],
|
||||
"01000000000102e9b542c5176808107ff1df906f46bb1f2583b16112b95ee5380665ba7fcfc0010000000000ffffffff80e68831516392fcd100d186b3c2c7b95c80b53c77e77c35ba03a66b429a2a1b0000000000ffffffff0280969800000000001976a914de4b231626ef508c9a74a8517e6783c0546d6b2888ac80969800000000001976a9146648a8cd4531e1ec47f35916de8e259237294d1e88ac02483045022100f6a10b8604e6dc910194b79ccfc93e1bc0ec7c03453caaa8987f7d6c3413566002206216229ede9b4d6ec2d325be245c5b508ff0339bf1794078e20bfe0babc7ffe683270063ab68210392972e2eb617b2388771abe27235fd5ac44af8e61693261550447a4c3e39da98ac024730440220032521802a76ad7bf74d0e2c218b72cf0cbc867066e2e53db905ba37f130397e02207709e2188ed7f08f4c952d9d13986da504502b8c3be59617e043552f506c46ff83275163ab68210392972e2eb617b2388771abe27235fd5ac44af8e61693261550447a4c3e39da98ac00000000", "P2SH,WITNESS"],
|
||||
|
||||
["BIP143 example: Same as the previous example with input-output paris swapped"],
|
||||
[[["1b2a9a426ba603ba357ce7773cb5805cb9c7c2b386d100d1fc9263513188e680", 0, "0x00 0x20 0xd9bbfbe56af7c4b7f960a70d7ea107156913d9e5a26b0a71429df5e097ca6537", 16777215],
|
||||
["01c0cf7fba650638e55eb91261b183251fbb466f90dff17f10086817c542b5e9", 0, "0x00 0x20 0xba468eea561b26301e4cf69fa34bde4ad60c81e70f059f045ca9a79931004a4d", 16777215]],
|
||||
"0100000000010280e68831516392fcd100d186b3c2c7b95c80b53c77e77c35ba03a66b429a2a1b0000000000ffffffffe9b542c5176808107ff1df906f46bb1f2583b16112b95ee5380665ba7fcfc0010000000000ffffffff0280969800000000001976a9146648a8cd4531e1ec47f35916de8e259237294d1e88ac80969800000000001976a914de4b231626ef508c9a74a8517e6783c0546d6b2888ac024730440220032521802a76ad7bf74d0e2c218b72cf0cbc867066e2e53db905ba37f130397e02207709e2188ed7f08f4c952d9d13986da504502b8c3be59617e043552f506c46ff83275163ab68210392972e2eb617b2388771abe27235fd5ac44af8e61693261550447a4c3e39da98ac02483045022100f6a10b8604e6dc910194b79ccfc93e1bc0ec7c03453caaa8987f7d6c3413566002206216229ede9b4d6ec2d325be245c5b508ff0339bf1794078e20bfe0babc7ffe683270063ab68210392972e2eb617b2388771abe27235fd5ac44af8e61693261550447a4c3e39da98ac00000000", "P2SH,WITNESS"],
|
||||
|
||||
["BIP143 example: P2SH-P2WSH 6-of-6 multisig signed with 6 different SIGHASH types"],
|
||||
[[["6eb98797a21c6c10aa74edf29d618be109f48a8e94c694f3701e08ca69186436", 1, "HASH160 0x14 0x9993a429037b5d912407a71c252019287b8d27a5 EQUAL", 987654321]],
|
||||
"0100000000010136641869ca081e70f394c6948e8af409e18b619df2ed74aa106c1ca29787b96e0100000023220020a16b5755f7f6f96dbd65f5f0d6ab9418b89af4b1f14a1bb8a09062c35f0dcb54ffffffff0200e9a435000000001976a914389ffce9cd9ae88dcc0631e88a821ffdbe9bfe2688acc0832f05000000001976a9147480a33f950689af511e6e84c138dbbd3c3ee41588ac080047304402206ac44d672dac41f9b00e28f4df20c52eeb087207e8d758d76d92c6fab3b73e2b0220367750dbbe19290069cba53d096f44530e4f98acaa594810388cf7409a1870ce01473044022068c7946a43232757cbdf9176f009a928e1cd9a1a8c212f15c1e11ac9f2925d9002205b75f937ff2f9f3c1246e547e54f62e027f64eefa2695578cc6432cdabce271502473044022059ebf56d98010a932cf8ecfec54c48e6139ed6adb0728c09cbe1e4fa0915302e022007cd986c8fa870ff5d2b3a89139c9fe7e499259875357e20fcbb15571c76795403483045022100fbefd94bd0a488d50b79102b5dad4ab6ced30c4069f1eaa69a4b5a763414067e02203156c6a5c9cf88f91265f5a942e96213afae16d83321c8b31bb342142a14d16381483045022100a5263ea0553ba89221984bd7f0b13613db16e7a70c549a86de0cc0444141a407022005c360ef0ae5a5d4f9f2f87a56c1546cc8268cab08c73501d6b3be2e1e1a8a08824730440220525406a1482936d5a21888260dc165497a90a15669636d8edca6b9fe490d309c022032af0c646a34a44d1f4576bf6a4a74b67940f8faa84c7df9abe12a01a11e2b4783cf56210307b8ae49ac90a048e9b53357a2354b3334e9c8bee813ecb98e99a7e07e8c3ba32103b28f0c28bfab54554ae8c658ac5c3e0ce6e79ad336331f78c428dd43eea8449b21034b8113d703413d57761b8b9781957b8c0ac1dfe69f492580ca4195f50376ba4a21033400f6afecb833092a9a21cfdf1ed1376e58c5d1f47de74683123987e967a8f42103a6d48b1131e94ba04d9737d61acdaa1322008af9602b3b14862c07a1789aac162102d8b661b0b3302ee2f162b09e07a55ad5dfbe673a9f01d9f0c19617681024306b56ae00000000", "P2SH,WITNESS"],
|
||||
|
||||
["FindAndDelete tests"],
|
||||
["This is a test of FindAndDelete. The first tx is a spend of normal P2SH and the second tx is a spend of bare P2WSH."],
|
||||
["The redeemScript/witnessScript is CHECKSIGVERIFY <0x30450220487fb382c4974de3f7d834c1b617fe15860828c7f96454490edd6d891556dcc9022100baf95feb48f845d5bfc9882eb6aeefa1bc3790e39f59eaa46ff7f15ae626c53e01>."],
|
||||
["The signature is <0x30450220487fb382c4974de3f7d834c1b617fe15860828c7f96454490edd6d891556dcc9022100baf95feb48f845d5bfc9882eb6aeefa1bc3790e39f59eaa46ff7f15ae626c53e01> <pubkey>,"],
|
||||
["where the pubkey is obtained through key recovery with sig and correct sighash."],
|
||||
["This is to show that FindAndDelete is applied only to non-segwit scripts"],
|
||||
["Non-segwit: correct sighash (with FindAndDelete) = 1ba1fe3bc90c5d1265460e684ce6774e324f0fabdf67619eda729e64e8b6bc08"],
|
||||
[[["f18783ace138abac5d3a7a5cf08e88fe6912f267ef936452e0c27d090621c169", 7000, "HASH160 0x14 0x0c746489e2d83cdbb5b90b432773342ba809c134 EQUAL", 200000]],
|
||||
"010000000169c12106097dc2e0526493ef67f21269fe888ef05c7a3a5dacab38e1ac8387f1581b0000b64830450220487fb382c4974de3f7d834c1b617fe15860828c7f96454490edd6d891556dcc9022100baf95feb48f845d5bfc9882eb6aeefa1bc3790e39f59eaa46ff7f15ae626c53e0121037a3fb04bcdb09eba90f69961ba1692a3528e45e67c85b200df820212d7594d334aad4830450220487fb382c4974de3f7d834c1b617fe15860828c7f96454490edd6d891556dcc9022100baf95feb48f845d5bfc9882eb6aeefa1bc3790e39f59eaa46ff7f15ae626c53e01ffffffff0101000000000000000000000000", "P2SH,WITNESS"],
|
||||
["BIP143: correct sighash (without FindAndDelete) = 71c9cd9b2869b9c70b01b1f0360c148f42dee72297db312638df136f43311f23"],
|
||||
[[["f18783ace138abac5d3a7a5cf08e88fe6912f267ef936452e0c27d090621c169", 7500, "0x00 0x20 0x9e1be07558ea5cc8e02ed1d80c0911048afad949affa36d5c3951e3159dbea19", 200000]],
|
||||
"0100000000010169c12106097dc2e0526493ef67f21269fe888ef05c7a3a5dacab38e1ac8387f14c1d000000ffffffff01010000000000000000034830450220487fb382c4974de3f7d834c1b617fe15860828c7f96454490edd6d891556dcc9022100baf95feb48f845d5bfc9882eb6aeefa1bc3790e39f59eaa46ff7f15ae626c53e012102a9781d66b61fb5a7ef00ac5ad5bc6ffc78be7b44a566e3c87870e1079368df4c4aad4830450220487fb382c4974de3f7d834c1b617fe15860828c7f96454490edd6d891556dcc9022100baf95feb48f845d5bfc9882eb6aeefa1bc3790e39f59eaa46ff7f15ae626c53e0100000000", "P2SH,WITNESS"],
|
||||
["This is multisig version of the FindAndDelete tests"],
|
||||
["Script is 2 CHECKMULTISIGVERIFY <sig1> <sig2> DROP"],
|
||||
["52af4830450220487fb382c4974de3f7d834c1b617fe15860828c7f96454490edd6d891556dcc9022100baf95feb48f845d5bfc9882eb6aeefa1bc3790e39f59eaa46ff7f15ae626c53e0148304502205286f726690b2e9b0207f0345711e63fa7012045b9eb0f19c2458ce1db90cf43022100e89f17f86abc5b149eba4115d4f128bcf45d77fb3ecdd34f594091340c0395960175"],
|
||||
["Signature is 0 <sig1> <sig2> 2 <key1> <key2>"],
|
||||
["Non-segwit: correct sighash (with FindAndDelete) = 1d50f00ba4db2917b903b0ec5002e017343bb38876398c9510570f5dce099295"],
|
||||
[[["9628667ad48219a169b41b020800162287d2c0f713c04157e95c484a8dcb7592", 7000, "HASH160 0x14 0x5748407f5ca5cdca53ba30b79040260770c9ee1b EQUAL", 200000]],
|
||||
"01000000019275cb8d4a485ce95741c013f7c0d28722160008021bb469a11982d47a662896581b0000fd6f01004830450220487fb382c4974de3f7d834c1b617fe15860828c7f96454490edd6d891556dcc9022100baf95feb48f845d5bfc9882eb6aeefa1bc3790e39f59eaa46ff7f15ae626c53e0148304502205286f726690b2e9b0207f0345711e63fa7012045b9eb0f19c2458ce1db90cf43022100e89f17f86abc5b149eba4115d4f128bcf45d77fb3ecdd34f594091340c03959601522102cd74a2809ffeeed0092bc124fd79836706e41f048db3f6ae9df8708cefb83a1c2102e615999372426e46fd107b76eaf007156a507584aa2cc21de9eee3bdbd26d36c4c9552af4830450220487fb382c4974de3f7d834c1b617fe15860828c7f96454490edd6d891556dcc9022100baf95feb48f845d5bfc9882eb6aeefa1bc3790e39f59eaa46ff7f15ae626c53e0148304502205286f726690b2e9b0207f0345711e63fa7012045b9eb0f19c2458ce1db90cf43022100e89f17f86abc5b149eba4115d4f128bcf45d77fb3ecdd34f594091340c0395960175ffffffff0101000000000000000000000000", "P2SH,WITNESS"],
|
||||
["BIP143: correct sighash (without FindAndDelete) = c1628a1e7c67f14ca0c27c06e4fdeec2e6d1a73c7a91d7c046ff83e835aebb72"],
|
||||
[[["9628667ad48219a169b41b020800162287d2c0f713c04157e95c484a8dcb7592", 7500, "0x00 0x20 0x9b66c15b4e0b4eb49fa877982cafded24859fe5b0e2dbfbe4f0df1de7743fd52", 200000]],
|
||||
"010000000001019275cb8d4a485ce95741c013f7c0d28722160008021bb469a11982d47a6628964c1d000000ffffffff0101000000000000000007004830450220487fb382c4974de3f7d834c1b617fe15860828c7f96454490edd6d891556dcc9022100baf95feb48f845d5bfc9882eb6aeefa1bc3790e39f59eaa46ff7f15ae626c53e0148304502205286f726690b2e9b0207f0345711e63fa7012045b9eb0f19c2458ce1db90cf43022100e89f17f86abc5b149eba4115d4f128bcf45d77fb3ecdd34f594091340c0395960101022102966f109c54e85d3aee8321301136cedeb9fc710fdef58a9de8a73942f8e567c021034ffc99dd9a79dd3cb31e2ab3e0b09e0e67db41ac068c625cd1f491576016c84e9552af4830450220487fb382c4974de3f7d834c1b617fe15860828c7f96454490edd6d891556dcc9022100baf95feb48f845d5bfc9882eb6aeefa1bc3790e39f59eaa46ff7f15ae626c53e0148304502205286f726690b2e9b0207f0345711e63fa7012045b9eb0f19c2458ce1db90cf43022100e89f17f86abc5b149eba4115d4f128bcf45d77fb3ecdd34f594091340c039596017500000000", "P2SH,WITNESS"],
|
||||
|
||||
["Make diffs cleaner by leaving a comment here without comma at the end"]
|
||||
]
|
||||
|
||||
588
test/fixtures/transaction.json
vendored
588
test/fixtures/transaction.json
vendored
@ -287,7 +287,591 @@
|
||||
{
|
||||
"exception": "Transaction has unexpected data",
|
||||
"hex": "0100000002f1fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe000000006b483045022100e661badd8d2cf1af27eb3b82e61b5d3f5d5512084591796ae31487f5b82df948022006df3c2a2cac79f68e4b179f4bbb8185a0bb3c4a2486d4405c59b2ba07a74c2101210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798fffffffff2fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe0100000083483045022100be54a46a44fb7e6bf4ebf348061d0dace7ddcbb92d4147ce181cf4789c7061f0022068ccab2a89a47fc29bb5074bca99ae846ab446eecf3c3aaeb238a13838783c78012102c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee517a9147ccb85f0ab2d599bc17246c98babd5a20b1cdc7687ffffffff0250c30000000000001976a914c42e7ef92fdb603af844d064faad95db9bcdfd3d88acf04902000000000017a9147ccb85f0ab2d599bc17246c98babd5a20b1cdc768700000000ffffffff"
|
||||
},
|
||||
{
|
||||
"exception": "Transaction has superfluous witness data",
|
||||
"hex": "0100000000010113ae35a2063ba413c3a1bb9b3820c76291e40e83bd3f23c8ff83333f0c64d623000000004a00483045022100e332e8367d5fee22c205ce1bf4e01e39f1a8decb3ba20d1336770cf38b8ee72d022076b5f83b3ee15390133b7ebf526ec189eb73cc6ee0a726f70b939bc51fa18d8001ffffffff0180969800000000001976a914b1ae3ceac136e4bdb733663e7a1e2f0961198a1788ac0000000000"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"hashForWitnessV0": [
|
||||
{
|
||||
"description": "Native P2WPKH with SIGHASH_ALL",
|
||||
"txHex": "0100000002fff7f7881a8099afa6940d42d1e7f6362bec38171ea3edf433541db4e4ad969f0000000000eeffffffef51e1b804cc89d182d279655c3aa89e815b1b309fe287d9b2b55d57b90ec68a0100000000ffffffff02202cb206000000001976a9148280b37df378db99f66f85c95a783a76ac7a6d5988ac9093510d000000001976a9143bde42dbee7e4dbe6a21b2d50ce2f0167faa815988ac11000000",
|
||||
"inIndex": 1,
|
||||
"script": "OP_DUP OP_HASH160 1d0f172a0ecb48aee1be1f2687d2963ae33f71a1 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"type": 1,
|
||||
"hash": "c37af31116d1b27caf68aae9e3ac82f1477929014d5b917657d0eb49478cb670",
|
||||
"value": 600000000
|
||||
},
|
||||
{
|
||||
"description": "P2SH(P2WPKH) with SIGHASH_ALL",
|
||||
"txHex": "0100000001db6b1b20aa0fd7b23880be2ecbd4a98130974cf4748fb66092ac4d3ceb1a54770100000000feffffff02b8b4eb0b000000001976a914a457b684d7f0d539a46a45bbc043f35b59d0d96388ac0008af2f000000001976a914fd270b1ee6abcaea97fea7ad0402e8bd8ad6d77c88ac92040000",
|
||||
"inIndex": 0,
|
||||
"script": "OP_DUP OP_HASH160 79091972186c449eb1ded22b78e40d009bdf0089 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"type": 1,
|
||||
"hash": "64f3b0f4dd2bb3aa1ce8566d220cc74dda9df97d8490cc81d89d735c92e59fb6",
|
||||
"value": 1000000000
|
||||
},
|
||||
{
|
||||
"description": "P2SH(P2WSH) with SIGHASH_ALL",
|
||||
"txHex": "010000000136641869ca081e70f394c6948e8af409e18b619df2ed74aa106c1ca29787b96e0100000000ffffffff0200e9a435000000001976a914389ffce9cd9ae88dcc0631e88a821ffdbe9bfe2688acc0832f05000000001976a9147480a33f950689af511e6e84c138dbbd3c3ee41588ac00000000",
|
||||
"inIndex": 0,
|
||||
"script": "OP_6 0307b8ae49ac90a048e9b53357a2354b3334e9c8bee813ecb98e99a7e07e8c3ba3 03b28f0c28bfab54554ae8c658ac5c3e0ce6e79ad336331f78c428dd43eea8449b 034b8113d703413d57761b8b9781957b8c0ac1dfe69f492580ca4195f50376ba4a 033400f6afecb833092a9a21cfdf1ed1376e58c5d1f47de74683123987e967a8f4 03a6d48b1131e94ba04d9737d61acdaa1322008af9602b3b14862c07a1789aac16 02d8b661b0b3302ee2f162b09e07a55ad5dfbe673a9f01d9f0c19617681024306b OP_6 OP_CHECKMULTISIG",
|
||||
"type": 1,
|
||||
"hash": "185c0be5263dce5b4bb50a047973c1b6272bfbd0103a89444597dc40b248ee7c",
|
||||
"value": 987654321
|
||||
},
|
||||
{
|
||||
"description": "P2SH(P2WSH) with SIGHASH_NONE",
|
||||
"txHex": "010000000136641869ca081e70f394c6948e8af409e18b619df2ed74aa106c1ca29787b96e0100000000ffffffff0200e9a435000000001976a914389ffce9cd9ae88dcc0631e88a821ffdbe9bfe2688acc0832f05000000001976a9147480a33f950689af511e6e84c138dbbd3c3ee41588ac00000000",
|
||||
"inIndex": 0,
|
||||
"script": "OP_6 0307b8ae49ac90a048e9b53357a2354b3334e9c8bee813ecb98e99a7e07e8c3ba3 03b28f0c28bfab54554ae8c658ac5c3e0ce6e79ad336331f78c428dd43eea8449b 034b8113d703413d57761b8b9781957b8c0ac1dfe69f492580ca4195f50376ba4a 033400f6afecb833092a9a21cfdf1ed1376e58c5d1f47de74683123987e967a8f4 03a6d48b1131e94ba04d9737d61acdaa1322008af9602b3b14862c07a1789aac16 02d8b661b0b3302ee2f162b09e07a55ad5dfbe673a9f01d9f0c19617681024306b OP_6 OP_CHECKMULTISIG",
|
||||
"type": 2,
|
||||
"hash": "e9733bc60ea13c95c6527066bb975a2ff29a925e80aa14c213f686cbae5d2f36",
|
||||
"value": 987654321
|
||||
},
|
||||
{
|
||||
"description": "P2SH(P2WSH) with SIGHASH_SINGLE",
|
||||
"txHex": "010000000136641869ca081e70f394c6948e8af409e18b619df2ed74aa106c1ca29787b96e0100000000ffffffff0200e9a435000000001976a914389ffce9cd9ae88dcc0631e88a821ffdbe9bfe2688acc0832f05000000001976a9147480a33f950689af511e6e84c138dbbd3c3ee41588ac00000000",
|
||||
"inIndex": 0,
|
||||
"script": "OP_6 0307b8ae49ac90a048e9b53357a2354b3334e9c8bee813ecb98e99a7e07e8c3ba3 03b28f0c28bfab54554ae8c658ac5c3e0ce6e79ad336331f78c428dd43eea8449b 034b8113d703413d57761b8b9781957b8c0ac1dfe69f492580ca4195f50376ba4a 033400f6afecb833092a9a21cfdf1ed1376e58c5d1f47de74683123987e967a8f4 03a6d48b1131e94ba04d9737d61acdaa1322008af9602b3b14862c07a1789aac16 02d8b661b0b3302ee2f162b09e07a55ad5dfbe673a9f01d9f0c19617681024306b OP_6 OP_CHECKMULTISIG",
|
||||
"type": 3,
|
||||
"hash": "1e1f1c303dc025bd664acb72e583e933fae4cff9148bf78c157d1e8f78530aea",
|
||||
"value": 987654321
|
||||
},
|
||||
{
|
||||
"description": "P2SH(P2WSH) with SIGHASH_ALL | SIGHASH_ANYONECANPAY",
|
||||
"txHex": "010000000136641869ca081e70f394c6948e8af409e18b619df2ed74aa106c1ca29787b96e0100000000ffffffff0200e9a435000000001976a914389ffce9cd9ae88dcc0631e88a821ffdbe9bfe2688acc0832f05000000001976a9147480a33f950689af511e6e84c138dbbd3c3ee41588ac00000000",
|
||||
"inIndex": 0,
|
||||
"script": "OP_6 0307b8ae49ac90a048e9b53357a2354b3334e9c8bee813ecb98e99a7e07e8c3ba3 03b28f0c28bfab54554ae8c658ac5c3e0ce6e79ad336331f78c428dd43eea8449b 034b8113d703413d57761b8b9781957b8c0ac1dfe69f492580ca4195f50376ba4a 033400f6afecb833092a9a21cfdf1ed1376e58c5d1f47de74683123987e967a8f4 03a6d48b1131e94ba04d9737d61acdaa1322008af9602b3b14862c07a1789aac16 02d8b661b0b3302ee2f162b09e07a55ad5dfbe673a9f01d9f0c19617681024306b OP_6 OP_CHECKMULTISIG",
|
||||
"type": 129,
|
||||
"hash": "2a67f03e63a6a422125878b40b82da593be8d4efaafe88ee528af6e5a9955c6e",
|
||||
"value": 987654321
|
||||
},
|
||||
{
|
||||
"description": "P2SH(P2WSH) with SIGHASH_NONE | SIGHASH_ANYONECANPAY",
|
||||
"txHex": "010000000136641869ca081e70f394c6948e8af409e18b619df2ed74aa106c1ca29787b96e0100000000ffffffff0200e9a435000000001976a914389ffce9cd9ae88dcc0631e88a821ffdbe9bfe2688acc0832f05000000001976a9147480a33f950689af511e6e84c138dbbd3c3ee41588ac00000000",
|
||||
"inIndex": 0,
|
||||
"script": "OP_6 0307b8ae49ac90a048e9b53357a2354b3334e9c8bee813ecb98e99a7e07e8c3ba3 03b28f0c28bfab54554ae8c658ac5c3e0ce6e79ad336331f78c428dd43eea8449b 034b8113d703413d57761b8b9781957b8c0ac1dfe69f492580ca4195f50376ba4a 033400f6afecb833092a9a21cfdf1ed1376e58c5d1f47de74683123987e967a8f4 03a6d48b1131e94ba04d9737d61acdaa1322008af9602b3b14862c07a1789aac16 02d8b661b0b3302ee2f162b09e07a55ad5dfbe673a9f01d9f0c19617681024306b OP_6 OP_CHECKMULTISIG",
|
||||
"type": 130,
|
||||
"hash": "781ba15f3779d5542ce8ecb5c18716733a5ee42a6f51488ec96154934e2c890a",
|
||||
"value": 987654321
|
||||
},
|
||||
{
|
||||
"description": "P2SH(P2WSH) with SIGHASH_SINGLE | SIGHASH_ANYONECANPAY",
|
||||
"txHex": "010000000136641869ca081e70f394c6948e8af409e18b619df2ed74aa106c1ca29787b96e0100000000ffffffff0200e9a435000000001976a914389ffce9cd9ae88dcc0631e88a821ffdbe9bfe2688acc0832f05000000001976a9147480a33f950689af511e6e84c138dbbd3c3ee41588ac00000000",
|
||||
"inIndex": 0,
|
||||
"script": "OP_6 0307b8ae49ac90a048e9b53357a2354b3334e9c8bee813ecb98e99a7e07e8c3ba3 03b28f0c28bfab54554ae8c658ac5c3e0ce6e79ad336331f78c428dd43eea8449b 034b8113d703413d57761b8b9781957b8c0ac1dfe69f492580ca4195f50376ba4a 033400f6afecb833092a9a21cfdf1ed1376e58c5d1f47de74683123987e967a8f4 03a6d48b1131e94ba04d9737d61acdaa1322008af9602b3b14862c07a1789aac16 02d8b661b0b3302ee2f162b09e07a55ad5dfbe673a9f01d9f0c19617681024306b OP_6 OP_CHECKMULTISIG",
|
||||
"type": 131,
|
||||
"hash": "511e8e52ed574121fc1b654970395502128263f62662e076dc6baf05c2e6a99b",
|
||||
"value": 987654321
|
||||
}
|
||||
],
|
||||
"witness": [
|
||||
{
|
||||
"description": "P2PK",
|
||||
"id": "8d4733995be9b3331a65eeb31bce24b213d4fabcbadf7f6634a8fea442c13e6a",
|
||||
"hash": "6a3ec142a4fea834667fdfbabcfad413b224ce1bb3ee651a33b3e95b9933478d",
|
||||
"hex": "010000000193aef40ae141694895e99e18e49d0181b086dd7c011c0241175c6eaf320099970000000049483045022100e57eba5380dcc8a7bdb5370b423dadd43070e1ca268f94bc97b2ded55ca45e9502206a43151c8af03a00f0ac86526d07981e303fc0daea8c6ed435abe8961533046d01ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac00000000",
|
||||
"hasWitness": false,
|
||||
"witnessHex": "",
|
||||
"raw": {
|
||||
"version": 1,
|
||||
"ins": [
|
||||
{
|
||||
"hash": "97990032af6e5c1741021c017cdd86b081019de4189ee995486941e10af4ae93",
|
||||
"index": 0,
|
||||
"sigHash": "8d590cd3c3622f1cc22b17967abfeac8aa72e5b64f80d9ca7a61c59f07a47a8f",
|
||||
"script": "3045022100e57eba5380dcc8a7bdb5370b423dadd43070e1ca268f94bc97b2ded55ca45e9502206a43151c8af03a00f0ac86526d07981e303fc0daea8c6ed435abe8961533046d01",
|
||||
"scriptHex": "483045022100e57eba5380dcc8a7bdb5370b423dadd43070e1ca268f94bc97b2ded55ca45e9502206a43151c8af03a00f0ac86526d07981e303fc0daea8c6ed435abe8961533046d01",
|
||||
"sequence": 4294967295,
|
||||
"witness": [],
|
||||
"value": 80000,
|
||||
"scriptPubKey": "21038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2bac",
|
||||
"redeemScript": "",
|
||||
"witnessScript": ""
|
||||
}
|
||||
],
|
||||
"outs": [
|
||||
{
|
||||
"value": 60000,
|
||||
"script": "OP_DUP OP_HASH160 851a33a5ef0d4279bd5854949174e2c65b1d4500 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"scriptHex": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
}
|
||||
],
|
||||
"locktime": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "P2SH P2PK",
|
||||
"id": "d4ebb5e09c06dd375f265b51eb7f1a14d12deba71329500e2a00a905fdfdc27d",
|
||||
"hash": "7dc2fdfd05a9002a0e502913a7eb2dd1141a7feb515b265f37dd069ce0b5ebd4",
|
||||
"hex": "0100000001a30e865fa60f6c25a8b218bb5a6b9acc7cf3f1db2f2e3a7114b51af5d6ae811f000000006c473044022026d2b56b6cb0269bf4e80dd655b9e917019e2ccef57f4b858d03bb45a2da59d9022010519a7f327f03e7c9613e0694f929544af29d3682e7ec8f19147e7a86651ecd012321038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2bacffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac00000000",
|
||||
"hasWitness": false,
|
||||
"witnessHex": "",
|
||||
"raw": {
|
||||
"version": 1,
|
||||
"ins": [
|
||||
{
|
||||
"hash": "1f81aed6f51ab514713a2e2fdbf1f37ccc9a6b5abb18b2a8256c0fa65f860ea3",
|
||||
"index": 0,
|
||||
"sigHash": "e5a339f87c44b443de94b28c1c2a5fe5acedd9ffd2d25ca194cd1d89284b08ed",
|
||||
"script": "3044022026d2b56b6cb0269bf4e80dd655b9e917019e2ccef57f4b858d03bb45a2da59d9022010519a7f327f03e7c9613e0694f929544af29d3682e7ec8f19147e7a86651ecd01 21038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2bac",
|
||||
"scriptHex": "473044022026d2b56b6cb0269bf4e80dd655b9e917019e2ccef57f4b858d03bb45a2da59d9022010519a7f327f03e7c9613e0694f929544af29d3682e7ec8f19147e7a86651ecd012321038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2bac",
|
||||
"sequence": 4294967295,
|
||||
"witness": [],
|
||||
"value": 80000,
|
||||
"scriptPubKey": "a914c99d9ebb5a4828e4e1b606dd6a51a2babebbdc0987",
|
||||
"redeemScript": "21038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2bac",
|
||||
"witnessScript": ""
|
||||
}
|
||||
],
|
||||
"outs": [
|
||||
{
|
||||
"value": 60000,
|
||||
"script": "OP_DUP OP_HASH160 851a33a5ef0d4279bd5854949174e2c65b1d4500 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"scriptHex": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
}
|
||||
],
|
||||
"locktime": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "P2WSH P2PK",
|
||||
"id": "60f04167a0c94d6439102f7fde9ad77c08a8716419805e77ef66b286cc5c7f87",
|
||||
"hash": "877f5ccc86b266ef775e80196471a8087cd79ade7f2f1039644dc9a06741f060",
|
||||
"hex": "01000000014533a3bc1e039bd787656068e135aaee10aee95a64776bfc047ee6a7c1ebdd2f0000000000ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac00000000",
|
||||
"hasWitness": true,
|
||||
"witnessHex": "010000000001014533a3bc1e039bd787656068e135aaee10aee95a64776bfc047ee6a7c1ebdd2f0000000000ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac02473044022039725bb7291a14dd182dafdeaf3ea0d5c05c34f4617ccbaa46522ca913995c4e02203b170d072ed2e489e7424ad96d8fa888deb530be2d4c5d9aaddf111a7efdb2d3012321038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2bac00000000",
|
||||
"raw": {
|
||||
"version": 1,
|
||||
"ins": [
|
||||
{
|
||||
"hash": "2fddebc1a7e67e04fc6b77645ae9ae10eeaa35e168606587d79b031ebca33345",
|
||||
"index": 0,
|
||||
"sigHash": "52601433fe6032a7de9afd72703ab6042015128b04472f8f896609ad274ae0f3",
|
||||
"script": "",
|
||||
"scriptHex": "",
|
||||
"sequence": 4294967295,
|
||||
"witness": [
|
||||
"3044022039725bb7291a14dd182dafdeaf3ea0d5c05c34f4617ccbaa46522ca913995c4e02203b170d072ed2e489e7424ad96d8fa888deb530be2d4c5d9aaddf111a7efdb2d301",
|
||||
"21038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2bac"
|
||||
],
|
||||
"value": 80000,
|
||||
"scriptPubKey": "00200f9ea7bae7166c980169059e39443ed13324495b0d6678ce716262e879591210",
|
||||
"redeemScript": "",
|
||||
"witnessScript": "21038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2bac"
|
||||
}
|
||||
],
|
||||
"outs": [
|
||||
{
|
||||
"value": 60000,
|
||||
"script": "OP_DUP OP_HASH160 851a33a5ef0d4279bd5854949174e2c65b1d4500 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"scriptHex": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
}
|
||||
],
|
||||
"locktime": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "P2SH P2WSH P2PK",
|
||||
"id": "da24fd5a422f72e3bde593628c2b47ff9ca7454e1f3ba5fb916344c218d31052",
|
||||
"hash": "5210d318c2446391fba53b1f4e45a79cff472b8c6293e5bde3722f425afd24da",
|
||||
"hex": "0100000001e0779d448aaa203a96b3de14d0482e26dd75a4278ae5bb6d7cc18e6874f3866000000000232200200f9ea7bae7166c980169059e39443ed13324495b0d6678ce716262e879591210ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac00000000",
|
||||
"hasWitness": true,
|
||||
"witnessHex": "01000000000101e0779d448aaa203a96b3de14d0482e26dd75a4278ae5bb6d7cc18e6874f3866000000000232200200f9ea7bae7166c980169059e39443ed13324495b0d6678ce716262e879591210ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac024730440220014207a5f0601ed7b3c3f9d82309b32e8f76dd6776a55cb5f8684b9ff029e0850220693afd7b69471b51d9354cc1a956b68b8d48e32f6b0ad7a19bb5dd3e4499179a012321038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2bac00000000",
|
||||
"raw": {
|
||||
"version": 1,
|
||||
"ins": [
|
||||
{
|
||||
"hash": "6086f374688ec17c6dbbe58a27a475dd262e48d014deb3963a20aa8a449d77e0",
|
||||
"index": 0,
|
||||
"sigHash": "b3caa13417b83a07e4684c5f1b5f4563936cd66791ca106b1770aeeaae682794",
|
||||
"script": "00200f9ea7bae7166c980169059e39443ed13324495b0d6678ce716262e879591210",
|
||||
"scriptHex": "2200200f9ea7bae7166c980169059e39443ed13324495b0d6678ce716262e879591210",
|
||||
"sequence": 4294967295,
|
||||
"witness": [
|
||||
"30440220014207a5f0601ed7b3c3f9d82309b32e8f76dd6776a55cb5f8684b9ff029e0850220693afd7b69471b51d9354cc1a956b68b8d48e32f6b0ad7a19bb5dd3e4499179a01",
|
||||
"21038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2bac"
|
||||
],
|
||||
"value": 80000,
|
||||
"scriptPubKey": "a9146d185c7042d01ea8276dc6be6603101dc441d8a487",
|
||||
"redeemScript": "00200f9ea7bae7166c980169059e39443ed13324495b0d6678ce716262e879591210",
|
||||
"witnessScript": "21038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2bac"
|
||||
}
|
||||
],
|
||||
"outs": [
|
||||
{
|
||||
"value": 60000,
|
||||
"script": "OP_DUP OP_HASH160 851a33a5ef0d4279bd5854949174e2c65b1d4500 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"scriptHex": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
}
|
||||
],
|
||||
"locktime": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "P2PKH",
|
||||
"id": "c7a77aeadf529759c8db9b3f205d690cdaed3df0eaf441ead648086e85a6a280",
|
||||
"hash": "80a2a6856e0848d6ea41f4eaf03dedda0c695d203f9bdbc8599752dfea7aa7c7",
|
||||
"hex": "010000000176d7b05b96e69d9760bacf14e496ea01085eff32be8f4e08b299eb92057826e5000000006b4830450221009bd6ff2561437155913c289923175d3f114cca1c0e2bc5989315d5261502c2c902201b71ad90dce076a5eb872330ed729e7c2c4bc2d0513efff099dbefb3b62eab4f0121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2bffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac00000000",
|
||||
"hasWitness": false,
|
||||
"witnessHex": "",
|
||||
"raw": {
|
||||
"version": 1,
|
||||
"ins": [
|
||||
{
|
||||
"hash": "e526780592eb99b2084e8fbe32ff5e0801ea96e414cfba60979de6965bb0d776",
|
||||
"index": 0,
|
||||
"sigHash": "b01334b1f522b3d824960b2ce215031b392b084eca649a6bd1efdf4caa841e7b",
|
||||
"script": "30450221009bd6ff2561437155913c289923175d3f114cca1c0e2bc5989315d5261502c2c902201b71ad90dce076a5eb872330ed729e7c2c4bc2d0513efff099dbefb3b62eab4f01 038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b",
|
||||
"scriptHex": "4830450221009bd6ff2561437155913c289923175d3f114cca1c0e2bc5989315d5261502c2c902201b71ad90dce076a5eb872330ed729e7c2c4bc2d0513efff099dbefb3b62eab4f0121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b",
|
||||
"sequence": 4294967295,
|
||||
"witness": [],
|
||||
"value": 80000,
|
||||
"scriptPubKey": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac",
|
||||
"redeemScript": "",
|
||||
"witnessScript": ""
|
||||
}
|
||||
],
|
||||
"outs": [
|
||||
{
|
||||
"value": 60000,
|
||||
"script": "OP_DUP OP_HASH160 851a33a5ef0d4279bd5854949174e2c65b1d4500 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"scriptHex": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
}
|
||||
],
|
||||
"locktime": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "P2SH P2PKH",
|
||||
"id": "0b8fa64f89b95666a23e424fe94e9114806726be9753e140dbd74c0d673c9593",
|
||||
"hash": "93953c670d4cd7db40e15397be26678014914ee94f423ea26656b9894fa68f0b",
|
||||
"hex": "01000000014b9ffc17c3cce03ee66980bf32d36aaa13462980c3af9d9d29ec6b97ab1c91650000000084473044022003d738d855d0c54a419ac62ebe1a1c0bf2dc6993c9585adb9a8666736658107002204d57ff62ee7efae6df73430bba62494faeba8c125a4abcf2488757a4f8877dd50121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b1976a914851a33a5ef0d4279bd5854949174e2c65b1d450088acffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac00000000",
|
||||
"hasWitness": false,
|
||||
"witnessHex": "",
|
||||
"raw": {
|
||||
"version": 1,
|
||||
"ins": [
|
||||
{
|
||||
"hash": "65911cab976bec299d9dafc380294613aa6ad332bf8069e63ee0ccc317fc9f4b",
|
||||
"index": 0,
|
||||
"sigHash": "40c2576db2ad631c5799d344dcb5efd05eef3c52aacb51585af327f8efb3bcde",
|
||||
"script": "3044022003d738d855d0c54a419ac62ebe1a1c0bf2dc6993c9585adb9a8666736658107002204d57ff62ee7efae6df73430bba62494faeba8c125a4abcf2488757a4f8877dd501 038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b 76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac",
|
||||
"scriptHex": "473044022003d738d855d0c54a419ac62ebe1a1c0bf2dc6993c9585adb9a8666736658107002204d57ff62ee7efae6df73430bba62494faeba8c125a4abcf2488757a4f8877dd50121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b1976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac",
|
||||
"sequence": 4294967295,
|
||||
"witness": [],
|
||||
"value": 80000,
|
||||
"scriptPubKey": "a9142162ff7c23d47a0c331f95c67d7c3e22abb12a0287",
|
||||
"redeemScript": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac",
|
||||
"witnessScript": ""
|
||||
}
|
||||
],
|
||||
"outs": [
|
||||
{
|
||||
"value": 60000,
|
||||
"script": "OP_DUP OP_HASH160 851a33a5ef0d4279bd5854949174e2c65b1d4500 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"scriptHex": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
}
|
||||
],
|
||||
"locktime": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "P2WSH P2PKH",
|
||||
"id": "62c62316f80beb10d9b1ce9183eb66e7e18a18324ca5f5e6f839be03f64aba83",
|
||||
"hash": "83ba4af603be39f8e6f5a54c32188ae1e766eb8391ceb1d910eb0bf81623c662",
|
||||
"hex": "010000000123539877e39a273819006de1c433e09f9e9af201fc178dd0f2cf2eaa5ad53b480000000000ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac00000000",
|
||||
"hasWitness": true,
|
||||
"witnessHex": "0100000000010123539877e39a273819006de1c433e09f9e9af201fc178dd0f2cf2eaa5ad53b480000000000ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac03483045022100f02a82b0a94a5d5dc4d2127ac34be62cb066713d71d56bdf5ef7810ab57a157302205f24abdde1dab554a02edcf378e98828024e57272e5e474a5b04accdca080a030121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b1976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac00000000",
|
||||
"raw": {
|
||||
"version": 1,
|
||||
"ins": [
|
||||
{
|
||||
"hash": "483bd55aaa2ecff2d08d17fc01f29a9e9fe033c4e16d001938279ae377985323",
|
||||
"index": 0,
|
||||
"sigHash": "b0197f4cd027b33ebb2ef54e02a7008dc29ec807ec2de58843fffbdf07ceb2c3",
|
||||
"script": "",
|
||||
"scriptHex": "",
|
||||
"sequence": 4294967295,
|
||||
"witness": [
|
||||
"3045022100f02a82b0a94a5d5dc4d2127ac34be62cb066713d71d56bdf5ef7810ab57a157302205f24abdde1dab554a02edcf378e98828024e57272e5e474a5b04accdca080a0301",
|
||||
"038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b",
|
||||
"76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
],
|
||||
"value": 80000,
|
||||
"scriptPubKey": "0020578db4b54a6961060b71385c17d3280379a557224c52b11b19a3a1c1eef606a0",
|
||||
"redeemScript": "",
|
||||
"witnessScript": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
}
|
||||
],
|
||||
"outs": [
|
||||
{
|
||||
"value": 60000,
|
||||
"script": "OP_DUP OP_HASH160 851a33a5ef0d4279bd5854949174e2c65b1d4500 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"scriptHex": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
}
|
||||
],
|
||||
"locktime": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "P2SH P2WSH P2PKH",
|
||||
"id": "2ef1431ec41a75791b75d16526f23534ae66d8d4abfb483d98d14bcb259311c0",
|
||||
"hash": "c0119325cb4bd1983d48fbabd4d866ae3435f22665d1751b79751ac41e43f12e",
|
||||
"hex": "0100000001363dfbfe2566db77e3b1195bedf1d0daeb9ce526cd7611ba81759b2654ce415c0000000023220020578db4b54a6961060b71385c17d3280379a557224c52b11b19a3a1c1eef606a0ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac00000000",
|
||||
"hasWitness": true,
|
||||
"witnessHex": "01000000000101363dfbfe2566db77e3b1195bedf1d0daeb9ce526cd7611ba81759b2654ce415c0000000023220020578db4b54a6961060b71385c17d3280379a557224c52b11b19a3a1c1eef606a0ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac03483045022100c8bd5ebb26ba6719158650c3e7c5e80be4c886ba025c44cc41f5149b3114705a02203ac6e1f38f6c081d506f28f1b5e38ebec9e0f0fa911d0e3f68d48d8b0e77b34b0121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b1976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac00000000",
|
||||
"raw": {
|
||||
"version": 1,
|
||||
"ins": [
|
||||
{
|
||||
"hash": "5c41ce54269b7581ba1176cd26e59cebdad0f1ed5b19b1e377db6625fefb3d36",
|
||||
"index": 0,
|
||||
"sigHash": "9580096496f72ae9fed63e6701b2a9df3c8d212d8accd4b1966d3239c33a859f",
|
||||
"script": "0020578db4b54a6961060b71385c17d3280379a557224c52b11b19a3a1c1eef606a0",
|
||||
"scriptHex": "220020578db4b54a6961060b71385c17d3280379a557224c52b11b19a3a1c1eef606a0",
|
||||
"sequence": 4294967295,
|
||||
"witness": [
|
||||
"3045022100c8bd5ebb26ba6719158650c3e7c5e80be4c886ba025c44cc41f5149b3114705a02203ac6e1f38f6c081d506f28f1b5e38ebec9e0f0fa911d0e3f68d48d8b0e77b34b01",
|
||||
"038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b",
|
||||
"76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
],
|
||||
"value": 80000,
|
||||
"scriptPubKey": "a91444a641c4e06eb6118c99e5ed29954b705b50fb6a87",
|
||||
"redeemScript": "0020578db4b54a6961060b71385c17d3280379a557224c52b11b19a3a1c1eef606a0",
|
||||
"witnessScript": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
}
|
||||
],
|
||||
"outs": [
|
||||
{
|
||||
"value": 60000,
|
||||
"script": "OP_DUP OP_HASH160 851a33a5ef0d4279bd5854949174e2c65b1d4500 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"scriptHex": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
}
|
||||
],
|
||||
"locktime": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Multisig",
|
||||
"id": "7f5d96a866a815f5a1896fcd3b49cd00ac4c366a371fe8555f124e628e977a5e",
|
||||
"hash": "5e7a978e624e125f55e81f376a364cac00cd493bcd6f89a1f515a866a8965d7f",
|
||||
"hex": "010000000179310ec46e734b3490ee839c5ae4a09d28561ee9fff2d051f733d201f958d6d2000000004a00483045022100d269531f120f377ed2f94f42bef893ff2fe6544ac97fb477fa291bc6cfb7647e02200983f6a5bbd4ce6cf97f571995634805a7324cc5d8353ed954fa62477b0fcd0901ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac00000000",
|
||||
"hasWitness": false,
|
||||
"witnessHex": "",
|
||||
"raw": {
|
||||
"version": 1,
|
||||
"ins": [
|
||||
{
|
||||
"hash": "d2d658f901d233f751d0f2ffe91e56289da0e45a9c83ee90344b736ec40e3179",
|
||||
"index": 0,
|
||||
"sigHash": "1c68226955e39aed91eb7f35fa106240951208138b584caeb05b44f367078b09",
|
||||
"script": "OP_0 3045022100d269531f120f377ed2f94f42bef893ff2fe6544ac97fb477fa291bc6cfb7647e02200983f6a5bbd4ce6cf97f571995634805a7324cc5d8353ed954fa62477b0fcd0901",
|
||||
"scriptHex": "00483045022100d269531f120f377ed2f94f42bef893ff2fe6544ac97fb477fa291bc6cfb7647e02200983f6a5bbd4ce6cf97f571995634805a7324cc5d8353ed954fa62477b0fcd0901",
|
||||
"sequence": 4294967295,
|
||||
"witness": [],
|
||||
"value": 80000,
|
||||
"scriptPubKey": "5121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b51ae",
|
||||
"redeemScript": "",
|
||||
"witnessScript": ""
|
||||
}
|
||||
],
|
||||
"outs": [
|
||||
{
|
||||
"value": 60000,
|
||||
"script": "OP_DUP OP_HASH160 851a33a5ef0d4279bd5854949174e2c65b1d4500 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"scriptHex": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
}
|
||||
],
|
||||
"locktime": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "P2SH Multisig",
|
||||
"id": "3aef827e4306bab01f118a8eccad74713bcd1695362caf9fed55202ed54ef88b",
|
||||
"hash": "8bf84ed52e2055ed9faf2c369516cd3b7174adcc8e8a111fb0ba06437e82ef3a",
|
||||
"hex": "010000000152882c661c49dd2f53bd9ced7e9f44b184888ad2fe7d86737f0efaa7aecdced1000000006f00473044022025f2e161f0a97888df948f4dcc7c04fe502510b8d8260ca9920f38d55e4d17720220271b6843224b3a34542a4df31781d048da56ee46b8c5fb99043e30abd527b2d801255121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b51aeffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac00000000",
|
||||
"hasWitness": false,
|
||||
"witnessHex": "",
|
||||
"raw": {
|
||||
"version": 1,
|
||||
"ins": [
|
||||
{
|
||||
"hash": "d1cecdaea7fa0e7f73867dfed28a8884b1449f7eed9cbd532fdd491c662c8852",
|
||||
"index": 0,
|
||||
"sigHash": "a1b982ea4d57c3255268a801885ea8ee8b785d52bf7dd024997a5111c9295f5a",
|
||||
"script": "OP_0 3044022025f2e161f0a97888df948f4dcc7c04fe502510b8d8260ca9920f38d55e4d17720220271b6843224b3a34542a4df31781d048da56ee46b8c5fb99043e30abd527b2d801 5121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b51ae",
|
||||
"scriptHex": "00473044022025f2e161f0a97888df948f4dcc7c04fe502510b8d8260ca9920f38d55e4d17720220271b6843224b3a34542a4df31781d048da56ee46b8c5fb99043e30abd527b2d801255121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b51ae",
|
||||
"sequence": 4294967295,
|
||||
"witness": [],
|
||||
"value": 80000,
|
||||
"scriptPubKey": "a91438c064c6387d1071eeb5c3d90350054aea0b3fc187",
|
||||
"redeemScript": "5121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b51ae",
|
||||
"witnessScript": ""
|
||||
}
|
||||
],
|
||||
"outs": [
|
||||
{
|
||||
"value": 60000,
|
||||
"script": "OP_DUP OP_HASH160 851a33a5ef0d4279bd5854949174e2c65b1d4500 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"scriptHex": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
}
|
||||
],
|
||||
"locktime": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "P2WSH Multisig",
|
||||
"id": "03e6b741d25cbd061b8d0999a521788ef90263dd8ba96d91c2136a4386afdf8e",
|
||||
"hash": "8edfaf86436a13c2916da98bdd6302f98e7821a599098d1b06bd5cd241b7e603",
|
||||
"hex": "0100000001c1eced6216de0889d4629ff64a8af8e8ec6d0b414de0c57b46c02cc303d321fe0000000000ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac00000000",
|
||||
"hasWitness": true,
|
||||
"witnessHex": "01000000000101c1eced6216de0889d4629ff64a8af8e8ec6d0b414de0c57b46c02cc303d321fe0000000000ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac0300483045022100d4c0cbdb45915b8a3162362fa5f74556de919aeda5337fc44a7fb000e833460d022017742c37d7a061e2ae3a086c7c585c9c85e5d31af468d3e00045c0f35b8f8eb601255121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b51ae00000000",
|
||||
"raw": {
|
||||
"version": 1,
|
||||
"ins": [
|
||||
{
|
||||
"hash": "fe21d303c32cc0467bc5e04d410b6dece8f88a4af69f62d48908de1662edecc1",
|
||||
"index": 0,
|
||||
"sigHash": "c57f8489d77552631b10fc703de3d2a72e473590b8b8283f4a1134855c6e4368",
|
||||
"script": "",
|
||||
"scriptHex": "",
|
||||
"sequence": 4294967295,
|
||||
"witness": [
|
||||
"",
|
||||
"3045022100d4c0cbdb45915b8a3162362fa5f74556de919aeda5337fc44a7fb000e833460d022017742c37d7a061e2ae3a086c7c585c9c85e5d31af468d3e00045c0f35b8f8eb601",
|
||||
"5121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b51ae"
|
||||
],
|
||||
"value": 80000,
|
||||
"scriptPubKey": "00201b8c0c2878c5634c3ce738cdc568c592e99783dbd28ff4c6cb5b7b4675d9ee99",
|
||||
"redeemScript": "",
|
||||
"witnessScript": "5121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b51ae"
|
||||
}
|
||||
],
|
||||
"outs": [
|
||||
{
|
||||
"value": 60000,
|
||||
"script": "OP_DUP OP_HASH160 851a33a5ef0d4279bd5854949174e2c65b1d4500 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"scriptHex": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
}
|
||||
],
|
||||
"locktime": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "P2SH P2WSH Multisig",
|
||||
"id": "e77fd9ea35346e295e1e15de9724fff42b5c127da4c5447a4ffddd361f66b1c1",
|
||||
"hash": "c1b1661f36ddfd4f7a44c5a47d125c2bf4ff2497de151e5e296e3435ead97fe7",
|
||||
"hex": "01000000013a5a2ab0223d3b504b52af76d650329750666fbf1be13d4cb08d0d9fc550a47d00000000232200201b8c0c2878c5634c3ce738cdc568c592e99783dbd28ff4c6cb5b7b4675d9ee99ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac00000000",
|
||||
"hasWitness": true,
|
||||
"witnessHex": "010000000001013a5a2ab0223d3b504b52af76d650329750666fbf1be13d4cb08d0d9fc550a47d00000000232200201b8c0c2878c5634c3ce738cdc568c592e99783dbd28ff4c6cb5b7b4675d9ee99ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac0300483045022100c97a5e205ce0023d3d44f846abf1f0e21b6f2646bd2496bbe92e4333fe4401be02201247e047d669f713582713e35d2eba430abc3d75a924bb500362bf47d6234ed501255121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b51ae00000000",
|
||||
"raw": {
|
||||
"version": 1,
|
||||
"ins": [
|
||||
{
|
||||
"hash": "7da450c59f0d8db04c3de11bbf6f6650973250d676af524b503b3d22b02a5a3a",
|
||||
"index": 0,
|
||||
"sigHash": "90ced36a2a53e986837407ec5b34fca11c68b477fa51806715186595372c0b37",
|
||||
"script": "00201b8c0c2878c5634c3ce738cdc568c592e99783dbd28ff4c6cb5b7b4675d9ee99",
|
||||
"scriptHex": "2200201b8c0c2878c5634c3ce738cdc568c592e99783dbd28ff4c6cb5b7b4675d9ee99",
|
||||
"sequence": 4294967295,
|
||||
"witness": [
|
||||
"",
|
||||
"3045022100c97a5e205ce0023d3d44f846abf1f0e21b6f2646bd2496bbe92e4333fe4401be02201247e047d669f713582713e35d2eba430abc3d75a924bb500362bf47d6234ed501",
|
||||
"5121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b51ae"
|
||||
],
|
||||
"value": 80000,
|
||||
"scriptPubKey": "a914cc6ea17c33de7996471e40892acdd6e5f61b9b6f87",
|
||||
"redeemScript": "00201b8c0c2878c5634c3ce738cdc568c592e99783dbd28ff4c6cb5b7b4675d9ee99",
|
||||
"witnessScript": "5121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b51ae"
|
||||
}
|
||||
],
|
||||
"outs": [
|
||||
{
|
||||
"value": 60000,
|
||||
"script": "OP_DUP OP_HASH160 851a33a5ef0d4279bd5854949174e2c65b1d4500 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"scriptHex": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
}
|
||||
],
|
||||
"locktime": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "P2WKH",
|
||||
"id": "10bbdf7e9301bc21f1da8684f25fd66bc1314904c30da25a8ebf967c58c89269",
|
||||
"hash": "6992c8587c96bf8e5aa20dc3044931c16bd65ff28486daf121bc01937edfbb10",
|
||||
"hex": "010000000133defbe3e28860007ff3e21222774c220cb35d554fa3e3796d25bf8ee983e1080000000000ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac00000000",
|
||||
"hasWitness": true,
|
||||
"witnessHex": "0100000000010133defbe3e28860007ff3e21222774c220cb35d554fa3e3796d25bf8ee983e1080000000000ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac0248304502210097c3006f0b390982eb47f762b2853773c6cedf83668a22d710f4c13c4fd6b15502205e26ef16a81fc818a37f3a34fc6d0700e61100ea6c6773907c9c046042c440340121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b00000000",
|
||||
"raw": {
|
||||
"version": 1,
|
||||
"ins": [
|
||||
{
|
||||
"hash": "08e183e98ebf256d79e3a34f555db30c224c772212e2f37f006088e2e3fbde33",
|
||||
"index": 0,
|
||||
"sigHash": "8ef2f4892fdbb44a7859ac059cdacf20903566a1472fae38ba37443c44b66202",
|
||||
"script": "",
|
||||
"scriptHex": "",
|
||||
"sequence": 4294967295,
|
||||
"witness": [
|
||||
"304502210097c3006f0b390982eb47f762b2853773c6cedf83668a22d710f4c13c4fd6b15502205e26ef16a81fc818a37f3a34fc6d0700e61100ea6c6773907c9c046042c4403401",
|
||||
"038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b"
|
||||
],
|
||||
"value": 80000,
|
||||
"scriptPubKey": "0014851a33a5ef0d4279bd5854949174e2c65b1d4500",
|
||||
"redeemScript": "",
|
||||
"witnessScript": ""
|
||||
}
|
||||
],
|
||||
"outs": [
|
||||
{
|
||||
"value": 60000,
|
||||
"script": "OP_DUP OP_HASH160 851a33a5ef0d4279bd5854949174e2c65b1d4500 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"scriptHex": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
}
|
||||
],
|
||||
"locktime": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "P2SH P2WKH",
|
||||
"id": "a0dd6714722a577c5db08f740cd1525f5383f8771dd0ebecd9ae96eb6623408a",
|
||||
"hash": "8a402366eb96aed9ecebd01d77f883535f52d10c748fb05d7c572a721467dda0",
|
||||
"hex": "01000000015df9a0b9ade2d835881704e0f53b51a4b19ecfc794ea1f3555783dd7f68659ce0000000017160014851a33a5ef0d4279bd5854949174e2c65b1d4500ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac00000000",
|
||||
"hasWitness": true,
|
||||
"witnessHex": "010000000001015df9a0b9ade2d835881704e0f53b51a4b19ecfc794ea1f3555783dd7f68659ce0000000017160014851a33a5ef0d4279bd5854949174e2c65b1d4500ffffffff0160ea0000000000001976a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac02483045022100cb3929c128fec5108071b662e5af58e39ac8708882753a421455ca80462956f6022030c0f4738dd1a13fc7a34393002d25c6e8a6399f29c7db4b98f53a9475d94ca20121038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b00000000",
|
||||
"raw": {
|
||||
"version": 1,
|
||||
"ins": [
|
||||
{
|
||||
"hash": "ce5986f6d73d7855351fea94c7cf9eb1a4513bf5e004178835d8e2adb9a0f95d",
|
||||
"index": 0,
|
||||
"sigHash": "b9d9a395dbd84365e93016a3ba1ffe2c373b85e245598597b2f8cd6eb0706252",
|
||||
"script": "0014851a33a5ef0d4279bd5854949174e2c65b1d4500",
|
||||
"scriptHex": "160014851a33a5ef0d4279bd5854949174e2c65b1d4500",
|
||||
"sequence": 4294967295,
|
||||
"witness": [
|
||||
"3045022100cb3929c128fec5108071b662e5af58e39ac8708882753a421455ca80462956f6022030c0f4738dd1a13fc7a34393002d25c6e8a6399f29c7db4b98f53a9475d94ca201",
|
||||
"038de63cf582d058a399a176825c045672d5ff8ea25b64d28d4375dcdb14c02b2b"
|
||||
],
|
||||
"value": 80000,
|
||||
"scriptPubKey": "a9140d061ae2c8ad224a81142a2e02181f5173b576b387",
|
||||
"redeemScript": "0014851a33a5ef0d4279bd5854949174e2c65b1d4500",
|
||||
"witnessScript": ""
|
||||
}
|
||||
],
|
||||
"outs": [
|
||||
{
|
||||
"value": 60000,
|
||||
"script": "OP_DUP OP_HASH160 851a33a5ef0d4279bd5854949174e2c65b1d4500 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"scriptHex": "76a914851a33a5ef0d4279bd5854949174e2c65b1d450088ac"
|
||||
}
|
||||
],
|
||||
"locktime": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -105,6 +105,30 @@ describe('script', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('solveOutput', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
var script
|
||||
if (f.scriptPubKeyHex) {
|
||||
script = new Buffer(f.scriptPubKeyHex, 'hex')
|
||||
} else if (f.scriptPubKey) {
|
||||
script = bscript.fromASM(f.scriptPubKey)
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
||||
it('solves ' + bscript.toASM(script) + ' as ' + f.type, function () {
|
||||
var solution = bscript.solveOutput(script)
|
||||
assert.equal(solution.type, f.type)
|
||||
if ([bscript.types.P2SH, bscript.types.P2WSH, bscript.types.P2WPKH, bscript.types.P2PKH, bscript.types.P2PK, bscript.types.MULTISIG].indexOf(f.type) === -1) {
|
||||
assert.equal(solution.solvedBy, null)
|
||||
}
|
||||
if (solution.canSign) {
|
||||
assert.notEqual(solution.requiredSigs, null)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('SCRIPT_VERIFY_MINIMALDATA policy', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
if (f.scriptSigHex) {
|
||||
|
||||
@ -2,7 +2,8 @@
|
||||
|
||||
var assert = require('assert')
|
||||
var bscript = require('../src/script')
|
||||
|
||||
var bcrypto = require('../src/crypto')
|
||||
var bufferReverse = require('buffer-reverse')
|
||||
var Transaction = require('../src/transaction')
|
||||
|
||||
var fixtures = require('./fixtures/transaction')
|
||||
@ -42,13 +43,29 @@ describe('Transaction', function () {
|
||||
}
|
||||
|
||||
describe('fromBuffer/fromHex', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
it('imports ' + f.description + ' (' + f.id + ')', function () {
|
||||
var actual = Transaction.fromHex(f.hex)
|
||||
function importExport (f) {
|
||||
var id = f.id || f.hash
|
||||
var txHex = f.hex || f.txHex
|
||||
|
||||
assert.strictEqual(actual.toHex(), f.hex, actual.toHex())
|
||||
if (f.hasWitness) {
|
||||
it('imports ' + f.description + ' (' + id + ') as witness', function () {
|
||||
var actual = Transaction.fromHex(f.witnessHex)
|
||||
|
||||
assert.strictEqual(actual.toHex(), f.witnessHex, actual.toHex())
|
||||
})
|
||||
}
|
||||
|
||||
it('imports ' + f.description + ' (' + id + ')', function () {
|
||||
var actual = Transaction.fromHex(txHex)
|
||||
|
||||
assert.strictEqual(actual.toHex(), txHex, actual.toHex())
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fixtures.valid.forEach(importExport)
|
||||
fixtures.witness.forEach(importExport)
|
||||
fixtures.hashForSignature.forEach(importExport)
|
||||
fixtures.hashForWitnessV0.forEach(importExport)
|
||||
|
||||
fixtures.invalid.fromBuffer.forEach(function (f) {
|
||||
it('throws on ' + f.exception, function () {
|
||||
@ -102,30 +119,19 @@ describe('Transaction', function () {
|
||||
prevTxHash = new Buffer('ffffffff00ffff000000000000000000000000000000000000000000101010ff', 'hex')
|
||||
})
|
||||
|
||||
it('accepts a transaction hash', function () {
|
||||
var tx = new Transaction()
|
||||
tx.addInput(prevTxHash, 0)
|
||||
assert.deepEqual(tx.ins[0].hash, prevTxHash)
|
||||
})
|
||||
|
||||
it('returns an index', function () {
|
||||
var tx = new Transaction()
|
||||
assert.strictEqual(tx.addInput(prevTxHash, 0), 0)
|
||||
assert.strictEqual(tx.addInput(prevTxHash, 0), 1)
|
||||
})
|
||||
|
||||
it('defaults to DEFAULT_SEQUENCE', function () {
|
||||
var tx = new Transaction()
|
||||
tx.addInput(prevTxHash, 0)
|
||||
|
||||
assert.strictEqual(tx.ins[0].sequence, Transaction.DEFAULT_SEQUENCE)
|
||||
})
|
||||
|
||||
it('defaults to empty script', function () {
|
||||
it('defaults to empty script, witness and 0xffffffff SEQUENCE number', function () {
|
||||
var tx = new Transaction()
|
||||
tx.addInput(prevTxHash, 0)
|
||||
|
||||
assert.strictEqual(tx.ins[0].script.length, 0)
|
||||
assert.strictEqual(tx.ins[0].witness.length, 0)
|
||||
assert.strictEqual(tx.ins[0].sequence, 0xffffffff)
|
||||
})
|
||||
|
||||
fixtures.invalid.addInput.forEach(function (f) {
|
||||
@ -207,4 +213,86 @@ describe('Transaction', function () {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('hashForWitnessV0', function () {
|
||||
fixtures.hashForWitnessV0.forEach(function (f) {
|
||||
it('should return ' + f.hash + ' for ' + (f.description ? ('case "' + f.description + '"') : ''), function () {
|
||||
var tx = Transaction.fromHex(f.txHex)
|
||||
var script = bscript.fromASM(f.script)
|
||||
|
||||
assert.strictEqual(tx.hashForWitnessV0(f.inIndex, script, f.value, f.type).toString('hex'), f.hash)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('signature hashing', function () {
|
||||
function unsignedTransactionFromRaw (raw) {
|
||||
var unsigned = new Transaction()
|
||||
unsigned.version = raw.version
|
||||
unsigned.ins = raw.ins.map(function (input) {
|
||||
return {
|
||||
hash: bufferReverse(new Buffer(input.hash, 'hex')),
|
||||
index: input.index,
|
||||
script: new Buffer(0), // Empty for now
|
||||
witness: [], // Empty for now
|
||||
sequence: 4294967295
|
||||
}
|
||||
})
|
||||
unsigned.outs = raw.outs.map(function (output) {
|
||||
return {
|
||||
value: output.value,
|
||||
script: new Buffer(output.scriptHex, 'hex')
|
||||
}
|
||||
})
|
||||
unsigned.locktime = 0
|
||||
return unsigned
|
||||
}
|
||||
|
||||
function checkInputsMatchSigHash (f) {
|
||||
var unsigned = unsignedTransactionFromRaw(f.raw)
|
||||
|
||||
f.raw.ins.forEach(function (input) {
|
||||
it('determines the correct sighash for all inputs', function () {
|
||||
var prevOutScript = new Buffer(input.scriptPubKey, 'hex')
|
||||
var valueOut = input.value ? input.value : 0
|
||||
var redeemScript = input.redeemScript ? new Buffer(input.redeemScript, 'hex') : undefined
|
||||
var witnessScript = input.witnessScript ? new Buffer(input.witnessScript, 'hex') : undefined
|
||||
var expectedSigHash = new Buffer(input.sigHash, 'hex')
|
||||
var tx = unsigned
|
||||
|
||||
// This is example usage of solveOutput
|
||||
|
||||
var sigVersion = 0
|
||||
var solution = bscript.solveOutput(prevOutScript)
|
||||
if (solution.type === bscript.types.P2SH) {
|
||||
// This line is useless given the example, but illustrates usage
|
||||
if (solution.solvedBy.equals(bcrypto.hash160(redeemScript))) {
|
||||
solution = bscript.solveOutput(redeemScript)
|
||||
}
|
||||
}
|
||||
|
||||
// We again use solvedBy (result of the script.*.output.decode() function)
|
||||
// But notice, here we don't know if it's witness due to (i) scriptPubKey or (ii) redeemScript
|
||||
// so it's nice solveOutput also returns solvedBy
|
||||
if (solution.type === bscript.types.P2WPKH) {
|
||||
sigVersion = 1
|
||||
solution = bscript.solveOutput(bscript.pubKeyHash.output.encode(solution.solvedBy))
|
||||
} else if (solution.type === bscript.types.P2WSH) {
|
||||
sigVersion = 1
|
||||
solution = bscript.solveOutput(witnessScript)
|
||||
}
|
||||
|
||||
assert([bscript.types.P2PKH, bscript.types.P2PK, bscript.types.MULTISIG].indexOf(solution.type) !== -1, 'should have found a signable type')
|
||||
|
||||
var hash = sigVersion === 1
|
||||
? tx.hashForWitnessV0(0, solution.script, valueOut, Transaction.SIGHASH_ALL)
|
||||
: tx.hashForSignature(0, solution.script, Transaction.SIGHASH_ALL)
|
||||
|
||||
assert.equal(hash.toString('hex'), expectedSigHash.toString('hex'))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fixtures.witness.forEach(checkInputsMatchSigHash)
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user