aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/wallet.cpp4
-rw-r--r--src/qt/bitcoin.cpp16
-rw-r--r--src/qt/bitcoingui.h5
-rw-r--r--src/script/descriptor.cpp18
-rw-r--r--src/validationinterface.cpp10
-rw-r--r--src/wallet/rpcdump.cpp2
-rw-r--r--src/wallet/wallet.cpp6
7 files changed, 41 insertions, 20 deletions
diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp
index 62ede0a95a..a2cae2a7a7 100644
--- a/src/interfaces/wallet.cpp
+++ b/src/interfaces/wallet.cpp
@@ -353,7 +353,7 @@ public:
LOCK(m_wallet.cs_wallet);
auto mi = m_wallet.mapWallet.find(txid);
if (mi != m_wallet.mapWallet.end()) {
- num_blocks = locked_chain->getHeight().value_or(-1);
+ num_blocks = locked_chain->getHeight().get_value_or(-1);
in_mempool = mi->second.InMempool();
order_form = mi->second.vOrderForm;
tx_status = MakeWalletTxStatus(*locked_chain, mi->second);
@@ -384,7 +384,7 @@ public:
return false;
}
balances = getBalances();
- num_blocks = locked_chain->getHeight().value_or(-1);
+ num_blocks = locked_chain->getHeight().get_value_or(-1);
return true;
}
CAmount getBalance() override { return m_wallet.GetBalance(); }
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index ca26131b95..85d79ee26c 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -218,6 +218,8 @@ BitcoinApplication::~BitcoinApplication()
#ifdef ENABLE_WALLET
delete paymentServer;
paymentServer = nullptr;
+ delete m_wallet_controller;
+ m_wallet_controller = nullptr;
#endif
delete optionsModel;
optionsModel = nullptr;
@@ -307,18 +309,20 @@ void BitcoinApplication::requestShutdown()
qDebug() << __func__ << ": Requesting shutdown";
startThread();
window->hide();
+ // Must disconnect node signals otherwise current thread can deadlock since
+ // no event loop is running.
+ window->unsubscribeFromCoreSignals();
+ // Request node shutdown, which can interrupt long operations, like
+ // rescanning a wallet.
+ m_node.startShutdown();
+ // Unsetting the client model can cause the current thread to wait for node
+ // to complete an operation, like wait for a RPC execution to complate.
window->setClientModel(nullptr);
pollShutdownTimer->stop();
-#ifdef ENABLE_WALLET
- delete m_wallet_controller;
- m_wallet_controller = nullptr;
-#endif
delete clientModel;
clientModel = nullptr;
- m_node.startShutdown();
-
// Request shutdown from core thread
Q_EMIT requestedShutdown();
}
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index f1b76a6b64..c31cefe603 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -95,6 +95,9 @@ public:
*/
bool hasTrayIcon() const { return trayIcon; }
+ /** Disconnect core signals from GUI client */
+ void unsubscribeFromCoreSignals();
+
protected:
void changeEvent(QEvent *e);
void closeEvent(QCloseEvent *event);
@@ -184,8 +187,6 @@ private:
/** Connect core signals to GUI client */
void subscribeToCoreSignals();
- /** Disconnect core signals from GUI client */
- void unsubscribeFromCoreSignals();
/** Update UI with latest network info from model. */
void updateNetworkState();
diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp
index a702be5b78..41e0f2e117 100644
--- a/src/script/descriptor.cpp
+++ b/src/script/descriptor.cpp
@@ -226,7 +226,7 @@ protected:
* @param pubkeys The evaluations of the m_pubkey_args field.
* @param script The evaluation of m_script_arg (or nullptr when m_script_arg is nullptr).
* @param out A FlatSigningProvider to put scripts or public keys in that are necessary to the solver.
- * The script and pubkeys argument to this function are automatically added.
+ * The script arguments to this function are automatically added, as is the origin info of the provided pubkeys.
* @return A vector with scriptPubKeys for this descriptor.
*/
virtual std::vector<CScript> MakeScripts(const std::vector<CPubKey>& pubkeys, const CScript* script, FlatSigningProvider& out) const = 0;
@@ -322,7 +322,6 @@ public:
for (auto& entry : entries) {
pubkeys.push_back(entry.first);
out.origins.emplace(entry.first.GetID(), std::move(entry.second));
- out.pubkeys.emplace(entry.first.GetID(), entry.first);
}
if (m_script_arg) {
for (const auto& subscript : subscripts) {
@@ -396,7 +395,12 @@ public:
class PKHDescriptor final : public DescriptorImpl
{
protected:
- std::vector<CScript> MakeScripts(const std::vector<CPubKey>& keys, const CScript*, FlatSigningProvider&) const override { return Singleton(GetScriptForDestination(keys[0].GetID())); }
+ std::vector<CScript> MakeScripts(const std::vector<CPubKey>& keys, const CScript*, FlatSigningProvider& out) const override
+ {
+ CKeyID id = keys[0].GetID();
+ out.pubkeys.emplace(id, keys[0]);
+ return Singleton(GetScriptForDestination(id));
+ }
public:
PKHDescriptor(std::unique_ptr<PubkeyProvider> prov) : DescriptorImpl(Singleton(std::move(prov)), {}, "pkh") {}
};
@@ -405,7 +409,12 @@ public:
class WPKHDescriptor final : public DescriptorImpl
{
protected:
- std::vector<CScript> MakeScripts(const std::vector<CPubKey>& keys, const CScript*, FlatSigningProvider&) const override { return Singleton(GetScriptForDestination(WitnessV0KeyHash(keys[0].GetID()))); }
+ std::vector<CScript> MakeScripts(const std::vector<CPubKey>& keys, const CScript*, FlatSigningProvider& out) const override
+ {
+ CKeyID id = keys[0].GetID();
+ out.pubkeys.emplace(id, keys[0]);
+ return Singleton(GetScriptForDestination(WitnessV0KeyHash(id)));
+ }
public:
WPKHDescriptor(std::unique_ptr<PubkeyProvider> prov) : DescriptorImpl(Singleton(std::move(prov)), {}, "wpkh") {}
};
@@ -418,6 +427,7 @@ protected:
{
std::vector<CScript> ret;
CKeyID id = keys[0].GetID();
+ out.pubkeys.emplace(id, keys[0]);
ret.emplace_back(GetScriptForRawPubKey(keys[0])); // P2PK
ret.emplace_back(GetScriptForDestination(id)); // P2PKH
if (keys[0].IsCompressed()) {
diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp
index 533d412888..70c274d20e 100644
--- a/src/validationinterface.cpp
+++ b/src/validationinterface.cpp
@@ -14,6 +14,7 @@
#include <list>
#include <atomic>
#include <future>
+#include <utility>
#include <boost/signals2/signal.hpp>
@@ -77,7 +78,10 @@ size_t CMainSignals::CallbacksPending() {
}
void CMainSignals::RegisterWithMempoolSignals(CTxMemPool& pool) {
- g_connNotifyEntryRemoved.emplace(&pool, pool.NotifyEntryRemoved.connect(std::bind(&CMainSignals::MempoolEntryRemoved, this, std::placeholders::_1, std::placeholders::_2)));
+ g_connNotifyEntryRemoved.emplace(std::piecewise_construct,
+ std::forward_as_tuple(&pool),
+ std::forward_as_tuple(pool.NotifyEntryRemoved.connect(std::bind(&CMainSignals::MempoolEntryRemoved, this, std::placeholders::_1, std::placeholders::_2)))
+ );
}
void CMainSignals::UnregisterWithMempoolSignals(CTxMemPool& pool) {
@@ -103,7 +107,9 @@ void RegisterValidationInterface(CValidationInterface* pwalletIn) {
}
void UnregisterValidationInterface(CValidationInterface* pwalletIn) {
- g_signals.m_internals->m_connMainSignals.erase(pwalletIn);
+ if (g_signals.m_internals) {
+ g_signals.m_internals->m_connMainSignals.erase(pwalletIn);
+ }
}
void UnregisterAllValidationInterfaces() {
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp
index 0da2dda092..32c36ceaeb 100644
--- a/src/wallet/rpcdump.cpp
+++ b/src/wallet/rpcdump.cpp
@@ -814,7 +814,7 @@ UniValue dumpwallet(const JSONRPCRequest& request)
file << strprintf("# Wallet dump created by Bitcoin %s\n", CLIENT_BUILD);
file << strprintf("# * Created on %s\n", FormatISO8601DateTime(GetTime()));
const Optional<int> tip_height = locked_chain->getHeight();
- file << strprintf("# * Best block at time of backup was %i (%s),\n", tip_height.value_or(-1), tip_height ? locked_chain->getBlockHash(*tip_height).ToString() : "(missing block hash)");
+ file << strprintf("# * Best block at time of backup was %i (%s),\n", tip_height.get_value_or(-1), tip_height ? locked_chain->getBlockHash(*tip_height).ToString() : "(missing block hash)");
file << strprintf("# mined on %s\n", tip_height ? FormatISO8601DateTime(locked_chain->getBlockTime(*tip_height)) : "(missing block time)");
file << "\n";
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 3ce8371abb..9b643be69a 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1720,10 +1720,10 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
}
ShowProgress(strprintf("%s " + _("Rescanning..."), GetDisplayName()), 100); // hide progress dialog in GUI
if (block_height && fAbortRescan) {
- WalletLogPrintf("Rescan aborted at block %d. Progress=%f\n", block_height.value_or(0), progress_current);
+ WalletLogPrintf("Rescan aborted at block %d. Progress=%f\n", block_height.get_value_or(0), progress_current);
result.status = ScanResult::USER_ABORT;
} else if (block_height && ShutdownRequested()) {
- WalletLogPrintf("Rescan interrupted by shutdown request at block %d. Progress=%f\n", block_height.value_or(0), progress_current);
+ WalletLogPrintf("Rescan interrupted by shutdown request at block %d. Progress=%f\n", block_height.get_value_or(0), progress_current);
result.status = ScanResult::USER_ABORT;
}
}
@@ -2584,7 +2584,7 @@ static bool IsCurrentForAntiFeeSniping(interfaces::Chain::Lock& locked_chain)
*/
static uint32_t GetLocktimeForNewTransaction(interfaces::Chain::Lock& locked_chain)
{
- uint32_t const height = locked_chain.getHeight().value_or(-1);
+ uint32_t const height = locked_chain.getHeight().get_value_or(-1);
uint32_t locktime;
// Discourage fee sniping.
//