Skip to content

Instantly share code, notes, and snippets.

@scottlingran
Created February 9, 2014 11:45
Show Gist options
  • Save scottlingran/8897964 to your computer and use it in GitHub Desktop.
Save scottlingran/8897964 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": "86fb9d87f7494db1d370b8ab17894a2954f1aca99fdd68a8297add7d31cf22ab",
"version": 1,
"locktime": 0,
"ins": [ {
"outpoint": {
"index": 1,
"hash": "9492e8a61ff0deab04cec0a7d1bd5dcef90612b94b7b57dd1e998b9bcdf4cb06",
"value": 3236980000,
},
"scriptSig": "493046022100fe11eb458ab6815a5f089dace0219e1defed0d2ef366c62ec0ae9481ac37e71e022100c3d50bc01fc1fc002d9652b0354512f9f9e2b75f84eaa8d89c82ce550ade4368012102c4803f5721d533264b8eb18018446698557042bc11c96592199add809428c8ff",
"sequence": 4294967295
} ],
"outs": [ {
"value": 3186970000,
"scriptPubKey": "76a914047f8e5c8707fc5435ee71926ff229f8737bcc1588ac"
}, {
"value": 50000000,
"scriptPubKey": "76a9140b7941c13197828f2070ef528b0e4560b085c98a88ac"
} ]
}
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