Architecture Reference · QML Application Side

Bitcoin Core App (GUI QML) Object Model

Complete architecture of the gui-qml application—covering every major QML view, controller, interface, model, operation, and execution owner, stopping cleanly at the Bitcoin Core interfaces::* boundary.

One-Way DependenciesView → Controller → Contract ← Model. Models never know about pages or controllers.
Dedicated + Elastic ThreadsDedicated node & control threads + elastic blocking pool (1 thread per active strand, uncapped cleanup) + QmlInitExecutor & payment-link QThread.
Strict Core BoundaryApp stops at interfaces::{Init, Node, Chain, Wallet, Handler} + ArgsManager, with one documented deviation: qml/walletsigning 3-phase external signer (off cs_wallet).
Bounded ShutdownCancel prompts & active signer subprocess → drain features (Finishing: <reason> / Quit anyway) → appShutdown() → destroy Views/Models → flush DeferredDelete → join threads → destroy Core roots.

01 Roles, Scopes & Dependency Rules

Role defines what an object does. Scope (page, wallet, app) defines how long it lives. Keeping them separate avoids god-models and redundant forwarding layers.

RoleResponsibilityNaming RuleExamples
View QML layout, bindings, focus, dialogs, and navigation. Holds no request tickets, schedulers, or native handles. *.qml MainWindow.qml, SendForm.qml, ActivityListPage.qml, ReceivePage.qml, Peers.qml
Controller Use-case state, prompts, busy/error state, and active operation handles. BitcoinQmlApplication::run is the composition root. *Controller, ShutdownCoordinator WalletController, SendDraftController, TransactionReviewController, FeeBumpController, WalletPasswordController, PeerCommandController
Interface Narrow abstract capability contract a controller depends on. Production models implement it; tests inject a fake. Capability contracts end in *Interface WalletAvailabilityInterface, SendDraftInterface, TransactionReviewInterface, FeeBumpInterface, WalletBackupInterface, WalletSecurityInterface, SettingsEditorFactoryInterface, PeerCommandInterface, PeerActionsInterface
Model Observable domain data, drafts, list/proxy models, self-contained editors, or backend sessions. Outlives pages. *Model or concrete adapter (no *Interface) NodeModel, ChainModel, SettingsModel, WalletModel, TransactionActivityModel, CoinsListModel, WalletReceiveModel, walletopening::Session
Operation One async domain request with its own terminal state, result, and error, bound to its original target. Operation contracts end in *Operation SendOperation, PreparationOperation, FeeBumpOperation, SecurityOperation, FileSaveOperation, PsbtOperation, PeerCommandOperation, PaymentImportOperation, ReceiveRequestOperation
Executor Dedicated node & control threads, elastic blocking pool, typed StrandHandles, prioritized/coalescing SerialQueues, and deterministic ManualScheduler test default. execution::* (Internal C++) execution::Executor, execution::SerialQueue, execution::StrandHandle, execution::ManualScheduler, execution::ValueCleanupQueue
Core External Bitcoin Core boundary (bitcoin/src/interfaces/). Owned exclusively by backend C++ owners—never QML or page controllers. interfaces::* interfaces::Init, interfaces::Node, interfaces::Chain, interfaces::Wallet, interfaces::Handler

Three Approved Dependency Paths

1. Workflow Coordination

View → Controller → narrow contract → Model / Session. Use an abstract *Interface where a capability/test seam helps, or an existing coherent facade like WalletReceiveModel.

2. Direct Presentation

View → Model / Controller. QML binds directly to observable models (TransactionActivityModel, CoinsListModel, PeerListProxyModel, BlockClockModel) and controller state.

3. Self-Contained Editors

View → EditorModel. Dedicated editor sessions (SettingsEditorModel, PaymentRequestEditorModel) own their draft, validation, and retiring-while-saving teardown directly.

One Owner for Each Kind of State

StateSingle AuthorityLifetime & Rule
Focus, layout, dialogs, navigationView pageLocal to the QML page/component. Wallet pages are created once per wallet and never rebound.
Prompts, busy state, active requests, page errorsController + Operation pageOne active operation per kind. Hiding a page cancels unclaimed work; committed work finishes on its wallet.
Domain data, drafts, busy state & unresolved effectsModel wallet / appOutlives pages. Publishes typed busy/busyReason (driving/reusing existing operation progress interfaces) and shared history snapshots per (tx_rev, addr_rev, tip_hash).
Native handles (Wallet, Handler)walletopening::Session / NodeModel / WalletRegistrySole app-model writer per open wallet (lint-enforced; console Node::executeRpc & Core threads exempt and ordered by Core locks). Freed on a per-wallet cleanup strand—never GUI.
Worker threads, strands, priority & drainExecutor appInvisible to QML and Controllers. Dedicated node & control threads + elastic pool; tests default to deterministic ManualScheduler.
Core roots (Init, Node, Chain)BitcoinQmlApplication::run appCreated first; moved into a final std::thread after executor.stopAndJoin(), destroyed in its body, then joined.

02 Ownership Tree, Threads & Core Interface Boundary

Containment shows ownership directly. Construction flows top-to-bottom; orderly teardown unwinds bottom-to-top so every worker joins before Core roots are destroyed.

