a transfer of bitcoins from one bitcoin user to another. containing an embedded script, a bitcoin transaction is created in a crypto wallet, which resides on the user’s computer, smartphone or tablet or on a cryptocurrency exchange. The transaction is posted to the bitcoin network, where it is validated by a bitcoin “miner” and added to the blockchain. see bitcoin wallet and bitcoin mining.
utxos (unspent transaction outputs)
A person’s spendable bitcoins are stored in data records known as “unspent transaction outputs” (utxos), and a single utxo can contain any amount of bitcoin. Unlike a bank account balance, which is a single amount, a user’s bitcoin balance is like having cash in different drawers throughout the house. the sum of all the money in the drawers is the available balance. In the case of bitcoin, the sum of all the utxos of a given user is that person’s coin balance. the utxo database resides on a full bitcoin node on the blockchain.
Reading: What is a bitcoin transaction
either a wallet or a third party service maintains a database of utxos identified by the user’s private key. spending bitcoin means searching for available utxos and selecting denominations that make up the required amount to send to the recipient. Like paper money, each utxo is indivisible. therefore, if the inputs of the utxo are greater than the amount to be paid, the change is made in the form of a new utxo, the same as buying something for $6 with a $10 bill and getting $4 in change.
utxo database contains all bitcoins
Known as the utxos pool or the utxos database, all utxos on the blockchain represent the total number of bitcoins in existence. utxos are constantly changing as coins are sent from one user to another.
transactions have inputs and outputs
transaction inputs are the utxos being used, and transaction outputs are the utxos payment to the recipient plus any change (see illustration below). the difference between the inputs and outputs is the fee miners charge for doing the work (see bitcoin mining and coin base transaction).
unblocking and blocking scripts
A script in the bitcoin transaction unlocks input devices by verifying their digital signatures. a lock script sets the conditions for how utxo outputs can be spent; for example, post payment for 30 days. see digital signature, bitcoin node, bitcoin and blockchain.
Alice Sends Bob Five Bitcoins Alice has four UTXOs totalling 23 bitcoins (23 BTC). Her wallet generates a transaction with inputs worth 6 BTC and outputs 5 BTC to Bob along with .99 BTC back to Alice. The .01 difference is the transaction fee. In this example, small numbers are used to simplify the concept. Real transactions use Bitcoin fractions (see Satoshi).
The following are the different ways bitcoin transactions are formatted.
bech32 for segregated token
In 2017, bitcoin adopted the segwit protocol, which enabled faster validation, among other improvements. Segwit’s native transaction is bech32, and crypto wallets that support Segwit generally incur lower fees. the name bech32 was derived from the bch encoding and 32 characters (see bch code). see segwit and bitcoin hard fork.
p2pk – payment to public key
the first type of bitcoin transaction paid to a public key. later types of transactions obscured the public key by encrypting it so that future quantum computers could not generate the private key from the public key (see quantum security). see hash160.
p2pkh – payment to a public key hash
p2pkh is the common format that pays a hash bitcoin address. p2wpkh is the segwit version.
p2sh – payment to script hash
p2sh supports advanced features, such as when multiple signatures are required to authorize a payment. p2wsh is the segwit version.
p2sh (p2wpkh) – payment for segwit public key hash
native segwit wrapped in a p2sh transaction.
p2tr – pay to root
In late 2021, bitcoin adopted the taproot protocol for greater privacy and efficiency. see taproot.