Trace Back Bitcoin Transaction Outputs

This section describes how to trace back transaction outputs with bitcoin-cli commands.

To find out where the 1.0 BTC came from, I used the following bitcoin-cli commands to trace back by following the old transaction ID in the "vin" list.

1. Get "vin" list and "vout" list of my outgoing transaction:

C:\>\local\bitcoin-0.15.1\bin\bitcoin-cli.exe -testnet getrawtransaction 
   155657a1688b7f7ede2041190b055aa7b1ef427bbc343e4ef67342866934407e true
   
{
  "txid": 
    "155657a1688b7f7ede2041190b055aa7b1ef427bbc343e4ef67342866934407e",
    ...,
    "vin": [
    {
      "txid": 
        "da9406c4a2e1fe61f541c9298f276d6753bb3aaa7fa8ee1cc370ab41a292cd65",
      "vout": 1,
    }
  ],
  "vout": [
    {
      "value": 0.67825060,
      "n": 0,
      "scriptPubKey": {
        ...,
        "addresses": [
          "mk7tqzNcvFwBSQEiuESH3C5wEB3GtCLDPU"
        ]
      }
    },
    {
      "value": 1.00000000,
      "n": 1,
      "scriptPubKey": {
        ...,
        "addresses": [
          "mrThGN62W4noVhUvWUqHXesaMLB79NCEbW"
        ]
      }
    }
  ],
  ...
}

2. Follow the "txid" in the "vin" list:

C:\>\local\bitcoin-0.15.1\bin\bitcoin-cli.exe -testnet getrawtransaction 
   da9406c4a2e1fe61f541c9298f276d6753bb3aaa7fa8ee1cc370ab41a292cd65 true
error code: -5
error message:
No such mempool transaction. Use -txindex to enable blockchain transaction 
queries. Use gettransaction for wallet transactions.

Too bad, that transaction is too old that my "bitcoind" server does not maintain it the "mempool".

3. Try the "bitcoin-cli gettransaction" instead, which searches transactions associated with my wallet:

C:\>\local\bitcoin-0.15.1\bin\bitcoin-cli.exe -testnet gettransaction 
   da9406c4a2e1fe61f541c9298f276d6753bb3aaa7fa8ee1cc370ab41a292cd65

{
  "amount": 1.67825345,
  "confirmations": 861,
  "blockhash": 
     "000000000000044f1a28b5f59c8ade1111ce0def42639a5928a2db25e30aacf4",
  "blockindex": 32,
  "blocktime": 1518723128,
  "txid": 
     "da9406c4a2e1fe61f541c9298f276d6753bb3aaa7fa8ee1cc370ab41a292cd65",
  "walletconflicts": [
  ],
  "time": 1518722444,
  "timereceived": 1518722444,
  "bip125-replaceable": "no",
  "details": [
    {
      "account": "Used on coinfaucet.eu",
      "address": "mp6mKbgWE25PyyX63zJ8SRibrKugHMkJDE",
      "category": "receive",
      "amount": 1.67825345,
      "label": "Used on coinfaucet.eu",
      "vout": 1
    }
  ],
  "hex": "..."
}

Ok. The output shows that 1.67825345 BTC fund was actually from my "Used on coinfaucet.eu" account!

4. Check my account balances again:

C:\>\local\bitcoin-0.15.1\bin\bitcoin-cli.exe -testnet listaccounts
{
  "": -1.00000285,
  "Test 1": 0.00000000,
  "Test 2": 1.00000000,
  "Used on coinfaucet.eu": 8.71492098
}

So the "listaccounts" did not report my balances correctly. It should have associated the -1.00000285 BTC spent fund to my "Used on coinfaucet.eu".

Last update: 2018.

Table of Contents

 About This Book

 Introduction of Bitcoin

 Bitcoin Blockchain

 Bitcoin Wallet

 Bitcoin Core

Bitcoin Transaction

 What Is Bitcoin Transaction

 Receive Test Bitcoin from testnet.coinfaucet.eu

 View Transaction on live.blockcypher.com

 Receive Bitcoin in My Test Wallet

 View Bitcoin in My Test Wallet

 Bitcoin-Qt New Incoming Transaction Alert

 "bitcoin-cli sendtoaddress" - Send Bitcoin

 Confirm Outgoing Transaction

Trace Back Bitcoin Transaction Outputs

 Bitcoin-Qt - Bitcoin Core GUI

 Bitcoin Mining

 Bitcoin Consensus Rules

 Bitcoin Block Data Structure

 Bitcoin Transaction Data Structure

 blockexplorer.com API

 Copay - Bitcoin Wallet

 References

 PDF Printing Version