Implement PSBT import, export, inspect, broadcast operations #750

Manually merged
pseudoramdom merged 23 commits from psbt-import-export into qt6 2026-06-24 11:23:57 +00:00 AGit
pseudoramdom commented 2026-06-08 04:15:36 +00:00 (Migrated from github.com)

This PR brings the ability to import, export and view PSBT files.

PSBT operations

  • Add ability to import PSBT file via the send options menu. This opens a file dialog to import the PSBT file.
    ScreenshotScreenshot 2026-06-07 at 8 57 37 PM
  • Export a transaction as PSBT when in Review transaction page
    ScreenshotScreenshot 2026-06-07 at 9 00 00 PM
  • Add support to view PSBT files that a wallet can't sign, including multi-sig PSBTs
    ScreenshotRegularScreenshot 2026-06-07 at 7 59 57 PM MultisigScreenshot 2026-06-07 at 8 22 05 PM
  • Broadcast a transaction if it has required signatures
    screenshotScreenshot 2026-06-07 at 7 59 44 PM

Other UI fixes

  • Introduce a new ContextMenu component that can list options with button with icons, toggle, separator. It replaces EllipsisMenu family of controls. Migrate existing menus to use ContextMenu across the app.
    screenshotScreenshot 2026-06-07 at 9 08 05 PMScreenshot 2026-06-07 at 9 08 13 PMScreenshot 2026-06-07 at 9 08 23 PMScreenshot 2026-06-07 at 9 08 39 PM
  • Refine Send and receive page layout
    screenshotScreenshot 2026-06-07 at 5 11 37 PMScreenshot 2026-06-07 at 9 14 20 PM
  • Review Transaction for watch-only wallets
    screenshotScreenshot 2026-06-07 at 7 58 38 PM

Fixes #662 , #663 , #664, #522, #745

This PR brings the ability to import, export and view PSBT files. ### PSBT operations - Add ability to import PSBT file via the send options menu. This opens a file dialog to import the PSBT file. <details><summary>Screenshot</summary><img width="1163" height="1028" alt="Screenshot 2026-06-07 at 8 57 37 PM" src="https://git.fish.foo/attachments/fd4c30c2-eff9-4d08-9b42-82ade9660bb4" /></details> - Export a transaction as PSBT when in Review transaction page <details><summary>Screenshot</summary><img width="1163" height="1028" alt="Screenshot 2026-06-07 at 9 00 00 PM" src="https://git.fish.foo/attachments/308fc307-bd98-455e-bef3-1d34b7755aef" /></details> - Add support to view PSBT files that a wallet can't sign, including multi-sig PSBTs <details><summary>Screenshot</summary>Regular<img width="1163" height="1028" alt="Screenshot 2026-06-07 at 7 59 57 PM" src="https://git.fish.foo/attachments/c37c8faa-9ca6-4b9a-a799-790d2e3e283b" /> Multisig<img width="1163" height="1028" alt="Screenshot 2026-06-07 at 8 22 05 PM" src="https://git.fish.foo/attachments/94ce8eff-7a1f-4d80-b0fc-4f4c6df401a8" /></details> - Broadcast a transaction if it has required signatures <details><summary>screenshot</summary><img width="1163" height="1028" alt="Screenshot 2026-06-07 at 7 59 44 PM" src="https://git.fish.foo/attachments/c5045638-b0b6-482e-b41d-b6b40556604d" /></details> ### Other UI fixes - Introduce a new ContextMenu component that can list options with button with icons, toggle, separator. It replaces `EllipsisMenu` family of controls. Migrate existing menus to use ContextMenu across the app. <details><summary>screenshot</summary><img width="282" height="265" alt="Screenshot 2026-06-07 at 9 08 05 PM" src="https://git.fish.foo/attachments/0a1dc08a-f85c-4269-a16d-fa2ca0d055cf" /><img width="250" height="296" alt="Screenshot 2026-06-07 at 9 08 13 PM" src="https://git.fish.foo/attachments/24f567a9-a003-45f4-b2d2-37feecfd7cf4" /><img width="250" height="275" alt="Screenshot 2026-06-07 at 9 08 23 PM" src="https://git.fish.foo/attachments/7ab223f7-d74e-42ac-b6ed-4cdecbca576f" /><img width="270" height="278" alt="Screenshot 2026-06-07 at 9 08 39 PM" src="https://git.fish.foo/attachments/2602621e-4483-44fb-be1e-c00ee160df32" /></details> - Refine Send and receive page layout <details><summary>screenshot</summary><img width="1163" height="1028" alt="Screenshot 2026-06-07 at 5 11 37 PM" src="https://git.fish.foo/attachments/4a0739d1-cfff-4cce-abc7-855d6b37691c" /><img width="1163" height="1028" alt="Screenshot 2026-06-07 at 9 14 20 PM" src="https://git.fish.foo/attachments/7908bfa7-8dad-44d9-8d68-237d59224909" /></details> - Review Transaction for watch-only wallets <details><summary>screenshot</summary><img width="1163" height="1028" alt="Screenshot 2026-06-07 at 7 58 38 PM" src="https://git.fish.foo/attachments/dc8eb8a4-db6b-4de7-a2e8-9e361dcddcee" /></details> Fixes #662 , #663 , #664, #522, #745
pseudoramdom commented 2026-06-08 04:17:32 +00:00 (Migrated from github.com)
Supersedes https://github.com/bitcoin-core/gui-qml/pull/557
jarolrod (Migrated from github.com) reviewed 2026-06-15 00:51:18 +00:00
jarolrod (Migrated from github.com) commented 2026-06-15 00:51:18 +00:00

we probably need to add the core file size guard here before readAll()

This reads the entire selected file into memory before any validation, and the decode paths also make additional full size copies.

Core defines MAX_FILE_SIZE_PSBT for this, and Qt Widgets rejects oversized PSBT files before loading them.

A very large selected file could freeze or OOM the gui before decode fails.

we probably need to add the core file size guard here before readAll() This reads the entire selected file into memory before any validation, and the decode paths also make additional full size copies. Core defines MAX_FILE_SIZE_PSBT for this, and Qt Widgets rejects oversized PSBT files before loading them. A very large selected file could freeze or OOM the gui before decode fails.
jarolrod (Migrated from github.com) reviewed 2026-06-15 18:45:19 +00:00
jarolrod (Migrated from github.com) commented 2026-06-15 18:45:15 +00:00

I think this drops a valid external signer result in the incomplete case. Core’s external signer notes that FinalizePSBT() “won’t work in a multisig setup”.

Widgets handle this differently: after external signing, signWithExternalSigner() returns success even if FinalizeAndExtractPSBT() leaves complete=false, and SendCoinsDialog then calls presentPSBT(psbtx) so the user can copy/save the partially signed PSBT for the next signer.

