mirror of
https://github.com/bitcoinbook/bitcoinbook
synced 2025-01-11 00:01:03 +00:00
ch4 and ch5 fixes, moved OP list to appendix
This commit is contained in:
parent
d4a2526c32
commit
23a6c8276c
163
appdx-scriptops.asciidoc
Normal file
163
appdx-scriptops.asciidoc
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
|
||||||
|
[[tx_script_ops]]
|
||||||
|
=== Transaction Script Language Operators, Constants and Symbols
|
||||||
|
|
||||||
|
[[tx_script_ops_table_pushdata]]
|
||||||
|
.Push Value onto Stack
|
||||||
|
[options="header"]
|
||||||
|
|=======
|
||||||
|
| Symbol | Value (hex) | Description
|
||||||
|
| OP_0 or OP_FALSE | 0x00 | An empty array is pushed on to the stack
|
||||||
|
| 1-75 | 0x01-0x4b | Push the next N bytes onto the stack, where N is 1 to 75 bytes
|
||||||
|
| OP_PUSHDATA1 | 0x4c | The next script byte contains N, push the following N bytes onto the stack
|
||||||
|
| OP_PUSHDATA2 | 0x4d | The next two script bytes contain N, push the following N bytes onto the stack
|
||||||
|
| OP_PUSHDATA4 | 0x4e | The next four script bytes contain N, push the following N bytes onto the stack
|
||||||
|
| OP_1NEGATE | 0x4f | Push the value "-1" onto the stack
|
||||||
|
| OP_RESERVED | 0x50 | Halt - Invalid transaction unless found in an unexecuted OP_IF clause
|
||||||
|
| OP_1 or OP_TRUE| 0x51 | Push the value "1" onto the stack
|
||||||
|
| OP_2 to OP_16 | 0x52 to 0x60 | For OP_N, push the value "N" onto the stack. E.g., OP_2 pushes "2"
|
||||||
|
|=======
|
||||||
|
|
||||||
|
[[tx_script_ops_table_control]]
|
||||||
|
.Conditional Flow Control
|
||||||
|
[options="header"]
|
||||||
|
|=======
|
||||||
|
| Symbol | Value (hex) | Description
|
||||||
|
| OP_NOP | 0x61 | Do nothing
|
||||||
|
| OP_VER | 0x62 | Halt - Invalid transaction unless found in an unexecuted OP_IF clause
|
||||||
|
| OP_IF | 0x63 | Execute the statements following if top of stack is not 0
|
||||||
|
| OP_NOTIF | 0x64 | Execute the statements following if top of stack is 0
|
||||||
|
| OP_VERIF | 0x65 | Halt - Invalid transaction
|
||||||
|
| OP_VERNOTIF | 0x66 | Halt - Invalid transaction
|
||||||
|
| OP_ELSE | 0x67 | Execute only if the previous statements were not executed
|
||||||
|
| OP_ENDIF | 0x68 | Ends the OP_IF, OP_NOTIF, OP_ELSE block
|
||||||
|
| OP_VERIFY | 0x69 | Check the top of the stack, Halt and Invalidate transaction if not TRUE
|
||||||
|
| OP_RETURN | 0x6a | Halt and invalidate transaction
|
||||||
|
|=======
|
||||||
|
|
||||||
|
[[tx_script_ops_table_stack]]
|
||||||
|
.Stack Operations
|
||||||
|
[options="header"]
|
||||||
|
|=======
|
||||||
|
| Symbol | Value (hex) | Description
|
||||||
|
| OP_TOALTSTACK | 0x6b | Pop top item from stack and push to alternative stack
|
||||||
|
| OP_FROMALTSTACK | 0x6c | Pop top item from alternative stack and push to stack
|
||||||
|
| OP_2DROP | 0x6d | Pop top two stack items
|
||||||
|
| OP_2DUP | 0x6e | Duplicate top two stack items
|
||||||
|
| OP_3DUP | 0x6f | Duplicate top three stack items
|
||||||
|
| OP_2OVER | 0x70 | Copies the third and fourth items in the stack to the top
|
||||||
|
| OP_2ROT | 0x71 | Moves the fifth and sixth items in the stack to the top
|
||||||
|
| OP_2SWAP | 0x72 | Swap the two top pairs of items in the stack
|
||||||
|
| OP_IFDUP | 0x73 | Duplicate the top item in the stack if it is not 0
|
||||||
|
| OP_DEPTH | 0x74 | Count the items on the stack and push the resulting count
|
||||||
|
| OP_DROP | 0x75 | Pop the top item in the stack
|
||||||
|
| OP_DUP | 0x76 | Duplicate the top item in the stack
|
||||||
|
| OP_NIP | 0x77 | Pop the second item in the stack
|
||||||
|
| OP_OVER | 0x78 | Copy the second item in the stack and push it on to the top
|
||||||
|
| OP_PICK | 0x79 | Pop value N from top, then copy the Nth item to the top of the stack
|
||||||
|
| OP_ROLL | 0x7a | Pop value N from top, then move the Nth item to the top of the stack
|
||||||
|
| OP_ROT | 0x7b | Rotate the top three items in the stack
|
||||||
|
| OP_SWAP | 0x7c | Swap the top three items in the stack
|
||||||
|
| OP_TUCK | 0x7d | Copy the top item and insert it between the top and second item.
|
||||||
|
|=======
|
||||||
|
|
||||||
|
[[tx_script_ops_table_splice]]
|
||||||
|
.String Splice Operations
|
||||||
|
[options="header"]
|
||||||
|
|=======
|
||||||
|
| Symbol | Value (hex) | Description
|
||||||
|
| _OP_CAT_ | 0x7e | Disabled (Concatenates top two items)
|
||||||
|
| _OP_SUBSTR_ | 0x7f | Disabled (Returns substring)
|
||||||
|
| _OP_LEFT_ | 0x80 | Disabled (Returns left substring)
|
||||||
|
| _OP_RIGHT_ | 0x81 | Disabled (Returns right substring)
|
||||||
|
| OP_SIZE | 0x82 | Calculate string length of top item and push the result
|
||||||
|
|=======
|
||||||
|
|
||||||
|
[[tx_script_ops_table_binmath]]
|
||||||
|
.Binary Arithmetic and Conditionals
|
||||||
|
[options="header"]
|
||||||
|
|=======
|
||||||
|
| Symbol | Value (hex) | Description
|
||||||
|
| _OP_INVERT_ | 0x83 | Disabled (Flip the bits of the top item)
|
||||||
|
| _OP_AND_ | 0x84 | Disabled (Boolean AND of two top items)
|
||||||
|
| _OP_OR_ | 0x85 | Disabled (Boolean OR of two top items)
|
||||||
|
| _OP_XOR_ | 0x86 | Disabled (Boolean XOR of two top items)
|
||||||
|
| OP_EQUAL | 0x87 | Push TRUE (1) if top two items are exactly equal, push FALSE (0) otherwise
|
||||||
|
| OP_EQUALVERIFY | 0x88 | Same as OP_EQUAL, but run OP_VERIFY after to halt if not TRUE
|
||||||
|
| OP_RESERVED1 | 0x89 | Halt - Invalid transaction unless found in an unexecuted OP_IF clause
|
||||||
|
| OP_RESERVED2 | 0x8a | Halt - Invalid transaction unless found in an unexecuted OP_IF clause
|
||||||
|
|=======
|
||||||
|
|
||||||
|
[[tx_script_ops_table_numbers]]
|
||||||
|
.Numeric Operators
|
||||||
|
[options="header"]
|
||||||
|
|=======
|
||||||
|
| Symbol | Value (hex) | Description
|
||||||
|
| OP_1ADD | 0x8b | Add 1 to the top item
|
||||||
|
| OP_1SUB | 0x8c | Subtract 1 from the top item
|
||||||
|
| _OP_2MUL_ | 0x8d | Disabled (Multiply top item by 2)
|
||||||
|
| _OP_2DIV_ | 0x8e | Disabled (Divide top item by 2)
|
||||||
|
| OP_NEGATE | 0x8f | Flip the sign of top item
|
||||||
|
| OP_ABS | 0x90 | Change the sign of the top item to positive
|
||||||
|
| OP_NOT | 0x91 | If top item is 0 or 1 boolean flip it, otherwise return 0
|
||||||
|
| OP_0NOTEQUAL | 0x92 | If top item is 0 return 0, otherwise return 1
|
||||||
|
| OP_ADD | 0x93 | Pop top two items, add them and push result
|
||||||
|
| OP_SUB | 0x94 | Pop top two items, subtract first form second, push result
|
||||||
|
| OP_MUL | 0x95 | Disabled (Multiply top two items)
|
||||||
|
| OP_DIV | 0x96 | Disabled (Divide second item by first item)
|
||||||
|
| OP_MOD | 0x97 | Disabled (Remainder divide second item by first item)
|
||||||
|
| OP_LSHIFT | 0x98 | Disabled (Shift second item left by first item number of bits)
|
||||||
|
| OP_RSHIFT | 0x99 | Disabled (Shift second item right by first item number of bits)
|
||||||
|
| OP_BOOLAND | 0x9a | Boolean AND of top two items
|
||||||
|
| OP_BOOLOR | 0x9b | Boolean OR of top two items
|
||||||
|
| OP_NUMEQUAL | 0x9c | Return TRUE if top two items are equal numbers
|
||||||
|
| OP_NUMEQUALVERIFY | 0x9d | Same as NUMEQUAL, then OP_VERIFY to halt if not TRUE
|
||||||
|
| OP_NUMNOTEQUAL | 0x9e | Return TRUE if top two items are not equal numbers
|
||||||
|
| OP_LESSTHAN | 0x9f | Return TRUE if second item is less than top item
|
||||||
|
| OP_GREATERTHAN | 0xa0 | Return TRUE if second item is greater than top item
|
||||||
|
| OP_LESSTHANOREQUAL | 0xa1 | Return TRUE if second item is less than or equal to top item
|
||||||
|
| OP_GREATERTHANOREQUAL | 0xa2 | Return TRUE if second item is great than or equal to top item
|
||||||
|
| OP_MIN | 0xa3 | Return the smaller of the two top items
|
||||||
|
| OP_MAX | 0xa4 | Return the larger of the two top items
|
||||||
|
| OP_WITHIN | 0xa5 | Return TRUE if the third item is between the second item (or equal) and first item
|
||||||
|
|=======
|
||||||
|
|
||||||
|
|
||||||
|
[[tx_script_ops_table_crypto]]
|
||||||
|
.Cryptographic and Hashing Operations
|
||||||
|
[options="header"]
|
||||||
|
|=======
|
||||||
|
| Symbol | Value (hex) | Description
|
||||||
|
| OP_RIPEMD160 | 0xa6 | Return RIPEMD160 hash of top item
|
||||||
|
| OP_SHA1 | 0xa7 | Return SHA1 hash of top item
|
||||||
|
| OP_SHA256 | 0xa8 | Return SHA256 hash of top item
|
||||||
|
| OP_HASH160 | 0xa9 | Return RIPEMD160(SHA256(x)) hash of top item
|
||||||
|
| OP_HASH256 | 0xaa | Return SHA256(SHA256(x)) hash of top item
|
||||||
|
| OP_CODESEPARATOR | 0xab | Mark the beginning of signature-checked data
|
||||||
|
| OP_CHECKSIG | 0xac | Pop a public key and signature and validate the signature for the transaction's hashed data, return TRUE if matching
|
||||||
|
| OP_CHECKSIGVERIFY | 0xad | Same as CHECKSIG, then OP_VEIRFY to halt if not TRUE
|
||||||
|
| OP_CHECKMULTISIG | 0xae | Run CHECKSIG for each pair of signature and public key provided. All must match. Bug in implementation pops an extra value, prefix with OP_NOP as workaround
|
||||||
|
| OP_CHECKMULTISIGVERIFY | 0xaf | Same as CHECKMULTISIG, then OP_VERIFY to halt if not TRUE
|
||||||
|
|=======
|
||||||
|
|
||||||
|
[[tx_script_ops_table_nop]]
|
||||||
|
.Non-Operators
|
||||||
|
[options="header"]
|
||||||
|
|=======
|
||||||
|
| Symbol | Value (hex) | Description
|
||||||
|
| OP_NOP1-OP_NOP10 | 0xb0-0xb9 | Does nothing, ignored.
|
||||||
|
|=======
|
||||||
|
|
||||||
|
|
||||||
|
[[tx_script_ops_table_internal]]
|
||||||
|
.Reserved OP codes for internal use by the parser
|
||||||
|
[options="header"]
|
||||||
|
|=======
|
||||||
|
| Symbol | Value (hex) | Description
|
||||||
|
| OP_SMALLDATA | 0xf9 | Represents small data field
|
||||||
|
| OP_SMALLINTEGER | 0xfa | Represents small integer data field
|
||||||
|
| OP_PUBKEYS | 0xfb | Represents public key fields
|
||||||
|
| OP_PUBKEYHASH | 0xfd | Represents a public key hash field
|
||||||
|
| OP_PUBKEY | 0xfe | Represents a public key field
|
||||||
|
| OP_INVALIDOPCODE | 0xff | Represents any OP code not currently assigned
|
||||||
|
|=======
|
@ -322,10 +322,11 @@ The private key we generated earlier can be represented as:
|
|||||||
|
|
||||||
All of the above representations are different ways of showing the same number, the same private key. They look different, but any one format can easily be converted to any other format.
|
All of the above representations are different ways of showing the same number, the same private key. They look different, but any one format can easily be converted to any other format.
|
||||||
|
|
||||||
|
|
||||||
===== Decode from Base58Check to Hex
|
===== Decode from Base58Check to Hex
|
||||||
|
|
||||||
The sx-tools package (See <<sx_tools>>) makes Base58Check format decoding easy on the command line. We use the base58check-decode command:
|
The sx-tools package (See <<sx_tools>>) makes it easy to write shell-scripts and command-line "pipes" that manipulate bitcoin keys, addresses, and transactions. You can use sx-tools to decode the Base58Check format on the command line:
|
||||||
|
|
||||||
|
We use the base58check-decode command:
|
||||||
----
|
----
|
||||||
$ sx base58check-decode 5J3mBbAH58CpQ3Y5RNJpUKPE62SQ5tfcvU2JpbnkeyhfsYB1Jcn
|
$ sx base58check-decode 5J3mBbAH58CpQ3Y5RNJpUKPE62SQ5tfcvU2JpbnkeyhfsYB1Jcn
|
||||||
1e99423a4ed27608a15a2616a2b0e9e52ced330ac530edcc32c8ffc6a526aedd 128
|
1e99423a4ed27608a15a2616a2b0e9e52ced330ac530edcc32c8ffc6a526aedd 128
|
||||||
@ -335,7 +336,7 @@ The result is the hexadecimal key, followed by the Wallet Import Format (WIF) ve
|
|||||||
|
|
||||||
===== Encode from Hex to Base58Check
|
===== Encode from Hex to Base58Check
|
||||||
|
|
||||||
To encode into Base58Check, we provide the hex private key, followed by the Wallet Import Format (WIF) version prefix 128:
|
To encode into Base58Check (the opposite of the previous command), we provide the hex private key, followed by the Wallet Import Format (WIF) version prefix 128:
|
||||||
----
|
----
|
||||||
$ sx base58check-encode 1e99423a4ed27608a15a2616a2b0e9e52ced330ac530edcc32c8ffc6a526aedd 128
|
$ sx base58check-encode 1e99423a4ed27608a15a2616a2b0e9e52ced330ac530edcc32c8ffc6a526aedd 128
|
||||||
5J3mBbAH58CpQ3Y5RNJpUKPE62SQ5tfcvU2JpbnkeyhfsYB1Jcn
|
5J3mBbAH58CpQ3Y5RNJpUKPE62SQ5tfcvU2JpbnkeyhfsYB1Jcn
|
||||||
@ -463,7 +464,7 @@ Wallets contain keys, not coins. The coins are stored on the blockchain in the f
|
|||||||
|
|
||||||
==== Non-Deterministic (Random) Wallets
|
==== Non-Deterministic (Random) Wallets
|
||||||
|
|
||||||
In the first implementations of bitcoin clients, wallets were simply collections of randomly generated private keys. For example, the Bitcoin Core Client pre-generates 100 random private keys when first started and generates more keys as needed, trying to use each key only once. This type of wallet is nicknamed "Just a Bunch Of Keys", or JBOK, and such wallets are being replaced with deterministic wallets because they are cumbersome to manage, backup and import. The disadvantage of random keys is that if you generate many of them you must keep copies of all of them, meaning that the wallet must be backed-up frequently. Each key must be backed-up, or the funds it controls are irrevocably lost if the wallet becomes inaccessible. This conflicts directly with the principle of avoiding address re-use, by using each bitcoin address for only one transaction. Address re-use reduces privacy by associating multiple transactions and addresses with each other. A Type-0 wallet is a poor choice of wallet, especially if you want to avoid address re-use as that means managing many keys, which creates the need for very frequent backups. The Bitcoin Core Client includes a wallet that is implemented as a Type-0 wallet, but the use of this wallet is actively discouraged by the Bitcoin Core developers.
|
In the first implementations of bitcoin clients, wallets were simply collections of randomly generated private keys. The types of wallets are called _Type-0 Non-Deterministic Wallets_. For example, the Bitcoin Core Client pre-generates 100 random private keys when first started and generates more keys as needed, trying to use each key only once. This type of wallet is nicknamed "Just a Bunch Of Keys", or JBOK, and such wallets are being replaced with deterministic wallets because they are cumbersome to manage, backup and import. The disadvantage of random keys is that if you generate many of them you must keep copies of all of them, meaning that the wallet must be backed-up frequently. Each key must be backed-up, or the funds it controls are irrevocably lost if the wallet becomes inaccessible. This conflicts directly with the principle of avoiding address re-use, by using each bitcoin address for only one transaction. Address re-use reduces privacy by associating multiple transactions and addresses with each other. A Type-0 non-deterministic wallet is a poor choice of wallet, especially if you want to avoid address re-use as that means managing many keys, which creates the need for very frequent backups. The Bitcoin Core Client includes a wallet that is implemented as a Type-0 wallet, but the use of this wallet is actively discouraged by the Bitcoin Core developers.
|
||||||
|
|
||||||
[[Type0_wallet]]
|
[[Type0_wallet]]
|
||||||
.Type-0 Non-Deterministic (Random) Wallet: A Collection of Randomly Generated Keys
|
.Type-0 Non-Deterministic (Random) Wallet: A Collection of Randomly Generated Keys
|
||||||
@ -475,7 +476,7 @@ Deterministic, or "seeded" wallets are wallets that contain private keys which a
|
|||||||
|
|
||||||
==== Mnemonic Code Words (DRAFT:BIP0039)
|
==== Mnemonic Code Words (DRAFT:BIP0039)
|
||||||
|
|
||||||
Mnemonic codes are English word sequences that are generated from a random sequence and used to produce a seed for use in deterministic wallets. The sequence of words is sufficient to re-create the seed and from there re-create the wallet and all the derived keys. A wallet application that implements deterministic wallets with mnemonic code will show the user a sequence of 12-24 words when first creating a wallet. That sequence of words is the wallet backup and can be used to recover and re-create all the keys in the same or any compatible wallet application.
|
Mnemonic codes are English word sequences that represent (encode) a random number used as a seed to derive a deterministic wallet. The sequence of words is sufficient to re-create the seed and from there re-create the wallet and all the derived keys. A wallet application that implements deterministic wallets with mnemonic code will show the user a sequence of 12-24 words when first creating a wallet. That sequence of words is the wallet backup and can be used to recover and re-create all the keys in the same or any compatible wallet application. Mnemonic code words make it easier for users to back up wallets, as they are easy to read and correctly transcribe, as compared to a random sequence of numbers.
|
||||||
|
|
||||||
Mnemonic codes are defined in Bitcoin Improvement Proposal 39 (see <<bip0039>>), currently in Draft status. Note that BIP0039 is a draft proposal and not a standard. Specifically, there is a different standard, with a different set of words used by the Electrum wallet and _predating_ BIP0039. BIP0039 is used by the Trezor wallet and a few other wallets but is incompatible with Electrum's implementation.
|
Mnemonic codes are defined in Bitcoin Improvement Proposal 39 (see <<bip0039>>), currently in Draft status. Note that BIP0039 is a draft proposal and not a standard. Specifically, there is a different standard, with a different set of words used by the Electrum wallet and _predating_ BIP0039. BIP0039 is used by the Trezor wallet and a few other wallets but is incompatible with Electrum's implementation.
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ A transaction contains a number of fields, as follows:
|
|||||||
| 4 bytes | Locktime | A unix timestamp or block number
|
| 4 bytes | Locktime | A unix timestamp or block number
|
||||||
|=======
|
|=======
|
||||||
|
|
||||||
Note: Locktime defines the earliest time that a transaction can be added to the blockchain. It is set to zero in most transactions to indicate immediate execution. If locktime is non-zero and below 500 million, it is interpreted as a block height, meaning the transaction is not included in the blockchain prior to the specified block height. If it is above 500 million, it is interpreted as a Unix Epoch timestamp (seconds since Jan-1-1970) and the transaction is not included in the blockchain prior to the specified time.
|
Note: Locktime defines the earliest time that a transaction can be added to the blockchain. It is set to zero in most transactions to indicate immediate execution. If locktime is non-zero and below 500 million, it is interpreted as a block height, meaning the transaction is not included in the blockchain prior to the specified block height. If it is above 500 million, it is interpreted as a Unix Epoch timestamp (seconds since Jan-1-1970) and the transaction is not included in the blockchain prior to the specified time. The use of locktime is equivalent to post-dating a paper cheque.
|
||||||
|
|
||||||
[[tx_inputs_outputs]]
|
[[tx_inputs_outputs]]
|
||||||
=== Transaction Outputs and Inputs
|
=== Transaction Outputs and Inputs
|
||||||
@ -72,7 +72,7 @@ There are no accounts or balances in bitcoin, there are only _unspent transactio
|
|||||||
|
|
||||||
A UTXO can have an arbitrary value denominated as a multiple of satoshis. Just like dollars can be divided down to two decimal places as cents, bitcoins can be divided down to eight decimal places as satoshis. While UTXO can be any arbitrary value, once created it is indivisible just like a coin that cannot be cut in half. If a UTXO is larger than the desired value of a transaction, it must still be consumed in its entirety and change must be generated in the transaction. In other words, if you have a 20 bitcoin UTXO and want to pay 1 bitcoin, your transaction must consume the entire 20 bitcoin UTXO and produce two outputs: one paying 1 bitcoin to your desired recipient and another paying 19 bitcoin in change back to your wallet. As a result, most bitcoin transactions will generate change.
|
A UTXO can have an arbitrary value denominated as a multiple of satoshis. Just like dollars can be divided down to two decimal places as cents, bitcoins can be divided down to eight decimal places as satoshis. While UTXO can be any arbitrary value, once created it is indivisible just like a coin that cannot be cut in half. If a UTXO is larger than the desired value of a transaction, it must still be consumed in its entirety and change must be generated in the transaction. In other words, if you have a 20 bitcoin UTXO and want to pay 1 bitcoin, your transaction must consume the entire 20 bitcoin UTXO and produce two outputs: one paying 1 bitcoin to your desired recipient and another paying 19 bitcoin in change back to your wallet. As a result, most bitcoin transactions will generate change.
|
||||||
|
|
||||||
In simple terms, transactions consume the sender's available UTXO and create new UTXO locked to the recipient's bitcoin address. Imagine a shopper buying a $1.50 beverage, reaching into their wallet and trying to find a combination of coins and bank notes to cover the $1.50 cost. The shopper will choose exact change if available (a dollar bill and two quarters), or a combination of smaller denominations (six quarters), or if necessary, a larger unit such as a five dollar bank note. If they hand too much money, say $5, to the shop owner they will expect $3.50 change, which they will return to their wallet and have available for future transactions. Similarly, a bitcoin transaction must be created from a user's UTXO in whatever denominations that user has available. They cannot cut a UTXO in half any more than they can cut a dollar bill in half and use it as currency. The user's wallet application will typically select from the user's available UTXO various units to compose an amount greater than or equal to the desired transaction amount. As with real life, the bitcoin application can use several strategies to satisfy the purchase amount: combining several smaller units, finding exact change, or using a single unit larger than the transaction value and making change.
|
In simple terms, transactions consume the sender's available UTXO and create new UTXO locked to the recipient's bitcoin address. Imagine a shopper buying a $1.50 beverage, reaching into their wallet and trying to find a combination of coins and bank notes to cover the $1.50 cost. The shopper will choose exact change if available (a dollar bill and two quarters), or a combination of smaller denominations (six quarters), or if necessary, a larger unit such as a five dollar bank note. If they hand too much money, say $5, to the shop owner they will expect $3.50 change, which they will return to their wallet and have available for future transactions. Similarly, a bitcoin transaction must be created from a user's UTXO in whatever denominations that user has available. They cannot cut a UTXO in half any more than they can cut a dollar bill in half and use it as currency. The user's wallet application will typically select from the user's available UTXO various units to compose an amount greater than or equal to the desired transaction amount. As with real life, the bitcoin application can use several strategies to satisfy the purchase amount: combining several smaller units, finding exact change, or using a single unit larger than the transaction value and making change. All of this complex assembly of spendable UTXO is done by the user's wallet automatically and is invisible to users. It is only relevant if you are programmatically constructing raw transactions from UTXO.
|
||||||
|
|
||||||
The UTXO consumed by a transaction are called transaction inputs, while the UTXO created by a transaction are called transaction outputs. This way, chunks of bitcoin value move forward from owner to owner in a chain of transactions consuming and creating UTXO. Transactions consume UTXO unlocking it with the signature of the current owner and create UTXO locking it to the bitcoin address of the new owner.
|
The UTXO consumed by a transaction are called transaction inputs, while the UTXO created by a transaction are called transaction outputs. This way, chunks of bitcoin value move forward from owner to owner in a chain of transactions consuming and creating UTXO. Transactions consume UTXO unlocking it with the signature of the current owner and create UTXO locking it to the bitcoin address of the new owner.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user