@@ -778,6 +778,8 @@ void CWalletTx::GetAmounts(list<COutputEntry>& listReceived, list<COutputEntry>&
778
778
779
779
strSentAccount = strFromAccount;
780
780
781
+ bool fIsFromMe = IsFromMe ();
782
+
781
783
// Used for coinstake rollup.
782
784
int64_t amount = 0 ;
783
785
@@ -808,8 +810,10 @@ void CWalletTx::GetAmounts(list<COutputEntry>& listReceived, list<COutputEntry>&
808
810
// 2) the output is to us (received)
809
811
if (nDebit > 0 )
810
812
{
811
- // Don't report 'change' txouts
812
- if (pwallet->IsChange (txout)) continue ;
813
+ // If not a coinstake, don't report 'change' txouts. Txouts on change addresses for coinstakes
814
+ // must be reported because a change address itself can stake, and there is no "change" on a
815
+ // coinstake.
816
+ if (!fIsCoinStake && pwallet->IsChange (txout)) continue ;
813
817
}
814
818
else
815
819
{
@@ -821,20 +825,21 @@ void CWalletTx::GetAmounts(list<COutputEntry>& listReceived, list<COutputEntry>&
821
825
822
826
// Send...
823
827
824
- // If the output is either (output > 1 and a coinstake and the coinstake input, i.e. output 1, is mine, and
825
- // the selected output is not mine) OR (not a coinstake and nDebit > 0, i.e. a normal send transaction),
826
- // add the output as a "sent" entry. We exclude coinstake outputs 0 and 1 from sends, because output 0 is
827
- // empty and output 1 MUST go back to the staker (i.e. is not a send by definition).
828
- // Notice that a normal self-transaction, an entry will be created as a send and below as a receive for the
829
- // same output. The fee will be reported on the send but not on the receive because of the fee condition
830
- // above.
831
- if ((i > 1 && fIsCoinStakeMine && fIsMine == ISMINE_NO)
832
- || (!fIsCoinStake && nDebit > 0 ))
828
+ // If the output is not mine and ((output > 1 and a coinstake and the coinstake input, i.e. output 1, is mine)
829
+ // OR (not a coinstake and nDebit > 0, i.e. a normal send transaction)), add the output as a "sent" entry.
830
+ // We exclude coinstake outputs 0 and 1 from sends, because output 0 is empty and output 1 MUST go back to
831
+ // the staker (i.e. is not a send by definition). Notice that for a normal self-transaction, the send and
832
+ // receive details will be suppressed; however, the fee will be reported in the nFee parameter.
833
+ if (fIsMine == ISMINE_NO && ((i > 1 && fIsCoinStakeMine ) || (!fIsCoinStake && nDebit > 0 )))
833
834
{
834
- if (!ExtractDestination (txout.scriptPubKey , address) && txout. scriptPubKey [ 0 ] != OP_RETURN )
835
+ if (!ExtractDestination (txout.scriptPubKey , address))
835
836
{
836
- LogPrintf (" CWalletTx::GetAmounts: Unknown transaction type found, txid %s" ,
837
- this ->GetHash ().ToString ().c_str ());
837
+ if (txout.scriptPubKey [0 ] != OP_RETURN)
838
+ {
839
+ LogPrintf (" CWalletTx::GetAmounts: Unknown transaction type found, txid %s" ,
840
+ this ->GetHash ().ToString ().c_str ());
841
+ }
842
+
838
843
address = CNoDestination ();
839
844
}
840
845
@@ -870,9 +875,8 @@ void CWalletTx::GetAmounts(list<COutputEntry>& listReceived, list<COutputEntry>&
870
875
}
871
876
}
872
877
873
- // If this is my output AND (it is not a coinstake OR the coinstake is not mine), add it as a
874
- // received entry.
875
- if (fIsMine != ISMINE_NO && (!fIsCoinStake || !fIsCoinStakeMine ))
878
+ // If this is my output AND the transaction is not from me, then record the output as received.
879
+ if (fIsMine != ISMINE_NO && !fIsFromMe )
876
880
{
877
881
if (!ExtractDestination (txout.scriptPubKey , address) && txout.scriptPubKey [0 ] != OP_RETURN)
878
882
{
0 commit comments