Here we emit INCOMPLETE and return before updating m_current_psbt, so the partial signature is discarded; saving afterwards reconstructs an unsigned PSBT.

We should probably for now preserve this behavior. I believe you are working on better multisig support, so maybe you intend this to be intentional for now?

I think this drops a valid external signer result in the incomplete case. Core’s external signer notes that `FinalizePSBT()` “won’t work in a multisig setup”. Widgets handle this differently: after external signing, `signWithExternalSigner()` returns success even if `FinalizeAndExtractPSBT()` leaves `complete=false`, and `SendCoinsDialog` then calls `presentPSBT(psbtx)` so the user can copy/save the partially signed PSBT for the next signer. Here we emit `INCOMPLETE` and return before updating `m_current_psbt`, so the partial signature is discarded; saving afterwards reconstructs an unsigned PSBT. We should probably for now preserve this behavior. I believe you are working on better multisig support, so maybe you intend this to be intentional for now?
jarolrod (Migrated from github.com) commented 2026-06-15 18:35:10 +00:00

We would reject an OP_RETURN output here, and those are quite popular

I'm not sure still why we are imposing extra restrictions on the qml side

We would reject an OP_RETURN output here, and those are quite popular I'm not sure still why we are imposing extra restrictions on the qml side
jarolrod (Migrated from github.com) commented 2026-06-15 18:30:04 +00:00

how come our qml send flow can only support 25 max recipients?

just documenting that the core limit is weight instead of recipients.

I see with send we are imposing a 25 limit as well.

Maybe some documentation on these design choices.

how come our qml send flow can only support 25 max recipients? just documenting that the core limit is weight instead of recipients. I see with send we are imposing a 25 limit as well. Maybe some documentation on these design choices.
pseudoramdom (Migrated from github.com) reviewed 2026-06-15 20:54:28 +00:00
pseudoramdom (Migrated from github.com) commented 2026-06-15 20:54:28 +00:00

This is a good catch. I should've caught this when I ported over the code (from #557)
I'll mirror the qt-widgets check to use MAX_FILE_SIZE_PSBT

This is a good catch. I should've caught this when I ported over the code (from #557) I'll mirror the qt-widgets check to use MAX_FILE_SIZE_PSBT
pseudoramdom (Migrated from github.com) reviewed 2026-06-15 20:56:44 +00:00
pseudoramdom (Migrated from github.com) commented 2026-06-15 20:56:44 +00:00

Will document it.
Something @epicleafies also caught while reviewing https://github.com/bitcoin-core/gui-qml/pull/557/changes#r3370700953

Will document it. Something @epicleafies also caught while reviewing https://github.com/bitcoin-core/gui-qml/pull/557/changes#r3370700953
jarolrod (Migrated from github.com) reviewed 2026-06-15 21:03:08 +00:00
jarolrod (Migrated from github.com) commented 2026-06-15 21:03:08 +00:00

the thing is that this is a new gui restriction on being able to broadcast a psbt; aside from how many recipients we allow during creation. So documentation on why we are adding that new restriction here would be valuable.

A user with many recipients will have to use the rpc, instead of our UI flow

the thing is that this is a new gui restriction on being able to broadcast a psbt; aside from how many recipients we allow during creation. So documentation on why we are adding that new restriction here would be valuable. A user with many recipients will have to use the rpc, instead of our UI flow
pseudoramdom (Migrated from github.com) reviewed 2026-06-15 21:15:11 +00:00
pseudoramdom (Migrated from github.com) commented 2026-06-15 21:15:11 +00:00

Looks like this was inherited from https://github.com/bitcoin-core/gui-qml/pull/450/changes/5fd444135a0f118bab0681036875610d637c960e change.
The limit seems arbitrary to me. I'm okay to drop this limit on GUI.
Unless @johnny9 has more insight on the limit?

Looks like this was inherited from https://github.com/bitcoin-core/gui-qml/pull/450/changes/5fd444135a0f118bab0681036875610d637c960e change. The limit seems arbitrary to me. I'm okay to drop this limit on GUI. Unless @johnny9 has more insight on the limit?
pseudoramdom (Migrated from github.com) reviewed 2026-06-16 05:22:00 +00:00
pseudoramdom (Migrated from github.com) commented 2026-06-16 05:22:00 +00:00

Ah! I previously hit a bug while testing wherein we'd sign automatically before exporting the PSBT. I might've regressed this there.
I changed the flow to preserve the externally signed PSBT when signing succeeds but the PSBT remains incomplete.

Ah! I previously hit a bug while testing wherein we'd sign automatically before exporting the PSBT. I might've regressed this there. I changed the flow to preserve the externally signed PSBT when signing succeeds but the PSBT remains incomplete.
jarolrod (Migrated from github.com) reviewed 2026-06-17 18:32:23 +00:00
jarolrod (Migrated from github.com) commented 2026-06-17 18:32:23 +00:00

it looks like this is making the linux ci task fail because we switched to a real mouseClick, but the row is not created under a visible item. The click never reaches the note button, so editRequested stays false.

It should be enough to make the test case visible and put the row under a visible host item.

like so:

