How do Bitcoin transactions work?

Posted underBlog
Cover Image for How do Bitcoin transactions work?

Learning how bitcoin transactions work may sound a bit silly, but it turns out, many traders and investors don’t really know what happens behind the scenes in order to get cryptocurrency into their possession.

Read on to find out how do bitcoin transactions work, how long they take, and the verification processes that go behind curtains to ensure security.

Money How Do I Do This GIF by Originals

“We define a bitcoin as a chain of digital signatures. Each owner transfers bitcoin to the next by digitally signing a hash of the previous transaction and the public key of the next owner and adding these to the end of the coin. A payee can verify the signatures to verify the chain of ownership.”

— Satoshi Nakamoto, Bitcoin Whitepaper

Before getting into the nitty-gritty details of bitcoin transactions, it’s worth mentioning the fundamentals of the cryptocurrency itself.

In essence, bitcoin is simply just small pieces of computer code. The currency has no physical manifestation, that is why it is digital — you can’t hold it in your hands, stick it in an envelope or in a physical wallet — but it can be used as a medium for transactions. That is, you can use it to buy or sell things, as long as the party on the other side of the transaction is willing to accept it.

Also worth noting: Bitcoin is built on something called “blockchain” technology, which is, at its core, a chain of blocks containing data. Blockchain enables cryptocurrency transactions, as well. It keeps a record of all transactions — storing the data in blocks — using a distributed ledger. It is like an Excel spreadsheet that is saved on thousands of different hard drives, all of which reference each other to validate the data’s accuracy.

The thing about bitcoin transactions is that although bitcoin is sent to and from wallets, these “wallets” don’t actually store bitcoin. Instead, they hold records of all your transactions in addresses. Bitcoin addresses are 34-character long strings of letters and numbers and are also known as your public key. This is the address that you share with people when you want to receive cryptocurrencies.

Public key (Bitcoin address)     1DSsgJdB2AnWaFNgSbv4MZC2m71116JafG

Each public key has its own corresponding private key—a string of letters and numbers that is used to “sign” transactions. The private key owner is the only one who can perform the encryption of it. Since it is impossible to regenerate the private key from a public key or address, if an owner loses their private key, any bitcoin located at this public address will be inaccessible. However, if the owner loses the public key, it is possible to recreate it with the private key. 

 Anyone who possessess your private keys has access to your bitcoin!

Think of your public key as IBAN and your private key as your pin code. Your IBAN is okay to share because that’s how people send you money, but you can’t share your pin code, for obvious reasons. Public and private keys are essentially the same, but instead of a bank account, it’s access to your BTC wallet.

Bitcoin Transaction Elements

If you own bitcoin and you’re looking to either spend it, send it to your crypto wallet or convert it to a different exchange, you’ll first need to know a transaction is verified on the blockchain. 

Transferring bitcoin funds from one user to another begins with the submission of a transaction request to the bitcoin network. This can be done on your computer or via a mobile app. Nodes – other computers on the blockchain network – verify the transaction details. With that being said here is a breakdown of the actual structure of each Bitcoin transaction, in detail:

Input: The input section of a Bitcoin transaction identifies the source of the funds being spent. This section contains the previous transaction output that is being spent and the index of the specific output being used as input for the current transaction. Each input must be signed by the owner of the funds, providing proof that they have the right to spend them.

Output: The output section of a Bitcoin transaction specifies the destination of the funds being sent. It contains the recipient’s address and the amount of Bitcoin being sent to that address. Each output can be spent only once as an input in a future transaction.

Script: The script section of a Bitcoin transaction contains the code that determines how the transaction can be spent. This section is called the “scriptPubKey” for the output being spent and the “scriptSig” for the input that spends it. The scriptPubKey typically includes the recipient’s public key and specifies the conditions that must be met to spend the funds. The scriptSig contains the signature of the input owner, which proves that they have the right to spend the funds.

Fee: The fee section of a Bitcoin transaction specifies the amount paid by the sender to incentivize miners to include the transaction in the blockchain. The fee is calculated based on the size of the transaction in bytes and the current demand for transaction processing on the network.

