Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 2,242 Lines • ▼ Show 20 Lines | bool CWalletTx::IsEquivalentTo(const CWalletTx &_tx) const { | ||||
for (auto &txin : tx2.vin) { | for (auto &txin : tx2.vin) { | ||||
txin.scriptSig = CScript(); | txin.scriptSig = CScript(); | ||||
} | } | ||||
return CTransaction(tx1) == CTransaction(tx2); | return CTransaction(tx1) == CTransaction(tx2); | ||||
} | } | ||||
// Rebroadcast transactions from the wallet. We do this on a random timer | |||||
// to slightly obfuscate which transactions come from our wallet. | |||||
// | |||||
// Ideally, we'd only resend transactions that we think should have been | |||||
// mined in the most recent block. Any transaction that wasn't in the top | |||||
// blockweight of transactions in the mempool shouldn't have been mined, | |||||
// and so is probably just sitting in the mempool waiting to be confirmed. | |||||
// Rebroadcasting does nothing to speed up confirmation and only damages | |||||
// privacy. | |||||
void CWallet::ResendWalletTransactions(interfaces::Chain::Lock &locked_chain) { | void CWallet::ResendWalletTransactions(interfaces::Chain::Lock &locked_chain) { | ||||
// During reindex, importing and IBD, old wallet transactions become | |||||
// unconfirmed. Don't resend them as that would spam other nodes. | |||||
if (!chain().isReadyToBroadcast()) { | |||||
return; | |||||
} | |||||
// Do this infrequently and randomly to avoid giving away that these are our | // Do this infrequently and randomly to avoid giving away that these are our | ||||
// transactions. | // transactions. | ||||
if (GetTime() < nNextResend || !fBroadcastTransactions) { | if (GetTime() < nNextResend || !fBroadcastTransactions) { | ||||
return; | return; | ||||
} | } | ||||
bool fFirst = (nNextResend == 0); | bool fFirst = (nNextResend == 0); | ||||
nNextResend = GetTime() + GetRand(30 * 60); | nNextResend = GetTime() + GetRand(30 * 60); | ||||
Show All 29 Lines | void CWallet::ResendWalletTransactions(interfaces::Chain::Lock &locked_chain) { | ||||
if (relayed_tx_count > 0) { | if (relayed_tx_count > 0) { | ||||
WalletLogPrintf("%s: rebroadcast %u unconfirmed transactions\n", | WalletLogPrintf("%s: rebroadcast %u unconfirmed transactions\n", | ||||
__func__, relayed_tx_count); | __func__, relayed_tx_count); | ||||
} | } | ||||
} | } | ||||
/** @} */ // end of mapWallet | /** @} */ // end of mapWallet | ||||
void MaybeResendWalletTxs() { | |||||
for (const std::shared_ptr<CWallet> &pwallet : GetWallets()) { | |||||
auto locked_chain = pwallet->chain().lock(); | |||||
pwallet->ResendWalletTransactions(*locked_chain); | |||||
} | |||||
} | |||||
/** | /** | ||||
* @defgroup Actions | * @defgroup Actions | ||||
* | * | ||||
* @{ | * @{ | ||||
*/ | */ | ||||
Amount CWallet::GetBalance(const isminefilter &filter, | Amount CWallet::GetBalance(const isminefilter &filter, | ||||
const int min_depth) const { | const int min_depth) const { | ||||
auto locked_chain = chain().lock(); | auto locked_chain = chain().lock(); | ||||
▲ Show 20 Lines • Show All 2,639 Lines • Show Last 20 Lines |