Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
d0636cc
Verify PSBT input amounts and discard unverifiable transactions
newtonick Aug 29, 2026
d30f349
Escalate PSBTInputAmountVerificationFailedView headline to "Likely an…
newtonick Sep 23, 2026
ba67bfd
Clarify comment on the non_witness_utxo outpoint bounds check
newtonick Sep 23, 2026
50c977a
Merge branch 'dev' into psbt-verify
newtonick Sep 23, 2026
cf18a0b
Admit bare p2sh outputs as nested single sig change
kdmukai Sep 24, 2026
f04675e
Narrow bare p2sh candidacy to what the rebuild cannot decide
kdmukai Sep 29, 2026
f5cbc18
Restore why change candidacy ignores cosigners
kdmukai Sep 30, 2026
b2199c6
Merge pull request #1046 from kdmukai/2026_09_psbt_nested_singlesig_c…
newtonick Oct 3, 2026
5fc0ea6
Reword PSBTInputAmountVerificationFailedView text based on feedback
newtonick Oct 5, 2026
457cef3
Trim input amount explanations duplicated outside _verify_input_amoun…
newtonick Oct 5, 2026
335c11a
Total verified_input_amount in _verify_input_amounts()
newtonick Oct 5, 2026
6605c68
Add PSBTMissingInputUtxoError for inputs with no utxo to verify
newtonick Oct 5, 2026
5ca043c
Reword the _verify_input_amounts() docstring
newtonick Oct 5, 2026
22a4ed4
Simplify the outpoint bounds check comment
newtonick Oct 5, 2026
2741166
Clarify the comments around InputScope.verify()
newtonick Oct 6, 2026
00ee771
Restructure _verify_input_amounts() around non_witness_utxo and rewor…
newtonick Oct 17, 2026
67e049e
Remove the psbt_parser reset from the input verification failure handler
newtonick Oct 17, 2026
5bfbe0b
Reword PSBTMissingInputUtxoView text based on feedback
newtonick Oct 17, 2026
efc92ca
Reword the PSBTInputAmountVerificationError, parse() and _get_script_…
newtonick Oct 17, 2026
9b60843
Apply suggestion from @kdmukai
newtonick Oct 20, 2026
698ae38
Apply suggestion from @kdmukai
newtonick Oct 20, 2026
4dcdcfa
Tidy the comments at the end of _verify_input_amounts()
newtonick Oct 20, 2026
34b881a
Apply suggestion from @kdmukai
newtonick Oct 20, 2026
ec51136
Apply suggestion from @kdmukai
newtonick Oct 20, 2026
d4acbf3
Apply suggestion from @kdmukai
newtonick Oct 20, 2026
ee853c3
correct indentation
newtonick Oct 20, 2026
a71b7b3
Replace the parse() test helper with direct PSBTParser calls
newtonick Oct 20, 2026
222bf3d
Tighten the input-amount test asserts and run the no-utxo test over e…
newtonick Oct 20, 2026
afb7305
Trim the input-amount verification test docstrings
newtonick Oct 20, 2026
e92c4ea
Merge pull request #995 from newtonick/psbt-verify
newtonick Oct 20, 2026
9b810ba
Reject psbts whose outputs exceed their inputs
Chaitanya-Keyal Sep 18, 2026
fdcf21b
style: restore the blank lines between the psbt parser tests
Chaitanya-Keyal Sep 29, 2026
bf5146e
Keep PSBTNegativeFeeError's docstring to what a caller needs
Chaitanya-Keyal Oct 4, 2026
9994a04
Drop the negative fee comment's claim that both totals are unverified
Chaitanya-Keyal Oct 21, 2026
ebc1e11
Merge pull request #1041 from Chaitanya-Keyal/psbt-negative-fee
newtonick Oct 22, 2026
7ecc8d9
Parse the OP_RETURN push opcode instead of assuming OP_PUSHDATA1
Chaitanya-Keyal Sep 18, 2026
89c5241
Cover every OP_RETURN push encoding in the parser tests
Chaitanya-Keyal Sep 18, 2026
36fb9b3
Build the screenshot generator's OP_RETURN with a minimal push
Chaitanya-Keyal Sep 18, 2026
79e22d2
Drop OP_RETURN test helper parameters that nothing passes
Chaitanya-Keyal Oct 15, 2026
6403723
Refuse an OP_RETURN that is not made of complete pushes
Chaitanya-Keyal Oct 15, 2026
d8f7956
Merge pull request #1042 from Chaitanya-Keyal/op-return-push-opcode
newtonick Oct 24, 2026
2b4c578
Verify input scripts against the scriptPubKey they commit to
kdmukai Sep 25, 2026
b4a56bc
Correct the input script docstring's BIP-174 claim
kdmukai Sep 28, 2026
aac8893
Document the payjoin gaps in input handling
kdmukai Sep 28, 2026
0aea073
Fix two stale comments on the input script checks
kdmukai Sep 30, 2026
4b93177
Move the foreign multisig test helper to the shared base class
kdmukai Oct 16, 2026
717a0e9
Name the input script check in the _parse_inputs docstring
kdmukai Oct 16, 2026
85833cc
Verify input scripts before reading the script type
kdmukai Oct 23, 2026
bcd2610
Rewrap the amount check's comments at 90 columns
kdmukai Oct 23, 2026
dd2a2be
Move error names out of parse()'s step list
kdmukai Oct 24, 2026
c255bf5
Enable Swahili
kdmukai Oct 28, 2026
cbc7ac3
Merge pull request #1065 from kdmukai/2026-10_add_swahili
SeedSigner Oct 28, 2026
ada81cd
Merge pull request #1047 from kdmukai/2026_09_psbt_input_scripts
newtonick Oct 29, 2026
f713e8e
Merge upstream/dev: input amount/script verification, OP_RETURN pushe…
3rdIteration Nov 1, 2026
f58e943
Add test vectors for the upstream input/OP_RETURN/nested-change merge
3rdIteration Nov 1, 2026
8e479ef
Vendor the follow-up vectors from psbt_faker; add nested multisig vec…
3rdIteration Nov 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
302 changes: 219 additions & 83 deletions src/seedsigner/models/psbt_parser.py

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/seedsigner/models/settings_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class SettingsConstants:
LOCALE__SLOVENIAN = "sl"
LOCALE__SPANISH = "es"
LOCALE__SWEDISH = "sv"
LOCALE__SWAHILI = "sw"
LOCALE__TAGALOG = "tl"
LOCALE__TAMIL = "ta"
LOCALE__TELUGU = "te"
Expand Down Expand Up @@ -154,6 +155,7 @@ class SettingsConstants:
LOCALE__PERSIAN: "(beta) فارسی (Persian)",
LOCALE__POLISH: "(beta) Polski",
LOCALE__PORTUGUESE_BR: "(beta) Português (Brasil)",
LOCALE__SWAHILI: "(beta) Kiswahili (Swahili)",
LOCALE__THAI: "(beta) ไทย (Thai)",
LOCALE__VIETNAMESE: "(beta) Tiếng Việt (Vietnamese)",