Version: The version section of a Bitcoin transaction identifies the version of the Bitcoin protocol used to create the transaction. This section allows for future upgrades to the protocol while maintaining backward compatibility.

Locktime: The locktime section of a Bitcoin transaction specifies the earliest time or block height at which the transaction can be included in the blockchain. This feature allows users to set a delay on transactions, making them unspendable until a specific time has passed.

SegWit: The SegWit (Segregated Witness) section of a Bitcoin transaction is an optional feature that separates the signature data from the rest of the transaction. This separation allows for more efficient use of block space and reduces transaction fees.

Having all of that in mind most of the time Bitcoin transactions consist of four main elements which in our case have context included for better understanding:

  1. Inputs (sender). The bitcoin address from which Bob wants to send bitcoin to John and from which he previously received bitcoin.
  2. Amounts. The amount of bitcoin Bob wants to send to John.
  3. Outputs(recipient info). John’s public key or bitcoin address. These contain the address to which the transfer is made and the amount shipped. They also contain the directions of change where the returns of the transactions are sent. So in a transaction, it can contain more than one output. 
  4. Commission rate. The small payment miners receive for processing a transaction. Thus, the miner that generates a new block will receive a fee for each transaction processed within the said block.

What Are The Different Types Of Bitcoin Address?

As noted above, a bitcoin address is also known as a public key and is the part of a bitcoin transaction that indicates where bitcoin is being sent. BTC addresses are 26 to 35 characters long and consist of numbers and letters. As of now, there are three different bitcoin address formats in use:

  1. A P2PKH Address, which starts with the number 1, is a pay-to-public key hash address, which is the basic and most common form of address for bitcoin transactions.;
  2. A P2SH address, which starts with the number 3, or pays to script hash. The address was standardized in BIP 16, allowing transactions to be sent to a script hash, rather than a public key hash, adding some additional security options.;
  3. A Bech32 address, which starts with “bc1”, is a SegWit address. Introduced by BIP 0173 to use block space more efficiently. It is now supported by many bitcoin wallets and many bitcoin users prefer this address type.

Once bitcoin transactions are transmitted to the network, they are first verified by available Bitcoin nodes. Once that verification is complete, the transaction sits in the node’s unconfirmed transactions waiting area, also known as “mempool.”

Miners take these pending transactions and combine them to create a “block,” which they then compete to verify by racing to solve a computational mathematical problem. In short, miners are verifying that the sender truly owns the bitcoin that they are trying to send. To incentivize BTC miners to verify their transactions first out of all pending transactions in the mempool, users attach transaction fees — rewards that miners will receive in addition to the programmed mining subsidy if they successfully verify the transaction and add it to the Bitcoin blockchain.

How does the magic happens?

The example

Bob’s bitcoin wallet address has received a total of 5 bitcoin over the course of a certain period of time (lucky him), and he wants to send 2 BTC to John (it’s good to have friends). The bitcoin transaction will have one input (the unspent outputs of the bitcoin transaction through which he received those 5 BTC) and create two different outputs when he sends BTC to John. The first output will be the transaction to John, for the full amount of 2 BTC. The second output will be the “change” transaction, which “returns” the unspent 3 BTC to Bob’s wallet address.

Now let’s connect the dots and dive deeper:

Each transaction consists of three main parts: an input, an amount, and an output.

The input in this example refers to the BTC address of Bob as well as the record of the coins inside. The amount is how much BTC Bob is trying to send to John – 2BTC. Lastly, the output is the address of the wallet receiving the BTC—John’s wallet address.

Simply put, if Bob wants to send John some bitcoins he has to submit his intention on the network. After inputting all the transaction details, he inputs his private key into the Bitcoin software to “sign” the transaction, which gives the green light to send the bitcoins. At this point, the transaction is up for validation by the network. The network first checks if the signature (private key) matches its corresponding public key. If it matches, the miners will then check if Bob has enough BTC to send or if he already sent it to someone else. If everything is OK – the transaction is validated.