Controller BitcoinQmlApplication::run app root
Composition root · exposes app models via ApplicationModels singleton
↓ CONSTRUCTION ORDER (TOP TO BOTTOM) ↑ ORDERLY TEARDOWN ORDER (BOTTOM TO TOP)
Core Boundary NativeApplicationInterfaces
Created 1st · destroyed last in a final std::thread · app stops here (no Core internals)
interfaces::InitCreates Node & Chain via MakeGuiInit
interfaces::NodeLifecycle, settings, peers, bans, traffic, RPC, prompts
interfaces::ChainNetwork/tip info, block lookup, wallet loading & catalog
interfaces::Wallet & HandlerAcquired at runtime; owned strictly by backend sessions/models
Executor execution::Executor (Dedicated node + control + Elastic Blocking Pool) & 3 Lifecycle Threads
No cross-wallet or wallet-to-node starvation · ManualScheduler default in tests
Target::Node (1 dedicated thread)All node, chain, peer, banlist, traffic & fee-estimation reads/commands—never shares a thread with wallet work
Target::Control (1 dedicated thread)Urgent control (startShutdown(), shutdown polling, settings writes, RPC stop), whenDrained, outcome strands & in-memory Outcome (ex-Domain)
Target::Pool (elastic blocking pool)Grows to 1 thread per active strand, warm floor (~2) & 30–60 s idle timeout (avoids thread churn on bursts—and paired IPC server-thread churn if node/wallet interfaces are later served over IPC). Runs per-wallet strands, per-request load/creation/import strands, per-wallet cleanup strands (never capped), rpc, signer & file I/O strands
QmlInitExecutor (1 std::thread)Sequential appInitMain(), subscription cleanup, appShutdown(); posts startShutdown() on Target::Control
desktopintent::transport::Service (1 QThread) & qtlog (1 std::thread)Qt IPC event loop (QLocalServer/sockets) and async Qt log sink
qml/walletsigning (3-phase adapter)Cancelable POSIX/Win32 signer subprocess on signer strand—holds no cs_wallet or wallet ref (no QProcess dependency)
App Controllers & App Models (exposed via ApplicationModels) app
Async owners hold lightweight SerialQueue(s) on the shared Executor
Lifecycle & ShellShutdownCoordinator, DesktopTrayIconController, DesktopWindowBehaviorModel, DesktopIntentModel, UiPreferencesStore, QRImageProvider
Node & ChainNodeModel (NetworkModel, PeerCommandModel, RuntimePromptModel, StartupDiagnosticsModel), ChainModel, BlockClockModel, NetworkStatusModel, NetworkTrafficTower
Peers, Console & LogsPeerListModel, PeerListProxyModel, PeerDetailsModel, PeerSelectionModel, BanListModel, RpcConsoleModel, DebugLogModel
Settings & OnboardingSettingsModel (CoreSettingsModel, SettingsEditorModel), OnboardingOptionsModel, SignerDiscoveryModel
Controller WalletController → WalletModel (1 per open wallet) wallet
Also owns WalletCreationController (parallel load/create/import strands), WalletNamesController, WalletRegistry, WalletListModel, WalletSelectionModel
walletopening::SessionSole app-model writer: unique_ptr<interfaces::Wallet>, Handler[], 1 serial wallet strand (actions overtake reads; shared history snapshot per (tx_rev, addr_rev, tip_hash)), typed busy state & per-wallet cleanup strand
Send, Coins & PSBTSendRecipientsListModel, FeeSelectionModel (fee reader on node), CoinsListModel, SendImportModel, PsbtQmlModel, TransactionReviewModel, WalletSendDraft, WalletTransactionReview, walletsigning
Activity & Speed UpTransactionActivityModel, ActivityFilterProxyModel, ActivityDetailModel, FlowDetailsModel, FeeBumpModel, BumpTransactionModel
Receive, Security & BackupWalletReceiveModel, AddressListModel, AddressReservationModel, ReceiveRequestHistoryModel, ReceiptReconciliationModel, WalletBackupModel, WalletSecurityModel, SignVerifyMessageModel
Views QQmlApplicationEngine → Pages → Page Controllers → Operations page
Destroyed 1st on exit · followed by QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete)
WalletPageController SubclassesIrreversible single-wallet m_bound: FeeBumpController, WalletPasswordController, WalletBackupController
Other Page ControllersCancel/drop pending state on hide or target change: SendDraftController, TransactionReviewController, PaymentRequestViewController, PaymentRequestDeleteController, ActivityDetailController, PeerCommandController, SettingsNavigationController
Active Operation HandlesPreparationOperation, SendOperation/WalletSendHandle, FeeBumpOperation, SecurityOperation, FileSaveOperation/BackupFileOperation, PsbtOperation, PeerCommandOperation, PaymentImportOperation, ReceiveRequestOperation

Bitcoin Core Interface Boundary (Where the QML App Stops)

