Tapscript and Lightning Network Upgrades
14. Tapscript and Lightning Network Upgrades
Taproot and Tapscript create the foundation for significant improvements to the Lightning Network. Several Lightning upgrades depend directly on Tapscript features.
Current Lightning Architecture vs Taproot Lightning
Current Lightning channels use P2WSH (SegWit v0) outputs. Each channel's funding transaction output reveals:
-
That it is a 2-of-2 multisig (from the scriptPubKey structure)
-
That it is likely a Lightning channel (statistical fingerprinting)
With Taproot Lightning (called "simple taproot channels" in the specification):
Current P2WSH channel funding:
OP_0 <32-byte-script-hash>
→ When spent, reveals: <sig1> <sig2> <2-of-2 multisig redeemscript>
→ Obviously a Lightning channel
Taproot channel funding:
OP_1 <32-byte-x-only-pubkey> (MuSig2 aggregate key)
→ When spent cooperatively: <64-byte aggregate signature>
→ Indistinguishable from any single-signer P2TR spend
PTLCs Replacing HTLCs
Hash Time Locked Contracts (HTLCs) are the fundamental building block of Lightning payments. They use OP_SHA256 to lock payment routing. The problem is that the same hash preimage is used along the entire payment path, allowing routing nodes to correlate payments.
PTLCs (Point Time Locked Contracts) replace the hash with an elliptic curve point (an adaptor signature commitment):
Current HTLC in Lightning:
// Offered HTLC output script:
OP_DUP OP_HASH160 <revocation_pubkey_hash> OP_EQUAL
OP_IF
OP_CHECKSIG
OP_ELSE
<remote_htlcpubkey> OP_SWAP OP_SIZE 32 OP_EQUAL
OP_IF
OP_HASH160 <payment_hash> OP_EQUALVERIFY
OP_2 <local_htlcpubkey> <remote_htlcpubkey> OP_2 OP_CHECKMULTISIG
OP_ELSE
OP_DROP <cltv_expiry> OP_CHECKLOCKTIMEVERIFY OP_DROP
OP_CHECKSIG
OP_ENDIF
OP_ENDIF
Future PTLC in Tapscript:
// Much simpler — the adaptor secret replaces the hash preimage
// Most of the complexity moves into the cryptographic protocol
<remote_ptlcpubkey> OP_CHECKSIGADD
<local_ptlcpubkey> OP_CHECKSIGADD
OP_2 OP_EQUAL
// With adaptor signatures handling the payment secret atomicity
Taproot Channel State Machine
The Lightning channel state machine benefits from Tapscript in several ways:
Commitment transactions (Taproot Lightning):
Funding output:
OP_1 <musig2_agg_key>
Commitment tx output options:
1. To-local (cooperative): Key path with MuSig2
2. To-local (penalty): Script path revealing revocation condition
3. To-remote: P2TR with remote's key
4. PTLC outputs: Tapscript leaves in MAST tree
Benefit: Unilateral close looks like cooperative close from output perspective
(script path reveals only the spent leaf, not the full channel structure)
Eltoo (LN-Symmetry) and Tapscript
Eltoo (renamed LN-Symmetry) is a proposed Lightning channel update mechanism that eliminates the need for penalty transactions. It requires OP_CHECKSEQUENCEVERIFY and an opcode called OP_CHECKSIGFROMSTACK (or alternatively OP_CAT + OP_CHECKSIG).
Both OP_CHECKSIGFROMSTACK and OP_CAT are candidates for OP_SUCCESS redefinition in Tapscript, making Eltoo a Tapscript-dependent upgrade:
Eltoo update mechanism (requires new opcode):
// Update transaction can be replaced by any later state
// Uses SIGHASH_ANYPREVOUT (another pending soft fork)
<settlement_sig> <update_sig>
<update_pubkey> OP_CHECKSIGVERIFY
<settlement_pubkey> OP_CHECKSIG
// Combined with SIGHASH_ANYPREVOUT to allow transaction rebinding
Technical Insight
This topic covers essential mechanics for Chapter 11. Understanding these details is key to mastering advanced Bitcoin script constructions like Taproot and specialized covenants.
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: