diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-08-07 09:05:43 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-08-07 09:06:06 +0200 |
commit | fa646369489d5655ac187f2a9e151317829581df (patch) | |
tree | 30f232f03fcdbe568010479a616119aa93dea9d0 | |
parent | c1c671feb163c2b3baa2caf97b05a997187e55d5 (diff) | |
parent | 01699fb283485918478017331872c75817b81bdb (diff) |
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
-rw-r--r-- | src/wallet/rpcwallet.cpp | 5 | ||||
-rw-r--r-- | src/wallet/wallet.cpp | 1 | ||||
-rw-r--r-- | src/wallet/wallet.h | 2 |
3 files changed, 8 insertions, 0 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a7c229fa74..27f84bfb7c 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2589,6 +2589,7 @@ UniValue resendwallettransactions(const JSONRPCRequest& request) "Immediately re-broadcast unconfirmed wallet transactions to all peers.\n" "Intended only for testing; the wallet code periodically re-broadcasts\n" "automatically.\n" + "Returns an RPC error if -walletbroadcast is set to false.\n" "Returns array of transaction ids that were re-broadcast.\n" ); @@ -2597,6 +2598,10 @@ UniValue resendwallettransactions(const JSONRPCRequest& request) LOCK2(cs_main, pwallet->cs_wallet); + if (!pwallet->GetBroadcastTransactions()) { + throw JSONRPCError(RPC_INVALID_REQUEST, "Error: Wallet transaction broadcasting is disabled with -walletbroadcast"); + } + std::vector<uint256> txids = pwallet->ResendWalletTransactionsBefore(GetTime(), g_connman.get()); UniValue result(UniValue::VARR); for (const uint256& txid : txids) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index d236b1de3f..18cc3bd028 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1868,6 +1868,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime, CCon std::vector<uint256> result; LOCK(cs_wallet); + // Sort them in chronological order std::multimap<unsigned int, CWalletTx*> mapSorted; for (std::pair<const uint256, CWalletTx>& item : mapWallet) diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 7ef2e6f1d8..3a02d1305d 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -470,6 +470,7 @@ public: int64_t GetTxTime() const; int GetRequestCount() const; + // RelayWalletTransaction may only be called if fBroadcastTransactions! bool RelayWalletTransaction(CConnman* connman); std::set<uint256> GetConflicts() const; @@ -937,6 +938,7 @@ public: CBlockIndex* ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false); void ReacceptWalletTransactions(); void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) override; + // ResendWalletTransactionsBefore may only be called if fBroadcastTransactions! std::vector<uint256> ResendWalletTransactionsBefore(int64_t nTime, CConnman* connman); CAmount GetBalance() const; CAmount GetUnconfirmedBalance() const; |