Skip to content

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

Merged
kiwidream merged 6 commits into
0.1.xfrom
issue-19-0.1.x
Jun 28, 2026
Merged

kiwidream merged 6 commits into
0.1.xfrom
issue-19-0.1.x

Conversation

@kiwidream

@kiwidream kiwidream commented Jun 25, 2026 •

Copy link
Copy Markdown
Member

Summary

  • require explicit wallet output types to be both chain-allowed and backed by a matching wallet manager
  • add receive/change destination guards so restricted-output chains cannot emit non-P2MR wallet outputs through lower-level paths
  • add mixed-manager restricted-chain coverage for address, change, funding, PSBT, and startup config paths

Fixes #19.

Validation

  • python3 -m py_compile test/functional/wallet_p2mr.py
  • cmake --build build --target test_qbit qbitd qbit-cli -j 8
  • build/bin/test_qbit --run_test=wallet_tests/WalletOutputAvailabilityRequiresAllowedTypeAndManager
  • ulimit -n 256; build/test/functional/wallet_p2mr.py --configfile build/test/config.ini
  • ulimit -n 256; build/bin/test_qbit --run_test=wallet_tests
  • Docker lint via ci/lint_imagefile / ci/lint/06_script.sh

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


Note

Medium Risk
Changes wallet address/change selection and RPC error semantics on restricted chains; behavior shifts for wallets without managers for requested types, but defaults and existing P2MR-only flows are covered by new tests.

Overview
Wallet output types must now be both chain-allowed and backed by a script-pubkey manager; availability is no longer satisfied by chain policy alone when the wallet lacks that manager.

RPC and startup split failures into “not available on this chain” vs “not available in this wallet,” and wallet load validates -addresstype / -changetype through shared init helpers. Receive/change paths (GetNewDestination, ReserveDestination) reject disallowed chain types before P2MR activation checks.

Unit/fuzz coin-selection fixtures run regtest with -p2mronly=0 so BECH32 tests still work. wallet_p2mr.py adds mixed-manager coverage (startup config, addresses, change, fundrawtransaction, PSBT). CI BuildKit helper sets LC_ALL=C for consistent locale.

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

@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 3c301b4. Configure here.

Comment thread src/wallet/wallet.cpp Resolved
@kiwidream

Copy link
Copy Markdown
Member Author

PR Review

Findings

No blocking findings from this review pass.

Consensus Impact

Consensus-adjacent

The PR does not change consensus validation itself, but it changes wallet/RPC output selection on restricted-output chains so wallet-created transactions do not produce spendable non-P2MR outputs that consensus later rejects with tx-output-not-p2mr.

Review Scope

Reviewed issue #19 as the contract, PR #25 body, full diff, surrounding wallet/RPC/spend call paths, changed tests, review timeline, and thread state. The prior bugbot missing-manager error report is resolved and outdated on the latest head.

Deep Checks Performed

Traced explicit address_type and change_type parsing through ParseWalletOutputType, startup -addresstype / -changetype validation, GetNewDestination, ReserveDestination, funding/PSBT change reservation, GUI available-address-type filtering, and the changeAddress bypass case. The implementation now enforces both chain allowance and matching wallet manager availability where needed.

Issue Fit

The PR matches #19: mixed-manager wallets under -p2mronly=1 reject explicit non-P2MR receive/change types, funding change_type, and PSBT change_type before producing invalid outputs. The tests cover all non-P2MR wallet output types, not just the legacy/bech32 examples, and also cover missing-manager errors for blank wallets.

qbit-Specific Checks

P2MR restricted-output behavior is kept at the wallet/RPC boundary; no AuxPoW, PHOTON, serialization, validation-state, or block-validity code is changed. Lower-level destination guards add defense for direct receive/change calls that bypass RPC parsing.

Validation Reviewed

Author-listed validation includes targeted unit, wallet functional, full wallet unit suite, build targets, and Docker lint. Visible GitHub checks were still pending for many jobs at review time, so I am not treating CI as fully green. Local static checks for this review: git diff --check passed, PR-head wallet_p2mr.py parsed with Python ast, and the PR-head BuildKit helper passed bash -n. I did not run the full unit or functional suites locally because there is no local build directory in this workspace.

Residual Risk

Full CI completion is still needed, especially wallet functional/unit jobs and Docker lint. I also did not exercise runtime behavior locally against built binaries; this review is based on static tracing plus the visible test additions.

@kiwidream
kiwidream merged commit 95f74fc into 0.1.x Jun 28, 2026
33 checks passed
kiwidream added a commit that referenced this pull request Jun 29, 2026
* 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
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.

1 participant