Skip to content

Record upstream #1032 ancestry after squash of #453 - #459

Merged
3rdIteration merged 13 commits into
devfrom
fix/record-upstream-1032-ancestry
Sep 23, 2026
Merged

3rdIteration merged 13 commits into
devfrom
fix/record-upstream-1032-ancestry

Conversation

@3rdIteration

Copy link
Copy Markdown
Owner

#453 was squash-merged by accident, so dev has the content of upstream SeedSigner#1032 but not its commits. This PR adds one merge commit whose second parent is the original #453 head (84c84c3c, which contains upstream dev at b225ae77).

No files change (the diff is empty). It only records ancestry so future upstream/dev merges don't replay SeedSigner#1032.

⚠️ Merge this with Create a merge commit. Squash or rebase would drop the ancestry again.

🤖 Generated with Claude Code

kdmukai and others added 13 commits August 29, 2026 13:49
No behavior change. Corrects prose that had drifted from what the code
does, and addresses two local names for the same reason.

Docstrings and comments:
- The two ownership-claim exceptions state the condition each signals,
  without speculating about how it arises.
- _get_seed_derivation_path drops the output-versus-input severity
  split, which _verify_claimed_derivation_paths already states.
- The verified_*_derivation_paths comment says what an entry holds, and
  no longer explains the None the positive statement already implies.
- parse() steps 1 and 2 name the per-key condition instead of "scopes".
- _parse_inputs gains a docstring covering the amount total and the
  one-shared-policy requirement.
- The single-sig branch comment names the script types it covers.

Naming:
- _parse_multisig's `sc` parameter becomes `multisig_script`.
- A TODO marks _get_policy's local `script`, which shadows the embit
  module imported at the top of the file.
"An output scope claims..." reads no better than "An output claims...".
The word is doing no work in a sentence about what the output says, and
the psbt-scope sense it borrows is not the one the reader needs there.
Clarify psbt_parser.py docstrings and comments; minor cleanup
An output counted as change when its policy matched the inputs' and its
rebuilt scriptPubKey matched what the output committed to. Neither step
established that the key involved was ours. The policy comparison
included cosigners resolved from the coordinator's own global xpubs, so
one misannotated fingerprint made an output stop matching and skip
verification altogether, and multisig never checked our key against the
committed script at all.

Outputs now compare on script shape alone, and every candidate proves
ownership: single sig by rebuilding from the claimed derivation path,
multisig by finding this seed's key in the committed script. Where the
psbt's account of an output contradicts what the output commits to, the
parse refuses rather than quietly reclassifying. A claim set too
malformed to answer that question, one populating both derivation path
maps or claiming more keys than its script uses, is refused as well.

change_data now carries the verified derivation path in place of the
coordinator's claimed fingerprints and paths, so the views no longer
re-derive trust from strings the parse has already settled.

Taproot mismatches stay exempt. A script tree tweaks the internal key,
so honest taproot change fails the rebuild too, and embit leaves
PSBT_OUT_TAP_TREE unparsed, which is what would tell the two apart.
In _parse_outputs the flag was set True as soon as the rebuilt
scriptPubKey matched, and two multisig branches then turned it back
off. That made "change" the default inside the matched arm, so a branch
that forgot the flag would record change with nothing verified behind
it. Now each branch sets the flag only once its own checks have passed,
and an output that satisfies none of them stays an external spend.

The two sites where the flag is set split by signature type, and each
carries the certainty it actually has: single sig is settled, because
our own key rebuilt the scriptPubKey; multisig is a presumption, because
our key in the committed script does not say which wallet that script
belongs to, and only the user's descriptor can. The reminder that
"change" means any output coming back to our seed moves to the line
where change_data is built, which is where the word takes that meaning.

No behavior change: the same outputs land in the same lists on every
fixture shape, and the suite is unchanged.
The rebuild chain in _parse_outputs matched single sig and taproot by
substring ("pkh" in type, "p2tr" in type) and had no else. embit reports
a script type it does not recognize as None, and _get_policy passes that
through, so a psbt whose inputs and outputs were both unrecognized passed
the shape gate and died in the substring test with a bare TypeError. The
guard meant for an unhandled type sat inside the scriptPubKey match,
where an empty rebuild cannot arrive.

