3

I put together some code using bitcoinjs-lib which allows me to create a testnet transaction and send some bitcoins from one address to another.

But I'm getting tired of waiting for 10 mins after every test. I'd like to be able to test my code a bit faster.

I set up testnet-in-a-box in a virtual machine and have played around with a few commands and it works fine.

But when I try to send a transaction to one of the nodes at 127.0.0.1:19000 it gives me an error saying:

{ [Error: socket hang up] code: 'ECONNRESET' }

I'm broadcasting the transaction as shown here using:

blockchain.t.transactions.propagate(tx.build().toHex(), done)

What am I doing wrong? Is it not possible to submit transactions to the node in testnet-in-a-box?

Any help will be appreciated! Thanks!

1 Answer 1

1

The propagate function isn't designed for testnet-in-a-box because there is no routing for requests in the bitoind program that testnet-in-a-box activates. Rather testnet-in-a-box is designed for JSON-RPC, so you can use sendrawtransaction, which described in https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list.

This is the propagate function:

blockchain.transactions.propagate = function broadcast (txHex, callback) {
  dhttp({
    method: 'POST',
    url: 'https://api.ei8ht.com.au:9443/3/pushtx',
    body: txHex
  }, callback)
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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