A Bitcoin transaction must be confirmed on a blockchain to verify that the transaction is legitimate. A confirmed transaction means that the transaction has been included in a block, and therefore included in the blockchain. That means the transaction has now been officially recorded and verified.

The number of confirmations needed for a bitcoin transaction to be processed will depend on the exchange, and on the amount being transferred. Some exchanges will process a transaction after just one confirmation, many require three confirmations, while some may require up to six. In the case of Bob and John – they will need three confirmations on their transaction by the network, so the data is added onto the blockchain.

Now John will be able to use his newly-acquired BTC and as a reward for validating the trade, miners are rewarded in BTC per block mined.

What is Bitcoin Mining?

Bitcoin Meme Library

Mining refers to a voluntary practice of miners devoting the processing power of their computers to solving complex math problems. By doing this they mint new blocks to which they add upcoming bitcoin transactions.

The bitcoin system relies on a method called proof of work, which ensures that the process of mining new blocks is difficult enough to preserve the balance of the market. But it isn’t made too difficult, so as not to discourage nodes from participating or slow down transactions.

Given that there are thousands of Bitcoin transactions per day, miners perform a crucial role. Mining verifies the integrity of new transactions, adding them to the blockchain and at the same time producing new bitcoins that enter circulation.

In addition to miner fees, they are also entitled to block reward: a portion of the newly created Bitcoin that comes with newly mined blocks.

Transaction Speed

The speed of bitcoin transactions can vary from 10 min to over 60 min. This depends on several factors. First, you must remember that all transactions need to be verified by the Bitcoin miners on the blockchain. When the queue is overloaded, your transaction doesn’t always make the cut for the current block. Instead, your transaction can be put on hold until the next block is assembled.

Another factor is the size of Bitcoin blocks. Although there’s always the chance of block size being increased in the future, the current Bitcoin protocol limits the block to 1MB. This limits each block to a certain number of transactions. That, in turn, can slow down confirmation times and as a result, the entire Bitcoin network.

Transaction Fees

Fees for sending bitcoin could be anywhere from a few cents all the way up to $100. The reason for the big variation is that Bitcoin fees depend on both supply and demand or how congested the network is at a given time. Another consideration is the “size” of your transaction. Size is affected primarily by inputs, so if your transaction has many inputs, it will take up more block space, and demand a higher fee.

How to track Bitcoin transactions?

When you send bitcoins you’re given a bitcoin transaction ID (TxID), which you can use to track the transaction. It’s easy to check the status of your bitcoin transaction and see if it has been confirmed, how many times it has been confirmed and additional information, by accessing Bitcoin’s blockchain at https://mempool.space/. Here, you’ll be able to enter your Bitcoin TxID or wallet address, to track your transactions and even be able to see the fee you’ve paid for it.

Need help?

Bitcoin transaction processes are long and complex, but guarantee transparency and security at the same time.

This article covers only the basic, most important aspects one should know when diving into this technology.

If you want to know more about bitcoin, Bitcoin blockchain and how it works – drop us a line or subscribe to our newsletter for future articles. 🙂


Silvia
About the author:

Silvia

Silvia is an aspiring marketing creative and civil engineering graduate who believes simplicity and empathy are key to conveying the ideas around revolutionary technologies like blockchain. Excited about NFTs, DeFi, DAOs and anything that brings the power back to people through transparent and decentralized solutions. Always striving to break down complex topics into core components while bringing meaningful insights, she believes a well-crafted story can change a person’s life.


More Stories

Cover Image for Real-World Assets and the Future of DeFi

Real-World Assets and the Future of DeFi

Real-world assets are blockchain-based digital tokens that represent physical and traditional financial assets. The first wave of decentralized finance (DeFi) […]

Read more
Cover Image for Navigating Upgradable Solidity Smart Contracts: A Practical Guide

Navigating Upgradable Solidity Smart Contracts: A Practical Guide

In the ever-evolving landscape of blockchain technology, the concept of upgradeable smart contracts has emerged as a crucial tool for […]

Read more

Have a project in mind?

We have the expertise! Drop us a line and lets talk!