mirror of
https://github.com/bitcoinbook/bitcoinbook
synced 2024-11-23 00:28:14 +00:00
Made changes to ch03.asciidoc
This commit is contained in:
parent
5586239657
commit
e4687c06eb
@ -730,14 +730,14 @@ $ bitcoin-cli gettransaction 9ca8f969bd3ef5ec2a8685660fdbf7a8bd365524c2e1fc66c30
|
||||
Here, we see the new information in the entries +blockhash+ (the hash of the block in which the transaction was included), and +blockindex+ with value 18 (indicating that our transaction was the 18th transaction in that block).
|
||||
|
||||
[[txindex]]
|
||||
.Transaction database index and txindex option
|
||||
.Transaction Database Index and txindex Option
|
||||
****
|
||||
By default, Bitcoin Core builds a database containing _only_ the transactions related to the user's wallet. If you want to be able to access _any_ transaction with commands like +gettransaction+, you need to configure Bitcoin Core to build a complete transaction index, which can be achieved with the +txindex+ option. Set +txindex=1+ in the Bitcoin Core configuration file (usually found in your home directory under +.bitcoin/bitcoin.conf+). Once you change this parameter, you need to restart bitcoind and wait for it to rebuild the index.
|
||||
By default, Bitcoin Core builds a database containing _only_ the transactions related to the user's wallet. If you want to be able to access _any_ transaction with commands like +gettransaction+, you need to configure Bitcoin Core to build a complete transaction index, which can be achieved with the +txindex+ option. Set +txindex=1+ in the Bitcoin Core configuration file (usually found in your home directory under _.bitcoin/bitcoin.conf_). Once you change this parameter, you need to restart bitcoind and wait for it to rebuild the index.
|
||||
****
|
||||
|
||||
==== Exploring blocks
|
||||
==== Exploring Blocks
|
||||
|
||||
Commands: getblock, getblockhash
|
||||
Commands: +getblock+, +getblockhash+
|
||||
|
||||
Now that we know which block our transaction was included in, we can query that block. We use the +getblock+ command with the block hash as the parameter:
|
||||
|
||||
@ -788,7 +788,7 @@ $ bitcoin-cli getblock 000000000000000051d2e759c63a26e247f185ecb7926ed7a6624bc31
|
||||
}
|
||||
----
|
||||
|
||||
The block contains 367 transactions and as you see above, the 18th transaction listed (+9ca8f9...+) is the txid of the one crediting 50 milliBits to our address. The +height+ entry tells us this is the 286384th block in the blockchain.
|
||||
The block contains 367 transactions and as you can see, the 18th transaction listed (+9ca8f9...+) is the txid of the one crediting 50 millibits to our address. The +height+ entry tells us this is the 286384th block in the blockchain.
|
||||
|
||||
We can also retrieve a block by its block height using the +getblockhash+ command, which takes the block height as the parameter and returns the block hash for that block:
|
||||
|
||||
@ -798,7 +798,7 @@ $ bitcoin-cli getblockhash 0
|
||||
000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
|
||||
----
|
||||
|
||||
Above, we retrieve the block hash of the "genesis block", the first block mined by Satoshi Nakamoto, at height zero. Retrieving this block shows:
|
||||
Here, we retrieve the block hash of the "genesis block," the first block mined by Satoshi Nakamoto, at height zero. Retrieving this block shows:
|
||||
|
||||
[source,bash]
|
||||
----
|
||||
@ -825,12 +825,12 @@ $ bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60
|
||||
}
|
||||
----
|
||||
|
||||
The +getblock+, +getblockhash+ and +gettransaction+ commands can be used to explore the blockchain database, programmatically.
|
||||
The +getblock+, +getblockhash+, and +gettransaction+ commands can be used to explore the blockchain database, programmatically.
|
||||
|
||||
|
||||
==== Creating, signing and submitting transactions based on unspent outputs
|
||||
==== Creating, Signing, and Submitting Transactions Based on Unspent Outputs
|
||||
|
||||
Commands: listunspent, gettxout, createrawtransaction, decoderawtransaction, signrawtransaction, sendrawtransaction
|
||||
Commands: +listunspent+, +gettxout+, +createrawtransaction+, +decoderawtransaction+, +signrawtransaction+, +sendrawtransaction+
|
||||
|
||||
Bitcoin's transactions are based on the concept of spending "outputs", which are the result of previous transactions, to create a transaction chain that transfers ownership from address to address. Our wallet has now received a transaction that assigned one such output to our address. Once this is confirmed, we can now spend that output.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user