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
| 1805 | // Rebroadcasting does nothing to speed up confirmation and only damages |
| 1806 | // privacy. |
| 1807 | void CWallet::ResendWalletTransactions() |
| 1808 | { |
| 1809 | // During reindex, importing and IBD, old wallet transactions become |
| 1810 | // unconfirmed. Don't resend them as that would spam other nodes. |
| 1811 | if (!chain().isReadyToBroadcast()) return; |
| 1812 | |
| 1813 | // Do this infrequently and randomly to avoid giving away |
| 1814 | // that these are our transactions. |
| 1815 | if (GetTime() < nNextResend || !fBroadcastTransactions) return; |
| 1816 | bool fFirst = (nNextResend == 0); |
| 1817 | // resend 12-36 hours from now, ~1 day on average. |
| 1818 | nNextResend = GetTime() + (12 * 60 * 60) + GetRand(24 * 60 * 60); |
| 1819 | if (fFirst) return; |
| 1820 | |
| 1821 | int submitted_tx_count = 0; |
| 1822 | |
| 1823 | { // cs_wallet scope |
| 1824 | LOCK(cs_wallet); |
| 1825 | |
| 1826 | // Relay transactions |
| 1827 | for (std::pair<const uint256, CWalletTx>& item : mapWallet) { |
| 1828 | CWalletTx& wtx = item.second; |
| 1829 | // Attempt to rebroadcast all txes more than 5 minutes older than |
| 1830 | // the last block. SubmitTxMemoryPoolAndRelay() will not rebroadcast |
| 1831 | // any confirmed or conflicting txs. |
| 1832 | if (wtx.nTimeReceived > m_best_block_time - 5 * 60) continue; |
| 1833 | std::string unused_err_string; |
| 1834 | if (SubmitTxMemoryPoolAndRelay(wtx, unused_err_string, true)) ++submitted_tx_count; |
| 1835 | } |
| 1836 | } // cs_wallet |
| 1837 | |
| 1838 | if (submitted_tx_count > 0) { |
| 1839 | WalletLogPrintf("%s: resubmit %u unconfirmed transactions\n", __func__, submitted_tx_count); |
| 1840 | } |
| 1841 | } |
| 1842 | |
| 1843 | /** @} */ // end of mapWallet |
| 1844 |
no test coverage detected