0

I'd like to calculate the total amount of bitcoin sent to anyone from a known wallet address.

My initial idea was to page through everything returned by the listtransactions RPC, get the transaction details through gettransaction and calculate the sum of all transaction details of category "send". But somehow the result appears to be by far too high.

1

The result you are getting is correct. The error is that you think it's too high when it's correct.

Say I buy a book for $5, but I pay with a $100 bill. The amount "sent to anyone" from my wallet is $100, not $5. So the total of the amounts sent will be greater than the net amounts paid.

The total of the amounts "sent to anyone from a known wallet address" will include the change that was sent from the wallet even though it remained the property of the owner of the wallet.

If you want to get a different answer, you'll have to ask a different question.

2
  • Makes sense. But by the looks of it the transaction details returned by gettransaction respresent the amount specified at the RPC API level, not the actual underpinnings - developer.bitcoin.org/reference/rpc/gettransaction.html Jun 28 '21 at 7:58
  • It depends what the client knows. If the transaction originated locally, the client knows what is change and what is not. If the transaction was observed, then it generally has no way of knowing. If it sees $100 go in and $30 come out one output and $70 come out the other, it has no way to know if $70 is change, $30 is change, or neither is change. Jun 28 '21 at 16:42

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.