0

Everything was done on regtest network.

So I've generated a new address using getrawchangeaddress on wallet 2 and made a 0.1 BTC transaction from wallet 1 to wallet 2 and tried check this address balance on wallet 2 using getreceivedbyaddress.

Well, it says that address received 0.1 BTC, but when I try to execute listreceivedbyaddress, it returns an empty list.

NOTE: This transaction have above 6 confirmations.

 > bitcoin-cli --rpcport=19011 --rpcuser=admin --rpcpassword=123 listreceivedbyaddress 1 true true bcrt1qn858fc33j9f6w83vu6vglk2d3e5th3zhrxj9lg
[
]

 > bitcoin-cli --rpcport=19011 --rpcuser=admin --rpcpassword=123 getreceivedbyaddress bcrt1qn858fc33j9f6w83vu6vglk2d3e5th3zhrxj9lg
0.10000000

Weird thing also is that I've marked include_empty to true, but the answer is an empty list.

EDIT: listtransactions shows the transactions, but there is a lot of other transactions.

1

listreceivedbyaddress (and the other transaction listing RPCs) list logical transactions, not physical transactions. So it really lists transaction outputs. Additionally, they share a lot of code. Because these are logical transactions, there are some things that are hidden so that the output is not confusing to the user. One of those things are change outputs, as those are not the same kind of transaction as a send or receive.

Since you used getrawchangeaddress, the address you have is marked as a change address. So the code that fetches the logical transactions for listing will filter the transaction outputs for the address you specify, but later code (that is intended for other RPCs), will filter out those outputs that belong are marked as change. Thus you see no results.

getreceivedbyaddress is a balance fetching RPC, and so it uses different code paths from listreceivedbyaddress. It does not filter out change addresses in the same way as balance calculation (for other RPCs) actually needs to include change outputs. So you see the balance of the change address in getreceivedbyaddress


This is intended behavior, but it is clearly confusing. However most users are not aware of change addresses and are unable to even see what their change addresses are, so fixing this is fairly low priority.

1
  • Thanks for your answer, pretty clear now. But is it even possible to list transactions of change address?
    – yallxe
    Dec 22 '21 at 6:54

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.