Expand Down
150 changes: 148 additions & 2 deletions src/seedsigner/views/psbt_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,85 @@ class RejectPresentation:
button_label=_mft("Discard transaction"),
),

# The declared input amounts are unproven or false: a previous tx that doesn't hash
# to the txid it claims, a witness_utxo that contradicts it, or a legacy input with
# only a witness_utxo, whose amount no legacy signature commits to. Any of them lets
# the coordinator show whatever fee it likes. Upstream's
# PSBTInputAmountVerificationFailedView.
RejectCode.UTXO_MISMATCH: RejectPresentation(
screen=DireWarningScreen,
title=_mft("Suspicious Transaction"),
headline=_mft("Likely an Attack!"),
text=_mft("This transaction's input amounts cannot be verified, so its fee cannot be trusted."),
button_label=_mft("Discard transaction"),
),

RejectCode.INVALID_WITNESS_UTXO: RejectPresentation(
screen=DireWarningScreen,
title=_mft("Suspicious Transaction"),
headline=_mft("Likely an Attack!"),
text=_mft("This transaction's input amounts cannot be verified, so its fee cannot be trusted."),
button_label=_mft("Discard transaction"),
),

RejectCode.SCRIPT_HASH_MISMATCH: RejectPresentation(
screen=DireWarningScreen,
title=_mft("Suspicious Transaction"),
headline=_mft("Likely an Attack!"),
# TRANSLATOR_NOTE: The transaction/psbt contains a deception that we consider an attack.
text=_mft("This transaction supplied the wrong script for one of its inputs."),
button_label=_mft("Discard transaction"),
),

# The rest are malformed psbts rather than proven deceptions: refused, but only at
# the "Warning" level.
RejectCode.MISSING_UTXO: RejectPresentation(
screen=WarningScreen,
title=_mft("Transaction Problem"),
# TRANSLATOR_NOTE: The transaction/psbt has an error but does not seem to be malicious.
text=_mft("This transaction is missing required data for one of its inputs."),
button_label=_mft("Discard transaction"),
),

