Skip to content

Commit fa64636

Browse files
committed
Merge #10995: Fix resendwallettransactions assert failure if -walletbroadcast=0
01699fb Fix resendwallettransactions assert failure if -walletbroadcast=0 (Matt Corallo) Pull request description: This fixes #10981 in my preferred way. Tree-SHA512: 2e43d3ac78d13c5d59db23a82c76c722cc3344767a8237617080e489296d27a98bb1b3bd469b2c9b289b57a9da3709c90448d7a23bcc2e1dfb791c4fd16be015
2 parents c1c671f + 01699fb commit fa64636

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,6 +2589,7 @@ UniValue resendwallettransactions(const JSONRPCRequest& request)
25892589
"Immediately re-broadcast unconfirmed wallet transactions to all peers.\n"
25902590
"Intended only for testing; the wallet code periodically re-broadcasts\n"
25912591
"automatically.\n"
2592+
"Returns an RPC error if -walletbroadcast is set to false.\n"
25922593
"Returns array of transaction ids that were re-broadcast.\n"
25932594
);
25942595

@@ -2597,6 +2598,10 @@ UniValue resendwallettransactions(const JSONRPCRequest& request)
25972598

25982599
LOCK2(cs_main, pwallet->cs_wallet);
25992600

2601+
if (!pwallet->GetBroadcastTransactions()) {
2602+
throw JSONRPCError(RPC_INVALID_REQUEST, "Error: Wallet transaction broadcasting is disabled with -walletbroadcast");
2603+
}
2604+
26002605
std::vector<uint256> txids = pwallet->ResendWalletTransactionsBefore(GetTime(), g_connman.get());
26012606
UniValue result(UniValue::VARR);
26022607
for (const uint256& txid : txids)

src/wallet/wallet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,6 +1868,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime, CCon
18681868
std::vector<uint256> result;
18691869

18701870
LOCK(cs_wallet);
1871+
18711872
// Sort them in chronological order
18721873
std::multimap<unsigned int, CWalletTx*> mapSorted;
18731874
for (std::pair<const uint256, CWalletTx>& item : mapWallet)

src/wallet/wallet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ class CWalletTx : public CMerkleTx
470470
int64_t GetTxTime() const;
471471
int GetRequestCount() const;
472472

473+
// RelayWalletTransaction may only be called if fBroadcastTransactions!
473474
bool RelayWalletTransaction(CConnman* connman);
474475

475476
std::set<uint256> GetConflicts() const;
@@ -937,6 +938,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
937938
CBlockIndex* ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false);
938939
void ReacceptWalletTransactions();
939940
void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) override;
941+
// ResendWalletTransactionsBefore may only be called if fBroadcastTransactions!
940942
std::vector<uint256> ResendWalletTransactionsBefore(int64_t nTime, CConnman* connman);
941943
CAmount GetBalance() const;
942944
CAmount GetUnconfirmedBalance() const;

0 commit comments

Comments
 (0)