Core InterfaceQML-Side OwnerUsed By (App Side Only)Destruction / Retirement
interfaces::InitNativeApplicationInterfacesBitcoinQmlApplication::run (creates Node & Chain)Destroyed last in final std::thread after all workers join
interfaces::NodeNativeApplicationInterfacesQmlInitExecutor, NodeModel, FeeEstimateReader, SettingsModel (control), PeerListModel, BanListModel, PeerCommandModel, NetworkTrafficTower, RpcConsoleModel (rpc strand), BlockClockHistoryDestroyed in final std::thread after appShutdown() & stopAndJoin()
interfaces::ChainNativeApplicationInterfacesChainModel (node), WalletRegistry, WalletListModel, WalletCreationController (parallel per-request load/create/import strands on pool)Destroyed in final std::thread after all wallet sessions stop
interfaces::Walletwalletopening::SessionSole app-model writer on the wallet's serial strand (lint forbids outside Session & pre-session loader/creator). Console Node::executeRpc & Core threads bypass Session and serialize via Core's cs_wallet. External signer device waits run off-lock in qml/walletsigning.std::unique_ptr freed on per-wallet cleanup strand (elastic pool, uncapped) inside Session::stop(done)
interfaces::HandlerNodeModel, QmlInitExecutor, WalletRegistry, SessionCore signal subscriptions (status, tip, wallet load/unload, tx/address changes, prompts)Disconnected & destroyed on worker (Init thread or per-wallet cleanup strand), never GUI

03 Execution & Cleanup Contract

All feature concurrency builds on three small internal C++ primitives in execution::.

execution::Executor, SerialQueue & Scheduler

namespace execution {

enum class Target { Node, Control, Pool }; // Dedicated node & control + elastic blocking pool
enum class Priority { Action, Read };      // Actions overtake queued reads; reads coalesce
struct StrandHandle { uint64_t id{0}; const char* debug_name{nullptr}; };

class Scheduler {
public:
    virtual ~Scheduler() = default;
    virtual bool dispatch(Target, StrandHandle, std::function<void()> turn) = 0;
};

class SerialQueue {
public:
    StrandHandle handle() const noexcept;
    bool post(std::function<void()> task, Priority = Priority::Action);
    bool postCoalescedRead(uint64_t key, std::function<void()> task);
    void close();                                 // Stops new posts to this strand only
    void whenDrained(std::function<void()> done); // Delivered on Target::Control
private:
    friend class ValueCleanupQueue;
    bool reserveCleanup();
    void cancelReservedCleanup();
    bool postReservedCleanup(std::function<void()> cleanup);
};

class Executor {
public:
    explicit Executor(Config config);                        // Production: node + control + elastic pool
    explicit Executor(std::shared_ptr<Scheduler> scheduler); // Tests: ManualScheduler by default
    SerialQueue makeStrand(Target, const char* debug_name = nullptr);
    void stopAndJoin();                                      // Closes, drains, joins all real workers
};

} // namespace execution