RejectCode.MISSING_INPUT_SCRIPT: RejectPresentation(
screen=WarningScreen,
title=_mft("Transaction Problem"),
# TRANSLATOR_NOTE: The transaction/psbt has an error but does not seem to be malicious.
text=_mft("This transaction left out a script that one of its inputs needs."),
button_label=_mft("Discard transaction"),
),

RejectCode.EXTRANEOUS_REDEEM_SCRIPT: RejectPresentation(
screen=WarningScreen,
title=_mft("Transaction Problem"),
# TRANSLATOR_NOTE: The transaction/psbt has an error but does not seem to be malicious.
text=_mft("This transaction supplied an extra script for one of its inputs."),
button_label=_mft("Discard transaction"),
),

RejectCode.EXTRANEOUS_WITNESS_SCRIPT: RejectPresentation(
screen=WarningScreen,
title=_mft("Transaction Problem"),
text=_mft("This transaction supplied an extra script for one of its inputs."),
button_label=_mft("Discard transaction"),
),

RejectCode.NEGATIVE_FEE: RejectPresentation(
screen=WarningScreen,
title=_mft("Transaction Problem"),
# TRANSLATOR_NOTE: The transaction's outputs spend more than its inputs hold, which is impossible.
text=_mft("This transaction's outputs send more than its inputs provide."),
button_label=_mft("Discard transaction"),
),

RejectCode.MALFORMED_OP_RETURN: RejectPresentation(
screen=WarningScreen,
title=_mft("Transaction Problem"),
# TRANSLATOR_NOTE: The transaction/psbt has an error but does not seem to be malicious.
text=_mft("This transaction's OP_RETURN data is malformed."),
button_label=_mft("Discard transaction"),
),

