Skip to content

Pay to Script (P2S) improves wallet ecosystem safety, simplifies contract design, and reduces transaction sizes for vault, multi-party, and DeFi applications.

Notifications You must be signed in to change notification settings

bitjson/bch-p2s

Repository files navigation

CHIP-2024-12 P2S: Pay to Script

    Title: Pay to Script
    Type: Standards
    Layer: Consensus
    Maintainer: Jason Dreyzehner
    Initial Publication Date: 2024-12-12
    Latest Revision Date: 2024-09-05
    Version: 1.0.3 (c144f03f)
    Status: Frozen for Lock-In

Summary

This proposal makes Pay to Script (P2S) outputs standard and increases the length limits on token commitments and standard unlocking bytecode.

These changes improve wallet ecosystem safety, simplify contract design, and reduce transaction sizes for many vault, multi-party covenant, and decentralized financial applications.

Motivation & Benefits

  • Improve wallet ecosystem safety - Many kinds of contracts should not by "randomly payable" by naive wallets, but because P2SH contracts always have payable addresses, it's easy for confused users to mistakenly send funds to unrecoverable locations. This proposal gives contract authors a new primitive that is both more byte efficient and safer for end users.

  • Simplify contracts - This proposal avoids the need for intermediate construction of P2SH contracts in a variety of use cases, simplifying inspection and modification of the active bytecode, and avoiding wasted bytes and hashing – both in packing (validating the P2SH address within the covenant) and unpacking (at spending time) the P2SH contract. This reduces the overhead of most covenant systems by at least 34 bytes per output.

Deployment

Deployment of this specification is proposed for the May 2026 upgrade.

  • Activation is proposed for 1763208000 MTP, (2025-11-15T12:00:00.000Z) on chipnet.
  • Activation is proposed for 1778846400 MTP, (2026-05-15T12:00:00.000Z) on the BCH network (mainnet), testnet3, testnet4, and scalenet.

Technical Specification

Standard output validation is relaxed to allow Pay to Script (P2S) outputs, and the limits on maximum token commitment length and maximum standard unlocking bytecode length are increased.

Locking Bytecode Length

The existing output standardness validation requiring spendable outputs to match a known pattern (P2PK, P2PKH, P2SH20, P2SH32, OP_RETURN, or BMS) is replaced by:

  1. Length check: the locking bytecode of standard outputs must have a length less than or equal to 201, the maximum length of currently standard bare multi-signature (BMS) outputs. See Rationale: Selection of Maximum Locking Bytecode Length.
  2. Data-carrier validation: locking bytecode which exceeds the length check but matches the existing data-carrier pattern (OP_RETURN) is standard if accepted by the existing data-carrier validation (the cumulative 223-byte limit across all transaction outputs).

Retained Allowance for Multi-Signature Spends

Note that UTXO standardness checks must also retain the additional allowance for bare multi-signature patterns; these remain nonstandard to create beyond the existing 3-key limit, but UTXOs exceeding the limit remain spendable in standard transactions (matching the existing behavior for these cases).

Token Commitment Length

The limit on maximum length of token commitments is raised from 40 bytes to 128 bytes. See Rationale: Selection of Maximum Token Commitment Length.

Unlocking Bytecode Length

The limit on maximum standard input bytecode length (A.K.A. MAX_TX_IN_SCRIPT_SIG_SIZE – 1,650 bytes) is removed such that the maximum unlocking bytecode length is equal for both standard and consensus validation: 10,000 bytes (A.K.A. MAX_SCRIPT_SIZE). See Rationale: Unification of Standard and Consensus Unlocking Bytecode Length.

Rationale

Evaluations of Alternatives

Risk Assessment

Test Vectors

This proposal includes a suite of functional tests and benchmarks to verify the performance of all operations within virtual machine implementations.

Implementations

Please see the following implementations for additional examples and test vectors:

Stakeholder Responses & Statements

Stakeholder Responses & Statements →

Feedback & Reviews

Changelog

This section summarizes the evolution of this proposal.

Copyright

This document is placed in the public domain.

About

Pay to Script (P2S) improves wallet ecosystem safety, simplifies contract design, and reduces transaction sizes for vault, multi-party, and DeFi applications.

Topics

Resources

Stars

Watchers

Forks

Contributors