Skip to content

Instantly share code, notes, and snippets.

@scottlingran
Last active August 29, 2015 13:56
Show Gist options
  • Save scottlingran/8898146 to your computer and use it in GitHub Desktop.
Save scottlingran/8898146 to your computer and use it in GitHub Desktop.
var binConv = require( "binstring" );
var btcTx = require( "btc-transaction" );
var Script = require( 'btc-script' );
var doc = {
"hash": "dc55d9c6ec03ceccf0db43d29e7d626a8b107f41066e3917f30398bb01dda2b5",
"version": 1,
"locktime": 0,
"ins": [ {
"outpoint": {
"index": 1,
"hash": "de2c3fa45a1b8fa7057fc2db09efa6acd6524551a13d01a846ac1e3acc1476f8",
"value": 6960000,
},
"scriptSig": "4830450221009aa61b4798a5a4c04f86d0de6c936b60bd046f15d4eb55a244d9206bc3af6f93022010a9f0f2186d76e71d781c5e4d36d704212b99efcf6ba5791db88379e6a23fbe014104b4c157eb55f8a04111d2eb55d2f4b632fa03d066a844254e350ff7ba67d2e355aad46ac73693c33bea5ddc86c426ee1557098554da9bc02acf0445f9775efdb5",
"sequence": 4294967295
} ],
"outs": [ {
"value": 2000000,
"scriptPubKey": "76a9140c79f15f08b0f94a2cba8de036272dee3ecb096188ac"
}, {
"value": 4950000,
"scriptPubKey": "76a9143858230049f6c83ba435eac829ae332cab3609f788ac"
} ]
}
var tx = new btcTx.Transaction( doc );
var ser = binConv( tx.serialize(), {
out: 'hex'
} )
var hash = binConv( tx.getHash(), {
out: 'hex'
} )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment