BIP 349 (OP_INTERNALKEY)

A proposed opcode that exposes the Taproot internal key to scripts, enabling contracts to commit to it.

Basically

BIP 349 is a proposed Bitcoin rule for Taproot spending scripts. It lets a script reuse the internal key already in the output instead of adding the key again.

Key Takeaways

  • BIP 349 defines OP_INTERNALKEY, a proposed tapscript opcode that pushes the 32-byte x-only Taproot internal key onto the script stack, removing the need to embed it as literal data.
  • The proposal replaces the reserved OP_SUCCESS203 slot, byte 0xcb, making it deployable as a backward-compatible soft fork under the existing tapscript upgrade framework defined in BIP 342.
  • BIP 349 is a core component of the LNHANCE soft-fork bundle, where it combines with CTV and CSFS to enable recursive covenants, delegation patterns and more efficient Lightning constructions.

What Is BIP 349?

BIP 349 is a Bitcoin Improvement Proposal for a new tapscript opcode called OP_INTERNALKEY. Brandon Black and Jeremy Rubin authored it, assigning opcode byte 0xcb to one operation: pushing the Taproot internal key onto the script execution stack during a script-path spend.

Taproot's design in BIP 341 makes every P2TR output commit to an "internal key" and, optionally, a Merkle tree of scripts. During a script-path spend, Bitcoin's consensus code already extracts this key from the control block to verify the Merkle proof, but the script cannot access it during execution. BIP 349 closes that gap by putting a value the consensus layer already has directly on the script stack.

The proposal remains in Draft status, with a reference implementation in Bitcoin Core PR #29269. You can test it on Bitcoin Inquisition, a signet-based testing environment for proposed consensus changes.

How It Works

BIP 349 is intentionally minimal, with no inputs and one output: the 32-byte x-only representation of the Taproot internal key, called p in BIP 341. It operates only within tapscript with leaf version 0xc0, as defined in BIP 342.

Technical Specification

The complete execution semantics fit in a few lines. You can describe the operation as a single stack push.

The opcode replaces an OP_SUCCESS slot, which currently makes any script containing OP_SUCCESS203 succeed unconditionally. After activation, scripts containing byte 0xcb are no longer automatically valid; the byte instead triggers a stack push and script execution continues normally. The change strictly narrows the set of valid scripts, which makes it a soft fork.

Weight Savings

A script without OP_INTERNALKEY must embed the internal key as a 32-byte literal push. The opcode performs the same operation with just 1 byte.

The change saves 32 bytes of witness data, or approximately 8 vBytes under the SegWit witness discount. The savings are modest for a single script but compound in channel factories and timeout trees, where hundreds of script leaves reference the same key.

Design Rationale

The BIP identifies three core motivations for exposing the internal key to scripts. They cover conditional key spends, NUMS points and automatic re-keying.

Key-Spend with Script Conditions

Many spending policies require the internal key holder to sign, but only under extra conditions such as a timelock, a hash preimage or a second co-signer. Without OP_INTERNALKEY, every script leaf that references the internal key must duplicate it as literal data. The opcode removes this redundancy, saving weight and simplifying script construction.

NUMS Point for Hash-Locked Outputs

A hash-locked covenant can intentionally disable key-path spending by setting the internal key to a Nothing-Up-My-Sleeve (NUMS) point, a valid secp256k1 x-coordinate with no known private key. BIP 349 notes that finding a valid NUMS point typically takes approximately 2 attempts because roughly half of 32-byte values are valid x-coordinates on the curve.

Automatic Re-Keying

The BIP presents automatic re-keying as its most powerful motivation. In multi-party protocols where participants change, such as updating a MuSig2 aggregate key when a signer rotates, scripts using OP_INTERNALKEY automatically reference the new key without reconstruction. Scripts embedding the key as literal data break when it changes, so you must rebuild the entire taptree.

The BIP illustrates this with a concrete example. It compares an opcode reference with a key embedded as literal data.

The first form automatically picks up the new key when you recreate the output with a new internal key X'. The second form still references the old key X, invalidating the construction.

The LNHANCE Bundle

BIP 349 is part of the LNHANCE soft-fork proposal, which bundles it with three other opcodes to unlock new protocol constructions. CTV and CSFS are among the opcodes it works with.

These opcodes compose in ways that none achieves alone. For example, OP_INTERNALKEY OP_CHECKSIGFROMSTACK verifies that the internal key holder signed an arbitrary message, enabling delegation without embedding the key in the script. Adding CTV lets the internal key holder authorise specific pre-committed transactions, forming the basis for vaults, LN-Symmetry channels and non-interactive channel opens.

