1
0
mirror of https://github.com/bitcoinbook/bitcoinbook synced 2024-12-28 01:18:30 +00:00

Merge pull request #807 from rating89us/patch-8

ch06: preceding input->input from Alice's transaction; change UTXO example…
This commit is contained in:
Will Binns 2021-03-04 19:07:48 +01:00 committed by GitHub
commit 47ae9960f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -210,10 +210,10 @@ It's not just Alice's wallet that needs to retrieve UTXO referenced in the input
Transactions on their own seem incomplete because they lack context. They reference UTXO in their inputs but without retrieving that UTXO we cannot know the value of the inputs or their locking conditions. When writing bitcoin software, anytime you decode a transaction with the intent of validating it or counting the fees or checking the unlocking script, your code will first have to retrieve the referenced UTXO from the blockchain in order to build the context implied but not present in the UTXO references of the inputs. For example, to calculate the amount paid in fees, you must know the sum of the values of inputs and outputs. But without retrieving the UTXO referenced in the inputs, you do not know their value. So a seemingly simple operation like counting fees in a single transaction in fact involves multiple steps and data from multiple transactions.
We can use the same sequence of commands with Bitcoin Core as we used when retrieving Alice's transaction (+getrawtransaction+ and +decoderawtransaction+). With that we can get the UTXO referenced in the preceding input and take a look:
We can use the same sequence of commands with Bitcoin Core as we used when retrieving Alice's transaction (+getrawtransaction+ and +decoderawtransaction+). With that we can get the UTXO referenced in the input from Alice's transaction and take a look:
[[alice_input_tx]]
.Alice's UTXO from the previous transaction, referenced in the input
.UTXO from the previous transaction, referenced in the input from Alice's transaction
[source,json]
----
"vout": [