Photo by Artūras Kokorevas
Sparrow Wallet (Bitcoin)#
Theory#
-
What is UTXO
-
UTXO, short for Unspent Transaction Outputs, refers to unspent transaction outputs.
-
In Bitcoin, every transaction has an input and corresponding outputs.
-
Compared to the EVM ecosystem, BTC is more like cash, while EVM is more like a bank [👉 The following examples do not consider actual RMB denomination limits 👈]
- For example, if you have 100 RMB in cash, one banknote, and you transfer 10 RMB to Wang, with gas set to 5, you will end up with a UTXO of 85. Your 100 RMB banknote has turned into a banknote of 85.
- In the above expenditure, the 100 RMB banknote serves as the input of the transaction, while the outputs are:
- 85 (returned to your own UTXO), which will return to your wallet,
- 10 (this UTXO, which is a banknote of 10) is given to the other party's wallet,
- 5 (a banknote of 5) is given to the miner's wallet.
- Later, when you spend money again, you can only spend this one banknote (of 85). As the input for the transaction, you initiate a new transaction.
- Finally, if you want to break down your UTXO of 85 into 30 + 50, you initiate a second transaction, with yourself as the recipient, for an amount of 50. Thus, the input is the UTXO of 85, and there are three outputs:
- You send yourself a UTXO of 50,
- The remaining UTXO of 30,
- And a UTXO of 5 goes to the miner's wallet.
-
-
Two methods to accelerate transactions
❤️ ❤️ ❤️ Regardless of whether you use RBF or CPFP, you need to ensure that your UTXO balance is sufficient; otherwise, you cannot accelerate ❤️ ❤️ ❤️
-
RBF, short for Replace-by-fee, allows an unconfirmed transaction to be replaced by a new transaction (with a higher gas fee).
-
First, it is clear that only your own UTXO can be used as input to initiate RBF 🍎
-
Secondly, check Here to see if your transaction can be RBF, for example, the transaction below can be RBF.
- Finally, let’s illustrate what RBF is with an example:
- Similarly, if there are only two UTXOs of 30 and 50 in the wallet, I initiate a new transaction using the UTXO of 50 to transfer 10 to Wang, with gas set to 5. This transaction is referred to as tx1.
- If tx1 is completed,
- My wallet should have two UTXOs, namely 30 and 35; the former is the untouched UTXO, and the latter is the UTXO returned after tx1 is completed.
- Wang's wallet will have 10 + 10, two UTXOs.
- The miner's wallet will have 5 + 5 + 5, three UTXOs.
- However, after initiating tx1, if I want to accelerate (there are two aspects here):
- I no longer want to give Wang money and want to back out.
- At this point, I can use RBF to accelerate by initiating a new transaction, called tx2, using the UTXO of 50 to transfer 20 to myself, with gas set to 10.
- After tx2 is completed,
- My wallet will have 20 + 20 + 30, these three UTXOs.
- Wang's wallet will only have 10, one UTXO.
- The miner's wallet will have 5 + 5 + 10, three UTXOs.
- tx2 will be completed, allowing me to back out of the transfer to Wang 🍓
- I find the gas too low and want to complete the transaction faster.
- I can also use RBF for the transaction, initiating a new tx2, using the UTXO of 50 to transfer 10 to Wang, with gas set to 10.
- After tx2 is completed,
- My wallet will have 30 + 30, these two UTXOs.
- Wang's wallet will have 10 + 10, these two UTXOs.
- The miner's wallet will have 5 + 5 + 10, these three UTXOs.
- I no longer want to give Wang money and want to back out.
-
-
CPFP, short for Child Pays For Parent, uses a high gas child transaction to accelerate the parent transaction.
Because to confirm a high gas child transaction, the parent transaction must also be confirmed.
- First, understand that a child transaction refers to a transaction whose input uses the output of an unconfirmed parent transaction.
- For example, I initiate tx1, transferring 100 with gas set to 10. 100 is the output of tx1.
- Wang wants to use this 100 as input to transfer 50 to Li, but since my tx1 has not been confirmed yet, he can only initiate a child transaction tx2 with gas set to 20 to accelerate the parent transaction.
- Here, the parent transaction is tx1, and the child transaction is tx2.
- First, understand that a child transaction refers to a transaction whose input uses the output of an unconfirmed parent transaction.
-
Practice#
-
For Sparrow Wallet, start testnet >>>> Tools-->Restart Testnet
You can play around in the testnet ⚱
-
When connecting to the blockchain, it may not go smoothly; using Clash with Direct may help, as shown below.
-
Faucet collection
-
Panel introduction
-
-
-
-
-
-
Introducing the panels on the left:
-
Transactions refer to the tx you have as a receiver or sender.
-
Send is to send BTC to a certain address,
- payto field is who you are sending to,
- label is a tag, similar to a note,
- amount is how much to send,
- Fee here can be adjusted by dragging; the final Fee = tx size * gas.
-
Receive here means you can choose to receive external transfers using a certain address.
-
Note that the addresses here are all usable addresses; since one mnemonic generates many addresses, all these addresses belong to you. You can use the UTXOs under their names. If you want to use a certain UTXO, simply select that UTXO and then "Send Selected" as shown in the image
-
The UTXOs section refers to the UTXOs you can spend, similarly; if you want to spend one, select it and click the small airplane icon, as shown in the image
-
The Setting section will not be elaborated on :walking:
-
-
-
RBF practice
- txB replaces txA, addressing the situation of "I find the gas too low and want to complete the transaction faster." The principle is as follows:
- I first initiate txA, using a UTXO (referred to as U1) of 1282 sats from the address tb1qn2zt7xzc4nwe4m5rzg8jt4gr446h069vjunapj to transfer 1131 sats to the address tb1q66spu0n20ru23yhc6katlwu4j9xl4sn9yxrnwh, spending 151 sats on gas. (151 + 1131 = 1282)
- Later, I initiate RBF, which is txB, using U1 and another UTXO (referred to as U2) of 1712 sats as inputs to transfer 2610 sats to the address tb1q66spu0n20ru23yhc6katlwu4j9xl4sn9yxrnwh, spending 384 on gas. (1282 + 1712 = 2610 + 384)
- Finally, txB is completed, while txA is not completed.
- The reason for using two UTXOs is that U1's balance is insufficient to support txB.
- txB replaces txA, addressing the situation of "I no longer want to give Wang money and want to back out." The principle is as follows:
- I initiate txA, using a UTXO (referred to as U1) of 8135 sats from the address tb1qn2zt7xzc4nwe4m5rzg8jt4gr446h069vjunapj to transfer 294 sats to the address tb1q4eqr370h7w37quke9nes5yc9ncnpctfpejv8df, spending 158 sats on gas.
- Later, I initiate txB, also using U1, to transfer 294 sats to the address tb1q4eqr370h7w37quke9nes5yc9ncnpctfpej8df, spending 748 sats on gas.
- Finally, txB is completed, while txA is not completed.
- txB replaces txA, addressing the situation of "I find the gas too low and want to complete the transaction faster." The principle is as follows:
-
CPFP practice
- Parent transaction and child transaction, generally proceed as follows:
- I first initiate the parent transaction, using a UTXO (referred to as U1) of 12281 sats from the address tb1qn2zt7xzc4nwe4m5rzg8jt4gr446h069vjunapj as input to transfer 1000 sats to the address tb1q4eqr370h7w37quke9nes5yc9ncnpctfpejv8df, with the remaining 11140 sats returned to the address tb1qzk35rutqjcuj7la95hvvcdqkczjv7dqwtyh6ls.
- Then, I use the 11140 sats received at address C to initiate a child transaction transferring 1000 sats to the address tb1q80262jz5ytdfhj38ur4l7duect6qppc4j6unj7 (referred to as address D).
- Due to the acceleration of the child transaction, the effective fee rate of the parent transaction increases from 1.01 to 1.43, while the effective fee rate of the child transaction decreases from 1.85 to 1.43.
- Parent transaction and child transaction, generally proceed as follows:
-
To emphasize again, when playing with BRC20, do not use RBF; use CPFP (as for why, I don't know much, so I won't elaborate).
-
In Sparrow, why are Fee and amount highlighted in red when trying to initiate acceleration?
- If there is a UTXO that was not initiated by you, but given to you by someone else, and this UTXO's value is only 546, then it is too small.
- In other words, the balance of this UTXO is insufficient to support the input of the new UTXO and to increase the gas fee (i.e., insufficient to pay for children).
感谢康纳和 alex 两位大哥的技术指导