|
|
@ -105,28 +105,29 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () { |
|
|
|
], redeemScript) |
|
|
|
tx.setInputScript(0, redeemScriptSig) |
|
|
|
|
|
|
|
regtestUtils.broadcast(tx.toHex(), function (err) { |
|
|
|
// fails before the expiry
|
|
|
|
assert.throws(function () { |
|
|
|
if (err) throw err |
|
|
|
}, /Error: 64: non-final/) |
|
|
|
|
|
|
|
// into the future!
|
|
|
|
regtestUtils.mine(51, function (err) { |
|
|
|
// TODO: test that it failures _prior_ to expiry, unfortunately, race conditions when run concurrently
|
|
|
|
// regtestUtils.broadcast(tx.toHex(), function (err) {
|
|
|
|
// // fails before the expiry
|
|
|
|
// assert.throws(function () {
|
|
|
|
// if (err) throw err
|
|
|
|
// }, /Error: 64: non-final/)
|
|
|
|
|
|
|
|
// into the future!
|
|
|
|
regtestUtils.mine(51, function (err) { |
|
|
|
if (err) return done(err) |
|
|
|
|
|
|
|
regtestUtils.broadcast(tx.toHex(), function (err) { |
|
|
|
if (err) return done(err) |
|
|
|
|
|
|
|
regtestUtils.broadcast(tx.toHex(), function (err) { |
|
|
|
if (err) return done(err) |
|
|
|
|
|
|
|
regtestUtils.verify({ |
|
|
|
txId: tx.getId(), |
|
|
|
address: regtestUtils.RANDOM_ADDRESS, |
|
|
|
vout: 0, |
|
|
|
value: 7e4 |
|
|
|
}, done) |
|
|
|
}) |
|
|
|
regtestUtils.verify({ |
|
|
|
txId: tx.getId(), |
|
|
|
address: regtestUtils.RANDOM_ADDRESS, |
|
|
|
vout: 0, |
|
|
|
value: 7e4 |
|
|
|
}, done) |
|
|
|
}) |
|
|
|
}) |
|
|
|
// })
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
@ -136,8 +137,8 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () { |
|
|
|
this.timeout(30000) |
|
|
|
|
|
|
|
// two hours ago
|
|
|
|
var timeUtc = utcNow() - (3600 * 2) |
|
|
|
var redeemScript = cltvCheckSigOutput(alice, bob, timeUtc) |
|
|
|
var lockTime = bip65.encode({ utc: utcNow() - (3600 * 2) }) |
|
|
|
var redeemScript = cltvCheckSigOutput(alice, bob, lockTime) |
|
|
|
var scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(redeemScript)) |
|
|
|
var address = bitcoin.address.fromOutputScript(scriptPubKey, regtest) |
|
|
|
|
|
|
@ -146,7 +147,7 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () { |
|
|
|
if (err) return done(err) |
|
|
|
|
|
|
|
var txb = new bitcoin.TransactionBuilder(regtest) |
|
|
|
txb.setLockTime(timeUtc) |
|
|
|
txb.setLockTime(lockTime) |
|
|
|
txb.addInput(unspent.txId, unspent.vout, 0xfffffffe) |
|
|
|
txb.addOutput(regtestUtils.RANDOM_ADDRESS, 8e4) |
|
|
|
|
|
|
@ -178,8 +179,8 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () { |
|
|
|
this.timeout(30000) |
|
|
|
|
|
|
|
// two hours from now
|
|
|
|
var timeUtc = utcNow() + (3600 * 2) |
|
|
|
var redeemScript = cltvCheckSigOutput(alice, bob, timeUtc) |
|
|
|
var lockTime = bip65.encode({ utc: utcNow() + (3600 * 2) }) |
|
|
|
var redeemScript = cltvCheckSigOutput(alice, bob, lockTime) |
|
|
|
var scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(redeemScript)) |
|
|
|
var address = bitcoin.address.fromOutputScript(scriptPubKey, regtest) |
|
|
|
|
|
|
@ -188,7 +189,7 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () { |
|
|
|
if (err) return done(err) |
|
|
|
|
|
|
|
var txb = new bitcoin.TransactionBuilder(regtest) |
|
|
|
txb.setLockTime(timeUtc) |
|
|
|
txb.setLockTime(lockTime) |
|
|
|
txb.addInput(unspent.txId, unspent.vout, 0xfffffffe) |
|
|
|
txb.addOutput(regtestUtils.RANDOM_ADDRESS, 1e4) |
|
|
|
|
|
|
|