@@ -1107,6 +1107,16 @@ bool CWallet::TransactionCanBeAbandoned(const uint256& hashTx) const
1107
1107
return wtx && !wtx->isAbandoned () && wtx->GetDepthInMainChain () == 0 && !wtx->InMempool ();
1108
1108
}
1109
1109
1110
+ void CWallet::MarkInputsDirty (const CTransactionRef& tx)
1111
+ {
1112
+ for (const CTxIn& txin : tx->vin ) {
1113
+ auto it = mapWallet.find (txin.prevout .hash );
1114
+ if (it != mapWallet.end ()) {
1115
+ it->second .MarkDirty ();
1116
+ }
1117
+ }
1118
+ }
1119
+
1110
1120
bool CWallet::AbandonTransaction (const uint256& hashTx)
1111
1121
{
1112
1122
LOCK2 (cs_main, cs_wallet);
@@ -1155,13 +1165,7 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
1155
1165
}
1156
1166
// If a transaction changes 'conflicted' state, that changes the balance
1157
1167
// available of the outputs it spends. So force those to be recomputed
1158
- for (const CTxIn& txin : wtx.tx ->vin )
1159
- {
1160
- auto it = mapWallet.find (txin.prevout .hash );
1161
- if (it != mapWallet.end ()) {
1162
- it->second .MarkDirty ();
1163
- }
1164
- }
1168
+ MarkInputsDirty (wtx.tx );
1165
1169
}
1166
1170
}
1167
1171
@@ -1217,31 +1221,19 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
1217
1221
}
1218
1222
// If a transaction changes 'conflicted' state, that changes the balance
1219
1223
// available of the outputs it spends. So force those to be recomputed
1220
- for (const CTxIn& txin : wtx.tx ->vin ) {
1221
- auto it = mapWallet.find (txin.prevout .hash );
1222
- if (it != mapWallet.end ()) {
1223
- it->second .MarkDirty ();
1224
- }
1225
- }
1224
+ MarkInputsDirty (wtx.tx );
1226
1225
}
1227
1226
}
1228
1227
}
1229
1228
1230
1229
void CWallet::SyncTransaction (const CTransactionRef& ptx, const CBlockIndex *pindex, int posInBlock, bool update_tx) {
1231
- const CTransaction& tx = *ptx;
1232
-
1233
1230
if (!AddToWalletIfInvolvingMe (ptx, pindex, posInBlock, update_tx))
1234
1231
return ; // Not one of ours
1235
1232
1236
1233
// If a transaction changes 'conflicted' state, that changes the balance
1237
1234
// available of the outputs it spends. So force those to be
1238
1235
// recomputed, also:
1239
- for (const CTxIn& txin : tx.vin ) {
1240
- auto it = mapWallet.find (txin.prevout .hash );
1241
- if (it != mapWallet.end ()) {
1242
- it->second .MarkDirty ();
1243
- }
1244
- }
1236
+ MarkInputsDirty (ptx);
1245
1237
}
1246
1238
1247
1239
void CWallet::TransactionAddedToMempool (const CTransactionRef& ptx) {
0 commit comments