Post
Topic
Board Development & Technical Discussion
Re: Bitcoin Taproot transaction STEP BY STEP on bitcoin-cli...
by
mano jacas
on 27/12/2023, 01:40:58 UTC
Hi guys,

I'm starting this topic after googling a lot about this and don't find nothing.

So, I'm offering a prize of €50 in Lightning Satoshis to the first guy that presents the solution, a step by step guide to move some part of the sats from one taproot address to another taproot address with the change coming back for the first one on mainnet.

This need to be done with node bitcoin-cli commands and explained step-by-step  for any newbie in the world that uses a bitcoin node could do it.

Until now I just met guys with nodes that can't do it, I think is time for everyone knows how to use it.

More questions you can send me PM.

PS: "Let's lead the way and show the light of day."
Certainly! Here is a step-by-step guide to transferring some Satoshis from one Taproot address to another using `bitcoin-cli` commands on the Bitcoin mainnet. Please note that this guide assumes you have a running Bitcoin Core full node and a basic understanding of using the Bitcoin Core command-line interface (`bitcoin-cli`).

### Prerequisites:
1. Running Bitcoin Core full node.
2. Access to the Bitcoin Core wallet.
3. Knowledge of both the sending and receiving Taproot addresses.

### Step-by-Step Guide:

#### 1. Start Bitcoin Core:
Ensure your Bitcoin Core node is running and fully synchronized with the network.

#### 2. Create a New Receiving Address:
Generate a new Taproot receiving address using the `getnewaddress` command:
```bash
bitcoin-cli getnewaddress "" "taproot"
```
Note the generated Taproot address; this will be your receiving address.

#### 3. Fund the Sending Address:
Make sure the sending Taproot address has enough funds to send.

#### 4. Prepare the Transaction:
Create a raw transaction using `createrawtransaction`:
```bash
bitcoin-cli createrawtransaction '[{"txid":"<input_txid>", "vout":<vout>}]' '{"<receiving_address>":<amount>, "<change_address>":<change_amount>}'
```
Replace `<input_txid>` and `<vout>` with the transaction ID and vout of the unspent transaction output you want to spend.
Replace `<receiving_address>` with the new Taproot address generated in step 2.
Specify `<amount>` to transfer and `<change_amount>` as the change amount (if any).
Note: Ensure the total amount (transfer + fee) is less than or equal to the input amount.

#### 5. Sign the Transaction:
Sign the raw transaction with the `signrawtransactionwithwallet` command:
```bash
bitcoin-cli signrawtransactionwithwallet "<raw_transaction>"
```
Replace `<raw_transaction>` with the output from the previous step.

#### 6. Send the Transaction:
Use `sendrawtransaction` to broadcast the signed transaction to the network:
```bash
bitcoin-cli sendrawtransaction "<signed_transaction>"
```
Replace `<signed_transaction>` with the signed transaction hex obtained in the previous step.

### Notes:
- Ensure you adjust the command parameters (`<input_txid>`, `<vout>`, `<receiving_address>`, `<amount>`, `<change_amount>`) with your specific details.
- Replace `<amount>` and `<change_amount>` with the actual amounts in Satoshis (1 Bitcoin = 100,000,000 Satoshis).
- Be cautious with the amounts and verify the transaction details thoroughly before broadcasting it to the network.

This guide should help you perform a basic Taproot-to-Taproot transaction using Bitcoin Core's `bitcoin-cli` commands. It's crucial to practice with small amounts and thoroughly understand each step before handling larger amounts of Bitcoin.