Key Runtime Invariants

  • No cross-wallet or node starvation (G1): Dedicated node & control threads never run wallet work. An elastic pool grows to 1 thread per active strand (warm floor ~2, 30–60 s idle timeout to avoid burst churn, and IPC server-thread churn if node/wallet interfaces are later served over IPC), with per-wallet cleanup strands never capped.
  • Single app-model writer + console exemption (G3): One serial strand per open wallet in Session (lint forbids interfaces::Wallet& outside Session, pre-session loader/creator, and the owning-strand ShowProgress → abortRescan() cancel hook). Console Node::executeRpc (on rpc strand) & Core threads bypass Session and are ordered by Core's cs_wallet.
  • Cooperative rescan cancellation: Rescans that already hold an interfaces::Wallet handle (watch-only import after createWallet, and open-wallet rescans) take a shared cancel flag polled in Core's ShowProgress callback on the owning strand's thread to call wallet.abortRescan() directly (polling avoids ChainScanner::TryReserve resetting m_abort at scan.cpp:64; no control-lane path). Load/restore AttachChain rescans have no wallet handle yet and stop only on shutdown (scan.cpp:246).
  • Priority, coalescing & shared history snapshot: Within a wallet strand, actions overtake queued reads, reads coalesce, and all 5 getWalletTxs readers share one immutable snapshot keyed by (transaction_revision, address_revision, tip_hash).
  • Three-phase signing & shared signer enumeration (G2, G5): Signing and discovery share one cancelable POSIX/Win32 subprocess runner in qml/walletsigning copying Core's ExternalSigner::Enumerate rules (no cs_wallet, no wallet ref, no QProcess); signing reuses discovery's command/fingerprint, checks SameTransaction (stricter than Core's external_signer.cpp:124), replaces PSBT, and finalizes under lock (output-parity tested against Core). External-signer createWallet (GetDescriptors) is the only step that waits on an external process with no way to cancel it.
  • Deterministic tests by default (G6): Unit/model tests default to ManualScheduler stepping typed StrandHandles (no dangling string_view tags); real-thread tests opt in explicitly to prove G1, G2, and G5.
  • Reserved teardown cleanup & consent boundary: ValueCleanupQueue preserves accepted teardown work during stopAndJoin(); passive close() stops new posts without revoking claimed send consent.

04 Feature Relationships (All 8 App Areas)

Every major area of gui-qml arranged strictly left-to-right from QML View to the Core interfaces::* boundary.

1. Startup, Onboarding, Shell & Desktop Integration

Composition root, pre-init onboarding, OS payment links, tray/window behavior, and shutdown coordination.

flowchart LR subgraph View["Views (QML · app scope)"] PRE["preinit.qml /<br/>OnboardingWizard.qml"] MW["MainWindow.qml<br/>(+ DesktopNativeMenuBar,<br/>DesktopRequestsBar)"] ERR["initerrormessage.qml /<br/>Shutdown.qml"] end subgraph Root["Composition & Controllers"] APP["BitcoinQmlApplication::run<br/>(ApplicationModels)"] SC["ShutdownCoordinator"] TRAY["DesktopTrayIconController"] PREP["startup::preparation::Coordinator"] end subgraph Models["App Services & Models"] ONB["OnboardingOptionsModel"] DI["DesktopIntentModel"] DWB["DesktopWindowBehaviorModel"] UIP["UiPreferencesStore"] DIAG["StartupDiagnosticsModel"] end subgraph Exec["Threads & Core Boundary"] QIE["QmlInitExecutor<br/>(1 Init thread + Control)"] TRANS["desktopintent::transport::Service<br/>(1 QThread + Control/Pool)"] CORE["interfaces::Init<br/>interfaces::Node<br/>interfaces::Chain"] end PRE --> ONB MW --> APP MW --> TRAY MW --> DI MW --> DWB ERR --> DIAG ERR --> SC APP --> SC APP --> PREP APP --> QIE APP --> UIP PREP --> TRANS DI --> TRANS QIE --> CORE SC --> QIE
Key relationships:
  • ApplicationModels exposes app-scoped models/controllers cleanly to QML without putting Executor or native handles into QML.
  • desktopintent::transport::Service owns 1 dedicated QThread for QLocalServer/QLocalSocket IPC and forwards payment links to DesktopIntentModel on shared strands.
  • QmlInitExecutor runs appInitMain(), subscription cleanup, and appShutdown() on 1 dedicated thread while posting startShutdown() on the dedicated control thread.

2. Node Status, BlockClock, Peers, Traffic, Console & Logs

Node, chain & fee reads on dedicated node thread; interactive RPC on rpc strand (elastic pool); shutdown polling, RPC stop & outcomes on dedicated control thread.

flowchart LR subgraph View["Views (QML)"] NS["NodeShell.qml /<br/>NodeRunner.qml /<br/>BlockClock.qml"] PV["Peers.qml /<br/>PeerDetails.qml /<br/>BannedPeersPopup.qml"] CC["CommandConsole.qml /<br/>SettingsRpcConsoleView.qml /<br/>SettingsDebugLogView.qml"] end subgraph Ctrl["Controller & Interfaces"] PCC["PeerCommandController"] PCI["PeerCommandInterface /<br/>PeerActionsInterface"] PCO["PeerCommandOperation /<br/>NodePeerCommandOperation"] end subgraph Models["App Models"] NM["NodeModel<br/>(+ NetworkModel,<br/>RuntimePromptModel)"] CM["ChainModel /<br/>BlockClockModel /<br/>NetworkTrafficTower"] PL["PeerListModel /<br/>PeerListProxyModel /<br/>PeerDetailsModel /<br/>BanListModel"] PCM["PeerCommandModel"] RPC["RpcConsoleModel /<br/>RpcCommandExecutor"] DBG["DebugLogModel"] end subgraph Core["Core Boundary"] NODE["interfaces::Node<br/>+ interfaces::Handler"] CHAIN["interfaces::Chain"] end NS --> NM NS --> CM PV --> PL PV --> PCC CC --> RPC CC --> DBG PCC --> PCI PCC --> PCO PCM -. implements .-> PCI PCO --> PCM NM --> NODE PCM --> NODE PL --> NODE RPC --> NODE CM --> CHAIN CM --> NODE
Thread & strand isolation:
  • All node, chain, peer, banlist, traffic, and fee-estimation reads run on the dedicated node thread—never sharing a thread with wallet work.
  • NodeModel::close() cancels RuntimePromptService immediately in Step 1 of shutdown so a blocked QuestionFn never deadlocks queued shutdown work.
  • RpcConsoleModel runs ordinary commands on the rpc strand (elastic pool), stops on control, and retires redacted output on control. Wallet RPCs through Node::executeRpc bypass Session and serialize against wallet strands via Core's cs_wallet.
  • PeerListModel and BanListModel read on node and project incrementally on control; DebugLogModel reads debug.log on a pool file strand.

3. Settings, Self-Contained Editors & Signer Discovery

SettingsModel persists changes on dedicated control before Core interruption; external signer CLIs run on the signer strand on the elastic pool.

flowchart LR subgraph View["Views (QML)"] SV["SettingsView.qml /<br/>Display / Storage /<br/>Connection / Effective"] SE["ProxySettingsPage.qml /<br/>StorageSettingsPage.qml"] ES["ExternalSignerSettingsPage.qml"] WB["WindowBehaviorSettingsPage.qml"] end subgraph Iface["Interface"] SEF["SettingsEditorFactoryInterface"] end subgraph Models["Models (app / page)"] SM["SettingsModel<br/>(beforeInterrupt drain)"] CSM["CoreSettingsModel"] SEM["SettingsEditorModel<br/>(self-contained editor)"] SDM["SignerDiscoveryModel<br/>(pool: signer strand)"] DWB["DesktopWindowBehaviorModel"] OW["execution::OwnedWork<br/>(Control + Node/Pool)"] end subgraph Core["Core Boundary"] NODE["interfaces::Node"] ARGS["ArgsManager<br/>(settings.json)"] end SV --> SM SE --> SEF SE --> SEM ES --> SM ES --> SDM WB --> DWB SM -. implements .-> SEF SM --> CSM SM --> SEM CSM --> OW SEM --> OW OW --> NODE OW --> ARGS
Key boundaries:
  • SettingsEditorFactoryInterface::createSettingsEditor() makes ownership clear: SettingsModel owns the returned SettingsEditorModel*.
  • SettingsEditorModel remains visible in a "retiring" state until its accepted save finishes on the worker.
  • SignerDiscoveryModel and 3-phase signing share one cancelable POSIX/Win32 enumerate runner in qml/walletsigning on the pool's signer strand—so a hung CLI never blocks node, control, or wallet strands, discovery & signing never disagree on device swap, and Cancel / "Quit anyway" terminate cleanly.

4. Wallet Loading, Creation, Naming & Registry

Parallel per-request load, creation, and watch-only import strands on the elastic pool; each open wallet gets one walletopening::Session and one WalletModel.

flowchart LR subgraph View["Views (QML)"] WV["WalletView.qml /<br/>DesktopWallets.qml /<br/>WalletSelect.qml"] CF["WalletCreationFlow.qml /<br/>WalletCreationHost.qml"] end subgraph Ctrl["App Controllers"] WC["WalletController"] WCC["WalletCreationController"] WNC["WalletNamesController"] end subgraph Models["Catalog, Registry & Session"] WLM["WalletListModel"] WSM["WalletSelectionModel"] WR["WalletRegistry"] WCM["WalletCreationModel /<br/>WalletOperationModel"] WM["WalletModel<br/>(1 per open wallet · busy/busyReason)"] WS["walletopening::Session<br/>(1 wallet strand + 1 cleanup strand)"] end subgraph Core["Core Boundary"] CHAIN["interfaces::Chain"] CWAL["unique_ptr&lt;interfaces::Wallet&gt;<br/>+ interfaces::Handler[]"] end WV --> WC WV --> WLM WV --> WSM CF --> WCC CF --> WCM WC --> WCC WC --> WNC WC --> WR WC --> WM WCC --> WCM WM --> WS WS --> CWAL WR --> CHAIN WLM --> CHAIN WCC --> CHAIN
Key guarantees:
  • Parallel pre-session work & cooperative rescan cancel: Each loadWallet / restoreWallet / migrateWallet and each pre-session createWallet + importDescriptors runs on its own per-request strand on the elastic pool (order tests cover both loads and creations). Rescans that already hold an interfaces::Wallet handle (watch-only import after createWallet, and open-wallet rescans) poll a shared cancel flag inside Core's ShowProgress callback on the owning strand to call wallet.abortRescan() directly (avoiding TryReserve's m_abort reset at scan.cpp:64; no control-lane path). Load/restore AttachChain rescans stop only on shutdown (scan.cpp:246; UPSTREAM-015), and external-signer createWallet (GetDescriptors, UPSTREAM-014) is the only step waiting on an uncancelable external process.
  • Typed busy state: Pending loads/restores/imports surface in the wallet list; open wallets publish typed WalletModel::busy / busyReason (Encrypting, WaitingForSigner, BackingUp, ExportingWatchOnly, Rescanning) driving/reusing existing operation progress contracts.
  • Single app-model writer & per-wallet cleanup: Once open, all app-model wallet calls route through Session's serial strand (lint-enforced), and each wallet retires unique_ptr<interfaces::Wallet> & handlers on its own uncapped cleanup strand on the pool.

