Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: tiehm on June 08, 2019, 10:03:26 AM



Title: Help with transaction pushing / encoding
Post by: tiehm on June 08, 2019, 10:03:26 AM
Hello everyone!

This is my first time using bitcoin in a project and create transactioins and so on myself. I have the issue that my testnet transaction is rejected because
Code:
 'Error validating transaction: Transaction 54f6fcefa67805ce3f0bf287ea99e145562878489f0fe8c63c04c1c77847e05e orphaned, missing reference b65fec66748b0232a2b453db0aecffbc3ba0c0243953e86e26b94164956556ae.'


I want to send tBTC from 2N5463KY5F8WExmKMMcd7XfK6ZnMAJuz4Cq to 2MvvviSm2c8r9UugpvLxusB9QKRdAzqupEf (all testnet addresses) but it seems that the input is somehow not validated. I put it in with the transaction b65fec66748b0232a2b453db0aecffbc3ba0c0243953e86e26b94164956556ae and vout of 1.

I am using bitcoinjs-lib for this and my code looks like (no issue with showing WIF since it is testnet anyway):

Code:
const sender = ECPair.fromWIF('cRwYEpNL2iQYvV7BLCi1YDfzwVnWwzi6ALjXLiWUgQfnpjXehNe1', networks.testnet);
const txb = new TransactionBuilder(networks.testnet);
txb.setVersion(1);
txb.addInput('b65fec66748b0232a2b453db0aecffbc3ba0c0243953e86e26b94164956556ae', 1);
txb.addOutput('2MvvviSm2c8r9UugpvLxusB9QKRdAzqupEf', 100000);

txb.sign(0, sender);
const txHex = txb.build().toHex();
The txHex is wrong or can not be decoded / will have the error thrown posted above.


Title: Re: Help with transaction pushing / encoding
Post by: achow101 on June 09, 2019, 08:23:12 AM
Try the byteswapped version of your txid. Txids are displayed with a byteswapped order, so if you have a txid from somewhere else, in order to put it into a transaction, you must byteswap it. Your txid byteswapped is ae5665956441b9266ee8533924c0a03bbcffec0adb53b4a232028b7466ec5fb6.