A separate proposal, BIP 448, also includes OP_INTERNALKEY alongside OP_TEMPLATEHASH (BIP 446) and CSFS as a "taproot-native covenant bundle." Both proposals share OP_INTERNALKEY as a common component. Their overlap shows broad agreement on its utility even where other opcode choices differ.

Recursive Covenants

A covenant restricts how you can spend a UTXO, and a recursive covenant carries those restrictions across multiple transactions. BIP 349 enables a clean recursive pattern: a script using OP_INTERNALKEY persists across state transitions because the opcode dynamically resolves to whatever key the current output commits to. You avoid hardcoding keys into covenant scripts, which would break recursion when keys change.

CTV constrains the transaction template, while CSFS validates authorisation signatures. Combined with them, OP_INTERNALKEY allows covenant scripts to enforce spending rules indefinitely without growing in size or complexity at each step.

Delegation

Delegation lets the internal key holder authorise a third party to spend under specific conditions without revealing their private key or constructing a new multisig arrangement. The pattern combines OP_INTERNALKEY with CSFS.

The internal key holder signs a message off-chain that encodes the delegated spending conditions. Anyone can then satisfy the script by providing this signature, without needing the internal key holder to be online. That helps Lightning channel constructions where one party may be offline during force-close scenarios.

LN-Symmetry Channels

LN-Symmetry, formerly eltoo, replaces Lightning's penalty-based channel model with a symmetric design where the latest state always wins. OP_INTERNALKEY lets update scripts reference the channel's aggregate signing key without hardcoding it, simplifying channel state machines and reducing on-chain costs during unilateral closes. The LNHANCE soft-fork proposal details how these opcodes compose for practical Lightning improvements.

Timeout Trees and Channel Factories

Channel factories and timeout trees use hierarchical taptree structures where potentially hundreds of script leaves reference the same key, so OP_INTERNALKEY's 32-byte saving per leaf compounds significantly. Combined with CTV for pre-committed exit paths, these structures can scale Lightning onboarding by orders of magnitude.

Vaults

Vault constructions use time-delayed spending to protect against key compromise, with CTV committing to the exact withdrawal template while OP_INTERNALKEY and CSFS provide flexible authorisation. A watchtower can monitor for unauthorised withdrawal attempts and trigger a clawback before the timelock expires. The internal key holder authorises withdrawals, but CTV ensures funds can only move to pre-committed destinations.

Why It Matters

BIP 349 is a small specification with broad implications for Bitcoin's programmability. It gives tapscript access to data the consensus layer already possesses, avoiding new cryptographic complexity while enabling more expressive spending conditions. Protocols built on Taproot, including Layer 2 networks like Spark, gain richer scripting capabilities for more sophisticated off-chain constructions with trustless on-chain settlement.

The proposal also reflects a design philosophy gaining traction in Bitcoin development: provide a general-purpose primitive that composes with other opcodes rather than a purpose-built opcode for a specific feature. That composability explains why it appears in multiple competing soft-fork bundles. As the covenant activation debate continues, OP_INTERNALKEY's minimal footprint and clear utility make it one of the least controversial components under discussion.

Draft Status

BIP 349 has no activation parameters defined, and whether it ships as part of LNHANCE, BIP 448 or a standalone soft fork remains open. Treat OP_INTERNALKEY as experimental until developers establish a concrete activation path.

Bundling Dynamics

OP_INTERNALKEY's inclusion in multiple soft-fork bundles has benefits and risks. It reflects consensus on the opcode's value, but disagreement over a companion opcode such as CTV or CSFS could delay OP_INTERNALKEY's activation alongside it. The Bitcoin development community continues to debate whether bundling or individual activation produces better outcomes.

Limited Standalone Value

On its own, OP_INTERNALKEY provides a modest 8 vByte saving per key reference. Its uses in recursive covenants, delegation and LN-Symmetry require companion opcodes. The opcode's full value therefore depends on other proposals also activating, creating a chicken-and-egg dynamic.

OP_SUCCESS Replacement

Redefining an OP_SUCCESS opcode is among the safest soft-fork approaches because it strictly narrows validity. However, anyone relying on OP_SUCCESS203's unconditional success would have their spends invalidated after activation. No known scripts depend on this specific behaviour, but the risk is non-zero for any OP_SUCCESS replacement.

Tapscript Scope

OP_INTERNALKEY works only in tapscript spends with leaf version 0xc0. It cannot be used in legacy scripts, P2WPKH or P2WSH outputs, so protocols operating on pre-Taproot output types cannot benefit from it, limiting its applicability to newer Taproot-native constructions.

The glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.

0

← All 1876 glossary terms