integration: update to new script encode/decode
This commit is contained in:
parent
a5e65ab977
commit
39897cacd5
4 changed files with 12 additions and 12 deletions
|
@ -16,7 +16,7 @@ describe('bitcoinjs-lib (advanced)', function () {
|
|||
|
||||
var tx = new bitcoin.TransactionBuilder(network)
|
||||
var data = new Buffer('bitcoinjs-lib')
|
||||
var dataScript = bitcoin.script.nullDataOutput(data)
|
||||
var dataScript = bitcoin.script.nullData.output.encode(data)
|
||||
|
||||
tx.addInput(unspent.txId, unspent.vout)
|
||||
tx.addOutput(dataScript, 1000)
|
||||
|
|
|
@ -39,7 +39,7 @@ describe('bitcoinjs-lib (CLTV)', function () {
|
|||
// three hours ago
|
||||
var timeUtc = utcNow() - (3600 * 3)
|
||||
var redeemScript = cltvCheckSigOutput(alice, bob, timeUtc)
|
||||
var scriptPubKey = bitcoin.script.scriptHashOutput(bitcoin.crypto.hash160(redeemScript))
|
||||
var scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(redeemScript))
|
||||
var address = bitcoin.address.fromOutputScript(scriptPubKey, network)
|
||||
|
||||
// fund the P2SH(CLTV) address
|
||||
|
@ -55,7 +55,7 @@ describe('bitcoinjs-lib (CLTV)', function () {
|
|||
var signatureHash = txRaw.hashForSignature(0, redeemScript, hashType)
|
||||
|
||||
// {Alice's signature} OP_TRUE
|
||||
var redeemScriptSig = bitcoin.script.scriptHashInput([
|
||||
var redeemScriptSig = bitcoin.script.scriptHash.input.encode([
|
||||
alice.sign(signatureHash).toScriptSignature(hashType),
|
||||
bitcoin.opcodes.OP_TRUE
|
||||
], redeemScript)
|
||||
|
@ -73,7 +73,7 @@ describe('bitcoinjs-lib (CLTV)', function () {
|
|||
// two hours ago
|
||||
var timeUtc = utcNow() - (3600 * 2)
|
||||
var redeemScript = cltvCheckSigOutput(alice, bob, timeUtc)
|
||||
var scriptPubKey = bitcoin.script.scriptHashOutput(bitcoin.crypto.hash160(redeemScript))
|
||||
var scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(redeemScript))
|
||||
var address = bitcoin.address.fromOutputScript(scriptPubKey, network)
|
||||
|
||||
// fund the P2SH(CLTV) address
|
||||
|
@ -86,7 +86,7 @@ describe('bitcoinjs-lib (CLTV)', function () {
|
|||
|
||||
var txRaw = tx.buildIncomplete()
|
||||
var signatureHash = txRaw.hashForSignature(0, redeemScript, hashType)
|
||||
var redeemScriptSig = bitcoin.script.scriptHashInput([
|
||||
var redeemScriptSig = bitcoin.script.scriptHash.input.encode([
|
||||
alice.sign(signatureHash).toScriptSignature(hashType),
|
||||
bob.sign(signatureHash).toScriptSignature(hashType),
|
||||
bitcoin.opcodes.OP_FALSE
|
||||
|
@ -105,7 +105,7 @@ describe('bitcoinjs-lib (CLTV)', function () {
|
|||
// two hours from now
|
||||
var timeUtc = utcNow() + (3600 * 2)
|
||||
var redeemScript = cltvCheckSigOutput(alice, bob, timeUtc)
|
||||
var scriptPubKey = bitcoin.script.scriptHashOutput(bitcoin.crypto.hash160(redeemScript))
|
||||
var scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(redeemScript))
|
||||
var address = bitcoin.address.fromOutputScript(scriptPubKey, network)
|
||||
|
||||
// fund the P2SH(CLTV) address
|
||||
|
@ -121,7 +121,7 @@ describe('bitcoinjs-lib (CLTV)', function () {
|
|||
var signatureHash = txRaw.hashForSignature(0, redeemScript, hashType)
|
||||
|
||||
// {Alice's signature} OP_TRUE
|
||||
var redeemScriptSig = bitcoin.script.scriptHashInput([
|
||||
var redeemScriptSig = bitcoin.script.scriptHash.input.encode([
|
||||
alice.sign(signatureHash).toScriptSignature(hashType),
|
||||
bitcoin.opcodes.OP_TRUE
|
||||
], redeemScript)
|
||||
|
|
|
@ -91,7 +91,7 @@ describe('bitcoinjs-lib (crypto)', function () {
|
|||
var script = transaction.ins[input.vout].script
|
||||
var scriptChunks = bitcoin.script.decompile(script)
|
||||
|
||||
assert(bitcoin.script.isPubKeyHashInput(scriptChunks), 'Expected pubKeyHash script')
|
||||
assert(bitcoin.script.pubKeyHash.input.check(scriptChunks), 'Expected pubKeyHash script')
|
||||
|
||||
var prevOutTxId = [].reverse.call(new Buffer(transaction.ins[input.vout].hash)).toString('hex')
|
||||
var prevVout = transaction.ins[input.vout].index
|
||||
|
|
|
@ -15,8 +15,8 @@ describe('bitcoinjs-lib (multisig)', function () {
|
|||
return new Buffer(hex, 'hex')
|
||||
})
|
||||
|
||||
var redeemScript = bitcoin.script.multisigOutput(2, pubKeys) // 2 of 3
|
||||
var scriptPubKey = bitcoin.script.scriptHashOutput(bitcoin.crypto.hash160(redeemScript))
|
||||
var redeemScript = bitcoin.script.multisig.output.encode(2, pubKeys) // 2 of 3
|
||||
var scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(redeemScript))
|
||||
var address = bitcoin.address.fromOutputScript(scriptPubKey)
|
||||
|
||||
assert.strictEqual(address, '36NUkt6FWUi3LAWBqWRdDmdTWbt91Yvfu7')
|
||||
|
@ -33,8 +33,8 @@ describe('bitcoinjs-lib (multisig)', function () {
|
|||
].map(function (wif) { return bitcoin.ECPair.fromWIF(wif, bitcoin.networks.testnet) })
|
||||
var pubKeys = keyPairs.map(function (x) { return x.getPublicKeyBuffer() })
|
||||
|
||||
var redeemScript = bitcoin.script.multisigOutput(2, pubKeys) // 2 of 4
|
||||
var scriptPubKey = bitcoin.script.scriptHashOutput(bitcoin.crypto.hash160(redeemScript))
|
||||
var redeemScript = bitcoin.script.multisig.output.encode(2, pubKeys) // 2 of 4
|
||||
var scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(redeemScript))
|
||||
var address = bitcoin.address.fromOutputScript(scriptPubKey, bitcoin.networks.testnet)
|
||||
|
||||
// attempt to send funds to the source address
|
||||
|
|
Loading…
Reference in a new issue