npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

bip69

2.1.4 • Public • Published

bip69

NPM Package Build Status

js-standard-style

Lexicographical Indexing of Transaction Inputs and Outputs.

See BIP69.

* Works only with node.js 0.11 or greater (because require Buffer.compare)

Example

var bitcoinjs = require('bitcoinjs-lib')
var bip69 = require('bip69')
 
var inputs = [{
    "txId": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "vout": 0
}, ...]
var outputs = [{
    "script": new Buffer("76a9145be32612930b8323add2212a4ec03c1562084f8488ac", "hex"),
    "value": 40000000000
}, ...]
 
// ...
 
var sortedInputs = bip69.sortInputs(inputs)
var sortedOutputs = bip69.sortOutputs(outputs)
 
var txb = new bitcoinjs.TransactionBuilder()
 
sortedInputs.forEach(function (input) {
    txb.addInput(input.txId, input.vout)
})
 
sortedOutputs.forEach(function (output) {
    txb.addOutput(bitcoinjs.Script.fromBuffer(output.script), output.value)
})
 
// ... and so on

LICENSE MIT

Keywords

install

npm i bip69

Downloadsweekly downloads

588

version

2.1.4

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
  • avatar
Report a vulnerability