How a Bitcoin Transaction Works

This article explains what a Bitcoin transaction is, its purpose and outcome. The explanation made below is suitable for both novice and intermediate Bitcoin users.

Spil a cryptocurrency user you need to be familiar with transaction rudiments – for the sake of your own confidence with this evolving innovation, and spil a foundation for understanding emerging multi-signature transactions and contracts, both of which will be explored zometeen ter the series. This is not a technical article and explanation will concentrate on what you need to know about standard bitcoin transactions – the spend transactions wij commonly make – and wij’ll gloss overheen what you can securely overlook.

An infographic at the bottom of the article provides a comprehensive illustration of the entire Bitcoin transaction process from wallet to blockchain.

Note: Even the Core developers acknowledge that some of the language being used to describe transactions and their components can lead one to a mistaken concept of what is indeed happening. Thesis misconceptions are avoided te the explanation below. So, while attempting to keep things spil plain spil possible, and with the aid of a few diagrams, let’s dive right ter.

Definition of Terms and Abbreviations

Bitcoin with a capital “B” refers to the protocol – the code, the knots, the network and their peer-to-peer interaction.

bitcoin with a lowercase ‘b’ refers to the currency – the cryptocurrency wij send and receive, via the Bitcoin network.

txid is an abbreviation for ‘transaction id’ – this is a hash that is used by both humans and the protocol to reference transactions.

Script is the name of the Bitcoin protocol’s scripting system that processes and validates transactions. Script is a clever, stack-based instruction engine, and it makes all transactions from elementary payments to ingewikkeld oracle overseen contracts possible.

UTXO is an abbreviation for Unspent Transaction Output, also referred to spil an “output”.

What is a Bitcoin Transaction and Why?

Definition

A Bitcoin transaction is a signed lump of gegevens that is broadcast to the network and, if valid, completes up te a block te the blockchain.

Purpose

The purpose of a Bitcoin transaction is to transfer ownership of an amount of Bitcoin to a Bitcoin address.

Outcome

When you send Bitcoin, a single gegevens structure, namely a Bitcoin transaction, is created by your wallet client and then broadcast to the network. Bitcoin knots on the network will relay and rebroadcast the transaction, and if the transaction is valid, knots will include it ter the block they are mining. Usually, within 10-20mins, the transaction will be included, along with other transactions, ter a block te the blockchain. At this point the receiver is able to see the transaction amount te their wallet.

Example

Here is an example transaction that wasgoed included ter the blockchain earlier this year:

The main components of this standard transaction are color-coded:

Bitcoin Transaction Inputs and Outputs

Firstly, four axiomatic truths about transactions:

  • Any Bitcoin amount that wij send is always sent to an address.
  • Any Bitcoin amount wij receive is locked to the receiving address – which is (usually) associated with our wallet.
  • Any time wij spend Bitcoin, the amount wij spend will always come from funds previously received and presently present te our wallet.
  • Addresses receive Bitcoin, but they do not send Bitcoin – Bitcoin is sent from a wallet.

The amounts that go into our wallet are not jumbled like the coins ter a physical wallet. The received amounts don’t mix but remain separate and distinct spil the precies amounts received by the wallet. Here’s an illustration:

Example

You create a brand fresh wallet and, te time, it receives three amounts of 0.01, 0.Two and Trio BTC spil goes after: you send Trio BTC to an address associated with the wallet and two payments are made to another address by Alice.

The wallet reports a balance of Three.21 BTC, yet if you were to virtually peek inwards the wallet, you would see – not 321,000,000 satoshi (321 mil satoshi) – but three distinct amounts still grouped together by their originating transactions: 0.01, 0.Two and Three BTC.

The received bitcoin amounts don’t mix but remain separated spil the precies amounts sent to the wallet. The three amounts te the example above are called the outputs of their originating transactions.

Bitcoin wallets always keep outputs separate and distinct.

Definition

An output is an amount that wasgoed sent (via a standard transaction) to a Bitcoin address, along with a set of rules to unlock the output amount. Ter Bitcoin parlance an output is called an “unspent transaction output”, or UTXO.

A standard transaction output can be unlocked with the private key associated with the receiving address. Addresses and their associated public/private key pairs will be covered zometeen ter the series. For now, wij are worried with the output amount only.

Example

Let’s consider an example by following the money ter a script where you send 0.15 BTC to Bob.

Spil wij have seen, your wallet does not select 15 mil satoshi (0.15 BTC) from an undifferentiated pool of 321 mil satoshi making up the wallet balance. Instead, the wallet selects a spend candidate from amongst the three existing “outputs” contained ter the wallet. So, it chooses (for various reasons that are not significant now) the 0.Two BTC output. The wallet will unlock the 0.Two BTC output and use the entire amount of 0.Two BTC spil an input to your fresh 0.15 BTC transaction. The 0.Two BTC output is “spent” ter the process. –Read this paragraph a 2nd time.

The spend transaction your wallet creates will send 0.15 BTC to Bob’s address – where it will reside te his wallet spil an output – waiting eventually to be spent.

The 0.05 BTC difference (0.Two BTC input minus 0.15 BTC output) is called “change” and the transaction will send this back to your wallet via a freshly created address. The 0.05 BTC switch amount will reside te your wallet spil a fresh output – waiting eventually to be spent. So, now, a virtual peek inwards your wallet exposes the following:

Each of the three outputs that are “waiting to be spent”, is locked to its receiving addresses until such time spil one or more of them are selected spil input(s) to a fresh spend transaction.

Behind the scenes, different wallet clients apply different logic rules when selecting UTXOs spil inputs to fresh transactions. A sane wallet policy is to use older UTXOs very first, wherever possible, but implementations differ. The manner ter which UTXOs are selected is not of concern to us right now, since the objective has bot emphasis of the point that amounts received to our wallets remain separate and distinct.

Summary of How a Bitcoin Transaction Works

Various received amounts don’t mix spil they do ter a physical wallet. Instead, received amounts (UTXOs) are used individually (or te combination) at the uur wij spend Bitcoin. When creating the spend transaction our wallet selects UTXOs (of sufficient value to sate the amount wij want to send) and typically creates two fresh outputs: one for the receiver and one for the switch wij receive back to our wallet. The switch becomes a brand fresh UTXO te our wallet, and the amount wij send becomes a UTXO locked to the recipient address – which may or may not be associated with a wallet, e.g. cold storage. The original UTXO used spil input to the spend transaction is “spent” and ruined forever.

This has bot an introduction to how outputs (UTXOs) are treated by wallet software. Once a UTXO is selected for expenditure, it requires the private key associated with the address that received it. This private key redeems the UTXO and permits it to become an input ter a fresh spend transaction. The mechanism whereby previous transaction outputs are reused spil the inputs to fresh transactions is central to the Bitcoin protocol’s function – and exactly spil vanaf Satoshi’s vormgeving.

Related movie: Understanding Bitcoin Difficulty


Leave a Reply