A bunch of fixes for Preview release target #736

Manually merged
johnny9 merged 40 commits from preview-send-fixes into qt6 2026-06-05 15:03:28 +00:00 AGit
johnny9 commented 2026-05-29 19:32:56 +00:00 (Migrated from github.com)

This PR groups Preview-targeted fixes around Send correctness, fee preview behavior, wallet shutdown/lifecycle handling, receive-request compatibility, and small wallet UI polish.

Issues

Fixes #467 - Send amount validation accounts for the selected fee estimate before allowing review.
Fixes #624 - Create-backup View file opens the selected wallet location and reports failures.
Fixes #636 - Fee bump confirmation prompts to unlock encrypted wallets and relocks after signing.
Fixes #692 - RBF speed-up prompts to unlock encrypted wallets before confirming and is covered by the encrypted-wallet RBF functional test.
Fixes #659 - Send validation rejects duplicate recipients and dust outputs before review.
Fixes #665 - Coin control selections are cleared after send and when clearing recipients.
Fixes #739 - QML coin control treats manually selected coins as exclusive during fee preview and transaction preparation.
Fixes #705 - Send review stays disabled when any visible multi-recipient row is incomplete, with a clear validation error.
Fixes #712 - Update-password mode focuses the current-password field first.
Fixes #715 - Fee previews no longer create persistent qml-fee-preview wallet addresses.
Fixes #721 - Receive request serialization stays compatible with bitcoin-qt and is covered by a bitcoin-qt v31.0 regression workflow.
Fixes #728 - Navigation button content padding is restored.
Fixes #730 - NodeModel unsubscribes from core signals during destruction.
Fixes #731 - SIGINT/Ctrl+C during interrupted initialization exits cleanly instead of hanging.

Refs #582
Refs #577
Refs #579

This PR groups Preview-targeted fixes around Send correctness, fee preview behavior, wallet shutdown/lifecycle handling, receive-request compatibility, and small wallet UI polish. ## Issues Fixes #467 - Send amount validation accounts for the selected fee estimate before allowing review. Fixes #624 - Create-backup `View file` opens the selected wallet location and reports failures. Fixes #636 - Fee bump confirmation prompts to unlock encrypted wallets and relocks after signing. Fixes #692 - RBF speed-up prompts to unlock encrypted wallets before confirming and is covered by the encrypted-wallet RBF functional test. Fixes #659 - Send validation rejects duplicate recipients and dust outputs before review. Fixes #665 - Coin control selections are cleared after send and when clearing recipients. Fixes #739 - QML coin control treats manually selected coins as exclusive during fee preview and transaction preparation. Fixes #705 - Send review stays disabled when any visible multi-recipient row is incomplete, with a clear validation error. Fixes #712 - Update-password mode focuses the current-password field first. Fixes #715 - Fee previews no longer create persistent `qml-fee-preview` wallet addresses. Fixes #721 - Receive request serialization stays compatible with bitcoin-qt and is covered by a bitcoin-qt v31.0 regression workflow. Fixes #728 - Navigation button content padding is restored. Fixes #730 - `NodeModel` unsubscribes from core signals during destruction. Fixes #731 - SIGINT/Ctrl+C during interrupted initialization exits cleanly instead of hanging. Refs #582 Refs #577 Refs #579
jarolrod (Migrated from github.com) reviewed 2026-06-01 22:10:26 +00:00
jarolrod (Migrated from github.com) commented 2026-06-01 22:10:26 +00:00

To finish closing out issue https://github.com/bitcoin-core/gui-qml/issues/730, we need to finish the implementation of unsubscribeFromCoreSignals().

The precedent in Qt Widgets is that all owned Core signal handlers are disconnected during teardown. For example, ClientModel clears all node event handlers, and BitcoinGUI disconnects both message/question handlers.

NodeModel currently registers eight Core handlers, but unsubscribeFromCoreSignals() only disconnects three of them. The remaining header, network, alert, messagebox, and question handlers also capture this, and the runtime dialog handlers can block. They should be disconnected before shutdown begins.

You could do something like this:


commit 3f27fc303ce02b590250529729507494ba79c7af
Author: jarolrod <[email protected]>
Date:   Mon Jun 1 18:05:47 2026 -0400

    fixup

diff --git a/qml/models/nodemodel.cpp b/qml/models/nodemodel.cpp
index 281357c40..3a9ed5ba1 100644
--- a/qml/models/nodemodel.cpp
+++ b/qml/models/nodemodel.cpp
@@ -805,13 +805,19 @@ void NodeModel::ConnectToBannedListChangedSignal()
 
 void NodeModel::unsubscribeFromCoreSignals()
 {
-    if (m_handler_notify_block_tip) {
-        m_handler_notify_block_tip->disconnect();
-    }
-    if (m_handler_notify_num_peers_changed) {
-        m_handler_notify_num_peers_changed->disconnect();
-    }
-    if (m_handler_notify_banned_list_changed) {
-        m_handler_notify_banned_list_changed->disconnect();
-    }
+    const auto disconnect = [](std::unique_ptr<interfaces::Handler>& handler) {
+        if (handler) {
+            handler->disconnect();
+            handler.reset();
+        }
+    };
+
+    disconnect(m_handler_notify_block_tip);
+    disconnect(m_handler_notify_header_tip);
+    disconnect(m_handler_notify_num_peers_changed);
+    disconnect(m_handler_notify_network_active_changed);
+    disconnect(m_handler_notify_alert_changed);
+    disconnect(m_handler_message_box);
+    disconnect(m_handler_question);
+    disconnect(m_handler_notify_banned_list_changed);
 }
