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

0
47


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

That is incorrect. You can’t use the identical transaction ID. It’s a must to use the brand new transactiond ID to spend UTXO for the reason that enter was additionally used as change deal with within the transaction so you could have a brand new UTXO related to the deal with. I’ll share one instance beneath:

I create a brand new deal with 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 deal with tb1q8flc50kum4jwfvfc4vzqrd5e7kdmc8nm85vwwj proper now.

I can use this transaction ID to create a brand new transaction by which 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 deal with with createrawtransaction command:

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

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

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

Signal the transaction:

signrawtransactionwithwallet 02000000013215d25e34f654e21df672f8020a6473f57078de09da35aca421841a96ab1e9a0100000000ffffffff02637e0e00000000001600143a7f8a3edcdd64e4b138ab0401b699f59bbc1e7b50c30000000000001600147c5ac840b455af9f9b3da2c327275c0b0e985e7600000000

Broadcast the transaction:

sendrawtransaction 020000000001013215d25e34f654e21df672f8020a6473f57078de09da35aca421841a96ab1e9a0100000000ffffffff02637e0e00000000001600143a7f8a3edcdd64e4b138ab0401b699f59bbc1e7b50c30000000000001600147c5ac840b455af9f9b3da2c327275c0b0e985e760247304402203dffb9e827b95ab91cb1b42df88629b0a9222c64d277596707ec97b78392cf4b02205390bc9844e157fa9c3c8dbcce69c71c0db84af9cbdb79811ca0b8f68562bff4012102bdce2c0d9dd8337d0d18dafe145848406eaee5d024382dcae086e52868d86d7200000000

I perceive the steps will not be 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:

Tx1: https://tbtc.bitaps.com/9a1eab961a8421a4ac35da09de7870f573640a02f872f61de254f6345ed21532/tb1q8flc50kum4jwfvfc4vzqrd5e7kdmc8nm85vwwj

Tx2: https://tbtc.bitaps.com/399375484659b8b1015edd752afa2ef3765adc331e8439acf14c017716d4b842/tb1q8flc50kum4jwfvfc4vzqrd5e7kdmc8nm85vwwj

We used Tx1 to spend UTXO which can’t be carried out twice. We acquired extra BTC in Tx2 which might be spent utilizing Tx2. An deal with can have many UTXOs related to it.



Supply hyperlink

Leave a reply