Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 1,757 Lines • ▼ Show 20 Lines | void CWallet::ReacceptWalletTransactions() { | ||||
} | } | ||||
// Try to add wallet transactions to memory pool. | // Try to add wallet transactions to memory pool. | ||||
for (std::pair<const int64_t, CWalletTx *> &item : mapSorted) { | for (std::pair<const int64_t, CWalletTx *> &item : mapSorted) { | ||||
CWalletTx &wtx = *(item.second); | CWalletTx &wtx = *(item.second); | ||||
LOCK(mempool.cs); | LOCK(mempool.cs); | ||||
CValidationState state; | CValidationState state; | ||||
wtx.AcceptToMemoryPool(maxTxFee, state); | wtx.AcceptToMemoryPool(state); | ||||
} | } | ||||
} | } | ||||
bool CWalletTx::RelayWalletTransaction(CConnman *connman) { | bool CWalletTx::RelayWalletTransaction(CConnman *connman) { | ||||
assert(pwallet->GetBroadcastTransactions()); | assert(pwallet->GetBroadcastTransactions()); | ||||
if (IsCoinBase() || isAbandoned() || GetDepthInMainChain() != 0) { | if (IsCoinBase() || isAbandoned() || GetDepthInMainChain() != 0) { | ||||
return false; | return false; | ||||
} | } | ||||
CValidationState state; | CValidationState state; | ||||
// GetDepthInMainChain already catches known conflicts. | // GetDepthInMainChain already catches known conflicts. | ||||
if (InMempool() || AcceptToMemoryPool(maxTxFee, state)) { | if (InMempool() || AcceptToMemoryPool(state)) { | ||||
LogPrintf("Relaying wtx %s\n", GetId().ToString()); | LogPrintf("Relaying wtx %s\n", GetId().ToString()); | ||||
if (connman) { | if (connman) { | ||||
CInv inv(MSG_TX, GetId()); | CInv inv(MSG_TX, GetId()); | ||||
connman->ForEachNode( | connman->ForEachNode( | ||||
[&inv](CNode *pnode) { pnode->PushInventory(inv); }); | [&inv](CNode *pnode) { pnode->PushInventory(inv); }); | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,304 Lines • ▼ Show 20 Lines | for (const CTxIn &txin : wtxNew.tx->vin) { | ||||
NotifyTransactionChanged(this, coin.GetId(), CT_UPDATED); | NotifyTransactionChanged(this, coin.GetId(), CT_UPDATED); | ||||
} | } | ||||
// Track how many getdata requests our transaction gets. | // Track how many getdata requests our transaction gets. | ||||
mapRequestCount[wtxNew.GetId()] = 0; | mapRequestCount[wtxNew.GetId()] = 0; | ||||
if (fBroadcastTransactions) { | if (fBroadcastTransactions) { | ||||
// Broadcast | // Broadcast | ||||
if (!wtxNew.AcceptToMemoryPool(maxTxFee, state)) { | if (!wtxNew.AcceptToMemoryPool(state)) { | ||||
LogPrintf("CommitTransaction(): Transaction cannot be " | LogPrintf("CommitTransaction(): Transaction cannot be " | ||||
"broadcast immediately, %s\n", | "broadcast immediately, %s\n", | ||||
state.GetRejectReason()); | state.GetRejectReason()); | ||||
// TODO: if we expect the failure to be long term or permanent, | // TODO: if we expect the failure to be long term or permanent, | ||||
// instead delete wtx from the wallet and return failure. | // instead delete wtx from the wallet and return failure. | ||||
} else { | } else { | ||||
wtxNew.RelayWalletTransaction(connman); | wtxNew.RelayWalletTransaction(connman); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,141 Lines • ▼ Show 20 Lines | |||||
int CMerkleTx::GetBlocksToMaturity() const { | int CMerkleTx::GetBlocksToMaturity() const { | ||||
if (!IsCoinBase()) { | if (!IsCoinBase()) { | ||||
return 0; | return 0; | ||||
} | } | ||||
return std::max(0, (COINBASE_MATURITY + 1) - GetDepthInMainChain()); | return std::max(0, (COINBASE_MATURITY + 1) - GetDepthInMainChain()); | ||||
} | } | ||||
bool CMerkleTx::AcceptToMemoryPool(const Amount nAbsurdFee, | bool CMerkleTx::AcceptToMemoryPool(CValidationState &state) { | ||||
CValidationState &state) { | const Config &config = GetConfig(); | ||||
return ::AcceptToMemoryPool(GetConfig(), mempool, state, tx, true, nullptr, | return ::AcceptToMemoryPool(config, mempool, state, tx, true, nullptr, | ||||
false, nAbsurdFee); | false, config.GetMaxFee()); | ||||
} | } |