diff --git a/test/test_nodemodel.cpp b/test/test_nodemodel.cpp
index 2362c47b2..8d0996f48 100644
--- a/test/test_nodemodel.cpp
+++ b/test/test_nodemodel.cpp
@@ -415,16 +415,37 @@ void NodeModelTests::destructorUnsubscribesCoreSignalsBeforeStoppingPolling()
     NiceMock<MockNode> node;
     MempoolState mempool;
     std::atomic<int> disconnected_handlers{0};
+    constexpr int expected_disconnected_handlers{8};
 
     InstallMempoolGetters(node, mempool);
     ON_CALL(node, handleNotifyBlockTip(testing::_))
         .WillByDefault(Invoke([&](interfaces::Node::NotifyBlockTipFn) {
             return interfaces::MakeCleanupHandler([&] { ++disconnected_handlers; });
         }));
+    ON_CALL(node, handleNotifyHeaderTip(testing::_))
+        .WillByDefault(Invoke([&](interfaces::Node::NotifyHeaderTipFn) {
+            return interfaces::MakeCleanupHandler([&] { ++disconnected_handlers; });
+        }));
     ON_CALL(node, handleNotifyNumConnectionsChanged(testing::_))
         .WillByDefault(Invoke([&](interfaces::Node::NotifyNumConnectionsChangedFn) {
             return interfaces::MakeCleanupHandler([&] { ++disconnected_handlers; });
         }));