The arms now name their types exactly, matching _build_singlesig_script,
and the chain ends in a catch-all else that raises RuntimeError with the
unsupported type in the message. The unreachable inner guard is removed.
A test drives a p2pk psbt into the catch-all.
The flag in _parse_outputs is set for two different strengths of
finding. For single sig our own key rebuilt the scriptPubKey, so the
output is provably ours. For multisig we have only shown that our key
sits in the committed script, and which wallet that script belongs to
is settled later, by the user's descriptor. Calling both "is_change"
gave the multisig case a certainty it does not have.

The process docstring is held to the same standard: it describes how
ownership is determined rather than how outputs are verified as change,
the verdict table reads "presumed change", and the multisig rebuild
bullet names the key-in-script step that the table row depends on.

No behavior change.
A multisig output whose committed script holds this seed's key can
still belong to a different wallet: a 2-of-3 over {p1,p2,p4} when the
inputs spend {p1,p2,p3}. When the psbt supplies global xpubs and fully
annotates the output, _get_cosigners resolves a cosigner list for the
inputs and one for the output, and lists that differ mean the output
pays a quorum other than the one being spent from. That output is now
counted as an external spend. It stays presumed change when the lists
match or when either side's cosigners are unresolved.

This is hygiene, not a security control. The global xpubs are optional
and unauthenticated, so a coordinator that omits them skips the check,
and a mismatch demotes rather than raises because a transfer into a
second multisig this seed belongs to is legitimate. No surveyed
coordinator produces the shape the check fires on: every one except
Bitcoin Core annotates only its own wallet's outputs, and Core, which
annotates any output a descriptor in its wallet file can solve, writes
no global xpubs at all. Settling which wallet a multisig output pays
still needs the user's own descriptor.

The comparison sits after the ownership checks rather than at the
policy shape gate, so a psbt whose output cosigners fail to resolve
still faces every ownership check.

_get_cosigners' sorted() is what makes the two lists comparable: two of
the three multisig fixtures order the same wallet's keys differently on
the input and on its change output. Its docstring now separates what
is claim from what is checked and what the result does and does not
establish, its loop carries the procedure inline, and two early-outs
name the omitted-xpubs and omitted-derivations cases before the loop
(behaviour-neutral: both already raised from inside it). Tests pin the
sort, the different-quorum spend, and the no-xpubs presumed-change
fallback.
The cosigner comparison skipped any output whose cosigners failed to
resolve, so the different-quorum case it exists for never fired on a
real psbt: coordinators write only the spending wallet's xpubs, and a
foreign cosigner's key then resolves against nothing. Once the inputs'
cosigners resolve, an output that differs or fails to resolve is
counted as a spend.

Keys now match xpubs by derivation alone rather than requiring the
claimed fingerprint to match first. The fingerprint is a label the
coordinator wrote; requiring it let one mislabeled cosigner turn
genuine change into a spend, and a key an xpub really derives is
proof enough on its own.

The different-quorum test now uses the wallet's own xpubs, the shape
every xpub-writing coordinator produces, and a second test keeps the
four-xpub variant.
[security] Verify that change outputs actually pay this seed
…ownership

# Conflicts:
#	src/seedsigner/models/psbt_parser.py
#	src/seedsigner/views/psbt_views.py
#	tests/test_psbt_parser.py
…squash #453)

#453 was squash-merged, so dev has the content of upstream PR SeedSigner#1032 but
not its commits. This merge changes no files; it only records the PR
head (84c84c3, which contains upstream/dev b225ae7) as an ancestor so
future upstream merges don't replay SeedSigner#1032.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@3rdIteration
3rdIteration merged commit 3f80d00 into dev Sep 23, 2026
25 of 29 checks passed
@3rdIteration
3rdIteration deleted the fix/record-upstream-1032-ancestry branch September 23, 2026 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants