mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Regression test for ResendWalletTransactions
Adds a regression test for the wallet's ResendWalletTransactions function, which uses a new, hidden RPC command "resendwallettransactions." I refactored main's Broadcast signal so it is passed the best-block time, which let me remove a global variable shared between main.cpp and the wallet (nTimeBestReceived). I also manually tested the "rebroadcast unconfirmed every half hour or so" functionality by: 1. Running bitcoind -connect=0.0.0.0:8333 2. Creating a couple of send-to-self transactions 3. Connect to a peer using -addnode 4. Waited a while, monitoring debug.log, until I see: ```2015-03-23 18:48:10 ResendWalletTransactions: rebroadcast 2 unconfirmed transactions``` One last change: don't bother putting ResendWalletTransactions messages in debug.log unless unconfirmed transactions were actually rebroadcast.
This commit is contained in:
@@ -2096,3 +2096,25 @@ Value getwalletinfo(const Array& params, bool fHelp)
|
||||
obj.push_back(Pair("unlocked_until", nWalletUnlockTime));
|
||||
return obj;
|
||||
}
|
||||
|
||||
Value resendwallettransactions(const Array& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() != 0)
|
||||
throw runtime_error(
|
||||
"resendwallettransactions\n"
|
||||
"Immediately re-broadcast unconfirmed wallet transactions to all peers.\n"
|
||||
"Intended only for testing; the wallet code periodically re-broadcasts\n"
|
||||
"automatically.\n"
|
||||
"Returns array of transaction ids that were re-broadcast.\n"
|
||||
);
|
||||
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
std::vector<uint256> txids = pwalletMain->ResendWalletTransactionsBefore(GetTime());
|
||||
Array result;
|
||||
BOOST_FOREACH(const uint256& txid, txids)
|
||||
{
|
||||
result.push_back(txid.ToString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user