0

How does Bitcoin core differentiate transactions category?

for instance, when we are calling listtrnasctions in the response body we have category, how bitcoin core assigns category type for a transaction? Programmatically, How it decides that some transaction should have send or receive string.

The answer is in here:

// Sent
if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount))
{

}

// Received
if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth)
{


}

Can someone read and explain the code? I see that receive transactions have zero fees, and Bitcoin core considers transactions with fees as sent.

0

Bitcoin Core has three types of transaction categories: send, receive, and move.

It differentiates between these as follows:

  1. move - This tx is not an onchain one, and has no transaction id. It is simply moving BTC from one wallet account to another (accounts are not addresses, but groupings of addresses). This is done using the move RPC call

  2. send - A send tx is one where an utxo from your wallet is used as the input to a transaction. This usually have a fee, since the fee is debited from the total sum of the utxos.

  3. receive - A receive tx is one where a new utxo spendable (or watched) by your wallet is created. These don't have a fee as you don't pay anything to receive Bitcoin.

You can see the ListTransaction code here.

2
  • What about HD wallet, when for example importing your mnemonic phrase on blockchain.info they differentiate sent and receive transaction! how is that?
    – Adam
    Apr 4 '18 at 14:37
  • Bitcoin core also utilizes HD wallets, the type of wallet doesn't change anything. A send/receive tx is differentiated the same way in every wallet, which is by utxos being spent/created. Apr 4 '18 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.