Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 1,287 Lines • ▼ Show 20 Lines | void CWallet::SyncTransaction(const CTransactionRef &ptx, | ||||
} | } | ||||
// If a transaction changes 'conflicted' state, that changes the balance | // If a transaction changes 'conflicted' state, that changes the balance | ||||
// available of the outputs it spends. So force those to be | // available of the outputs it spends. So force those to be | ||||
// recomputed, also: | // recomputed, also: | ||||
MarkInputsDirty(ptx); | MarkInputsDirty(ptx); | ||||
} | } | ||||
void CWallet::transactionAddedToMempool(const CTransactionRef &tx) { | void CWallet::transactionAddedToMempool(const CTransactionRef &tx, | ||||
uint64_t mempool_sequence) { | |||||
LOCK(cs_wallet); | LOCK(cs_wallet); | ||||
SyncTransaction(tx, {CWalletTx::Status::UNCONFIRMED, /* block_height */ 0, | SyncTransaction(tx, {CWalletTx::Status::UNCONFIRMED, /* block_height */ 0, | ||||
BlockHash(), /* nIndex */ 0}); | BlockHash(), /* nIndex */ 0}); | ||||
auto it = mapWallet.find(tx->GetId()); | auto it = mapWallet.find(tx->GetId()); | ||||
if (it != mapWallet.end()) { | if (it != mapWallet.end()) { | ||||
it->second.fInMempool = true; | it->second.fInMempool = true; | ||||
} | } | ||||
} | } | ||||
void CWallet::transactionRemovedFromMempool(const CTransactionRef &tx, | void CWallet::transactionRemovedFromMempool(const CTransactionRef &tx, | ||||
MemPoolRemovalReason reason) { | MemPoolRemovalReason reason, | ||||
uint64_t mempool_sequence) { | |||||
LOCK(cs_wallet); | LOCK(cs_wallet); | ||||
auto it = mapWallet.find(tx->GetId()); | auto it = mapWallet.find(tx->GetId()); | ||||
if (it != mapWallet.end()) { | if (it != mapWallet.end()) { | ||||
it->second.fInMempool = false; | it->second.fInMempool = false; | ||||
} | } | ||||
// Handle transactions that were removed from the mempool because they | // Handle transactions that were removed from the mempool because they | ||||
// conflict with transactions in a newly connected block. | // conflict with transactions in a newly connected block. | ||||
if (reason == MemPoolRemovalReason::CONFLICT) { | if (reason == MemPoolRemovalReason::CONFLICT) { | ||||
Show All 33 Lines | void CWallet::blockConnected(const CBlock &block, int height) { | ||||
LOCK(cs_wallet); | LOCK(cs_wallet); | ||||
m_last_block_processed_height = height; | m_last_block_processed_height = height; | ||||
m_last_block_processed = block_hash; | m_last_block_processed = block_hash; | ||||
for (size_t index = 0; index < block.vtx.size(); index++) { | for (size_t index = 0; index < block.vtx.size(); index++) { | ||||
SyncTransaction(block.vtx[index], {CWalletTx::Status::CONFIRMED, height, | SyncTransaction(block.vtx[index], {CWalletTx::Status::CONFIRMED, height, | ||||
block_hash, int(index)}); | block_hash, int(index)}); | ||||
transactionRemovedFromMempool(block.vtx[index], | transactionRemovedFromMempool(block.vtx[index], | ||||
MemPoolRemovalReason::BLOCK); | MemPoolRemovalReason::BLOCK, | ||||
0 /* mempool_sequence */); | |||||
} | } | ||||
} | } | ||||
void CWallet::blockDisconnected(const CBlock &block, int height) { | void CWallet::blockDisconnected(const CBlock &block, int height) { | ||||
LOCK(cs_wallet); | LOCK(cs_wallet); | ||||
// At block disconnection, this will change an abandoned transaction to | // At block disconnection, this will change an abandoned transaction to | ||||
// be unconfirmed, whether or not the transaction is added back to the | // be unconfirmed, whether or not the transaction is added back to the | ||||
▲ Show 20 Lines • Show All 3,724 Lines • Show Last 20 Lines |