skyone

skyone

Hello, World

Sparrow Wallet (Bitcoin)

image

Photo by Artūras Kokorevas

Sparrow Wallet (Bitcoin)#

Theory#

  1. 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 yuan in cash, one banknote, and you transfer 10 yuan to Wang, with gas set to 5, you will end up with a UTXO of 85. Your 100 yuan banknote has turned into a banknote of 85.
      • In the above expenditure, the 100 yuan banknote acts as the input for the transaction, while the outputs are:
        1. 85 (returned to your own UTXO), which will return to your wallet,
        2. 10 (this UTXO, which is a banknote of 10) is given to the other party's wallet,
        3. 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:
        1. You send yourself a UTXO of 50,
        2. The remaining UTXO of 30,
        3. And a UTXO of 5 goes to the miner's wallet.
  2. 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 ❤️ ❤️ ❤️

    1. RBF, short for Replace-by-fee, allows an unconfirmed transaction to be replaced by a new transaction (with a higher gas fee).

      • First, clarify that only your own UTXO as input can initiate RBF 🍎

      • Next, check Here to see if your transaction can be RBF, for example, the one below can be RBF.

      image

      • Finally, let’s illustrate what RBF is with an example:
        • Suppose in the above wallet, there are only two UTXOs of 30 and 50. I initiate a 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, 30 and 35, where 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):
          1. 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 three UTXOs: 20 + 20 + 30.
              • 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 🍓
          2. 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 two UTXOs: 30 + 30.
              • Wang's wallet will have two UTXOs: 10 + 10.
              • The miner's wallet will have three UTXOs: 5 + 5 + 10.
    2. CPFP, short for Child Pays For Parent, uses a high gas child transaction to accelerate the parent transaction.

      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 to transfer 100 to Wang 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, 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.

Practice#

  1. For Sparrow Wallet, start testnet >>>> Tools-->Restart Testnet

    image

    You can play around on the testnet ⚱

  2. When connecting to the blockchain, it may not go smoothly; using Clash with Direct may help, as shown below.

    image

  3. Faucet collection

    1. https://testnet-faucet.com/btc-testnet/
    2. https://bitcoinfaucet.uo1.net/send.php
    3. https://testnet-faucet.mempool.co/
  4. Panel introduction

    • image

    • image

    • image

    • image

    • image

      • Introduce the panels on the left:

      • Transactions refer to your transactions as a receiver or sender.

      • Send is to send BTC to a certain address,

        • payto field indicates who to send to,
        • label is a tag, similar to a comment,
        • amount is how much to send,
        • Fee here can be adjusted by dragging; the final Fee = transaction size * gas.
      • Receive here means you can choose to receive external transfers using a certain address.

      • Note regarding Address: all addresses here are usable by you; since a set of mnemonic phrases generates many addresses, all these addresses belong to you, and 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 imageimage

      • The UTXOs section refers to the UTXOs you can spend, similar to above; to spend one, select it and click the small airplane icon, as shown in the imageimage

      • The Setting section will not be elaborated on :walking:

  5. RBF practice

    1. 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 the above 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.
    2. 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 tb1q4eqr370h7w37quke9nes5yc9ncnpctfpejv8df, spending 748 sats on gas.
      • Finally, txB is completed, while txA is not completed.
  6. CPFP practice

    1. Parent transaction and Child transaction 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.
  7. One more point to emphasize, when playing with BRC20, do not use RBF; use CPFP (as for why, I don't know much, so I won't elaborate).

  8. In Sparrow, why are Fee and amount highlighted in red when trying to initiate acceleration?

    1. If there is a UTXO that is not initiated by yourself, but given to you by someone else, and this UTXO's value is only 546, then it is too small.
    2. In other words, the balance of this UTXO is insufficient to support the input of the new UTXO and to increase the gas fee (that is, insufficient to pay for children).

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.