RejectCode.SEED_CANNOT_SIGN: RejectPresentation(
# An informational mismatch, not a warning, so it uses the neutral info icon and
# color rather than WarningScreen's alarming yellow edges.
Expand Down Expand Up @@ -611,6 +690,10 @@ class PSBTRefusalView(View):
"""
code: str = None

# Further codes a named subclass also stands for. Each is still drawn from its own
# REJECT_PRESENTATION entry; this only decides which View class it routes to.
also_codes: tuple = ()

def __init__(self, code: str = None, message: str = None):
super().__init__()
self.code = code if code is not None else self.code
Expand Down Expand Up @@ -687,10 +770,73 @@ class PSBTSeedCannotSignView(PSBTRefusalView):
SELECT_DIFFERENT_SEED = ButtonOption("Select a different seed")


class PSBTInputAmountVerificationFailedView(PSBTRefusalView):
"""
An input's declared amount is unproven or false, so the fee cannot be trusted. Shows
a dire warning and discards the psbt.
"""
code = RejectCode.UTXO_MISMATCH
also_codes = (RejectCode.INVALID_WITNESS_UTXO,)
DISCARD = ButtonOption("Discard transaction")



class PSBTMissingInputUtxoView(PSBTRefusalView):
"""An input is missing the utxo it spends. Malformed rather than hostile."""
code = RejectCode.MISSING_UTXO
DISCARD = ButtonOption("Discard transaction")



class PSBTMissingInputScriptView(PSBTRefusalView):
"""An input commits to a script the psbt did not supply. Malformed rather than hostile."""
code = RejectCode.MISSING_INPUT_SCRIPT
DISCARD = ButtonOption("Discard transaction")



class PSBTInputScriptMismatchView(PSBTRefusalView):
"""
An input supplies a script other than the one its scriptPubKey commits to. Treated
as an attack: a dire warning, and the psbt is discarded.
"""
code = RejectCode.SCRIPT_HASH_MISMATCH
DISCARD = ButtonOption("Discard transaction")



class PSBTExtraneousInputScriptView(PSBTRefusalView):
"""
An input supplies a redeem or witness script its scriptPubKey doesn't commit to. Not
graded as an attack or a mistake.
"""
code = RejectCode.EXTRANEOUS_REDEEM_SCRIPT
also_codes = (RejectCode.EXTRANEOUS_WITNESS_SCRIPT,)
DISCARD = ButtonOption("Discard transaction")



class PSBTNegativeFeeView(PSBTRefusalView):
"""The outputs spend more than the inputs bring in. Malformed rather than hostile."""
code = RejectCode.NEGATIVE_FEE
DISCARD = ButtonOption("Discard transaction")



class PSBTMalformedOpReturnView(PSBTRefusalView):
"""An OP_RETURN script is not made of complete pushes. Malformed rather than hostile."""
code = RejectCode.MALFORMED_OP_RETURN
DISCARD = ButtonOption("Discard transaction")


# The named subclasses above, keyed by the code each one fixes. A code without one is
# rendered by PSBTRefusalView itself; give a code its own subclass when it is worth
# naming in a flow test or a screenshot, and it lands here automatically.
REFUSAL_VIEWS = {cls.code: cls for cls in PSBTRefusalView.__subclasses__()}
REFUSAL_VIEWS = {
code: cls
for cls in PSBTRefusalView.__subclasses__()
for code in (cls.code, *cls.also_codes)
}


def refusal_destination(error: InvalidPSBTError) -> Destination:
Expand Down Expand Up @@ -1158,7 +1304,7 @@ def run(self):

selected_menu_num = self.run_screen(
PSBTMathScreen,
input_amount=psbt_parser.input_amount,
input_amount=psbt_parser.verified_input_amount,
num_inputs=psbt_parser.num_inputs,
# An OP_RETURN carrying value is value leaving the wallet with no
# recipient. Counting it as spend is what makes
Expand Down
31 changes: 31 additions & 0 deletions tests/data/psbt_test_suite/PROVENANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,34 @@ Without a `non_witness_utxo`, an offline signer cannot tell those bytes from an
honest v2 spend. Signing it is safe: the input is segwit v0, and BIP-143 commits
the signature to the `witness_utxo` amount and script, so the signature is
invalid for any outpoint that does not hold exactly that.

## Follow-up of 2026-10-31

Vectors for the merge of upstream SeedSigner #995 (input amounts), #1041 (negative
fee), #1042 (OP_RETURN push opcodes), #1046 (nested single sig change without a
redeem_script) and #1047 (input scripts), plus nested segwit multisig input
scripts. They are generated by the local psbt_faker's new 2026-10-31 builders and
vendored with `psbt_test_suite/generate.py --keep-existing`, which adds new tests
without regenerating the shipped ones. Each builder runs with the RNG seeded from its
test id, so its bytes are reproducible. Single sig wrapped vectors use the seed's
BIP49 account (`m/49h/0h/0h`).

* OP_RETURN: `XTRAS.OP_RETURN_RUNESTONE`, `_SMALLINT` and `_MULTI_PUSH` are negative
controls (push-only, so they must be shown). `_TRUNCATED_PUSH` and `_NON_PUSH` are
refused as `MALFORMED_OP_RETURN`. Every one has a `_V2` twin.
* Input scripts: `XTRAS.STRAY_REDEEM_SCRIPT` (`EXTRANEOUS_REDEEM_SCRIPT`),
`XTRAS.MISSING_REDEEM_SCRIPT` and `XTRAS.MISSING_WITNESS_SCRIPT`
(`MISSING_INPUT_SCRIPT`), `XTRAS.WRONG_REDEEM_SCRIPT` and
`XTRAS.FOREIGN_INPUT_BAD_SCRIPT` (`SCRIPT_HASH_MISMATCH`).
* Nested segwit multisig: `XTRAS.MS_NESTED_*` use the corpus's three seeds as a
2-of-3 P2SH-P2WSH wallet at `m/48h/0h/0h/1h`, the second wallet in psbt_faker's
multisig section. `_HONEST` is the negative control. `_WRONG_WITNESS_SCRIPT` breaks
only the inner layer (witness_script to redeem_script) and `_WRONG_REDEEM_SCRIPT`
only the outer one (redeem_script to scriptPubKey), so a signer must check both.
`_MISSING_WITNESS_SCRIPT` is malformed. Building these needed a psbt_faker fix:
`fake_ms_txn` used to set a nested input's redeem_script to the multisig itself and
omitted the redeem_script on nested change.
* Change: `XTRAS.NESTED_CHANGE_NO_REDEEM` (negative control, counted as change) and
`TX-21.nested_bare_p2sh_claims_us_pays_other` (`FORGED_OUTPUT_OWNERSHIP`). Before
the merge, the second one parsed as an ordinary payment.
* Fee: `XTRAS.ZERO_FEE` is a negative control. Zero is pointless but not malformed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added tests/data/psbt_test_suite/XTRAS.ZERO_FEE.psbt
Binary file not shown.
Binary file added tests/data/psbt_test_suite/XTRAS.ZERO_FEE_V2.psbt
Binary file not shown.
Loading
Loading