diff --git a/test/qml/tst_address_components.qml b/test/qml/tst_address_components.qml
index 6ba2baeb9a..c2365759c5 100644
--- a/test/qml/tst_address_components.qml
+++ b/test/qml/tst_address_components.qml
@@ -13,6 +13,13 @@ TestCase {
     when: windowShown
     width: 720
     height: 480
+    visible: true
+
+    Item {
+        id: host
+        width: parent.width
+        height: parent.height
+    }
 
     function findObject(root, objectName) {
         if (!root) {
@@ -80,7 +87,7 @@ TestCase {
     }
 
     function test_row_uses_display_amount_and_emits_actions() {
-        const row = createTemporaryObject(rowComponent, this)
+        const row = createTemporaryObject(rowComponent, host)
         verify(row !== null)
 
         const amountText = findObject(row, "addressRowAmountText")

Maybe there is a more elegant fix.

it looks like this is making the linux ci task fail because we switched to a real mouseClick, but the row is not created under a visible item. The click never reaches the note button, so editRequested stays false. It should be enough to make the test case visible and put the row under a visible host item. like so: <details> ```diff diff --git a/test/qml/tst_address_components.qml b/test/qml/tst_address_components.qml index 6ba2baeb9a..c2365759c5 100644 --- a/test/qml/tst_address_components.qml +++ b/test/qml/tst_address_components.qml @@ -13,6 +13,13 @@ TestCase { when: windowShown width: 720 height: 480 + visible: true + + Item { + id: host + width: parent.width + height: parent.height + } function findObject(root, objectName) { if (!root) { @@ -80,7 +87,7 @@ TestCase { } function test_row_uses_display_amount_and_emits_actions() { - const row = createTemporaryObject(rowComponent, this) + const row = createTemporaryObject(rowComponent, host) verify(row !== null) const amountText = findObject(row, "addressRowAmountText") ``` </details> Maybe there is a more elegant fix.
jarolrod (Migrated from github.com) reviewed 2026-06-17 19:53:35 +00:00
jarolrod (Migrated from github.com) commented 2026-06-17 19:53:35 +00:00

I think this should store the original imported PSBT, not analysis_psbt.

analysis_psbt has already gone through FinalizePSBT() above, and that call mutates the PSBT.

For a complete-but-not-finalized PSBT, finalization moves data into the final script fields and clears fields like partial_sigs, keypaths, and scripts. So if the user only imports/reviews the PSBT and then clicks “Save transaction”, they can get back a different PSBT than the one they imported.

I added a local regression test for this with a complete unfinalized 2-of-2 P2WSH PSBT. It imports the PSBT, saves it without signing/broadcasting, then reloads it. On this branch the saved PSBT has 0 partial sigs, while the original has 2.

see:

diff --git a/test/test_walletqmlmodel.cpp b/test/test_walletqmlmodel.cpp
index 274f20a5ea..0e0a67f9e8 100644
--- a/test/test_walletqmlmodel.cpp
+++ b/test/test_walletqmlmodel.cpp
@@ -467,6 +467,7 @@ private Q_SLOTS:
     void externalSignerApprovalKeepsIncompleteSignedPsbt();
     void importPsbtFromFile_opensForeignUnsignedPsbtForReviewOnly();
     void importPsbtFromFile_broadcastsCompleteForeignMultisigPsbt();
+    void saveCompleteBroadcastableImportedPsbt_preservesOriginalPsbt();
     void importPsbtFromFile_opensUnsignedMultisigPsbtForReviewOnly();
     void importPsbtFromFile_blocksBroadcastWhenFeeIsInvalid();
     void importPsbtFromFile_returnsTransactionAlreadyKnownWhenTxIsInWallet();
@@ -2330,6 +2331,81 @@ void WalletQmlModelTests::importPsbtFromFile_broadcastsCompleteForeignMultisigPs
     QVERIFY(model->transactionError().isEmpty());
 }
 
+void WalletQmlModelTests::saveCompleteBroadcastableImportedPsbt_preservesOriginalPsbt()
+{
+    NiceMock<MockNode> node;
+    FakePasswordWallet* wallet{nullptr};
+    auto model = MakeWalletModel(wallet, &node);
+
+    wallet->fill_psbt_fn = [wallet](std::optional<int>,
+                                    bool sign,
+                                    bool,
+                                    size_t* n_signed,
+                                    PartiallySignedTransaction&,
+                                    bool& complete) {
+        wallet->fill_psbt_sign_args.push_back(sign);
+        if (n_signed) {
+            *n_signed = 0;
+        }
+        complete = false;
+        return std::nullopt;
+    };
+
+    CKey key1;
+    CKey key2;
+    key1.MakeNewKey(true);
+    key2.MakeNewKey(true);
+    const CScript witness_script{GetScriptForMultisig(2, {key1.GetPubKey(), key2.GetPubKey()})};
+
+    CMutableTransaction mtx;
+    mtx.vin.emplace_back(COutPoint{Txid::FromUint256(uint256::ONE), 0});
+    mtx.vout.emplace_back(1'500, GetScriptForDestination(DecodeDestination(VALID_MAINNET_ADDRESS.toStdString())));
+
+    PartiallySignedTransaction psbt{mtx};
+    psbt.inputs[0].witness_utxo = CTxOut{2'000, GetScriptForDestination(WitnessV0ScriptHash(witness_script))};
+    psbt.inputs[0].witness_script = witness_script;
+
+    FillableSigningProvider provider;
+    QVERIFY(provider.AddCScript(witness_script));
+    QVERIFY(provider.AddKey(key1));
+    QVERIFY(provider.AddKey(key2));
+
+    const PrecomputedTransactionData txdata{PrecomputePSBTData(psbt)};
+    QCOMPARE(
+        SignPSBTInput(provider, psbt, 0, &txdata, std::nullopt, nullptr, /*finalize=*/false),
+        PSBTError::OK);
+
+    QVERIFY(!psbt.inputs[0].partial_sigs.empty());
+    QVERIFY(!psbt.inputs[0].witness_script.empty());
+    QVERIFY(psbt.inputs[0].final_script_witness.IsNull());
+
+    PartiallySignedTransaction finalized_copy{psbt};
+    QVERIFY(FinalizePSBT(finalized_copy));
+    QVERIFY(finalized_copy.inputs[0].partial_sigs.empty());
+    QVERIFY(finalized_copy.inputs[0].witness_script.empty());
+    QVERIFY(!finalized_copy.inputs[0].final_script_witness.IsNull());
+
+    QTemporaryDir temp_dir;
+    QVERIFY(temp_dir.isValid());
+    const QString source_path{WritePsbt(psbt, temp_dir, QStringLiteral("complete-unfinalized.psbt"))};
+    QVERIFY(!source_path.isEmpty());
+
+    QCOMPARE(model->importPsbtFromFile(source_path), WalletQmlModel::PsbtImportResult::WalletCannotSign);
+    QVERIFY(!model->currentTransactionCanSend());
+    QVERIFY(model->currentTransactionCanBroadcast());
+
+    const QString saved_path{temp_dir.filePath(QStringLiteral("saved.psbt"))};
+    QCOMPARE(model->saveCurrentTransactionAsPsbt(saved_path), QString{});
+
+    PartiallySignedTransaction saved;
+    QCOMPARE(PsbtQmlModel::LoadPsbtFromFile(saved_path, saved), QString{});
+
+    QCOMPARE(saved.inputs[0].partial_sigs.size(), psbt.inputs[0].partial_sigs.size());
+    QVERIFY(saved.inputs[0].witness_script == psbt.inputs[0].witness_script);
+    QVERIFY(saved.inputs[0].final_script_witness.IsNull());
+    QCOMPARE(PsbtQmlModel::SerializePsbtRaw(saved), PsbtQmlModel::SerializePsbtRaw(psbt));
+}
+
 void WalletQmlModelTests::importPsbtFromFile_opensUnsignedMultisigPsbtForReviewOnly()
 {
     FakePasswordWallet* wallet{nullptr};

A possible fix is keep using analysis_psbt as a temporary scratch copy for FinalizePSBT(), AnalyzePSBT(), fee checks, and can_broadcast, but keep/store the original imported psbt for passive save/export.

Broadcasting can still finalize/extract from a temporary copy.

I think this issue is hairy, and is tangentially related to how, currently, the gui PSBT usage implementation differs from the internal core PSBT wallet possible operations/possible outputs.

I think this should store the original imported PSBT, not `analysis_psbt`. `analysis_psbt` has already gone through `FinalizePSBT()` above, and that call mutates the PSBT. For a complete-but-not-finalized PSBT, finalization moves data into the final script fields and clears fields like `partial_sigs`, keypaths, and scripts. So if the user only imports/reviews the PSBT and then clicks “Save transaction”, they can get back a different PSBT than the one they imported. I added a local regression test for this with a complete unfinalized 2-of-2 P2WSH PSBT. It imports the PSBT, saves it without signing/broadcasting, then reloads it. On this branch the saved PSBT has 0 partial sigs, while the original has 2. see: <details> ```diff diff --git a/test/test_walletqmlmodel.cpp b/test/test_walletqmlmodel.cpp index 274f20a5ea..0e0a67f9e8 100644 --- a/test/test_walletqmlmodel.cpp +++ b/test/test_walletqmlmodel.cpp @@ -467,6 +467,7 @@ private Q_SLOTS: void externalSignerApprovalKeepsIncompleteSignedPsbt(); void importPsbtFromFile_opensForeignUnsignedPsbtForReviewOnly(); void importPsbtFromFile_broadcastsCompleteForeignMultisigPsbt(); + void saveCompleteBroadcastableImportedPsbt_preservesOriginalPsbt(); void importPsbtFromFile_opensUnsignedMultisigPsbtForReviewOnly(); void importPsbtFromFile_blocksBroadcastWhenFeeIsInvalid(); void importPsbtFromFile_returnsTransactionAlreadyKnownWhenTxIsInWallet(); @@ -2330,6 +2331,81 @@ void WalletQmlModelTests::importPsbtFromFile_broadcastsCompleteForeignMultisigPs QVERIFY(model->transactionError().isEmpty()); } +void WalletQmlModelTests::saveCompleteBroadcastableImportedPsbt_preservesOriginalPsbt() +{ + NiceMock<MockNode> node; + FakePasswordWallet* wallet{nullptr}; + auto model = MakeWalletModel(wallet, &node); + + wallet->fill_psbt_fn = [wallet](std::optional<int>, + bool sign, + bool, + size_t* n_signed, + PartiallySignedTransaction&, + bool& complete) { + wallet->fill_psbt_sign_args.push_back(sign); + if (n_signed) { + *n_signed = 0; + } + complete = false; + return std::nullopt; + }; + + CKey key1; + CKey key2; + key1.MakeNewKey(true); + key2.MakeNewKey(true); + const CScript witness_script{GetScriptForMultisig(2, {key1.GetPubKey(), key2.GetPubKey()})}; + + CMutableTransaction mtx; + mtx.vin.emplace_back(COutPoint{Txid::FromUint256(uint256::ONE), 0}); + mtx.vout.emplace_back(1'500, GetScriptForDestination(DecodeDestination(VALID_MAINNET_ADDRESS.toStdString()))); + + PartiallySignedTransaction psbt{mtx}; + psbt.inputs[0].witness_utxo = CTxOut{2'000, GetScriptForDestination(WitnessV0ScriptHash(witness_script))}; + psbt.inputs[0].witness_script = witness_script; + + FillableSigningProvider provider; + QVERIFY(provider.AddCScript(witness_script)); + QVERIFY(provider.AddKey(key1)); + QVERIFY(provider.AddKey(key2)); + + const PrecomputedTransactionData txdata{PrecomputePSBTData(psbt)}; + QCOMPARE( + SignPSBTInput(provider, psbt, 0, &txdata, std::nullopt, nullptr, /*finalize=*/false), + PSBTError::OK); + + QVERIFY(!psbt.inputs[0].partial_sigs.empty()); + QVERIFY(!psbt.inputs[0].witness_script.empty()); + QVERIFY(psbt.inputs[0].final_script_witness.IsNull()); + + PartiallySignedTransaction finalized_copy{psbt}; + QVERIFY(FinalizePSBT(finalized_copy)); + QVERIFY(finalized_copy.inputs[0].partial_sigs.empty()); + QVERIFY(finalized_copy.inputs[0].witness_script.empty()); + QVERIFY(!finalized_copy.inputs[0].final_script_witness.IsNull()); + + QTemporaryDir temp_dir; + QVERIFY(temp_dir.isValid()); + const QString source_path{WritePsbt(psbt, temp_dir, QStringLiteral("complete-unfinalized.psbt"))}; + QVERIFY(!source_path.isEmpty()); + + QCOMPARE(model->importPsbtFromFile(source_path), WalletQmlModel::PsbtImportResult::WalletCannotSign); + QVERIFY(!model->currentTransactionCanSend()); + QVERIFY(model->currentTransactionCanBroadcast()); + + const QString saved_path{temp_dir.filePath(QStringLiteral("saved.psbt"))}; + QCOMPARE(model->saveCurrentTransactionAsPsbt(saved_path), QString{}); + + PartiallySignedTransaction saved; + QCOMPARE(PsbtQmlModel::LoadPsbtFromFile(saved_path, saved), QString{}); + + QCOMPARE(saved.inputs[0].partial_sigs.size(), psbt.inputs[0].partial_sigs.size()); + QVERIFY(saved.inputs[0].witness_script == psbt.inputs[0].witness_script); + QVERIFY(saved.inputs[0].final_script_witness.IsNull()); + QCOMPARE(PsbtQmlModel::SerializePsbtRaw(saved), PsbtQmlModel::SerializePsbtRaw(psbt)); +} + void WalletQmlModelTests::importPsbtFromFile_opensUnsignedMultisigPsbtForReviewOnly() { FakePasswordWallet* wallet{nullptr}; ``` </details> A possible fix is keep using `analysis_psbt` as a temporary scratch copy for `FinalizePSBT()`, `AnalyzePSBT()`, fee checks, and `can_broadcast`, but keep/store the original imported `psbt` for passive save/export. Broadcasting can still finalize/extract from a temporary copy. I think this issue is hairy, and is tangentially related to how, currently, the gui PSBT usage implementation differs from the internal core PSBT wallet possible operations/possible outputs.
jarolrod (Migrated from github.com) reviewed 2026-06-17 19:54:33 +00:00
jarolrod (Migrated from github.com) commented 2026-06-17 19:54:33 +00:00

Also, maybe we should add more tests for PSBT operations in this PR. Another one we can add is the oversized PSBT one we previously found.

Also, maybe we should add more tests for PSBT operations in this PR. Another one we can add is the oversized PSBT one we previously found.
jarolrod (Migrated from github.com) reviewed 2026-06-19 16:11:53 +00:00
jarolrod (Migrated from github.com) commented 2026-06-19 16:11:53 +00:00

I took some more time to think about what was going on here, and I think overall we need to revisit some invariants.

Let's think of the possible user roles in a PSBT's lifecycle:

flowchart LR
    A["Creator"] --> B["Updater"]
    B --> C["Signer"]
    C --> D["Combiner"]
    D --> E["Finalizer"]
    E --> F["Extractor"]
    F --> G["Broadcaster"]

The QML Send form is one possible user role. Imported PSBTs arrive at any later stage: unsigned, partially signed, fully signed but not finalized, finalized, foreign, watch-only, multisig, external-signer, or broadcast-only.

That means imported PSBT review cannot depend on the editable SendRecipient model. Recipient rows are draft construction state. Imported PSBT outputs are review session state.

For wallet-created transactions, the current Send flow makes sense:

flowchart TD
    A["User edits recipients and fee"] --> B["Wallet creates funded transaction"]
    B --> C["Review Send draft"]
    C --> D{"User action"}
    D --> E["Save unsigned PSBT"]
    D --> F["Sign and wallet commit"]
    D --> G["External signer approval"]
    G --> H{"Complete?"}
    H -- "yes" --> F
    H -- "no" --> I["Save partially signed PSBT"]

But imported PSBTs need a different lifecycle:

flowchart TD
    A["Import PSBT"] --> B["Decode and validate shape"]
    B --> C["Create imported PSBT session"]
    C --> D["Analyze copies only"]
    D --> E["Render all outputs read-only"]
    E --> F{"Capabilities"}
    F -- "wallet can sign" --> G["Sign transaction"]
    F -- "complete and fee known" --> H["Broadcast transaction"]
    F -- "incomplete or foreign" --> I["Save / Done"]
    G --> J{"Still incomplete?"}
    J -- "yes" --> K["Save partial signature"]
    J -- "no" --> H
    H --> L["Finalize/extract copy"]
    L --> M["Node broadcast"]

The key point is object ownership. Passive review should not mutate the PSBT the user later saves.

Core finalization is intentionally mutating: it can move partial signatures and scripts into final script fields and clear the original partial data.

So the imported session needs separate concepts:

  • original_psbt: the exact imported PSBT.
  • current_psbt: the working PSBT after explicit user actions.
  • save_psbt: what Save exports.
  • Analysis, finalization, and broadcast copies: temporary objects only.

That gives us the right behavior:

  • Save before signing preserves the original.
  • Signing updates the saveable PSBT with new signatures.
  • Partial signatures are useful output and remain saveable.
  • Broadcast finalizes and extracts a temporary copy.
  • Broadcast does not rewrite the saved PSBT as a side effect.

The same split fixes the output issue we've been having.

A valid PSBT can contain OP_RETURN, unknown scripts, wallet owned outputs, many outputs, or outputs that do not convert to addresses. Those are not reasons to reject import or broadcast. They are review and display concerns.

flowchart TD
    A["PSBT output"] --> B{"ExtractDestination works?"}
    B -- "yes" --> C["Address row"]
    B -- "no" --> D{"IsUnspendable?"}
    D -- "yes" --> E["Data output row"]
    D -- "no" --> F["Unknown script row"]
    F --> G{"value > 0?"}
    G -- "yes" --> H["Show warning before sign/broadcast"]
    G -- "no" --> I["Render script detail"]

The UI does not need to become a full transaction editor in this PR. It just needs to faithfully represent the imported PSBT session.

The minimum target architecture I would recommend for this PR should be:

  1. Wallet created Send draft session stays editable and uses wallet commit for Send.
  2. Imported PSBT review is read-only and uses PSBT output rows.
  3. Imported PSBT Save preserves the original until the user explicitly signs.
  4. Imported PSBT Sign mutates the session PSBT and keeps partial results saveable.
  5. Imported PSBT Broadcast uses Core finalization and extraction on a copy, then node broadcast.
  6. Imported PSBT Broadcast never calls wallet commit.
  7. Unknown and proprietary fields are preserved.
  8. Unknown positive value scripts bring up a warning (like sparrow wallet does), but do not block anything. OP_RETURN is addressless and normally zero-value, so it should render as a data output without becoming a scary failure.

This transaction has one or more positive-value outputs that cannot be shown as a Bitcoin address. Review the script details before signing or broadcasting.

So I think the original PR branch should move toward this shape rather than adding more exceptions around the existing Send recipient path. The branch is trying to add PSBT import, export, inspect, sign, and broadcast -> and we should think about those in terms of creation and import PSBT session operations.

How I would adapt the current branch

The target state should look like this:

flowchart TD
    A["WalletQmlModel::importPsbtFromFile"] --> B["Decode PSBT"]
    B --> C{"Known wallet tx?"}
    C -- "yes" --> D["TransactionAlreadyKnown"]
    C -- "no" --> E["Create ImportedPsbtSession"]
    E --> F["Analyze temporary PSBT copies"]
    F --> G["Build read-only PSBT output rows"]
    G --> H["Return PsbtImportedForReview"]
    H --> I["Send.qml opens inspection review"]
    I --> J{"Session capabilities"}
    J -- "can_sign" --> K["Show Sign transaction"]
    J -- "can_broadcast" --> L["Show Broadcast transaction"]
    J -- "neither" --> M["Show Save / Done with review message"]

The model changes should be organized around an imported session object rather than around populated Send recipients. I would add a small private session type in WalletQmlModel with these fields:

  • original_psbt: the exact PSBT loaded from disk.
  • current_psbt: the working PSBT after explicit user actions.
  • save_psbt: the PSBT that Save transaction writes.
  • can_sign: whether the selected wallet can add signatures now.
  • can_broadcast: whether Core can extract a final transaction with a known nonnegative fee.
  • review_message: fee, multisig, cannot-sign, or unknown-script warning text.

The important implementation rule related to my original comment here is that we use review copies:

flowchart LR
    A["original_psbt"] --> B["save_psbt"]
    A --> C["analysis copy"]
    C --> D["fillPSBT sign=false bip32derivs=false"]
    C --> E["AnalyzePSBT"]
    C --> F["FinalizeAndExtractPSBT"]
    B --> G["Save transaction"]
I took some more time to think about what was going on here, and I think overall we need to revisit some invariants. Let's think of the possible user roles in a PSBT's lifecycle: ```mermaid flowchart LR A["Creator"] --> B["Updater"] B --> C["Signer"] C --> D["Combiner"] D --> E["Finalizer"] E --> F["Extractor"] F --> G["Broadcaster"] ``` The QML Send form is **one** possible user role. Imported PSBTs arrive at any later stage: unsigned, partially signed, fully signed but not finalized, finalized, foreign, watch-only, multisig, external-signer, or broadcast-only. That means imported PSBT review **cannot** depend on the editable `SendRecipient` model. Recipient rows are draft construction state. Imported PSBT outputs are review session state. For wallet-created transactions, the current Send flow makes sense: ```mermaid flowchart TD A["User edits recipients and fee"] --> B["Wallet creates funded transaction"] B --> C["Review Send draft"] C --> D{"User action"} D --> E["Save unsigned PSBT"] D --> F["Sign and wallet commit"] D --> G["External signer approval"] G --> H{"Complete?"} H -- "yes" --> F H -- "no" --> I["Save partially signed PSBT"] ``` But imported PSBTs need a different lifecycle: ```mermaid flowchart TD A["Import PSBT"] --> B["Decode and validate shape"] B --> C["Create imported PSBT session"] C --> D["Analyze copies only"] D --> E["Render all outputs read-only"] E --> F{"Capabilities"} F -- "wallet can sign" --> G["Sign transaction"] F -- "complete and fee known" --> H["Broadcast transaction"] F -- "incomplete or foreign" --> I["Save / Done"] G --> J{"Still incomplete?"} J -- "yes" --> K["Save partial signature"] J -- "no" --> H H --> L["Finalize/extract copy"] L --> M["Node broadcast"] ``` The key point is object ownership. Passive review should not mutate the PSBT the user later saves. Core finalization is intentionally mutating: it can move partial signatures and scripts into final script fields and clear the original partial data. So the imported session needs separate concepts: - `original_psbt`: the exact imported PSBT. - `current_psbt`: the working PSBT after explicit user actions. - `save_psbt`: what Save exports. - Analysis, finalization, and broadcast copies: temporary objects only. That gives us the right behavior: - Save before signing preserves the original. - Signing updates the saveable PSBT with new signatures. - Partial signatures are useful output and remain saveable. - Broadcast finalizes and extracts a temporary copy. - Broadcast does not rewrite the saved PSBT as a side effect. **The same split fixes the output issue we've been having.** A valid PSBT can contain `OP_RETURN`, unknown scripts, wallet owned outputs, many outputs, or outputs that do not convert to addresses. Those are not reasons to reject import or broadcast. They are review and display concerns. ```mermaid flowchart TD A["PSBT output"] --> B{"ExtractDestination works?"} B -- "yes" --> C["Address row"] B -- "no" --> D{"IsUnspendable?"} D -- "yes" --> E["Data output row"] D -- "no" --> F["Unknown script row"] F --> G{"value > 0?"} G -- "yes" --> H["Show warning before sign/broadcast"] G -- "no" --> I["Render script detail"] ``` The UI does not need to become a full transaction editor in this PR. It just needs to faithfully represent the imported PSBT session. The minimum target architecture I would recommend for this PR should be: 1. Wallet created Send draft session stays editable and uses wallet commit for Send. 2. Imported PSBT review is read-only and uses PSBT output rows. 3. Imported PSBT **Save** preserves the original until the user explicitly signs. 4. Imported PSBT **Sign** mutates the session PSBT and keeps partial results saveable. 5. Imported PSBT **Broadcast** uses Core finalization and extraction on a copy, then node broadcast. 6. Imported PSBT **Broadcast** never calls wallet commit. 7. Unknown and proprietary fields are preserved. 8. Unknown positive value scripts bring up a warning (like sparrow wallet does), but do not block anything. `OP_RETURN` is addressless and normally zero-value, so it should render as a data output without becoming a scary failure. > This transaction has one or more positive-value outputs that cannot be shown as a Bitcoin address. Review the script details before signing or broadcasting. So I think the original PR branch should move toward this shape rather than adding more exceptions around the existing Send recipient path. The branch is trying to add PSBT import, export, inspect, sign, and broadcast -> and we should think about those in terms of creation and import PSBT session operations. ## How I would adapt the current branch The target state should look like this: ```mermaid flowchart TD A["WalletQmlModel::importPsbtFromFile"] --> B["Decode PSBT"] B --> C{"Known wallet tx?"} C -- "yes" --> D["TransactionAlreadyKnown"] C -- "no" --> E["Create ImportedPsbtSession"] E --> F["Analyze temporary PSBT copies"] F --> G["Build read-only PSBT output rows"] G --> H["Return PsbtImportedForReview"] H --> I["Send.qml opens inspection review"] I --> J{"Session capabilities"} J -- "can_sign" --> K["Show Sign transaction"] J -- "can_broadcast" --> L["Show Broadcast transaction"] J -- "neither" --> M["Show Save / Done with review message"] ``` The model changes should be organized around an imported session object rather than around populated Send recipients. I would add a small private session type in `WalletQmlModel` with these fields: - `original_psbt`: the exact PSBT loaded from disk. - `current_psbt`: the working PSBT after explicit user actions. - `save_psbt`: the PSBT that `Save transaction` writes. - `can_sign`: whether the selected wallet can add signatures now. - `can_broadcast`: whether Core can extract a final transaction with a known nonnegative fee. - `review_message`: fee, multisig, cannot-sign, or unknown-script warning text. The important implementation rule related to my original comment here is that we use review copies: ```mermaid flowchart LR A["original_psbt"] --> B["save_psbt"] A --> C["analysis copy"] C --> D["fillPSBT sign=false bip32derivs=false"] C --> E["AnalyzePSBT"] C --> F["FinalizeAndExtractPSBT"] B --> G["Save transaction"] ```
pseudoramdom (Migrated from github.com) reviewed 2026-06-19 20:27:01 +00:00
pseudoramdom (Migrated from github.com) commented 2026-06-19 20:27:01 +00:00

Thanks for the detailed review. The diagrams were helpful.
I agree that send-recipient is probably overloaded here and that imported PSBT operations should eventually move into a separate review/session model rather than being projected into send-draft state.

As a middle ground for this PR, I’m planning to keep the current review flow, but change the saveable PSBT state so it preserves the original imported PSBT.

analysis_psbt will stay as a scrattch copy for FinalizePSBT(), fillPSBT(sign=false), fee analysis etc, but it won’t be stored in m_current_psbt.
For imported PSBTs, saveCurrentTransactionAsPsbt() will write the retained original directly, so passive review + save won’t finalize or otherwise rewrite the imported PSBT.

Thanks for the detailed review. The diagrams were helpful. I agree that send-recipient is probably overloaded here and that imported PSBT operations should eventually move into a separate review/session model rather than being projected into send-draft state. As a middle ground for this PR, I’m planning to keep the current review flow, but change the saveable PSBT state so it preserves the original imported PSBT. `analysis_psbt` will stay as a scrattch copy for `FinalizePSBT()`, `fillPSBT(sign=false)`, fee analysis etc, but it won’t be stored in `m_current_psbt`. For imported PSBTs, `saveCurrentTransactionAsPsbt()` will write the retained original directly, so passive review + save won’t finalize or otherwise rewrite the imported PSBT.
pseudoramdom (Migrated from github.com) reviewed 2026-06-19 22:33:20 +00:00
pseudoramdom (Migrated from github.com) commented 2026-06-19 22:33:20 +00:00

Thanks! Should be fixed now

Thanks! Should be fixed now
jarolrod commented 2026-06-19 22:40:25 +00:00 (Migrated from github.com)

ACK 1113aa9d31

In a reduced-scope, this is okay to merge. Will open issues for what is left to address.

ACK 1113aa9d31ae621ba5055c47c76710b6cca18a97 In a reduced-scope, this is okay to merge. Will open issues for what is left to address.
epicleafies (Migrated from github.com) reviewed 2026-06-23 20:46:46 +00:00
epicleafies (Migrated from github.com) left a comment

Concept ACK, found 2 blockers. Was able to run all automated tests and look over code but because of 1st blocker wasn't able to manually test behavior in the gui. The main issues are below, the smaller ones are inline.

Blocker: navigating to the Send tab crashes on Qt 6.4.2. Not sure if any later Qt versions are affected, my understanding was 6.4 is the minimum Qt version. Root cause: AlertPopup.qml nests a Repeater directly inside a Quick RowLayout (contentItem ColumnLayout -> RowLayout -> Repeater over visibleActions), and Component.onCompleted: refreshActions() swaps the visibleActions model during construction. This PR adds three AlertPopup instances to the Send page (broadcastSuccessPopup, unsupportedPsbtPopup, knownPsbtTxPopup), which lay out on Send-tab navigation; on Qt 6.4.x the Repeater rebuilds its delegates while the RowLayout does its first rearrange, so QQuickLayout::effectiveSizePolicy_helper (qquicklayout.cpp:1188) runs qobject_cast<QQuickLayout*> on a freed delegate and SIGSEGVs. It reproduces under a real windowing backend (xcb/wayland) but not offscreen, which is why the offscreen functional harness on the Qt 6.4.2 CI runner stays green even on the Send tests.

Blocker: the new functional test is not wired into CI. test/functional/qml_test_psbt.py wasn't added to .github/workflows/gui-functional-tests.yml

Architecture (meta): one addition to jarolrod's PSBT-lifecycle thread is the extracted PsbtQmlModel's stateful methods (sign/broadcast/refreshState/save/copy) are reachable only from unit tests, not the UI, so the refreshState finalize bug below sits in code the app never runs today, though it will once that follow-up wires it up.

Concept ACK, found 2 blockers. Was able to run all automated tests and look over code but because of 1st blocker wasn't able to manually test behavior in the gui. The main issues are below, the smaller ones are inline. Blocker: navigating to the Send tab crashes on Qt 6.4.2. Not sure if any later Qt versions are affected, my understanding was 6.4 is the minimum Qt version. Root cause: AlertPopup.qml nests a Repeater directly inside a Quick RowLayout (contentItem ColumnLayout -> RowLayout -> Repeater over visibleActions), and Component.onCompleted: refreshActions() swaps the visibleActions model during construction. This PR adds three AlertPopup instances to the Send page (broadcastSuccessPopup, unsupportedPsbtPopup, knownPsbtTxPopup), which lay out on Send-tab navigation; on Qt 6.4.x the Repeater rebuilds its delegates while the RowLayout does its first rearrange, so QQuickLayout::effectiveSizePolicy_helper (qquicklayout.cpp:1188) runs qobject_cast<QQuickLayout*> on a freed delegate and SIGSEGVs. It reproduces under a real windowing backend (xcb/wayland) but not offscreen, which is why the offscreen functional harness on the Qt 6.4.2 CI runner stays green even on the Send tests. Blocker: the new functional test is not wired into CI. test/functional/qml_test_psbt.py wasn't added to .github/workflows/gui-functional-tests.yml Architecture (meta): one addition to jarolrod's PSBT-lifecycle thread is the extracted PsbtQmlModel's stateful methods (sign/broadcast/refreshState/save/copy) are reachable only from unit tests, not the UI, so the refreshState finalize bug below sits in code the app never runs today, though it will once that follow-up wires it up.
epicleafies (Migrated from github.com) commented 2026-06-23 19:47:04 +00:00

Nit (a11y, raised on #557): this interactive row sets Accessible.checkable/checked but no Accessible.name/Accessible.role. ContextMenuButton sets Accessible.role: Accessible.MenuItem and Accessible.name: text; mirror that here.

Nit (a11y, raised on #557): this interactive row sets `Accessible.checkable`/`checked` but no `Accessible.name`/`Accessible.role`. `ContextMenuButton` sets `Accessible.role: Accessible.MenuItem` and `Accessible.name: text`; mirror that here.
epicleafies (Migrated from github.com) commented 2026-06-23 19:47:04 +00:00

Nit (raised on #557): FormatBtc hardcodes the BTC unit, ignoring the user's display setting, and it is only reached by the unused buildSummary. Remove it together with that code, or, if the summary path gets wired up later, format via the active display unit instead of hardcoding BTC.

Nit (raised on #557): `FormatBtc` hardcodes the BTC unit, ignoring the user's display setting, and it is only reached by the unused `buildSummary`. Remove it together with that code, or, if the summary path gets wired up later, format via the active display unit instead of hardcoding BTC.
epicleafies (Migrated from github.com) commented 2026-06-23 19:47:04 +00:00

Nit (raised on #557): this copies the QByteArray byte-by-byte. You can span it directly (std::as_bytes over bytes.constData()/bytes.size()) and drop the loop.

Nit (raised on #557): this copies the `QByteArray` byte-by-byte. You can span it directly (`std::as_bytes` over `bytes.constData()`/`bytes.size()`) and drop the loop.
epicleafies (Migrated from github.com) commented 2026-06-23 19:47:04 +00:00

Nit: MAX_FILE_SIZE_PSBT is 100,000,000 bytes (100 MB, ~95.4 MiB), so the message should say 100 MB.

        return tr("PSBT file must be smaller than 100 MB");
Nit: `MAX_FILE_SIZE_PSBT` is 100,000,000 bytes (100 MB, ~95.4 MiB), so the message should say 100 MB. ```suggestion return tr("PSBT file must be smaller than 100 MB"); ```
epicleafies (Migrated from github.com) commented 2026-06-23 19:47:04 +00:00

Nit: loadFromFile does not reset m_matched_txid on the success path (only clear()/setError() do), so a stale matched-txid can survive a reload. Low impact since the wallet flow clears the model on success, but resetting it on load makes the model self-consistent regardless of caller order.

Nit: `loadFromFile` does not reset `m_matched_txid` on the success path (only `clear()`/`setError()` do), so a stale matched-txid can survive a reload. Low impact since the wallet flow clears the model on success, but resetting it on load makes the model self-consistent regardless of caller order.
epicleafies (Migrated from github.com) commented 2026-06-23 19:47:04 +00:00

Suggestion (latent correctness, root cause): FinalizePSBT(*m_psbt) mutates the stored PSBT. FinalizePSBT is destructive (it clears partial_sigs/redeem_script/witness_script into the final scripts for any finalizable input), so a later saveToFile/copyToClipboard emits a finalized PSBT rather than the imported one, dropping combiner-relevant fields for a complete-but-not-finalized or partially-signed PSBT. This is the same bug class fixed in the wallet path (finalize a copy, keep the original); apply it here too: compute state on a local copy and leave m_psbt untouched. Only reachable from unit tests today, but a landmine once this model is wired to the UI.

Suggestion (latent correctness, root cause): `FinalizePSBT(*m_psbt)` mutates the stored PSBT. `FinalizePSBT` is destructive (it clears `partial_sigs`/`redeem_script`/`witness_script` into the final scripts for any finalizable input), so a later `saveToFile`/`copyToClipboard` emits a finalized PSBT rather than the imported one, dropping combiner-relevant fields for a complete-but-not-finalized or partially-signed PSBT. This is the same bug class fixed in the wallet path (finalize a copy, keep the original); apply it here too: compute state on a local copy and leave `m_psbt` untouched. Only reachable from unit tests today, but a landmine once this model is wired to the UI.
epicleafies (Migrated from github.com) commented 2026-06-23 19:47:04 +00:00

Question (raised on #557): > 25 is a bare magic number, and this is a new GUI-only restriction on broadcasting an imported PSBT (more recipients forces the user to the RPC). If kept, name it (e.g. MAX_REVIEWABLE_RECIPIENTS) with a one-line rationale, or reference the send-side cap if this is meant to mirror it, so the two cannot drift.

Question (raised on #557): `> 25` is a bare magic number, and this is a new GUI-only restriction on broadcasting an imported PSBT (more recipients forces the user to the RPC). If kept, name it (e.g. `MAX_REVIEWABLE_RECIPIENTS`) with a one-line rationale, or reference the send-side cap if this is meant to mirror it, so the two cannot drift.
epicleafies (Migrated from github.com) commented 2026-06-23 19:47:04 +00:00

Blocker (crash, headed on Qt 6.4.x): this AlertPopup, and the two siblings this PR adds on the Send page (unsupportedPsbtPopup, knownPsbtTxPopup), crash the app when navigating to the Send tab. AlertPopup.qml nests a Repeater directly inside a Quick RowLayout (contentItem ColumnLayout -> RowLayout -> Repeater over visibleActions), and Component.onCompleted: refreshActions() swaps the visibleActions model during construction. On Qt 6.4.x the Repeater rebuilds its delegates while the RowLayout does its first rearrange on Send-tab navigation, so QQuickLayout::effectiveSizePolicy_helper (qquicklayout.cpp:1188) runs qobject_cast<QQuickLayout*> on a freed delegate and SIGSEGVs. Confirmed introduced by this PR via a same-machine merge-base A/B, and confirmed fixed by changing that RowLayout to a Row. It reproduces under a real windowing backend (xcb/wayland) but not offscreen, which is why the offscreen functional harness on the Qt 6.4.2 CI runner stays green even on the Send tests (and so wiring the new qml_test_psbt.py would not catch it either), and it is masked on newer Qt. Fix the shared AlertPopup (avoid a Repeater directly in a Quick Layout, or stabilize visibleActions before first layout) and verify headed on Qt 6.4.

Blocker (crash, headed on Qt 6.4.x): this `AlertPopup`, and the two siblings this PR adds on the Send page (`unsupportedPsbtPopup`, `knownPsbtTxPopup`), crash the app when navigating to the Send tab. `AlertPopup.qml` nests a `Repeater` directly inside a Quick `RowLayout` (contentItem `ColumnLayout` -> `RowLayout` -> `Repeater` over `visibleActions`), and `Component.onCompleted: refreshActions()` swaps the `visibleActions` model during construction. On Qt 6.4.x the Repeater rebuilds its delegates while the `RowLayout` does its first rearrange on Send-tab navigation, so `QQuickLayout::effectiveSizePolicy_helper` (`qquicklayout.cpp:1188`) runs `qobject_cast<QQuickLayout*>` on a freed delegate and SIGSEGVs. Confirmed introduced by this PR via a same-machine merge-base A/B, and confirmed fixed by changing that `RowLayout` to a `Row`. It reproduces under a real windowing backend (xcb/wayland) but not offscreen, which is why the offscreen functional harness on the Qt 6.4.2 CI runner stays green even on the Send tests (and so wiring the new `qml_test_psbt.py` would not catch it either), and it is masked on newer Qt. Fix the shared `AlertPopup` (avoid a Repeater directly in a Quick Layout, or stabilize `visibleActions` before first layout) and verify headed on Qt 6.4.
epicleafies (Migrated from github.com) commented 2026-06-23 19:47:04 +00:00

Suggestion (security-hygiene, raised on #557): this production handler has a test-only fast path backed by a hidden psbtImportPathField (L226) that ships in the release binary, and the same shape exists for save in SendReview.qml (savePsbtAutomationPath). The C++ test bridge is already compiled behind ENABLE_TEST_AUTOMATION; these QML fields and their handler branches are not. Real-world severity is bounded (only the gated bridge can populate the field, so it is inert in a release build), so this is hygiene/defense-in-depth rather than an exploitable hole, but please gate these behind ENABLE_TEST_AUTOMATION so they match the bridge and do not exist in release builds.

Suggestion (security-hygiene, raised on #557): this production handler has a test-only fast path backed by a hidden `psbtImportPathField` (L226) that ships in the release binary, and the same shape exists for save in `SendReview.qml` (`savePsbtAutomationPath`). The C++ test bridge is already compiled behind `ENABLE_TEST_AUTOMATION`; these QML fields and their handler branches are not. Real-world severity is bounded (only the gated bridge can populate the field, so it is inert in a release build), so this is hygiene/defense-in-depth rather than an exploitable hole, but please gate these behind `ENABLE_TEST_AUTOMATION` so they match the bridge and do not exist in release builds.
epicleafies (Migrated from github.com) commented 2026-06-23 19:47:04 +00:00

Suggestion (cross-platform): "file://" + homePath() is malformed on Windows. homePath() returns a plain path, so on Windows (C:/Users/Foo) this yields file://C:/Users/Foo, parsing C: as the URL authority, and the save dialog's default folder will be wrong. Same at L126 (currentFolder). Return a proper URL from C++ (QUrl::fromLocalFile(QDir::homePath()).toString()) instead of concatenating the scheme in QML, and verify on Windows.

Suggestion (cross-platform): `"file://" + homePath()` is malformed on Windows. `homePath()` returns a plain path, so on Windows (`C:/Users/Foo`) this yields `file://C:/Users/Foo`, parsing `C:` as the URL authority, and the save dialog's default folder will be wrong. Same at L126 (`currentFolder`). Return a proper URL from C++ (`QUrl::fromLocalFile(QDir::homePath()).toString()`) instead of concatenating the scheme in QML, and verify on Windows.
Sign in to join this conversation.
No description provided.