Skip to content

Wallet explicit output types can create non-P2MR outputs on restricted-output chains #19

Closed

Description

@kiwidream

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:

  • getnewaddress with explicit address_type
  • getrawchangeaddress with explicit address_type
  • send/funding paths with explicit change_type
  • fundrawtransaction
  • walletcreatefundedpsbt

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 handling
  • src/wallet/rpc/util.cpp: explicit wallet output type parsing
  • src/wallet/rpc/addresses.cpp: receive/change address RPC paths
  • src/wallet/rpc/spend.cpp: explicit change type handling
  • src/validation.cpp: restricted-output consensus rejection via tx-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:

  1. the wallet has a usable ScriptPubKeyMan, and
  2. 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
  • fundrawtransaction
  • walletcreatefundedpsbt

The tests should verify that explicit non-P2MR spendable output types fail before producing wallet outputs that consensus would later reject.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions