Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 2,163 Lines • ▼ Show 20 Lines | void CWallet::ReacceptWalletTransactions( | ||||
for (const std::pair<const int64_t, CWalletTx *> &item : mapSorted) { | for (const std::pair<const int64_t, CWalletTx *> &item : mapSorted) { | ||||
CWalletTx &wtx = *(item.second); | CWalletTx &wtx = *(item.second); | ||||
CValidationState state; | CValidationState state; | ||||
wtx.AcceptToMemoryPool(locked_chain, state); | wtx.AcceptToMemoryPool(locked_chain, state); | ||||
} | } | ||||
} | } | ||||
bool CWalletTx::RelayWalletTransaction(interfaces::Chain::Lock &locked_chain) { | bool CWalletTx::RelayWalletTransaction(interfaces::Chain::Lock &locked_chain) { | ||||
assert(pwallet->GetBroadcastTransactions()); | // Can't relay if wallet is not broadcasting | ||||
if (IsCoinBase() || isAbandoned() || | if (!pwallet->GetBroadcastTransactions()) { | ||||
GetDepthInMainChain(locked_chain) != 0) { | return false; | ||||
} | |||||
// Don't relay coinbase transactions outside blocks | |||||
if (IsCoinBase()) { | |||||
return false; | |||||
} | |||||
// Don't relay abandoned transactions | |||||
if (isAbandoned()) { | |||||
return false; | |||||
} | |||||
// Don't relay conflicted or already confirmed transactions | |||||
if (GetDepthInMainChain(locked_chain) != 0) { | |||||
return false; | |||||
} | |||||
// Don't relay transactions that aren't accepted to the mempool | |||||
CValidationState unused_state; | |||||
if (!InMempool() && !AcceptToMemoryPool(locked_chain, unused_state)) { | |||||
return false; | |||||
} | |||||
// Don't try to relay if the node is not connected to the p2p network | |||||
if (!pwallet->chain().p2pEnabled()) { | |||||
return false; | return false; | ||||
} | } | ||||
CValidationState state; | // Try to relay the transaction | ||||
// GetDepthInMainChain already catches known conflicts. | |||||
if (InMempool() || AcceptToMemoryPool(locked_chain, state)) { | |||||
pwallet->WalletLogPrintf("Relaying wtx %s\n", GetId().ToString()); | pwallet->WalletLogPrintf("Relaying wtx %s\n", GetId().ToString()); | ||||
if (pwallet->chain().p2pEnabled()) { | |||||
pwallet->chain().relayTransaction(GetId()); | pwallet->chain().relayTransaction(GetId()); | ||||
return true; | |||||
} | |||||
} | |||||
return false; | return true; | ||||
} | } | ||||
std::set<TxId> CWalletTx::GetConflicts() const { | std::set<TxId> CWalletTx::GetConflicts() const { | ||||
std::set<TxId> result; | std::set<TxId> result; | ||||
if (pwallet != nullptr) { | if (pwallet != nullptr) { | ||||
const TxId &txid = GetId(); | const TxId &txid = GetId(); | ||||
result = pwallet->GetConflicts(txid); | result = pwallet->GetConflicts(txid); | ||||
result.erase(txid); | result.erase(txid); | ||||
▲ Show 20 Lines • Show All 2,887 Lines • Show Last 20 Lines |