Browse Source

Fix resendwallettransactions assert failure if -walletbroadcast=0

0.15
Matt Corallo 7 years ago
parent
commit
01699fb283
  1. 5
      src/wallet/rpcwallet.cpp
  2. 1
      src/wallet/wallet.cpp
  3. 2
      src/wallet/wallet.h

5
src/wallet/rpcwallet.cpp

@ -2589,6 +2589,7 @@ UniValue resendwallettransactions(const JSONRPCRequest& request) @@ -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) @@ -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)

1
src/wallet/wallet.cpp

@ -1868,6 +1868,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime, CCon @@ -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)

2
src/wallet/wallet.h

@ -470,6 +470,7 @@ public: @@ -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: @@ -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;

Loading…
Cancel
Save