5. Send Creation, Coin Control, Payment/PSBT Import & Review

Reusable form components take explicit draft values; preparation, PSBT, signer approval, and send run through narrow contracts.

flowchart LR subgraph View["Views (QML · page scope)"] SC["SendCreate.qml<br/>+ SendForm.qml<br/>+ SendFeeSelection"] CO["WalletCoins.qml<br/>+ CoinsList.qml"] SR["SendTransactionReview.qml<br/>+ ExternalSignerReviewActions<br/>+ SendComplete.qml"] end subgraph Ctrl["Page Controllers"] SDC["SendDraftController"] TRC["TransactionReviewController"] end subgraph Contract["Interfaces & Operations"] SDI["SendDraftInterface"] TRI["TransactionReviewInterface"] OPS["PreparationOperation /<br/>SendOperation (WalletSendHandle) /<br/>PsbtOperation / FileSaveOperation"] end subgraph Models["Wallet Models & Session"] WSD["WalletSendDraft"] WTR["WalletTransactionReview"] WM["WalletModel<br/>(+ SendRecipientsListModel,<br/>FeeSelectionModel [node thread],<br/>CoinsListModel, SendImportModel,<br/>PsbtQmlModel, TransactionReviewModel)"] WS["walletopening::Session<br/>(+ walletsend::SendTask,<br/>walletsigning 3-phase adapter)"] end subgraph Core["Core & Device Boundary"] CWAL["interfaces::Wallet"] SIGNER["Cancelable Signer Subprocess<br/>(pool: signer strand, off cs_wallet)"] end SC --> SDC CO --> WM SR --> TRC SDC --> SDI SDC --> OPS TRC --> TRI TRC --> OPS WSD -. implements .-> SDI WTR -. implements .-> TRI WSD --> WM WTR --> WM WM --> WS OPS --> WS WS --> CWAL WS --> SIGNER
Key contracts:
  • 3-phase external signing (qml/walletsigning): Phase 1 fills PSBT under lock on Session; Phase 2 runs the cancelable POSIX/Win32 signer subprocess on the signer strand with no cs_wallet or wallet ref (so blocks keep connecting and Wallet B stays live); Phase 3 runs an app-side SameTransaction check (stricter than Core), replaces PSBT, and finalizes/verifies on Session (output-parity tested against Core).
  • Fee reader on node: Fee estimation runs on the dedicated node thread instead of contending with wallet history reads on the wallet strand.
  • SendForm.qml, SendFeeSelection.qml, SendRecipientCard.qml, SendRecipientEditor.qml, and ExternalSignerReviewActions.qml take explicit values/signals and never depend on WalletModel.

