2

I'm new to bitcoin programming and decided to give it a try with the release of bitcoinjs-lib 1.0. Here is how I generate the hex for the transaction

var bitcoin = require('bitcoinjs-lib');

var key = bitcoin.ECKey.fromWIF("cS4fb6sHrJ2VrfqRNBkk6eHMCB5PY6Bayyo695VaSdfZLMbPZiGv");
var tx = new bitcoin.Transaction();

tx.addInput("129aa78e5649715ecc7121aee0cdba06527061976be9c38c3a9fd9ae258665c3", 0);
tx.addOutput("msj42CCGruhRsFrGATiUuh25dtxYtnpbTx", 15000)

tx.sign(0, key)

console.log(tx.toHex())

and here is the hex output

0100000001c3658625aed99f3a8cc3e96b9761705206bacde0ae2171cc5e7149568ea79a12000000006b483045022100e807c222e6f53795d1fa5fcef7e50176e5a2cd9c164a9c955a5e717544a0ef250220743c40908d190bd13c407b8dbbf0dd2d685858c34bc998ee99e4de9f4e9eb2830121023cb4fea046a3747ee2e966ac382435cfca4570f959bcccb6b680fdcc812e15b9ffffffff01983a0000000000001976a91485eb47fe98f349065d6f044e27a4ac541af79ee288ac00000000

I looked through the lib but couldn't find where to inject the bitcoin.networks.testnet object and the documentation is empty

1

Everything is fine with your tx.

Here it is: http://test.webbtc.com/tx/034dfa392aa7ea46bc0917cdaa2794a5f03e6f935b6518a103cb0f5e923a05be

I've pushed it to the network with this form: http://test.webbtc.com/relay_tx

  • weird I used tbtc.blockr.io/tx/push and got an error when trying to push, i'll use webbtc.com instead thanks ! – JohnT Jul 3 '14 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.