Fix #14136.
In the rpc gettransaction
, there is an error in calculating nFee
.
0CAmount nFee = (wtx.IsFromMe(filter) ? wtx.tx->GetValueOut() - nDebit : 0);
If not all the inputs are from me (like the case of CoinJoin), wtx.IsFromMe(filter)
returns true
, and nFee
would get a wrong value from wtx.tx->GetValueOut() - nDebit
. Here nDebit
only stands for sum of my inputs rather than all inputs, so in this case, nFee
would equal to all outputs minus my inputs.
A feasible solution is to use IsAllFromMe
instead of IsFromMe
. By this method, nFee
is set as 0
and amount
can be correctly calculated from nCredit - nDebit
, aka, all my outputs minus all my inputs.
The right amount
and fee
in the case of #14136 is successfully got through this way, as illustrated below. Here we use importaddress
, aka the watch-only mode, to simulate the case.