tests: pin multisig no-descriptor and consolidation behaviour in PSBTParser#933
Open
nkatha23 wants to merge 1 commit into
Open
tests: pin multisig no-descriptor and consolidation behaviour in PSBTParser#933nkatha23 wants to merge 1 commit into
nkatha23 wants to merge 1 commit into
Conversation
b91a825 to
28c700f
Compare
28c700f to
976f78b
Compare
When a coordinator strips witness_script/redeem_script from multisig output scopes, _get_policy() returns a bare policy dict with no m/n/cosigners, which never matches the input policy — so no output is classified as change and all value shows as spend_amount. This was the correct conservative behaviour but had no test pinning it. Also adds a consolidation test: a PSBT where both a change-branch (1/*) and a receive-branch (0/*) output belong to the signing wallet. PSBTParser classifies both as internal regardless of branch index, giving spend_amount == 0. Covers all three multisig types for the no-descriptor case, all seven script types for the consolidation case. Part of SeedSigner#931.
976f78b to
0e71f30
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In response to issue #931 , this is what I found:
Reading through PSBTParser._parse_outputs(), I noticed two spending scenarios that weren't covered by the existing test suite:
policy from a bare script hash, so it has no way to verify that the output belongs to the wallet. The safe, correct behaviour is to treat it as an external spend. That path existed in the code but was never exercised by a test, meaning a future refactor could silently break it.
classifies any output as internal when the derived key matches the output scriptPubKey, regardless of branch index. Again, this worked but wasn't tested.
so this PR adds:
Two new test methods inside TestPSBTParser in tests/test_psbt_parser.py:
test_multisig_no_descriptor_all_outputs_are_spend- covers all three multisig script types. Strips witness_script and redeem_script from the output scope and pins that num_change_outputs == 0 with everything treated as spend.
test_consolidation_all_outputs_internal- covers all seven supported script types. Two internal outputs (change-branch + receive-branch) both belonging to the signing wallet, pins spend_amount == 0 and change_amount == input_amount - fee.