Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 311 Lines • ▼ Show 20 Lines | |||||
const CChainParams &CWallet::GetChainParams() const { | const CChainParams &CWallet::GetChainParams() const { | ||||
// Get CChainParams from interfaces::Chain, unless wallet doesn't have a | // Get CChainParams from interfaces::Chain, unless wallet doesn't have a | ||||
// chain (i.e. bitcoin-wallet), in which case return global Params() | // chain (i.e. bitcoin-wallet), in which case return global Params() | ||||
return m_chain ? m_chain->params() : Params(); | return m_chain ? m_chain->params() : Params(); | ||||
} | } | ||||
const CWalletTx *CWallet::GetWalletTx(const TxId &txid) const { | const CWalletTx *CWallet::GetWalletTx(const TxId &txid) const { | ||||
LOCK(cs_wallet); | AssertLockHeld(cs_wallet); | ||||
std::map<TxId, CWalletTx>::const_iterator it = mapWallet.find(txid); | std::map<TxId, CWalletTx>::const_iterator it = mapWallet.find(txid); | ||||
if (it == mapWallet.end()) { | if (it == mapWallet.end()) { | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
return &(it->second); | return &(it->second); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,867 Lines • ▼ Show 20 Lines | bool CWalletTx::IsTrusted(std::set<TxId> &trusted_parents) const { | ||||
// Don't trust unconfirmed transactions from us unless they are in the | // Don't trust unconfirmed transactions from us unless they are in the | ||||
// mempool. | // mempool. | ||||
if (!InMempool()) { | if (!InMempool()) { | ||||
return false; | return false; | ||||
} | } | ||||
// Trusted if all inputs are from us and are in the mempool: | // Trusted if all inputs are from us and are in the mempool: | ||||
LOCK(pwallet->cs_wallet); | |||||
for (const CTxIn &txin : tx->vin) { | for (const CTxIn &txin : tx->vin) { | ||||
// Transactions not sent by us: not trusted | // Transactions not sent by us: not trusted | ||||
const CWalletTx *parent = pwallet->GetWalletTx(txin.prevout.GetTxId()); | const CWalletTx *parent = pwallet->GetWalletTx(txin.prevout.GetTxId()); | ||||
if (parent == nullptr) { | if (parent == nullptr) { | ||||
return false; | return false; | ||||
} | } | ||||
const CTxOut &parentOut = parent->tx->vout[txin.prevout.GetN()]; | const CTxOut &parentOut = parent->tx->vout[txin.prevout.GetN()]; | ||||
▲ Show 20 Lines • Show All 2,866 Lines • Show Last 20 Lines |