Programmatically, How does Bitcoin core differentiate transactions category?

0

1

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.

Adam

Posted 2018-04-03T20:25:20.990

Reputation: 3 215

Answers

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.

Raghav Sood

Posted 2018-04-03T20:25:20.990

Reputation: 10 897

What about HD wallet, when for example importing your mnemonic phrase on blockchain.info they differentiate sent and receive transaction! how is that?Adam 2018-04-04T14:37:00.403

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.Raghav Sood 2018-04-04T14:39:54.787