@@ -569,11 +569,17 @@ std::set<uint256> CWallet::GetConflicts(const uint256& txid) const
569
569
return result;
570
570
}
571
571
572
- bool CWallet::HasWalletSpend (const uint256& txid ) const
572
+ bool CWallet::HasWalletSpend (const CTransactionRef& tx ) const
573
573
{
574
574
AssertLockHeld (cs_wallet);
575
- auto iter = mapTxSpends.lower_bound (COutPoint (txid, 0 ));
576
- return (iter != mapTxSpends.end () && iter->first .hash == txid);
575
+ const uint256& txid = tx->GetHash ();
576
+ for (unsigned int i = 0 ; i < tx->vout .size (); ++i) {
577
+ auto iter = mapTxSpends.find (COutPoint (txid, i));
578
+ if (iter != mapTxSpends.end ()) {
579
+ return true ;
580
+ }
581
+ }
582
+ return false ;
577
583
}
578
584
579
585
void CWallet::Flush ()
@@ -1191,12 +1197,13 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
1191
1197
batch.WriteTx (wtx);
1192
1198
NotifyTransactionChanged (wtx.GetHash (), CT_UPDATED);
1193
1199
// Iterate over all its outputs, and mark transactions in the wallet that spend them abandoned too
1194
- TxSpends::const_iterator iter = mapTxSpends.lower_bound (COutPoint (now, 0 ));
1195
- while (iter != mapTxSpends.end () && iter->first .hash == now) {
1196
- if (!done.count (iter->second )) {
1197
- todo.insert (iter->second );
1200
+ for (unsigned int i = 0 ; i < wtx.tx ->vout .size (); ++i) {
1201
+ std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range = mapTxSpends.equal_range (COutPoint (now, i));
1202
+ for (TxSpends::const_iterator iter = range.first ; iter != range.second ; ++iter) {
1203
+ if (!done.count (iter->second )) {
1204
+ todo.insert (iter->second );
1205
+ }
1198
1206
}
1199
- iter++;
1200
1207
}
1201
1208
// If a transaction changes 'conflicted' state, that changes the balance
1202
1209
// available of the outputs it spends. So force those to be recomputed
@@ -1242,12 +1249,13 @@ void CWallet::MarkConflicted(const uint256& hashBlock, int conflicting_height, c
1242
1249
wtx.MarkDirty ();
1243
1250
batch.WriteTx (wtx);
1244
1251
// Iterate over all its outputs, and mark transactions in the wallet that spend them conflicted too
1245
- TxSpends::const_iterator iter = mapTxSpends.lower_bound (COutPoint (now, 0 ));
1246
- while (iter != mapTxSpends.end () && iter->first .hash == now) {
1247
- if (!done.count (iter->second )) {
1248
- todo.insert (iter->second );
1249
- }
1250
- iter++;
1252
+ for (unsigned int i = 0 ; i < wtx.tx ->vout .size (); ++i) {
1253
+ std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range = mapTxSpends.equal_range (COutPoint (now, i));
1254
+ for (TxSpends::const_iterator iter = range.first ; iter != range.second ; ++iter) {
1255
+ if (!done.count (iter->second )) {
1256
+ todo.insert (iter->second );
1257
+ }
1258
+ }
1251
1259
}
1252
1260
// If a transaction changes 'conflicted' state, that changes the balance
1253
1261
// available of the outputs it spends. So force those to be recomputed
0 commit comments