How do bitcoin transactions work
Bitcoin101

How Do Bitcoin Transactions Work?

Bitcoin transactions are designed to be publicly searchable, programmatically confirmed by miners and immutable once embedded on the blockchain. 

BTC transactions contain three pieces of essential data: the amount being transacted, an input (the addresses where the bitcoin being sent have come from) and the output (the bitcoin address, also known as the public key, where the bitcoin is being sent). When 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, called the “mempool.”

Miners take these pending transactions and combine them to create a “block,” which they then compete to verify by (in an oversimplified sense) racing to complete a computational puzzle. In short, miners are verifying that the transaction sender’s keys are able to access the inputs necessary to complete the transaction (in essence, 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 can attach transaction fees — rewards that miners will receive in addition to the programmed mining subsidy if they successfully verify the transaction.

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. At the time of this writing, there are three different Bitcoin address formats in use:

  1. A P2PKH Address, which starts with the number 1
  2. A P2SH address, which starts with the number 3
  3. A Bech32 address, which starts with “bc1”

A P2PKH, or pay-to-pubkeyhash address, is the basic and most common form of address for bitcoin transactions. 

P2SH, or pay to script hash, 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. 

A Bech32 address is a SegWit address, introduced by BIP 0173 to use block space more efficiently. It is now supported by many bitcoin wallets and many Bitcoiners prefer this address type.

How to Send Bitcoin

In order to send bitcoin, you have to prove to the network that you truly “own” it. This is no simple thing, as bitcoin does not exist physically and there are no third parties with the authority to approve or deny transactions. 

To initiate a bitcoin transaction, you will have to access both the public and private keys associated with the bitcoin you hope to send. Public keys, also known as bitcoin addresses, are somewhat akin to email addresses in that they are safe to share and, in fact, they have to be shared in order to receive transactions (though, as just stated, they are also needed to send bitcoin). But private keys are more like passwords: they are used to send transactions and should not be shared, because they could be used to send your bitcoin somewhere you wouldn’t want it.

When you send BTC, you use your private key to sign a message that describes the transaction (including the amount, input and output) to the Bitcoin network.

How to Receive Bitcoin

As noted above, in order to receive BTC, you will need a public key, or bitcoin address. Bitcoin addresses are generated by bitcoin wallets, through online exchanges or on Bitcoin Core. Most Bitcoin software and websites will generate a new bitcoin address for users every time they request a bitcoin payment or create an invoice. 

This is recommended as a way to differentiate transactions — if multiple payments of the same amount are sent to the same address, there would be no way to tell who made which payment. And, because transactions are public on the blockchain, malicious actors could claim that they sent bitcoin to your address that was actually sent by someone else and it would be impossible to determine the truth.