(Mastering Bitcoin) When sending a raw transaction, why is the receiver included in the details hash as a "send" transaction? I'm working my way through Mastering Bitcoin. The author made a transaction to send 0.05 BTC from one address to another (http://chainquery.com/bitcoin-api/getrawtransaction/ae74538baa914f3799081ba78429d5d84f36a0127438e9f721dff584ac17b346/1)

In the book, he runs the following command to get the transaction details:

bitcoin-cli gettransaction ae74538baa914f3799081ba78429d5d84f36a0127438e9f721dff584ac17b346

The JSONRPC returns the following object:

{  
   "details":[  
      {  
         "account":"",
         "address":"1LnfTndy3qzXGN19Jwscj1T8LR3MVe3JDb",
         "category":"send",
         "amount":-0.02500000,
         "fee":-0.00050000
      },
      {  
         "account":"",
         "address":"1hvzSofGwT8cjb8JU7nBsCSfEVQX5u9CL",
         "category":"send",
         "amount":-0.02450000,
         "fee":-0.00050000
      },
      {  
         "account":"",
         "address":"1LnfTndy3qzXGN19Jwscj1T8LR3MVe3JDb",
         "category":"receive",
         "amount":0.02500000
      },
      {  
         "account":"",
         "address":"1hvzSofGwT8cjb8JU7nBsCSfEVQX5u9CL",
         "category":"receive",
         "amount":0.02450000
      }
   ]
}


Why is there an object with the receiving address (1hvzSofGwT8cjb8JU7nBsCSfEVQX5u9CL) with the category "send"? 

Shouldn't there only be 3 objects nested under "details" (i.e. 1 input and 2 outputs)?
Shouldn't there only be 3 objects nested under "details" (i.e. 1 input and 2 outputs)?


In the actual Bitcoin blockchain that transaction has one input and two outputs. One of the outputs appears to be change being returned to the input address. This is normal.

In an early version of the book, the same information (1 in, 2 out) is shown and the author says on page 52:


  That looks correct! Our new transaction “consumes” the unspent output from our confirmed transaction and then spends it in two outputs, one for 25 millibits to our new address and one for 24.5 millibits as change back to the original address.


The output you show is from page 55 and looks like an editing error to me. If the author has not issued an errata, you could report this to the author or to the publisher.



The example in the question is from Chapter 3 of Mastering Bitcoin. It exists in the previous edition but that chapter has been completely revised in chapter 3 of  the latest edition