|
|
@ -22,27 +22,17 @@ describe('bitcoinjs-lib (advanced)', function () { |
|
|
|
}) |
|
|
|
|
|
|
|
it('can create an OP_RETURN transaction', function (done) { |
|
|
|
this.timeout(20000) |
|
|
|
this.timeout(30000) |
|
|
|
|
|
|
|
var network = bitcoin.networks.testnet |
|
|
|
var keyPair = bitcoin.ECPair.makeRandom({ network: network }) |
|
|
|
var address = keyPair.getAddress() |
|
|
|
|
|
|
|
blockchain.t.faucet(address, 2e4, function (err) { |
|
|
|
blockchain.t.faucet(address, 2e4, function (err, unspents) { |
|
|
|
if (err) return done(err) |
|
|
|
|
|
|
|
blockchain.t.addresses.unspents(address, function (err, unspents) { |
|
|
|
if (err) return done(err) |
|
|
|
|
|
|
|
// filter small unspents
|
|
|
|
unspents = unspents.filter(function (unspent) { |
|
|
|
return unspent.value > 1e4 |
|
|
|
}) |
|
|
|
|
|
|
|
// use the oldest unspent
|
|
|
|
var unspent = unspents.pop() |
|
|
|
if (!unspent) throw new Error('Faucet didn\'t provide an unspent') |
|
|
|
|
|
|
|
var tx = new bitcoin.TransactionBuilder(network) |
|
|
|
var data = new Buffer('bitcoinjs-lib') |
|
|
|
var dataScript = bitcoin.script.nullDataOutput(data) |
|
|
@ -73,4 +63,3 @@ describe('bitcoinjs-lib (advanced)', function () { |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|