Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 1,799 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(maxTxFee.GetSatoshis(), 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(maxTxFee.GetSatoshis(), 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,219 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(maxTxFee.GetSatoshis(), 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 57 Lines • ▼ Show 20 Lines | if (nFeeNeeded == 0) { | ||||
} | } | ||||
} | } | ||||
// Prevent user from paying a fee below minRelayTxFee or minTxFee. | // Prevent user from paying a fee below minRelayTxFee or minTxFee. | ||||
nFeeNeeded = std::max(nFeeNeeded, GetRequiredFee(nTxBytes)); | nFeeNeeded = std::max(nFeeNeeded, GetRequiredFee(nTxBytes)); | ||||
// But always obey the maximum. | // But always obey the maximum. | ||||
if (nFeeNeeded > maxTxFee) { | if (nFeeNeeded > maxTxFee) { | ||||
nFeeNeeded = maxTxFee; | nFeeNeeded = maxTxFee.GetSatoshis(); | ||||
} | } | ||||
return nFeeNeeded; | return nFeeNeeded; | ||||
} | } | ||||
DBErrors CWallet::LoadWallet(bool &fFirstRunRet) { | DBErrors CWallet::LoadWallet(bool &fFirstRunRet) { | ||||
if (!fFileBacked) { | if (!fFileBacked) { | ||||
return DB_LOAD_OK; | return DB_LOAD_OK; | ||||
▲ Show 20 Lines • Show All 1,352 Lines • Show Last 20 Lines |