bitcoin-cli Transaction Commands

This section describes transaction related 'bitcoin-cli' commands.

If you want to learn the structure of Bitcoin transactions, you can play with the "bitcoin-cli" transaction commands as shown below.

1. Get the hash of the block at a given height.

C:\>\local\bitcoin-0.15.1\bin\bitcoin-cli -testnet getblockhash 100000
00000000009e2958c15ff9290d571bf9459e93b19765c6801ddeccadbb160a1e

2. Get transaction IDs from a given block.

C:\>\local\bitcoin-0.15.1\bin\bitcoin-cli -testnet
   getblock 00000000009e2958c15ff9290d571bf9459e93b19765c6801ddeccadbb160a1e

{
  "hash": "00000000009e2958c15ff9290d571bf9459e93b19765c6801ddeccadbb160a1e",
  "confirmations": 51096,
  "strippedsize": 221,
  "size": 221,
  "weight": 884,
  "height": 100000,
  "version": 2,
  "versionHex": "00000002",
  "merkleroot": 
     "d574f343976d8e70d91cb278d21044dd8a396019e6db70755a0a50e4783dba38",
  "tx": [
    "d574f343976d8e70d91cb278d21044dd8a396019e6db70755a0a50e4783dba38"
  ],
  ...
}

3. Get details of a given transaction.

C:\>\local\bitcoin-0.15.1\bin\bitcoin-cli -testnet getrawtransaction
   d574f343976d8e70d91cb278d21044dd8a396019e6db70755a0a50e4783dba38 1
   
{
  "txid": "d574f343976d8e70d91cb278d21044dd8a396019e6db70755a0a50e4783dba38",
  "hash": "d574f343976d8e70d91cb278d21044dd8a396019e6db70755a0a50e4783dba38",
  "version": 1,
  "size": 140,
  "vsize": 140,
  "locktime": 0,
  "vin": [
    {
      "coinbase": 
         "03a08601000427f1001c046a510100522cfabe6d6d000000000000000000006869
2066726f6d20706f6f6c7365727665726aac1eeeed88",
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 50.00000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 912e2b234f941f30b18afbb4fa46171214bf66c8 
           OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914912e2b234f941f30b18afbb4fa46171214bf66c888ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "mtkbaiLiUH3fvGJeSzuN3kUgmJzqinLejJ"
        ]
      }
    }
  ],
  "hex": "010000000100000000000000000000000000000000000000000000000000000000
00000000ffffffff3703a08601000427f1001c046a510100522cfabe6d6d0000000000000000
000068692066726f6d20706f6f6c7365727665726aac1eeeed88ffffffff0100f2052a010000
001976a914912e2b234f941f30b18afbb4fa46171214bf66c888ac00000000",
  "blockhash": 
     "00000000009e2958c15ff9290d571bf9459e93b19765c6801ddeccadbb160a1e",
  "confirmations": 51096,
  "time": 1376123972,
  "blocktime": 1376123972
}

As you can see from the output, this transaction gave out 50 BTC to "mtkbaiLiUH3fvGJeSzuN3kUgmJzqinLejJ" from the coin base.

Table of Contents

 About This Book

 Introduction of Bitcoin

 Bitcoin Blockchain

 Bitcoin Wallet

Bitcoin Core

 Bitcoin Core Programs

 Bitcoin Core Daemon

 Bitcoin Core CLI

 Bitcoin Core CLI Commands

 Access Bitcoin Test Network "-testnet"

 bitcoin-cli Network Commands

 "bitcoin-cli getclock" Command

bitcoin-cli Transaction Commands

 bitcoin-cli Wallet Commands

 "bitcoin-cli encryptwallet" - Set Wallet Password

 "bitcoin-cli walletpassphrase" - Unlock Wallet

 "bitcoin-cli backupwallet" - Backup Wallet

 Bitcoin Transaction

 Bitcoin-Qt - Bitcoin Core GUI

 Bitcoin Mining

 Bitcoin Consensus Rules

 Bitcoin Block Data Structure

 Bitcoin Transaction Data Structure

 Bitcoin Blockchain APIs

 Copay - Bitcoin Wallet

 Archived Tutorials

 References

 Full Version in PDF/EPUB