+    ON_CALL(node, handleNotifyNetworkActiveChanged(testing::_))
+        .WillByDefault(Invoke([&](interfaces::Node::NotifyNetworkActiveChangedFn) {
+            return interfaces::MakeCleanupHandler([&] { ++disconnected_handlers; });
+        }));
+    ON_CALL(node, handleNotifyAlertChanged(testing::_))
+        .WillByDefault(Invoke([&](interfaces::Node::NotifyAlertChangedFn) {
+            return interfaces::MakeCleanupHandler([&] { ++disconnected_handlers; });
+        }));
+    ON_CALL(node, handleMessageBox(testing::_))
+        .WillByDefault(Invoke([&](interfaces::Node::MessageBoxFn) {
+            return interfaces::MakeCleanupHandler([&] { ++disconnected_handlers; });
+        }));
+    ON_CALL(node, handleQuestion(testing::_))
+        .WillByDefault(Invoke([&](interfaces::Node::QuestionFn) {
+            return interfaces::MakeCleanupHandler([&] { ++disconnected_handlers; });
+        }));
     ON_CALL(node, handleBannedListChanged(testing::_))
         .WillByDefault(Invoke([&](interfaces::Node::BannedListChangedFn) {
             return interfaces::MakeCleanupHandler([&] { ++disconnected_handlers; });
@@ -441,14 +462,14 @@ void NodeModelTests::destructorUnsubscribesCoreSignalsBeforeStoppingPolling()
     QObject::connect(model.get(), &NodeModel::mempoolInfoPollingActiveChanged, [&](bool active) {
         if (!active) {
             checked_shutdown_order = true;
-            QCOMPARE(disconnected_handlers.load(), 3);
+            QCOMPARE(disconnected_handlers.load(), expected_disconnected_handlers);
         }
     });
 
     model.reset();
 
     QVERIFY(checked_shutdown_order);
-    QCOMPARE(disconnected_handlers.load(), 3);
+    QCOMPARE(disconnected_handlers.load(), expected_disconnected_handlers);
 }
 
 void NodeModelTests::nodeNotificationHandlersUpdateModelThroughQueuedSignals()
To finish closing out issue https://github.com/bitcoin-core/gui-qml/issues/730, we need to finish the implementation of `unsubscribeFromCoreSignals()`. The precedent in Qt Widgets is that all owned Core signal handlers are disconnected during teardown. For example, `ClientModel` clears all node event handlers, and `BitcoinGUI` disconnects both message/question handlers. `NodeModel` currently registers eight Core handlers, but `unsubscribeFromCoreSignals()` only disconnects three of them. The remaining header, network, alert, messagebox, and question handlers also capture `this`, and the runtime dialog handlers can block. They should be disconnected before shutdown begins. You could do something like this: <details> ```diff commit 3f27fc303ce02b590250529729507494ba79c7af Author: jarolrod <[email protected]> Date: Mon Jun 1 18:05:47 2026 -0400 fixup diff --git a/qml/models/nodemodel.cpp b/qml/models/nodemodel.cpp index 281357c40..3a9ed5ba1 100644 --- a/qml/models/nodemodel.cpp +++ b/qml/models/nodemodel.cpp @@ -805,13 +805,19 @@ void NodeModel::ConnectToBannedListChangedSignal() void NodeModel::unsubscribeFromCoreSignals() { - if (m_handler_notify_block_tip) { - m_handler_notify_block_tip->disconnect(); - } - if (m_handler_notify_num_peers_changed) { - m_handler_notify_num_peers_changed->disconnect(); - } - if (m_handler_notify_banned_list_changed) { - m_handler_notify_banned_list_changed->disconnect(); - } + const auto disconnect = [](std::unique_ptr<interfaces::Handler>& handler) { + if (handler) { + handler->disconnect(); + handler.reset(); + } + }; + + disconnect(m_handler_notify_block_tip); + disconnect(m_handler_notify_header_tip); + disconnect(m_handler_notify_num_peers_changed); + disconnect(m_handler_notify_network_active_changed); + disconnect(m_handler_notify_alert_changed); + disconnect(m_handler_message_box); + disconnect(m_handler_question); + disconnect(m_handler_notify_banned_list_changed); } diff --git a/test/test_nodemodel.cpp b/test/test_nodemodel.cpp index 2362c47b2..8d0996f48 100644 --- a/test/test_nodemodel.cpp +++ b/test/test_nodemodel.cpp @@ -415,16 +415,37 @@ void NodeModelTests::destructorUnsubscribesCoreSignalsBeforeStoppingPolling() NiceMock<MockNode> node; MempoolState mempool; std::atomic<int> disconnected_handlers{0}; + constexpr int expected_disconnected_handlers{8}; InstallMempoolGetters(node, mempool); ON_CALL(node, handleNotifyBlockTip(testing::_)) .WillByDefault(Invoke([&](interfaces::Node::NotifyBlockTipFn) { return interfaces::MakeCleanupHandler([&] { ++disconnected_handlers; }); })); + ON_CALL(node, handleNotifyHeaderTip(testing::_)) + .WillByDefault(Invoke([&](interfaces::Node::NotifyHeaderTipFn) { + return interfaces::MakeCleanupHandler([&] { ++disconnected_handlers; }); + })); ON_CALL(node, handleNotifyNumConnectionsChanged(testing::_)) .WillByDefault(Invoke([&](interfaces::Node::NotifyNumConnectionsChangedFn) { return interfaces::MakeCleanupHandler([&] { ++disconnected_handlers; }); })); + ON_CALL(node, handleNotifyNetworkActiveChanged(testing::_)) + .WillByDefault(Invoke([&](interfaces::Node::NotifyNetworkActiveChangedFn) { + return interfaces::MakeCleanupHandler([&] { ++disconnected_handlers; }); + })); + ON_CALL(node, handleNotifyAlertChanged(testing::_)) + .WillByDefault(Invoke([&](interfaces::Node::NotifyAlertChangedFn) { + return interfaces::MakeCleanupHandler([&] { ++disconnected_handlers; }); + })); + ON_CALL(node, handleMessageBox(testing::_)) + .WillByDefault(Invoke([&](interfaces::Node::MessageBoxFn) { + return interfaces::MakeCleanupHandler([&] { ++disconnected_handlers; }); + })); + ON_CALL(node, handleQuestion(testing::_)) + .WillByDefault(Invoke([&](interfaces::Node::QuestionFn) { + return interfaces::MakeCleanupHandler([&] { ++disconnected_handlers; }); + })); ON_CALL(node, handleBannedListChanged(testing::_)) .WillByDefault(Invoke([&](interfaces::Node::BannedListChangedFn) { return interfaces::MakeCleanupHandler([&] { ++disconnected_handlers; }); @@ -441,14 +462,14 @@ void NodeModelTests::destructorUnsubscribesCoreSignalsBeforeStoppingPolling() QObject::connect(model.get(), &NodeModel::mempoolInfoPollingActiveChanged, [&](bool active) { if (!active) { checked_shutdown_order = true; - QCOMPARE(disconnected_handlers.load(), 3); + QCOMPARE(disconnected_handlers.load(), expected_disconnected_handlers); } }); model.reset(); QVERIFY(checked_shutdown_order); - QCOMPARE(disconnected_handlers.load(), 3); + QCOMPARE(disconnected_handlers.load(), expected_disconnected_handlers); } void NodeModelTests::nodeNotificationHandlersUpdateModelThroughQueuedSignals() ``` </details>
jarolrod (Migrated from github.com) reviewed 2026-06-01 22:51:17 +00:00
jarolrod (Migrated from github.com) commented 2026-06-01 22:51:18 +00:00

While these unit tests are good it's probably worthwhile to do a functional test so we can have appInitMain() running and have the GUI be in the load_on_startup path while the OS signal is delivered -> since that is where the hang occurred previously.

We could add a functional test like so:

commit f2bbf564f75c82ad193e0963784da18c91d8b6c7
Author: jarolrod <[email protected]>
Date:   Mon Jun 1 18:48:53 2026 -0400

    test startup interrupt

diff --git a/.github/workflows/gui-functional-tests.yml b/.github/workflows/gui-functional-tests.yml
index 774f772fd..ecce78862 100644
--- a/.github/workflows/gui-functional-tests.yml
+++ b/.github/workflows/gui-functional-tests.yml
@@ -155,6 +155,7 @@ jobs:
           python3 test/functional/qml_test_receive.py
           python3 test/functional/qml_test_activity_filter_export.py
           python3 test/functional/qml_test_password_wallet.py
+          python3 test/functional/qml_test_startup_interrupt.py
           python3 test/functional/qml_test_send_receive.py
           python3 test/functional/qml_test_addresses.py
           python3 test/functional/qml_test_send_review.py
diff --git a/test/functional/qml_test_startup_interrupt.py b/test/functional/qml_test_startup_interrupt.py
new file mode 100644
index 000000000..82e94f416
--- /dev/null
+++ b/test/functional/qml_test_startup_interrupt.py
@@ -0,0 +1,208 @@
+#!/usr/bin/env python3
+# Copyright (c) 2026 The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+"""Regression test for interrupted QML initialization during wallet loading."""
+
+import os
+import shutil
+import signal
+import subprocess
+import sys
+import tempfile
+import time
+
+from qml_test_harness import find_gui_binary, qsettings_sandbox_args
+from qml_wallet_test_lib import (
+    pick_unused_port,
+    find_bitcoind,
+    rpc_call,
+    wait_for_rpc,
+    write_datadir,
+)
+
+
+WALLET_PASSWORD = "correct horse battery staple"
+STARTUP_WALLET_NAMES = [f"startup_interrupt_wallet_{i}" for i in range(4)]
+WALLET_LOADING_LOG_MARKER = "Using wallet"
+
+
+def debug_log_path(datadir):
+    return os.path.join(datadir, "regtest", "debug.log")
+
+
+def process_output(process):
+    if not process:
+        return ""
+    stdout = process.stdout.read().decode("utf-8", errors="replace") if process.stdout else ""
+    stderr = process.stderr.read().decode("utf-8", errors="replace") if process.stderr else ""
+    if stdout and stderr:
+        return f"stdout:\n{stdout}\n\nstderr:\n{stderr}"
+    return stdout or stderr
+
+
+def debug_log_tail(datadir, lines=200):
+    log_path = debug_log_path(datadir)
+    if not os.path.isfile(log_path):
+        return ""
+    with open(log_path, "r", encoding="utf8", errors="replace") as log_file:
+        return "".join(log_file.readlines()[-lines:])
+
+
+def stop_node(process, rpc_port):
+    if process and process.poll() is None:
+        try:
+            rpc_call(rpc_port, "stop")
+        except Exception:
+            process.send_signal(signal.SIGTERM)
+        try:
+            process.wait(timeout=20)
+        except subprocess.TimeoutExpired:
+            process.kill()
+            process.wait()
+
+
+def prepare_encrypted_startup_wallets(datadir, rpc_port):
+    process = subprocess.Popen(
+        [find_bitcoind(), f"-datadir={datadir}"],
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+    )
+    try:
+        wait_for_rpc(rpc_port)
+        for wallet_name in STARTUP_WALLET_NAMES:
+            rpc_call(
+                rpc_port,
+                "createwallet",
+                {
+                    "wallet_name": wallet_name,
+                    "passphrase": WALLET_PASSWORD,
+                    "load_on_startup": True,
+                },
+            )
+    finally:
+        stop_node(process, rpc_port)
+
+
+def wait_for_startup_wallet_loading(process, datadir, start_offset, timeout=20):
+    log_path = debug_log_path(datadir)
+    deadline = time.time() + timeout
+    last_error = None
+
+    while time.time() < deadline:
+        if process.poll() is not None:
+            raise AssertionError(
+                f"GUI exited before startup wallet loading was observed "
+                f"(code {process.returncode}).\n{process_output(process)}\n"
+                f"debug.log tail:\n{debug_log_tail(datadir)}"
+            )
+
+        try:
+            if os.path.isfile(log_path) and os.path.getsize(log_path) > start_offset:
+                with open(log_path, "r", encoding="utf8", errors="replace") as log_file:
+                    log_file.seek(start_offset)
+                    # bitcoin-core-app does not mirror early Core init messages to
+                    # debug.log, so use the wallet database log emitted while Core is
+                    # loading startup wallets.
+                    if WALLET_LOADING_LOG_MARKER in log_file.read():
+                        return
+        except OSError as err:
+            last_error = err
+
+        time.sleep(0.05)
+
+    suffix = f": {last_error}" if last_error else ""
+    raise AssertionError(
+        f"Timed out waiting for startup wallet loading marker{suffix}.\n"
+        f"debug.log tail:\n{debug_log_tail(datadir)}"
+    )
+
+
+def launch_gui(datadir, config_home, socket_path):
+    env = dict(os.environ)
+    env["QT_QPA_PLATFORM"] = "offscreen"
+    settings_args = qsettings_sandbox_args(env, config_home)
+    args = [
+        find_gui_binary(),
+        f"-datadir={datadir}",
+        f"-test-automation={socket_path}",
+    ] + settings_args + [
+        "-logtimemicros",
+        "-debug",
+        "-debugexclude=libevent",
+        "-debugexclude=leveldb",
+        "-nolisten",
+    ]
+    print(f"[startup_interrupt] starting GUI: {' '.join(args)}")
+    return subprocess.Popen(
+        args,
+        env=env,
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+    )
+
+
+def run_test():
+    tmpdir = tempfile.mkdtemp(prefix="qml_startup_interrupt_")
+    datadir = os.path.join(tmpdir, "node")
+    config_home = os.path.join(tmpdir, "config")
+    socket_path = os.path.join(tmpdir, "test_bridge.sock")
+    rpc_port = pick_unused_port()
+    p2p_port = pick_unused_port()
+    gui_process = None
+
+    try:
+        write_datadir(datadir, rpc_port, p2p_port)
+        prepare_encrypted_startup_wallets(datadir, rpc_port)
+        print("[startup_interrupt] encrypted startup wallets prepared")
+
+        log_path = debug_log_path(datadir)
+        start_offset = os.path.getsize(log_path) if os.path.isfile(log_path) else 0
+
+        gui_process = launch_gui(datadir, config_home, socket_path)
+        wait_for_startup_wallet_loading(gui_process, datadir, start_offset)
+        print("[startup_interrupt] startup wallet loading observed; sending SIGINT")
+
+        gui_process.send_signal(signal.SIGINT)
+        try:
+            gui_process.wait(timeout=30)
+        except subprocess.TimeoutExpired as err:
+            gui_process.kill()
+            gui_process.wait()
+            raise AssertionError(
+                "GUI did not exit after SIGINT during startup wallet loading.\n"
+                f"GUI output:\n{process_output(gui_process)}\n"
+                f"debug.log tail:\n{debug_log_tail(datadir)}"
+            ) from err
+
+        if gui_process.returncode != 0:
+            raise AssertionError(
+                f"Expected clean exit after SIGINT, got code {gui_process.returncode}.\n"
+                f"GUI output:\n{process_output(gui_process)}\n"
+                f"debug.log tail:\n{debug_log_tail(datadir)}"
+            )
+
+        print("[startup_interrupt] GUI exited cleanly after interrupted startup")
+        return 0
+
+    except Exception as err:  # noqa: BLE001 - preserve functional test context
+        print(f"\nFAILED: {err}", file=sys.stderr)
+        import traceback
+        traceback.print_exc()
+        return 1
+    finally:
+        if gui_process and gui_process.poll() is None:
+            gui_process.send_signal(signal.SIGTERM)
+            try:
+                gui_process.wait(timeout=10)
+            except subprocess.TimeoutExpired:
+                gui_process.kill()
+                gui_process.wait()
+        if os.getenv("KEEP_QML_TEST_TMPDIR") == "1":
+            print(f"Preserving test directory: {tmpdir}")
+        else:
+            shutil.rmtree(tmpdir, ignore_errors=True)
+
+
+if __name__ == "__main__":
+    sys.exit(run_test())
While these unit tests are good it's probably worthwhile to do a functional test so we can have `appInitMain()` running and have the GUI be in the `load_on_startup` path while the OS signal is delivered -> since that is where the hang occurred previously. We could add a functional test like so: <details> ```diff commit f2bbf564f75c82ad193e0963784da18c91d8b6c7 Author: jarolrod <[email protected]> Date: Mon Jun 1 18:48:53 2026 -0400 test startup interrupt diff --git a/.github/workflows/gui-functional-tests.yml b/.github/workflows/gui-functional-tests.yml index 774f772fd..ecce78862 100644 --- a/.github/workflows/gui-functional-tests.yml +++ b/.github/workflows/gui-functional-tests.yml @@ -155,6 +155,7 @@ jobs: python3 test/functional/qml_test_receive.py python3 test/functional/qml_test_activity_filter_export.py python3 test/functional/qml_test_password_wallet.py + python3 test/functional/qml_test_startup_interrupt.py python3 test/functional/qml_test_send_receive.py python3 test/functional/qml_test_addresses.py python3 test/functional/qml_test_send_review.py diff --git a/test/functional/qml_test_startup_interrupt.py b/test/functional/qml_test_startup_interrupt.py new file mode 100644 index 000000000..82e94f416 --- /dev/null +++ b/test/functional/qml_test_startup_interrupt.py @@ -0,0 +1,208 @@ +#!/usr/bin/env python3 +# Copyright (c) 2026 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +"""Regression test for interrupted QML initialization during wallet loading.""" + +import os +import shutil +import signal +import subprocess +import sys +import tempfile +import time + +from qml_test_harness import find_gui_binary, qsettings_sandbox_args +from qml_wallet_test_lib import ( + pick_unused_port, + find_bitcoind, + rpc_call, + wait_for_rpc, + write_datadir, +) + + +WALLET_PASSWORD = "correct horse battery staple" +STARTUP_WALLET_NAMES = [f"startup_interrupt_wallet_{i}" for i in range(4)] +WALLET_LOADING_LOG_MARKER = "Using wallet" + + +def debug_log_path(datadir): + return os.path.join(datadir, "regtest", "debug.log") + + +def process_output(process): + if not process: + return "" + stdout = process.stdout.read().decode("utf-8", errors="replace") if process.stdout else "" + stderr = process.stderr.read().decode("utf-8", errors="replace") if process.stderr else "" + if stdout and stderr: + return f"stdout:\n{stdout}\n\nstderr:\n{stderr}" + return stdout or stderr + + +def debug_log_tail(datadir, lines=200): + log_path = debug_log_path(datadir) + if not os.path.isfile(log_path): + return "" + with open(log_path, "r", encoding="utf8", errors="replace") as log_file: + return "".join(log_file.readlines()[-lines:]) + + +def stop_node(process, rpc_port): + if process and process.poll() is None: + try: + rpc_call(rpc_port, "stop") + except Exception: + process.send_signal(signal.SIGTERM) + try: + process.wait(timeout=20) + except subprocess.TimeoutExpired: + process.kill() + process.wait() + + +def prepare_encrypted_startup_wallets(datadir, rpc_port): + process = subprocess.Popen( + [find_bitcoind(), f"-datadir={datadir}"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + try: + wait_for_rpc(rpc_port) + for wallet_name in STARTUP_WALLET_NAMES: + rpc_call( + rpc_port, + "createwallet", + { + "wallet_name": wallet_name, + "passphrase": WALLET_PASSWORD, + "load_on_startup": True, + }, + ) + finally: + stop_node(process, rpc_port) + + +def wait_for_startup_wallet_loading(process, datadir, start_offset, timeout=20): + log_path = debug_log_path(datadir) + deadline = time.time() + timeout + last_error = None + + while time.time() < deadline: + if process.poll() is not None: + raise AssertionError( + f"GUI exited before startup wallet loading was observed " + f"(code {process.returncode}).\n{process_output(process)}\n" + f"debug.log tail:\n{debug_log_tail(datadir)}" + ) + + try: + if os.path.isfile(log_path) and os.path.getsize(log_path) > start_offset: + with open(log_path, "r", encoding="utf8", errors="replace") as log_file: + log_file.seek(start_offset) + # bitcoin-core-app does not mirror early Core init messages to + # debug.log, so use the wallet database log emitted while Core is + # loading startup wallets. + if WALLET_LOADING_LOG_MARKER in log_file.read(): + return + except OSError as err: + last_error = err + + time.sleep(0.05) + + suffix = f": {last_error}" if last_error else "" + raise AssertionError( + f"Timed out waiting for startup wallet loading marker{suffix}.\n" + f"debug.log tail:\n{debug_log_tail(datadir)}" + ) + + +def launch_gui(datadir, config_home, socket_path): + env = dict(os.environ) + env["QT_QPA_PLATFORM"] = "offscreen" + settings_args = qsettings_sandbox_args(env, config_home) + args = [ + find_gui_binary(), + f"-datadir={datadir}", + f"-test-automation={socket_path}", + ] + settings_args + [ + "-logtimemicros", + "-debug", + "-debugexclude=libevent", + "-debugexclude=leveldb", + "-nolisten", + ] + print(f"[startup_interrupt] starting GUI: {' '.join(args)}") + return subprocess.Popen( + args, + env=env, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + + +def run_test(): + tmpdir = tempfile.mkdtemp(prefix="qml_startup_interrupt_") + datadir = os.path.join(tmpdir, "node") + config_home = os.path.join(tmpdir, "config") + socket_path = os.path.join(tmpdir, "test_bridge.sock") + rpc_port = pick_unused_port() + p2p_port = pick_unused_port() + gui_process = None + + try: + write_datadir(datadir, rpc_port, p2p_port) + prepare_encrypted_startup_wallets(datadir, rpc_port) + print("[startup_interrupt] encrypted startup wallets prepared") + + log_path = debug_log_path(datadir) + start_offset = os.path.getsize(log_path) if os.path.isfile(log_path) else 0 + + gui_process = launch_gui(datadir, config_home, socket_path) + wait_for_startup_wallet_loading(gui_process, datadir, start_offset) + print("[startup_interrupt] startup wallet loading observed; sending SIGINT") + + gui_process.send_signal(signal.SIGINT) + try: + gui_process.wait(timeout=30) + except subprocess.TimeoutExpired as err: + gui_process.kill() + gui_process.wait() + raise AssertionError( + "GUI did not exit after SIGINT during startup wallet loading.\n" + f"GUI output:\n{process_output(gui_process)}\n" + f"debug.log tail:\n{debug_log_tail(datadir)}" + ) from err + + if gui_process.returncode != 0: + raise AssertionError( + f"Expected clean exit after SIGINT, got code {gui_process.returncode}.\n" + f"GUI output:\n{process_output(gui_process)}\n" + f"debug.log tail:\n{debug_log_tail(datadir)}" + ) + + print("[startup_interrupt] GUI exited cleanly after interrupted startup") + return 0 + + except Exception as err: # noqa: BLE001 - preserve functional test context + print(f"\nFAILED: {err}", file=sys.stderr) + import traceback + traceback.print_exc() + return 1 + finally: + if gui_process and gui_process.poll() is None: + gui_process.send_signal(signal.SIGTERM) + try: + gui_process.wait(timeout=10) + except subprocess.TimeoutExpired: + gui_process.kill() + gui_process.wait() + if os.getenv("KEEP_QML_TEST_TMPDIR") == "1": + print(f"Preserving test directory: {tmpdir}") + else: + shutil.rmtree(tmpdir, ignore_errors=True) + + +if __name__ == "__main__": + sys.exit(run_test()) ``` </details>
jarolrod (Migrated from github.com) reviewed 2026-06-01 23:42:08 +00:00
jarolrod (Migrated from github.com) commented 2026-06-01 23:42:08 +00:00

I think its wrong to use this here

This should use the node’s active dust relay fee instead of the static default DUST_RELAY_TX_FEE.

DUST_RELAY_TX_FEE is only the default value. The node policy can be changed with -dustrelayfee, and Qt Widgets already validates dust with node.getDustRelayFee().

Wallet transaction creation also uses the live relay dust fee, so this seems wrong to do like this.

I think its wrong to use this here This should use the node’s **active** dust relay fee instead of the **static** default DUST_RELAY_TX_FEE. DUST_RELAY_TX_FEE is only the default value. The node policy can be changed with -dustrelayfee, and Qt Widgets already validates dust with node.getDustRelayFee(). Wallet transaction creation also uses the live relay dust fee, so this seems wrong to do like this.
jarolrod (Migrated from github.com) reviewed 2026-06-02 00:09:30 +00:00
jarolrod (Migrated from github.com) commented 2026-06-02 00:09:30 +00:00

while auditing the changes around coin control, I think there is still an adjacent coin-control parity issue here.

It seems selected coins are still not exclusive during transaction preparation.

CCoinControl::m_allow_other_inputs defaults to true, which means Core will require the selected inputs but may still add additional unselected wallet inputs. Qt Widgets overrides this before preparing a send: coin_control.m_allow_other_inputs = !coin_control.HasSelected();

As QML isn't doing that, it can prepare a transaction that spends the user-selected coins plus other wallet coins. I haven't exactly tested, but that is the logical conclusion. Probably worth it to reevaluate the context around this, the wallet, and qt widgets; and maybe include any changes here or open an issue to be addressed as a follow-up.

while auditing the changes around coin control, I think there is still an adjacent coin-control parity issue here. It seems selected coins are still not *exclusive* during transaction preparation. CCoinControl::m_allow_other_inputs defaults to true, which means Core will require the selected inputs but may still add additional unselected wallet inputs. Qt Widgets overrides this before preparing a send: `coin_control.m_allow_other_inputs = !coin_control.HasSelected();` As QML isn't doing that, it can prepare a transaction that spends the user-selected coins plus other wallet coins. I haven't exactly tested, but that is the logical conclusion. Probably worth it to reevaluate the context around this, the wallet, and qt widgets; and maybe include any changes here or open an issue to be addressed as a follow-up.
johnny9 (Migrated from github.com) reviewed 2026-06-02 13:25:37 +00:00
johnny9 (Migrated from github.com) commented 2026-06-02 13:25:37 +00:00

Yeah i built these already. I guess they got lost in the shuffle. Will add back the shutdown qml functional test.

Yeah i built these already. I guess they got lost in the shuffle. Will add back the shutdown qml functional test.
johnny9 (Migrated from github.com) reviewed 2026-06-02 13:25:50 +00:00
johnny9 (Migrated from github.com) commented 2026-06-02 13:25:50 +00:00

Will look into this.

Will look into this.
johnny9 (Migrated from github.com) reviewed 2026-06-02 13:26:05 +00:00
johnny9 (Migrated from github.com) commented 2026-06-02 13:26:05 +00:00

I'll see how big of an issue this is.

I'll see how big of an issue this is.
johnny9 (Migrated from github.com) reviewed 2026-06-02 13:43:01 +00:00
johnny9 (Migrated from github.com) commented 2026-06-02 13:43:01 +00:00

added #739 for tracking and made an attempt

added #739 for tracking and made an attempt
johnny9 (Migrated from github.com) reviewed 2026-06-02 13:43:34 +00:00
johnny9 (Migrated from github.com) commented 2026-06-02 13:43:34 +00:00

Should disconnect all handlers now

Should disconnect all handlers now
johnny9 (Migrated from github.com) reviewed 2026-06-02 13:51:06 +00:00
johnny9 (Migrated from github.com) commented 2026-06-02 13:51:06 +00:00

I think this is correct and matches the intended behavior of the user interface

I think this is correct and matches the intended behavior of the user interface
pseudoramdom (Migrated from github.com) reviewed 2026-06-02 18:26:09 +00:00
pseudoramdom (Migrated from github.com) commented 2026-06-02 18:26:09 +00:00

We've got some weird UX going on.
If I select a UTXO with amount less than the one I'm sending, the "Review" button is enabled. But we get stopped after entering the passphrase.

We should probably emit Q_EMIT sendAmountExhaustsBalanceChanged() on coin selection

https://github.com/user-attachments/assets/5534e3ef-4876-4ea9-be2c-c41e098ff063

We've got some weird UX going on. If I select a UTXO with amount less than the one I'm sending, the "Review" button is enabled. But we get stopped after entering the passphrase. We should probably emit `Q_EMIT sendAmountExhaustsBalanceChanged()` on coin selection https://github.com/user-attachments/assets/5534e3ef-4876-4ea9-be2c-c41e098ff063
johnny9 (Migrated from github.com) reviewed 2026-06-02 18:56:03 +00:00
johnny9 (Migrated from github.com) commented 2026-06-02 18:56:03 +00:00

I'll take a look at this. It is a gap with the calculations when considering coin control and the added coin control restriction to not include other coins. I changed coin control to not pull in other coins if the amount isnt covered and I didnt update the rules for deciding if we have enough of the amount covered

I'll take a look at this. It is a gap with the calculations when considering coin control and the added coin control restriction to not include other coins. I changed coin control to not pull in other coins if the amount isnt covered and I didnt update the rules for deciding if we have enough of the amount covered
jarolrod (Migrated from github.com) reviewed 2026-06-02 19:24:28 +00:00
jarolrod (Migrated from github.com) commented 2026-06-02 19:24:28 +00:00

The root cause looks like the pre-review check is still using the full wallet balance, while the actual prepare path now uses coincontrol aware available balance, from my previous review.

Emitting sendAmountExhaustsBalanceChanged() on coin selection is needed so the button refreshes immediately, but it won’t fix the mismatch by itself.

I think this path should use the same effective balance as prepareTransactionInternal(), then apply the same CCoinControl policy and call getAvailableBalance(coin_control), ideally through a small shared helper so Review and prepare can’t drift in the future.

The root cause looks like the pre-review check is still using the full wallet balance, while the actual prepare path now uses coincontrol aware available balance, from my previous review. Emitting `sendAmountExhaustsBalanceChanged()` on coin selection is needed so the button refreshes immediately, but it won’t fix the mismatch by itself. I think this path should use the same effective balance as `prepareTransactionInternal()`, then apply the same `CCoinControl` policy and call `getAvailableBalance(coin_control)`, ideally through a small shared helper so Review and prepare can’t drift in the future.
jarolrod (Migrated from github.com) reviewed 2026-06-02 19:34:38 +00:00
jarolrod (Migrated from github.com) commented 2026-06-02 19:34:38 +00:00

There is another adjacent state issue here around this code, thought not as important as this one.

When send inputs change, this only schedules a future preview. The existing fee estimate is not marked stale, and feeEstimatePending is not set until requestFeeEstimatesNow() runs after the debounce.

Even after that, the preview still runs asynchronously. During that whole period, sendAmountExhaustsBalance() can still answer using either no estimate or an estimate from the previous send inputs.

That means the Review enabled state can temporarily be based on fee data that does not correspond to the current reality; of course keep in mind we're talking about 250ms, so its not the worst thing.

But architecturally, and this is where my comment focuses on, it means the model does not know whether the selected fee estimate is current, which makes the pre-review check quite weak, and its worthwhile to revisit the architecture,

There is another adjacent state issue here around this code, thought not as important as this one. When send inputs change, this only schedules a future preview. The existing fee estimate is not marked stale, and `feeEstimatePending` is not set until `requestFeeEstimatesNow()` runs after the debounce. Even after that, the preview still runs asynchronously. During that whole period, `sendAmountExhaustsBalance()` can still answer using either no estimate or an estimate from the previous send inputs. That means the Review enabled state can temporarily be based on fee data that does not correspond to the current reality; of course keep in mind we're talking about 250ms, so its not the worst thing. But architecturally, and this is where my comment focuses on, it means the model does not know whether the selected fee estimate is current, which makes the pre-review check quite weak, and its worthwhile to revisit the architecture,
pseudoramdom commented 2026-06-02 19:45:21 +00:00 (Migrated from github.com)

Fixes https://github.com/bitcoin-core/gui-qml/issues/692 - RBF speed-up prompts to unlock encrypted wallets before confirming and is covered by the encrypted-wallet RBF functional test.

The text in red while doing RBF is redundant.
Screenshot 2026-06-02 at 12 43 18 PM

> Fixes https://github.com/bitcoin-core/gui-qml/issues/692 - RBF speed-up prompts to unlock encrypted wallets before confirming and is covered by the encrypted-wallet RBF functional test. The text in red while doing RBF is redundant. <img width="1222" height="947" alt="Screenshot 2026-06-02 at 12 43 18 PM" src="https://git.fish.foo/attachments/6f7ef7f5-cd84-463c-87c2-762dcf4c5fb0" />
jarolrod (Migrated from github.com) reviewed 2026-06-02 19:53:48 +00:00
jarolrod (Migrated from github.com) commented 2026-06-02 19:53:48 +00:00

maybe also assert the wallet is locked again after the successful bump?

After the passphrase popup closes and the bump succeeds, checking getwalletinfo()["unlocked_until"] == 0 would catch a regression where the gui signs but leaves the wallet unlocked.

maybe also assert the wallet is locked again after the successful bump? After the passphrase popup closes and the bump succeeds, checking `getwalletinfo()["unlocked_until"] == 0` would catch a regression where the gui signs but leaves the wallet unlocked.
jarolrod (Migrated from github.com) reviewed 2026-06-02 19:54:18 +00:00
jarolrod (Migrated from github.com) commented 2026-06-02 19:54:18 +00:00

don't we need to add the new shutdown test here?

don't we need to add the new shutdown test here?
johnny9 (Migrated from github.com) reviewed 2026-06-03 15:06:23 +00:00
johnny9 (Migrated from github.com) commented 2026-06-03 15:06:23 +00:00

Stale pending reviews should be ignored now.

Stale pending reviews should be ignored now.
johnny9 commented 2026-06-03 15:52:05 +00:00 (Migrated from github.com)

Fixes #692 - RBF speed-up prompts to unlock encrypted wallets before confirming and is covered by the encrypted-wallet RBF functional test.

The text in red while doing RBF is redundant.

Set the default text to ""

> > Fixes #692 - RBF speed-up prompts to unlock encrypted wallets before confirming and is covered by the encrypted-wallet RBF functional test. > > The text in red while doing RBF is redundant. Set the default text to ""
pseudoramdom commented 2026-06-04 18:33:03 +00:00 (Migrated from github.com)
Screenshot 2026-06-04 at 11 28 18 AM

nit: The payment message and the import result seem to be not up to spec.

This is what I see in Figma.
Screenshot 2026-06-04 at 11 30 40 AM

"The payment request imported..." should probably be a toast banner.

I can fix both in my upcoming PR for PSBT where I'm fixing the Send page layout.

<img width="1041" height="887" alt="Screenshot 2026-06-04 at 11 28 18 AM" src="https://git.fish.foo/attachments/b3e4d4ea-2655-48d8-acd7-48ee921ee966" /> nit: The payment message and the import result seem to be not up to spec. This is what I see in Figma. <img width="307" height="145" alt="Screenshot 2026-06-04 at 11 30 40 AM" src="https://git.fish.foo/attachments/3b07530f-2365-4848-a297-fdd7e7a64529" /> "The payment request imported..." should probably be a toast banner. I can fix both in my upcoming PR for PSBT where I'm fixing the Send page layout.
johnny9 commented 2026-06-04 19:08:49 +00:00 (Migrated from github.com)

"The payment request imported..." should probably be a toast banner.

I can fix both in my upcoming PR for PSBT where I'm fixing the Send page layout.

Ill leave it to you then if you already have some ideas or considerations with relation to PSBT.

> > "The payment request imported..." should probably be a toast banner. > > I can fix both in my upcoming PR for PSBT where I'm fixing the Send page layout. Ill leave it to you then if you already have some ideas or considerations with relation to PSBT.
pseudoramdom (Migrated from github.com) reviewed 2026-06-04 19:31:24 +00:00
pseudoramdom (Migrated from github.com) commented 2026-06-04 19:31:25 +00:00

We should probably call root.scheduleFeeEstimates() so that we don't see a stale fee after importing the URI

We should probably call `root.scheduleFeeEstimates()` so that we don't see a stale fee after importing the URI
pseudoramdom (Migrated from github.com) reviewed 2026-06-04 19:44:57 +00:00
pseudoramdom (Migrated from github.com) commented 2026-06-04 19:44:57 +00:00

If I import a URI without label/message to a form that has label & message, should we clear them out?

If I import a URI without label/message to a form that has label & message, should we clear them out?
pseudoramdom (Migrated from github.com) approved these changes 2026-06-05 04:09:28 +00:00
pseudoramdom (Migrated from github.com) left a comment
ACK fdb30e81effcd76d5fae0a201814384ca2849cf6
Sign in to join this conversation.
No description provided.