Skip to content

Cover P2MR SIGHASH_SINGLE missing outputs - #57

Merged
kiwidream merged 1 commit into
0.1.xfrom
p2mr-sighash-single-missing-output
Jul 2, 2026
Merged

kiwidream merged 1 commit into
0.1.xfrom
p2mr-sighash-single-missing-output

Conversation

@kiwidream

@kiwidream kiwidream commented Jun 29, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Extend the independent P2MR PQC witness vector fixture with explicit SIGHASH_SINGLE cases.
  • Add matched-output coverage proving OP_CHECKSIGPQC accepts a valid fixed P2MR SIGHASH_SINGLE spend.
  • Add missing-output coverage proving P2MR SIGHASH_SINGLE rejects with SCRIPT_ERR_P2MR_SIG_HASHTYPE, including ANYONECANPAY variants.
  • Assert direct SignatureHashP2MR(... MissingDataBehavior::FAIL) failure so the test guards against legacy uint256::ONE behavior.

Fixes #48

Validation

  • git diff --check
  • cmake -B build -DWITH_USDT=OFF -DBUILD_TESTS=ON
  • cmake --build build --target test_bitcoin -j2
  • build/bin/test_qbit --run_test=script_p2mr_tests --catch_system_error=no --log_level=test_suite
  • build/bin/test_qbit --run_test=script_p2mr_tests/p2mr_checksigpqc_accepts_independent_sighash_single_matched_output --catch_system_error=no --log_level=test_suite
  • build/bin/test_qbit --run_test=script_p2mr_tests/p2mr_checksigpqc_rejects_independent_sighash_single_missing_output --catch_system_error=no --log_level=test_suite
  • Docker lint with the repo bitcoin-linter image from ci/lint_imagefile

Note: local CMake configuration used WITH_USDT=OFF because the dev preset could not find USDT headers on this machine.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Note

Low Risk
Test and fixture-only changes; no production interpreter or sighash logic modified in this diff.

Overview
Adds four independent P2MR PQC witness vectors for SIGHASH_SINGLE (and ANYONECANPAY variants) when the signed input index has no matching transaction output—empty vout or index past the last output. Those fixtures set expectedError: P2MR_SIG_HASHTYPE and deliberately omit p2mrSigMsg / p2mrSighash because P2MR fails before a digest is defined.

The vector generator gains missing_output_vector_specs, build_missing_output_vector, and a shared build_spent_outputs helper; build_vector uses the helper for spent outputs. script_p2mr_tests learns to parse expectedError, treats sighash fields as optional on failure vectors, skips the “accepts” loop for them, and adds p2mr_checksigpqc_rejects_independent_sighash_single_missing_output, which asserts SignatureHashP2MR fails and spend verification returns SCRIPT_ERR_P2MR_SIG_HASHTYPE (not legacy uint256::ONE behavior).

Reviewed by Cursor Bugbot for commit b19a676. Bugbot is set up for automated code reviews on this repo. Configure here.

@kiwidream
kiwidream force-pushed the p2mr-sighash-single-missing-output branch from 0a51c4d to fdf83e4 Compare June 29, 2026 19:12

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fdf83e4. Configure here.

Comment thread src/test/script_p2mr_tests.cpp Resolved
@kiwidream
kiwidream force-pushed the p2mr-sighash-single-missing-output branch from 8ef832c to 8b2e42d Compare June 30, 2026 01:00
@djh58
djh58 self-requested a review June 30, 2026 13:53
djh58
djh58 previously approved these changes Jun 30, 2026
@kiwidream
kiwidream force-pushed the p2mr-sighash-single-missing-output branch from 8b2e42d to 8f8fbc0 Compare June 30, 2026 14:51
djh58
djh58 previously approved these changes Jun 30, 2026
@kiwidream
kiwidream force-pushed the p2mr-sighash-single-missing-output branch 2 times, most recently from 4a7af70 to 5a2b1a6 Compare July 2, 2026 13:51
@kiwidream

Copy link
Copy Markdown
Member Author

Expediting merge for 0.1.2 release

@kiwidream
kiwidream force-pushed the p2mr-sighash-single-missing-output branch from 5a2b1a6 to b19a676 Compare July 2, 2026 16:49
@kiwidream
kiwidream merged commit acf37ce into 0.1.x Jul 2, 2026
18 of 30 checks passed
djh58 pushed a commit that referenced this pull request Jul 2, 2026
* Accept legacy AuxPoW RPC payloads (#23)

* Prevent AuxPoW signalling in permissionless GBT (#22)

* wallet: defer P2MR getnewaddress keypool refill (#13)

* wallet: defer P2MR getnewaddress keypool refill

* wallet: bound internal P2MR keypool refill

* wallet: align P2MR top-up lock ordering

* wallet: schedule raw change P2MR refills

* wallet: report paused P2MR refills as failed

* wallet: log inline P2MR refill failures

* ci: fix BuildKit helper lint

* Document AuxPoW commitment order fields (#35)

* Restrict explicit wallet output types on P2MR-only chains (#25)

* Restrict explicit wallet output types

* test: run BECH32 wallet suites on unrestricted regtest

* fuzz: run wallet transaction target on unrestricted regtest

* Fix BuildKit helper lint

* Report missing wallet output managers accurately

* Allow managerless wallets with default output options

* test: add independent P2MR and CTV script vectors (#29)

* Add independent P2MR PQC witness vector tests (#30)

* test: add independent P2MR PQC witness vector

* test: verify P2MR wrong-domain vector signature

* Fix AuxPoW legacy payload disambiguation

* wallet: avoid MarkUnused P2MR full top-up (#31)

* wallet: avoid MarkUnused P2MR full top-up

* wallet: avoid MarkUnused lock inversion

* wallet: preserve P2MR recovery lookahead

* Split P2MR wallet unit tests (#52)

* Remove unused P2MR wallet test import (#58)

* Shard P2MR wallet unit tests (#60)

* Add independent CHECKDATASIGPQC vector tests (#38)

* test: add P2MR data-hash proof fixtures (#43)

* test: add independent P2MR commitment vectors (#47)

* Reject invalid raw funding outputs (#37)

* Validate witness-pruned assumevalid before wipe (#59)

* Add independent CHECKDATASIGADDPQC vector tests (#42)

* qt: recommend wallet encryption by default (#62)

* Verify libbitcoinpqc tagged subtree imports (#41)

* ci: verify libbitcoinpqc tagged subtree imports

* ci: handle peeled libbitcoinpqc tag refs

* ci: peel libbitcoinpqc tag objects before compare

* ci: pass auth to libbitcoinpqc verifier

* ci: pin libbitcoinpqc verifier inputs

* ci: verify libbitcoinpqc import tree

* Add P2MR PQC annex sighash vectors (#54)

* Add P2MR PQC annex sighash vectors

* Guard annex mutation vector test

* Add P2MR data signature support to Qt Sign/Verify (#63)

* qt: add P2MR data signature dialog

* qt: support text data in P2MR signatures

* qt: align P2MR proof verification with RPC

* test: add P2MR CHECKSIGPQC sighash vectors (#55)

* Add rawmr future-leaf coverage (#64)

* test: cover P2MR SIGHASH_SINGLE missing outputs (#57)

* test: add P2MR PQC codeseparator vectors (#56)

* Fix PQC data-hash counter accounting (#46)

* Fix PQC data-hash counter accounting

* Fix PQC data-hash leaf error priority

* Report final PQC slot failures as exhausted

* doc: add v0.1.2-testnet4 release notes

* build: bump version to v0.1.2-testnet4
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.

2 participants