bitcoind – TransactionId Not working Second Time in NBitcoin and QBitNinja?


Since i nonetheless have unspent quantity in that transactionId so i used the identical TransactionId this time as nicely.

That is incorrect. You can not use the identical transaction ID. You need to use the brand new transactiond ID to spend UTXO for the reason that enter was additionally used as change tackle within the transaction so you will have a brand new UTXO related to the tackle. I’ll share one instance under:

I create a brand new tackle in Bitcoin Core with getnewaddress command: tb1q8flc50kum4jwfvfc4vzqrd5e7kdmc8nm85vwwj

I ship 0.01 testnet BTC to it from my Electrum Pockets in transaction: 9a1eab961a8421a4ac35da09de7870f573640a02f872f61de254f6345ed21532

There is just one UTXO (Unspent Transaction Output) related to tackle tb1q8flc50kum4jwfvfc4vzqrd5e7kdmc8nm85vwwj proper now.

I can use this transaction ID to create a brand new transaction wherein I attempt to spend this 0.0005 BTC from 0.01 BTC I acquired.

I create a brand new transaction to ship 0.0005 BTC to a random tackle with createrawtransaction command:

createrawtransaction "[{"txid":"9a1eab961a8421a4ac35da09de7870f573640a02f872f61de254f6345ed21532","vout":1}]" "[{"tb1q03dvss952khelxea5tpjwf6upv8fshnk95sj6y":0.0005}]"

I add change tackle in it to obtain (0.01-0.0005-Tx_Fee) and use the identical tackle related to the UTXO being spent (Though a brand new tackle ought to be used for change):

fundrawtransaction "02000000013215d25e34f654e21df672f8020a6473f57078de09da35aca421841a96ab1e9a0100000000ffffffff0150c30000000000001600147c5ac840b455af9f9b3da2c327275c0b0e985e7600000000" '{"changeAddress" : "tb1q8flc50kum4jwfvfc4vzqrd5e7kdmc8nm85vwwj"}'

Signal the transaction:

signrawtransactionwithwallet 02000000013215d25e34f654e21df672f8020a6473f57078de09da35aca421841a96ab1e9a0100000000ffffffff02637e0e00000000001600143a7f8a3edcdd64e4b138ab0401b699f59bbc1e7b50c30000000000001600147c5ac840b455af9f9b3da2c327275c0b0e985e7600000000

Broadcast the transaction:

sendrawtransaction 020000000001013215d25e34f654e21df672f8020a6473f57078de09da35aca421841a96ab1e9a0100000000ffffffff02637e0e00000000001600143a7f8a3edcdd64e4b138ab0401b699f59bbc1e7b50c30000000000001600147c5ac840b455af9f9b3da2c327275c0b0e985e760247304402203dffb9e827b95ab91cb1b42df88629b0a9222c64d277596707ec97b78392cf4b02205390bc9844e157fa9c3c8dbcce69c71c0db84af9cbdb79811ca0b8f68562bff4012102bdce2c0d9dd8337d0d18dafe145848406eaee5d024382dcae086e52868d86d7200000000

I perceive the steps should not precisely the identical as utilized in NBitcoin however the primary ideas of making, signing and broadcasting transactions stays the identical.

Let me share a tough diagram to indicate the issues I did above:



We used Tx1 to spend UTXO which can’t be achieved twice. We acquired extra BTC in Tx2 which could be spent utilizing Tx2. An tackle can have many UTXOs related to it.

Supply hyperlink

Leave a reply