Add PSBTMissingInputUtxoError for inputs with no utxo to verify
What changed, and why it matters
This commit changes how SeedSigner handles Bitcoin transaction files (PSBTs) that are missing required data about how much an input is worth. Previously, missing input amount data was treated as a suspicious transaction (a potential attack). Now it gets its own, gentler error type and a warning screen that tells the user the transaction left out an input amount, but does not label it as malicious. The user can only discard the transaction. This is a defensive correctness improvement, not a vulnerability fix.
No urgent action required. Reviewers may want to confirm that downgrading the missing-utxo case from a dire warning to a warning screen does not inadvertently train users to treat incomplete PSBTs as benign in contexts where they could be maliciously constructed.
Security signals we found
New exception separates missing UTXO data from amount-verification failures
UI route downgrades missing-utxo case from dire warning to warning screen
User cannot proceed past missing-utxo PSBT; flow terminates at discard
No cryptographic or parsing vulnerability is fixed; change is defensive UX/correctness
Evidence from the diff
The patch introduces a new exception class PSBTMissingInputUtxoError in psbt_parser.py and routes it to a new PSBTMissingInputUtxoView in psbt_views.py. Two previously existing error cases—an out-of-range non_witness_utxo vout and a completely missing utxo—now raise the new exception instead of PSBTInputAmountVerificationError. The new view is a WarningScreen (not DireWarningScreen) with a single Discard button and no back navigation. Tests and screenshot generation are updated accordingly. The commit message and docstrings explicitly describe this as a correctness problem rather than an attack.
Changed components
src/seedsigner/models/psbt_parser.pysrc/seedsigner/views/psbt_views.pytests/screenshot_generator/generator.pytests/test_flows_psbt.pytests/test_psbt_parser.pyInspect captured patch +83 / −13
### src/seedsigner/models/psbt_parser.py
@@ -111,6 +111,15 @@ class PSBTInputAmountVerificationError(PSBTVerificationError):
pass
+class PSBTMissingInputUtxoError(PSBTVerificationError):
+ """
+ An input is missing its utxo, which holds its amount. A psbt supplies the amount in
+ the witness_utxo or non_witness_utxo field, and without either there is no amount to
+ verify. This is a correctness problem rather than an attack.
+ """
+ pass
+
+
class PSBTSeedCannotSignError(PSBTVerificationError):
"""
The selected seed holds no key that could sign any input.
@@ -247,9 +256,11 @@ def parse(self):
here so the flow can say so before showing a transaction.
4. _verify_input_amounts: verifies each input's claimed amount, then totals them
- as verified_input_amount. Raises PSBTInputAmountVerificationError if an amount
- cannot be verified. Runs after the ownership checks so a psbt this seed cannot
- sign is reported as a mismatch rather than as a suspicious transaction.
+ as verified_input_amount. Raises PSBTMissingInputUtxoError if an input is
+ missing the utxo that holds its amount, or PSBTInputAmountVerificationError
+ if an amount cannot be verified. Runs after the ownership checks so a psbt
+ this seed cannot sign is reported as a mismatch rather than as a suspicious
+ transaction.
5. _parse_inputs: every input must resolve to the same policy otherwise a
RuntimeError is raised. TODO: make this a PSBTVerificationError subclass so
@@ -366,11 +377,12 @@ def _verify_input_amounts(self):
# non_witness_utxo. Otherwise the lookups below raise an IndexError instead of
# rejecting the psbt.
if inp.non_witness_utxo and inp.vout >= len(inp.non_witness_utxo.vout):
- raise PSBTInputAmountVerificationError(
+ raise PSBTMissingInputUtxoError(
f"Input {i}: outpoint index {inp.vout} is out of range of its non_witness_utxo")
+ # Without any utxo data there is no amount to verify or total
if inp.utxo is None:
- raise PSBTInputAmountVerificationError(f"Input {i} has no utxo data")
+ raise PSBTMissingInputUtxoError(f"Input {i} has no utxo data")
try:
verified = inp.verify(ignore_missing=True)
### src/seedsigner/views/psbt_views.py
@@ -3,9 +3,10 @@
from gettext import gettext as _
from seedsigner.models.psbt_parser import (PSBTInputAmountVerificationError,
- PSBTInputOwnershipClaimError, PSBTMixedDerivationPathTypesError,
- PSBTOutputOwnershipClaimError, PSBTOutputOwnershipContradictionError, PSBTParser,
- PSBTSeedCannotSignError, PSBTSurplusDerivationPathsError)
+ PSBTInputOwnershipClaimError, PSBTMissingInputUtxoError,
+ PSBTMixedDerivationPathTypesError, PSBTOutputOwnershipClaimError,
+ PSBTOutputOwnershipContradictionError, PSBTParser, PSBTSeedCannotSignError,
+ PSBTSurplusDerivationPathsError)
from seedsigner.models.settings import SettingsConstants
from seedsigner.gui.components import FontAwesomeIconConstants, GUIConstants, SeedSignerIconConstants
from seedsigner.gui.screens.screen import (RET_CODE__BACK_BUTTON, ButtonListScreen, ButtonOption, LargeIconStatusScreen, WarningScreen, DireWarningScreen, QRDisplayScreen)
@@ -139,6 +140,10 @@ def __init__(self):
self.set_redirect(Destination(PSBTSeedCannotSignView))
return
+ except PSBTMissingInputUtxoError:
+ self.set_redirect(Destination(PSBTMissingInputUtxoView, clear_history=True))
+ return
+
except PSBTInputAmountVerificationError as e:
# The declared input amounts could not be verified, so the fee we would show is unproven
# Set clear_history to disable returning via BACK button.
@@ -723,6 +728,33 @@ def run(self):
+class PSBTMissingInputUtxoView(View):
+ """
+ Reached when an input is missing the utxo it spends (see PSBTMissingInputUtxoError).
+
+ We view this as a correctness problem rather than an attack. We do not allow the user
+ to continue, but only give this the "Warning" level.
+ """
+ DISCARD = ButtonOption("Discard transaction")
+
+ def run(self):
+ self.run_screen(
+ WarningScreen,
+ title=_("Transaction Problem"),
+ status_headline=None,
+ # TRANSLATOR_NOTE: The transaction/psbt has an error but does not seem to be malicious.
+ text=_("This transaction left out the amount for one of its inputs."),
+ button_data=[self.DISCARD],
+ show_back_button=False,
+ )
+
+ # We're done with this PSBT. Route back to MainMenuView, which clears all
+ # ephemeral data (except in-memory seeds).
+ # Set clear_history to disable returning via BACK button.
+ return Destination(MainMenuView, clear_history=True)
+
+
+
class PSBTOpReturnView(View):
"""
Shows the OP_RETURN data
### tests/screenshot_generator/generator.py
@@ -459,6 +459,7 @@ def mock_version_to_most_recent_release():
ScreenshotConfig(psbt_views.PSBTInputOwnershipClaimFailedView),
ScreenshotConfig(psbt_views.PSBTSeedCannotSignView),
ScreenshotConfig(psbt_views.PSBTInputAmountVerificationFailedView),
+ ScreenshotConfig(psbt_views.PSBTMissingInputUtxoView),
ScreenshotConfig(psbt_views.PSBTFinalizeView, mock_context_manager=mock_multisig_psbt_loaded),
#ScreenshotConfig(PSBTSignedQRDisplayViewScreenshotConfig),
ScreenshotConfig(psbt_views.PSBTSigningErrorView, mock_context_manager=mock_multisig_psbt_loaded),
### tests/test_flows_psbt.py
@@ -353,6 +353,30 @@ def test_mixed_derivation_path_types_terminate_signing_flow(self):
])
+ def test_missing_input_utxo_terminates_signing_flow(self):
+ """
+ An input that carries no utxo data gives us no amount to verify, so parsing
+ refuses the psbt.
+
+ It ends the flow at its own warning before any transaction detail is rendered.
+ """
+ psbt = PSBT.parse(a2b_base64(PSBTTestData.SINGLE_SIG_NATIVE_SEGWIT_2_INPUTS))
+
+ # Input 0 is left intact, so the seed can still sign and the parse gets as far as
+ # the amount check.
+ psbt.inputs[1].witness_utxo = None
+ psbt.inputs[1].non_witness_utxo = None
+
+ self._load_psbt_for_signing(psbt, seed=PSBTTestData.two_input_seed)
+
+ self.run_sequence([
+ FlowStep(psbt_views.PSBTSelectSeedView, screen_return_value=0),
+ FlowStep(psbt_views.PSBTOverviewView, is_redirect=True),
+ FlowStep(psbt_views.PSBTMissingInputUtxoView, button_data_selection=psbt_views.PSBTMissingInputUtxoView.DISCARD),
+ FlowStep(MainMenuView),
+ ])
+
+
def test_wrong_seed_routes_back_to_seed_selection_flow(self):
"""
The wrong seed for a psbt redirects before any transaction detail is rendered and
### tests/test_psbt_parser.py
@@ -13,9 +13,10 @@
from embit.script import Script
from seedsigner.models.psbt_parser import (PSBTInputAmountVerificationError,
- PSBTInputOwnershipClaimError, PSBTMixedDerivationPathTypesError,
- PSBTOutputOwnershipClaimError, PSBTOutputOwnershipContradictionError, PSBTParser,
- PSBTSeedCannotSignError, PSBTSurplusDerivationPathsError)
+ PSBTInputOwnershipClaimError, PSBTMissingInputUtxoError,
+ PSBTMixedDerivationPathTypesError, PSBTOutputOwnershipClaimError,
+ PSBTOutputOwnershipContradictionError, PSBTParser, PSBTSeedCannotSignError,
+ PSBTSurplusDerivationPathsError)
from seedsigner.models.seed import Seed
from seedsigner.models.settings_definition import SettingsConstants
@@ -652,7 +653,7 @@ def test_input_with_no_utxo_data_raises(self):
psbt.inputs[0].witness_utxo = None
psbt.inputs[0].non_witness_utxo = None
- with pytest.raises(PSBTInputAmountVerificationError):
+ with pytest.raises(PSBTMissingInputUtxoError):
self.parse(psbt)
@@ -670,7 +671,7 @@ def test_outpoint_index_past_end_of_non_witness_utxo_raises(self):
assert inp.vout < len(inp.non_witness_utxo.vout)
inp.vout = len(inp.non_witness_utxo.vout)
- with pytest.raises(PSBTInputAmountVerificationError):
+ with pytest.raises(PSBTMissingInputUtxoError):
self.parse(psbt)
Why this scored 32/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.