Skip to content

Commit a0285e4

Browse files
committed
[Wallet] Fix bug with coinstake inputs wrongly marked as spent
1 parent bb683c7 commit a0285e4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/wallet/wallet.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,11 @@ bool CWallet::IsSpent(const uint256& hash, unsigned int n) const
472472
const uint256& wtxid = it->second;
473473
std::map<uint256, CWalletTx>::const_iterator mit = mapWallet.find(wtxid);
474474
if (mit != mapWallet.end()) {
475-
int depth = mit->second.GetDepthInMainChain();
476-
if (depth > 0 || (depth == 0 && !mit->second.isAbandoned()))
475+
bool fConflicted;
476+
const int nDepth = mit->second.GetDepthAndMempool(fConflicted);
477+
// not in mempool txes can spend coins only if not coinstakes
478+
const bool fConflictedCoinstake = fConflicted && mit->second.IsCoinStake();
479+
if (nDepth > 0 || (nDepth == 0 && !mit->second.isAbandoned() && !fConflictedCoinstake) )
477480
return true; // Spent
478481
}
479482
}

0 commit comments

Comments
 (0)