Repository navigation
Description
Summary
On restricted-output chains, wallet defaults correctly prefer P2MR receive/change outputs. However, explicit wallet output type selection can still accept legacy or bech32 when the corresponding ScriptPubKeyMan exists.
That can let wallet RPC/config paths construct outputs that consensus later rejects with tx-output-not-p2mr.
Impact
A wallet in a mixed-manager state can hand out or create addresses/transactions that look valid from the wallet side but are invalid under restricted-output consensus rules.
Affected surfaces may include:
getnewaddresswith explicitaddress_typegetrawchangeaddresswith explicitaddress_type- send/funding paths with explicit
change_type fundrawtransactionwalletcreatefundedpsbt
Default change selection appears safe; the issue is explicit type selection when a non-P2MR manager is available.
Source Trace
Relevant areas:
src/wallet/wallet.cpp: output type availability and default change handlingsrc/wallet/rpc/util.cpp: explicit wallet output type parsingsrc/wallet/rpc/addresses.cpp: receive/change address RPC pathssrc/wallet/rpc/spend.cpp: explicit change type handlingsrc/validation.cpp: restricted-output consensus rejection viatx-output-not-p2mr
The risky pattern is that explicit output type parsing checks whether the wallet has a matching manager, but does not also require that the selected type is allowed by the chain's restricted-output consensus policy.
Expected Behavior
On restricted-output chains, explicit receive/change output type requests should be accepted only if the requested type is chain-allowed.
For current restricted-output mode, wallet-created spendable outputs should be P2MR unless the output type is a consensus exception such as OP_RETURN or PayToAnchor where applicable.
Proposed Fix
Require explicit address_type / change_type selection on restricted-output chains to satisfy both:
- the wallet has a usable
ScriptPubKeyMan, and - the requested output type is allowed by the chain's restricted-output rules.
Suggested Tests
Add mixed-manager restricted-chain coverage for:
getnewaddress(address_type=legacy)getnewaddress(address_type=bech32)getrawchangeaddress(address_type=legacy|bech32)- send/funding RPCs with explicit non-P2MR
change_type fundrawtransactionwalletcreatefundedpsbt
The tests should verify that explicit non-P2MR spendable output types fail before producing wallet outputs that consensus would later reject.
Activity