6. Activity History, Transaction Details, Export & Speed Up (Fee Bump)

Shared immutable history snapshot per (tx_rev, addr_rev, tip_hash) across all 5 readers; RBF bumps use 3-phase external signing and survive page dismissal.

flowchart LR subgraph View["Views (QML · page scope)"] AL["ActivityListPage.qml /<br/>ActivityList.qml"] TD["TransactionDetail.qml<br/>(+ TransactionFlow)"] SU["SpeedUpOverlay.qml /<br/>SpeedUpComplete.qml"] end subgraph Ctrl["Controller, Interface & Ops"] FBC["FeeBumpController<br/>(WalletPageController)"] FBI["FeeBumpInterface"] FBO["FeeBumpOperation"] AEO["ActivityExportOperation<br/>(FileSaveOperation)"] end subgraph Models["Wallet Models & Session"] TAM["TransactionActivityModel /<br/>ActivityFilterProxyModel"] ADM["ActivityDetailModel /<br/>FlowDetailsModel"] FBM["FeeBumpModel /<br/>BumpTransactionModel"] WS["walletopening::Session<br/>(wallet strand + shared snapshot)"] end subgraph Core["Core Boundary"] CWAL["interfaces::Wallet"] end AL --> TAM AL --> AEO TD --> ADM TD --> FBC SU --> FBC FBC --> FBI FBC --> FBO FBM -. implements .-> FBI FBO --> FBM TAM --> WS ADM --> WS FBM --> WS AEO --> TAM WS --> CWAL
Key guarantees:
  • Shared history snapshot: Session captures one immutable getWalletTxs() snapshot per (transaction_revision, address_revision, tip_hash) and shares it across all 5 readers (activity, addresses, payments, requests, reservations), while actions overtake queued reads on the wallet strand.
  • TransactionActivityModel builds row projections in bounded chunks on control; ActivityExportOperation writes export files on a pool file strand.
  • External-signer RBF bumps use the same 3-phase split (createBumpTransaction → PSBT fill → cancelable signer strand → FinalizeAndExtractPSBT + commitBumpTransaction); unresolved outcomes survive overlay dismissal on FeeBumpModel.

7. Receive Addresses, Address Book & Payment Requests

WalletReceiveModel coherent facade + self-contained request editor + view/delete controllers + QR export.

flowchart LR subgraph View["Views (QML · page scope)"] RP["ReceivePage.qml /<br/>ReceiveRequestModal.qml"] AD["AddressList.qml /<br/>AddressDetails.qml"] end subgraph Ctrl["Controllers & Operations"] PVC["PaymentRequestViewController"] PDC["PaymentRequestDeleteController"] RRO["ReceiveRequestOperation /<br/>RequestImageExportOperation<br/>(FileSaveOperation)"] end subgraph Models["Wallet Models & Session"] WRM["WalletReceiveModel<br/>(coherent facade)"] ARM["AddressReservationModel /<br/>AddressListModel"] PREM["PaymentRequestEditorModel<br/>(self-contained editor)"] RHM["ReceiveRequestHistoryModel /<br/>ReceiptReconciliationModel /<br/>RequestSharingModel"] WS["walletopening::Session<br/>(wallet strand + shared snapshot)"] end subgraph Core["Core Boundary"] CWAL["interfaces::Wallet"] end RP --> WRM RP --> PREM RP --> PVC RP --> PDC AD --> ARM PVC --> RRO PVC --> WRM PDC --> WRM WRM --> ARM WRM --> RHM WRM --> WS PREM --> WS ARM --> WS RHM --> WS WS --> CWAL
Key boundaries:
  • WalletReceiveModel is retained as a coherent facade rather than wrapped behind a redundant forwarding interface; AddressListModel, WalletPayments, ReceiveRequestHistoryModel, and AddressReservationModel share Session's revisioned history snapshot.
  • PaymentRequestEditorModel stays visible while retiring accepted backend writes; RequestImageExportOperation writes QR PNGs on a pool file strand while outcomes deliver on control.

