Initiating a bitcoin transaction

Tharaka Wijesundara
6 min readMar 22, 2023

--

Have you been exhausted searching for a complete but simple guide to understanding how a bitcoin transaction takes place? 😰 This is a series of articles that explain bitcoin from its history of evolution to the complete journey of a bitcoin transaction with its underlying mathematics. The series consists of six articles and now you are in the third article.3️⃣ To kick off from the very beginning, click here. Happy reading.👨‍💻👩‍💻

Bitcoin transaction journey

Here you have reached the first section of the most interesting parts of this blockchain blog series. Up to now, you have gone through the basic fundamentals of blockchain. Not basic actually. It is up to you to decide how much you have learned so far.😉 It’s time to get deeper into the concepts and find out the end-to-end flow of transactions. Here I’m referring to transactions because the explanation will focus on the Bitcoin network and its clear intent is to make transactions from one to another. Let’s start off with the initiation of a transaction and then to adding it to a block after validation and verification. It’s better to look through this with an example.

Joe owns a car sale. One of his friends Bob is going to buy a car and wants to settle the payment through bitcoin. Let’s say for the sake of simplicity, the car is valued at 1 BTC and Bob has 1.6 BTC in his wallet. Here, Bob can run his own Bitcoin full-node with Bitcoin core or similar kind of software installed to add this transaction to the network as we discussed in the previous section, or use a wallet application like Metamask, Trust Wallet, etc as a light node. Whatever method Bob uses, the transaction makes its way to the network following the same steps.

Let’s assume that Bob has limited resources in his devices and therefore chooses to use a wallet application. If you want to follow Bob, click here and set up your own Metamask wallet.

Note: Here, Metamask supports only EVM-based tokens and native cryptocurrencies, and not possible to exchange Bitcoin. I have used it for Bob’s case only for its simplicity in setting up a wallet. Click here for bitcoin-specific wallet applications.

Once you are done, you have your own private and public keys with you. Later you would see what is that key pair, what we need it for, and why we need to secure it in greater detail. You might be warned not to share the listed phrases with anyone else. What do you think? What if you mistakenly shared it with the public?🤔Since the wallet software uses its own algorithm to make the private key, anyone with your phrase in hand can pretend him/her the legitimate owner of the wallet.😱

To make it simpler, let’s assume a scenario where you send and receive emails. If you want someone to send you an email, what do you share with them? Email or the password? 😂

In that context, email is public while the password is private. We can apply the same concept to the Bitcoin example while keeping in mind that private/public key pairs are numbers and not simply traditional email credentials.

For Bob to send BTC, it’s obvious that somehow Bob needs BTC in his wallet. How can he receive BTC? There are only two possible ways.

  1. He needs to ask someone to send him.
  2. He can mine BTC by running his own mining node

Since we assumed that Bob has limited computing power, he must have received a total worth of 1.6 BTC from someone else. In Bitcoin, we refer to it as UTXOs, Unspent Transaction Outputs.

UTXO — Unspent Transaction Outputs

As its name refers, in bitcoin and some other cryptocurrencies UTXOs are used to make payments. UTXO is a transaction where the sender needs to reference them when making a payment and then the referenced UTXOs will be removed from the sender while assigning them to the receiver. Does it confuse you more? 🙃If then, let’s clear the doubts with an example.

As the above picture depicted, Bob receive a total of 1.6 BTC from Charlie, Pinkie, and Salie. Now let’s say Bob is going to pay Alice 1 BTC. How can we do that? Can we break them into further small pieces until the sum adds up to 1 BTC?🤔 No, it’s not possible in the UTXO model, Bob needs to use one or multiple UTXOs even if the sum is greater than the expected amount to be paid.

Bob’s Wallet

There is a term called UTXO set in the Bitcoin network. As its name implies, each full node in the network maintains a set of UTXOs where that can be used for validation without going deeper into the blockchain. If we explain it further, full nodes keep the complete UTXO set which means every UTXO that can be used from anywhere in the network to initiate a transaction. Node just needs to refer and check whether the user is going to double spend (reuse previously used UTXO) or is valid.

UTXO Set

When it comes to the wallet, it keeps the track of UTXOs available under your address, not the whole set. The wallet will sum up the UTXOs and display it as the available balance. Once a transaction is validated and added to a block, the UTXO set will be updated. (Both in the wallet and the full nodes). As I stated above, making a transaction means utilizing a single or set of UTXOs and assigning the total value under the recipient address as a new UTXO. Therefore the values of the UTXO set will sum up to the circulating supply of the particular coin, here BTC.

We need to pay an amount for the mining node as a fee to add the transaction into a block. We can set the transaction fee as zero and try to make the payment but it will be rejected since it won’t be picked by any node for their block and the amount will be refunded to Bob. It is worth it for the mining node to pick transactions with higher fees.

Eventually, for a successful transaction, you will end up having a single UTXO for future transactions. This means on Alice’s side, once the transaction is confirmed, his account will be filled with 1 BTC worth of UTXO. Miner’s account will be filled with 0.1 BTC and Bob will get his balance of 0.5 BTC as another UTXO.

Bitcoin transaction — Source

Have you noticed that we have missed something?🧐Yeah. It's not possible to initiate a transaction without the owner's permission. Here, we need Bob’s permission. Let’s hold it for the next section.😋

--

--