Skip to content

Commit af4275e

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#23332: doc: Fix CWalletTx::Confirmation doc
fa8fef6 doc: Fix CWalletTx::Confirmation doc (MarcoFalke) Pull request description: Follow-up to: * commit 700c42b, which replaced pIndex with block_hash in AddToWalletIfInvolvingMe. * commit 9700fcb, which replaced posInBlock with confirm.nIndex. ACKs for top commit: laanwj: Code review ACK fa8fef6 ryanofsky: Code review ACK fa8fef6 Tree-SHA512: e7643b8e9200b8ebab3eda30435ad77006568a03476006013c9ac42c826c84e42e29bcdefc6f443fe4d55e76e903bfed5aa7a51f831665001c204634b6f06508
2 parents 22a9018 + fa8fef6 commit af4275e

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/wallet/transaction.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ class CWalletTx
162162
int block_height;
163163
uint256 hashBlock;
164164
int nIndex;
165-
Confirmation(Status s = UNCONFIRMED, int b = 0, uint256 h = uint256(), int i = 0) : status(s), block_height(b), hashBlock(h), nIndex(i) {}
165+
Confirmation(Status status = UNCONFIRMED, int block_height = 0, uint256 block_hash = uint256(), int block_index = 0)
166+
: status{status}, block_height{block_height}, hashBlock{block_hash}, nIndex{block_index} {}
166167
};
167168

168169
Confirmation m_confirm;

src/wallet/wallet.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ void CWallet::SyncTransaction(const CTransactionRef& ptx, CWalletTx::Confirmatio
12121212

12131213
void CWallet::transactionAddedToMempool(const CTransactionRef& tx, uint64_t mempool_sequence) {
12141214
LOCK(cs_wallet);
1215-
SyncTransaction(tx, {CWalletTx::Status::UNCONFIRMED, /* block height */ 0, /* block hash */ {}, /* index */ 0});
1215+
SyncTransaction(tx, {CWalletTx::Status::UNCONFIRMED, /*block_height=*/0, /*block_hash=*/{}, /*block_index=*/0});
12161216

12171217
auto it = mapWallet.find(tx->GetHash());
12181218
if (it != mapWallet.end()) {
@@ -1253,7 +1253,7 @@ void CWallet::transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRe
12531253
// distinguishing between conflicted and unconfirmed transactions are
12541254
// imperfect, and could be improved in general, see
12551255
// https://github.com/bitcoin-core/bitcoin-devwiki/wiki/Wallet-Transaction-Conflict-Tracking
1256-
SyncTransaction(tx, {CWalletTx::Status::UNCONFIRMED, /* block height */ 0, /* block hash */ {}, /* index */ 0});
1256+
SyncTransaction(tx, {CWalletTx::Status::UNCONFIRMED, /*block_height=*/0, /*block_hash=*/{}, /*block_index=*/0});
12571257
}
12581258
}
12591259

@@ -1281,7 +1281,7 @@ void CWallet::blockDisconnected(const CBlock& block, int height)
12811281
m_last_block_processed_height = height - 1;
12821282
m_last_block_processed = block.hashPrevBlock;
12831283
for (const CTransactionRef& ptx : block.vtx) {
1284-
SyncTransaction(ptx, {CWalletTx::Status::UNCONFIRMED, /* block height */ 0, /* block hash */ {}, /* index */ 0});
1284+
SyncTransaction(ptx, {CWalletTx::Status::UNCONFIRMED, /*block_height=*/0, /*block_hash=*/{}, /*block_index=*/0});
12851285
}
12861286
}
12871287

src/wallet/wallet.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,17 +260,17 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
260260
void AddToSpends(const uint256& wtxid, WalletBatch* batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
261261

262262
/**
263-
* Add a transaction to the wallet, or update it. pIndex and posInBlock should
263+
* Add a transaction to the wallet, or update it. confirm.block_* should
264264
* be set when the transaction was known to be included in a block. When
265-
* pIndex == nullptr, then wallet state is not updated in AddToWallet, but
265+
* block_hash.IsNull(), then wallet state is not updated in AddToWallet, but
266266
* notifications happen and cached balances are marked dirty.
267267
*
268268
* If fUpdate is true, existing transactions will be updated.
269269
* TODO: One exception to this is that the abandoned state is cleared under the
270270
* assumption that any further notification of a transaction that was considered
271271
* abandoned is an indication that it is not safe to be considered abandoned.
272272
* Abandoned state should probably be more carefully tracked via different
273-
* posInBlock signals or by checking mempool presence when necessary.
273+
* chain notifications or by checking mempool presence when necessary.
274274
*
275275
* Should be called with rescanning_old_block set to true, if the transaction is
276276
* not discovered in real time, but during a rescan of old blocks.
@@ -285,8 +285,6 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
285285

286286
void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
287287

288-
/* Used by TransactionAddedToMemorypool/BlockConnected/Disconnected/ScanForWalletTransactions.
289-
* Should be called with non-zero block_hash and posInBlock if this is for a transaction that is included in a block. */
290288
void SyncTransaction(const CTransactionRef& tx, CWalletTx::Confirmation confirm, bool update_tx = true, bool rescanning_old_block = false) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
291289

292290
/** WalletFlags set on this wallet. */

0 commit comments

Comments
 (0)