Don't track spends of coins we sent

This commit is contained in:
David Burkett 2022-04-12 03:49:32 -04:00 committed by Loshan T
parent e1edf6ba30
commit 8634cc1c25
2 changed files with 6 additions and 2 deletions

View File

@ -62,6 +62,10 @@ void TxList::List(std::vector<WalletTxRecord>& tx_records, const CWalletTx& wtx,
CAmount nDebit = wtx.GetDebit(filter_ismine);
CAmount nNet = nCredit - nDebit;
if (nCredit == 0 && nDebit == 0) {
return;
}
if (nNet > 0 || wtx.IsCoinBase() || wtx.IsHogEx()) {
// Credit
List_Credit(tx_records, wtx, filter_ismine);

View File

@ -1313,7 +1313,7 @@ void CWallet::blockConnected(const CBlock& block, int height)
if (!block.mweb_block.IsNull()) {
mw::Coin coin;
for (const mw::Hash& spent_id : block.mweb_block.GetSpentIDs()) {
if (GetCoin(spent_id, coin) && !IsSpent(spent_id)) {
if (GetCoin(spent_id, coin) && coin.IsMine() && !IsSpent(spent_id)) {
AddToWallet(
MakeTransactionRef(),
boost::make_optional<MWEB::WalletTxInfo>(spent_id),
@ -1382,7 +1382,7 @@ void CWallet::blockDisconnected(const CBlock& block, int height)
if (!block.mweb_block.IsNull()) {
mw::Coin coin;
for (const mw::Hash& spent_id : block.mweb_block.GetSpentIDs()) {
if (GetCoin(spent_id, coin)) {
if (GetCoin(spent_id, coin) && coin.IsMine()) {
std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range = mapTxSpends.equal_range(spent_id);
// MWEB: We just choose the first spend. In the future, we may need a better approach for handling conflicted txs
if (range.first != range.second) {