8. Wallet Security, Backup & Sign/Verify Message

Wallet settings pages bind irreversibly to one wallet via WalletSettingsHost + WalletPageController.

flowchart LR subgraph View["Views (QML · page scope)"] WSH["WalletSettingsHost.qml /<br/>WalletSettingsStack.qml"] WPS["WalletPasswordSettings.qml"] SVM["SignVerifyMessage.qml"] end subgraph Ctrl["Page Controllers"] WPC["WalletPasswordController<br/>(WalletPageController)"] WBC["WalletBackupController<br/>(WalletPageController)"] end subgraph Contract["Interfaces & Operations"] WAI["WalletAvailabilityInterface"] WSI["WalletSecurityInterface"] WBI["WalletBackupInterface"] SEC["SecurityOperation"] BKO["BackupFileOperation<br/>(FileSaveOperation)"] end subgraph Models["Wallet Models & Session"] WSM["WalletSecurityModel"] WBM["WalletBackupModel"] SVMM["SignVerifyMessageModel"] WS["walletopening::Session<br/>(wallet strand + shared snapshot)"] end subgraph Core["Core Boundary"] CWAL["interfaces::Wallet"] end WSH --> WPS WSH --> WBC WPS --> WPC SVM --> SVMM WPC --> WSI WPC --> SEC WBC --> WBI WBC --> BKO WSI -. extends .-> WAI WBI -. extends .-> WAI WSM -. implements .-> WSI WBM -. implements .-> WBI WSM --> WS WBM --> WS SVMM --> WS WS --> CWAL
Key guarantees:
  • WalletSettingsHost instantiates a fresh WalletSettingsStack per wallet so no wallet page controller is ever rebound to a second wallet.
  • WalletSecurityModel (encryptWallet / changeWalletPassphrase) and WalletBackupModel (backupWallet, plus pinned Core's exportWatchOnlyWallet at wallet/interfaces.cpp:540) run on the wallet strand and publish typed WalletModel::busy / busyReason (Encrypting, BackingUp, ExportingWatchOnly), driving/reusing existing operation progress interfaces while refusing conflicting actions via acceptAction. Encryption and watch-only export hold cs_wallet for their duration, so node validation/notifications stall for at most that hold duration.
  • WalletBackupModel enforces app-wide destination/file-identity collision checks (refusing loaded wallet DB paths) and finishes active backups even if the page closes.

05 Concurrency & Shutdown Sequences

Time flows downward across thread lifelines. Core roots always outlive every worker join.

Orderly Application Shutdown (5 Steps + "Quit anyway")

Normal quit, early startup exit, and recoverable errors. Active signer subprocesses are cancelled cleanly so every thread joins with zero detached threads.

sequenceDiagram participant GUI as GUI Thread (Qt) participant SC as ShutdownCoordinator participant Pre as Pre-Interrupt (Settings / Transport) participant Ctrl as Target::Control Thread participant Pool as Elastic Pool (Wallets / Signer / Cleanup) participant Init as QmlInitExecutor Thread participant Exec as Executor Workers participant Final as Final std::thread Note over GUI,SC: Step 1 — Close admission & cancel waiting prompts immediately GUI->>SC: requestShutdown() SC->>GUI: disable windows · close() features · cancel waiting prompts SC->>Pre: beforeInterrupt stop(done) Pre-->>SC: settings persisted on Control · transport QThread joined Note over SC,Ctrl: Step 2 — Interrupt Core SC->>Ctrl: node.startShutdown() Ctrl-->>SC: interrupted (Core never waits on external signer) Note over SC,Pool: Step 3 — Drain remaining features (shows "Finishing: [reason]") SC->>Pool: afterInterrupt stop(done) opt User clicks "Quit anyway" while device is held GUI->>Pool: walletsigning cancel() → terminate signer subprocess cleanly end Pool-->>SC: wallet strands drained · per-wallet cleanup frees Wallet & Handler[] Note over SC,Init: Step 4 — Shut down Core cleanly SC->>Init: node.appShutdown() + retire subscriptions Init-->>SC: shutdownResult() · Init thread joined Note over GUI,Final: Step 5 — Reverse-order unwind (Qt loop stays active during final joins) SC->>GUI: finished → exit main event loop GUI->>GUI: destroy QQmlApplicationEngine & Models GUI->>GUI: sendPostedEvents(DeferredDelete) + WaitForThreadJoins GUI->>Exec: executor.stopAndJoin() (with QEventLoop pumping) Exec-->>GUI: node, control & pool threads physically joined GUI->>Final: move Chain / Node / Init → destroy in thread body Final-->>GUI: final thread joined → process exits

Three-Phase External Signing (No cs_wallet Device Wait)

qml/walletsigning keeps Core's validation callbacks, block connection, Wallet B, and wallet unload live while waiting on a hardware wallet—with a cancelable POSIX/Win32 subprocess runner and an output-parity test against Core.

sequenceDiagram participant Page as Review / Speed Up participant A as Wallet A Session (pool strand) participant Sig as Signer Strand (pool · off cs_wallet) participant Node as Dedicated Node Thread & Core participant B as Wallet B Session (pool strand) Note over A: Phase 1 — Fill under lock (under 1 ms) Page->>A: start external-signer send / bump (busyReason = WaitingForSigner) A->>A: fillPSBT(sign=false, bip32_derivs=true) → releases cs_wallet Note over Sig,B: Phase 2 — Device wait runs off-lock with no wallet ref A->>Sig: enumerate (size==1, fingerprint match) + cancelable signtx subprocess par Core & Wallet B stay completely live Node->>Node: blocks mined → ActivateBestChain & ValidationSignals advance Node-->>B: blockConnected → Wallet B balance & activity update and Device waits on user (or cancel / unload / "Quit anyway") alt User confirms on device Sig->>Sig: decode signer_psbt · verify SameTransaction · replace psbt Sig-->>A: return signed PSBT Note over A: Phase 3 — Verify & finalize under lock (under 1 ms) A->>A: fillPSBT(sign=false, bip32_derivs=true, finalize=true) + fee/sig checks A-->>Page: complete & broadcast (clear busy) else Wallet A unloads or user clicks Cancel / "Quit anyway" Page->>Sig: terminate signer subprocess cleanly · drop late result Sig-->>A: signer thread exits cleanly → unload/shutdown completes end end

Blocked Wallet / Prompt + Pre-Interrupt Settings Write

Node runs on its own dedicated thread and SettingsModel runs on dedicated control, so neither waits behind a wallet strand, restore, or watch-only import on the elastic pool before Step 2 interrupts Core.

sequenceDiagram participant GUI as GUI Thread participant SC as ShutdownCoordinator participant NM as NodeModel (Prompts · Node Thread) participant Pool as Elastic Pool (Wallet / Load Strand) participant Set as SettingsModel participant Ctrl as Target::Control Thread Pool->>Pool: wallet restore / import rescan / encrypt [holds pool strand only] NM-->>GUI: node & chain reads stay live (or show runtime prompt dialog) GUI->>Set: setMaxMempoolSizeMB(newVal) Set->>Ctrl: post settings write [dedicated Control thread] GUI->>SC: requestShutdown() Note over SC,NM: Step 1 stop hooks run BEFORE beforeInterrupt drain SC->>NM: node_model.close() → m_prompt_service->close() NM-->>NM: unblock QuestionFn (returns false) Ctrl->>Ctrl: run queued SettingsModel write → persist settings.json Ctrl-->>Set: write complete Set-->>SC: shutdownFinished() Note over SC,Ctrl: Step 2 only begins after Settings persisted SC->>Ctrl: node.startShutdown()

Single Wallet Close, Per-Wallet Cleanup & Send Consent Boundary

Wallet A stops and runs cleanup on its own uncapped pool cleanup strand without delaying Wallet B; page hide cancels unclaimed sends but never aborts a claimed send.

sequenceDiagram participant Page as Review Page / Controller participant A as Wallet A Session (pool strand) participant B as Wallet B Session (pool strand) participant Ctrl as Target::Control Thread participant CleanA as Wallet A Cleanup Strand (pool · uncapped) par Sibling wallet stays active on its own strand B->>B: Wallet B reads / actions continue uninterrupted and Send consent boundary on Wallet A (action overtakes queued reads) Page->>A: submit SendTask (with shared consent) alt Page dismissed BEFORE consent->claim() Page->>Page: withdraw consent A->>A: SendTask sees unclaimed consent → Cancelled else Page dismissed AFTER consent->claim() A->>A: SendTask finishes broadcast on Wallet A strand A->>Ctrl: postWithOutcome() → record actual outcome end end Note over A,CleanA: Wallet A close (never blocks Wallet B's cleanup) Page->>A: Session::stop(done) A->>A: close Wallet A strand (drain on Control) A->>CleanA: disconnect Handlers · optional remove() · wallet.reset() CleanA-->>Ctrl: cleanup complete → done()

Native-Fatal Fast-Fail Path

Kept separate from orderly shutdown so a fatal Core error reports diagnostics on control and exits without hanging on stalled pool strands.

sequenceDiagram participant Init as QmlInitExecutor Thread participant Ctrl as Target::Control Thread participant NM as NodeModel / Diagnostics participant GUI as GUI Thread Init->>Init: uncaught native exception in appInitMain() / Core Init->>Init: bound diagnostic text on worker Init-->>NM: runawayException(boundedSummary) NM->>Ctrl: format StartupDiagnosticsModel off-UI Ctrl-->>GUI: display fatal error dialog Note over GUI,Init: Never invokes unsafe appShutdown() or waits on a stalled pool strand GUI->>GUI: user acknowledges → fast-fail exit with non-zero status

06 Complete QML App Class Directory

All main objects across the gui-qml project up to the Bitcoin Core interfaces::* boundary. Filter by area, role, scope, or keyword (native Ctrl+F works on every row).

TypeAreaRoleScopeThread / LaneResponsibility & Key Relationships
Guiding constraint: Every object on the QML side fits one of the 6 roles and stops at interfaces::{Init, Node, Chain, Wallet, Handler} + ArgsManager (with one documented deviation: qml/walletsigning's 3-phase cancelable external signer adapter). Prefer a typed strand on Executor and a narrow contract over adding custom thread loops or raw cross-strand wallet calls.