How to replace your own bitcoin transaction and send to a different address

If you recently broadcasted a Bitcoin transaction and it is still unconfirmed, it is possible to replace it by broadcasting a second transaction that spends the same inputs at a higher fee.

The bumpfee command is used to increase the fee of an existing transaction. However, it is possible to use the bumpfee command to increase the fee on an unconfirmed transaction and also spend it to a different address.

To do this, you will need to use the createrawtransaction and signrawtransaction commands to create and sign a new transaction that spends the outputs of the fee-bumped transaction to a different address.

Here is an example of how you can use these commands to create and sign a new transaction that spends the outputs of a fee-bumped transaction to a different address:

  1. Use the getrawtransaction command to retrieve the raw transaction hex for the fee-bumped transaction:
bitcoin-cli getrawtransaction <txid>

Replace <txid> with the transaction ID of the fee-bumped transaction.

  1. Use the decoderawtransaction command to decode the raw transaction hex and get a list of the transaction’s outputs:
bitcoin-cli decoderawtransaction <rawtx>

Replace <rawtx> with the raw transaction hex returned by the getrawtransaction command.

  1. Create a new transaction that spends the outputs of the fee-bumped transaction to a different address using the createrawtransaction command:
bitcoin-cli createrawtransaction '[{"txid": <txid>, "vout": <vout>}]' '{"<destination_address>": <amount>}'

Replace <txid> and <vout> with the transaction ID and output index of the fee-bumped transaction, and replace <destination_address> with the address you want to send the transaction to and <amount> with the amount you want to send.

  1. Sign the new transaction using the signrawtransaction command:
bitcoin-cli signrawtransaction <rawtx>

Replace <rawtx> with the raw transaction hex returned by the createrawtransaction command.

  1. Use the sendrawtransaction command to broadcast the signed transaction to the network:
bitcoin-cli sendrawtransaction <signedtx>

Replace <signedtx> with the signed transaction hex returned by the signrawtransaction command.

This will create and broadcast a new transaction that spends the outputs of the fee-bumped transaction to a different address.

Leave a Reply

Your email address will not be published. Required fields are marked *

Comments (

)