Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 1,111 Lines • ▼ Show 20 Lines | bool CWallet::AddToWalletIfInvolvingMe(const CTransactionRef &ptx, | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
bool CWallet::TransactionCanBeAbandoned(const TxId &txid) const { | bool CWallet::TransactionCanBeAbandoned(const TxId &txid) const { | ||||
LOCK2(cs_main, cs_wallet); | LOCK2(cs_main, cs_wallet); | ||||
const CWalletTx *wtx = GetWalletTx(txid); | const CWalletTx *wtx = GetWalletTx(txid); | ||||
return wtx && !wtx->isAbandoned() && wtx->GetDepthInMainChain() <= 0 && | return wtx && !wtx->isAbandoned() && wtx->GetDepthInMainChain() == 0 && | ||||
!wtx->InMempool(); | !wtx->InMempool(); | ||||
} | } | ||||
bool CWallet::AbandonTransaction(const TxId &txid) { | bool CWallet::AbandonTransaction(const TxId &txid) { | ||||
LOCK2(cs_main, cs_wallet); | LOCK2(cs_main, cs_wallet); | ||||
CWalletDB walletdb(*dbw, "r+"); | CWalletDB walletdb(*dbw, "r+"); | ||||
std::set<TxId> todo; | std::set<TxId> todo; | ||||
std::set<TxId> done; | std::set<TxId> done; | ||||
// Can't mark abandoned if confirmed or in mempool | // Can't mark abandoned if confirmed or in mempool | ||||
auto it = mapWallet.find(txid); | auto it = mapWallet.find(txid); | ||||
assert(it != mapWallet.end()); | assert(it != mapWallet.end()); | ||||
CWalletTx &origtx = it->second; | CWalletTx &origtx = it->second; | ||||
if (origtx.GetDepthInMainChain() > 0 || origtx.InMempool()) { | if (origtx.GetDepthInMainChain() != 0 || origtx.InMempool()) { | ||||
return false; | return false; | ||||
} | } | ||||
todo.insert(txid); | todo.insert(txid); | ||||
while (!todo.empty()) { | while (!todo.empty()) { | ||||
const TxId now = *todo.begin(); | const TxId now = *todo.begin(); | ||||
todo.erase(now); | todo.erase(now); | ||||
▲ Show 20 Lines • Show All 3,509 Lines • Show Last 20 Lines |