THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

Bitcoin Taproot Explained: P2TR, Key-Path, and Script-Path Spending

permalink THAMER
#bip341#bip342#bitcoin-taproot#key-path#p2tr#script-path#tapscript

Taproot is a Bitcoin upgrade activated in November 2021. It defines a SegWit version 1 output type called Pay-to-Taproot (P2TR) and supports spending through either a key path or a script path. Taproot is not a separate blockchain, token, or AI feature.

What is a P2TR output?

A P2TR output commits to a 32-byte x-only public key encoded as a witness version 1 program. Its output key can commit to an optional tree of scripts. The public address commonly begins with bc1p on mainnet and uses Bech32m encoding.

The output key is constructed using a Taproot tweak. A wallet cannot safely assume an arbitrary x-only public key is interchangeable with the final output key without applying the relevant construction rules.

What is key-path spending?

A key-path spend authorizes the output with a valid Schnorr signature for the Taproot output key. This can be compact and does not reveal a script tree. Wallet implementations often begin with this path, including BIP86-style single-key wallets that use a Taproot output without a script spending path.

What is script-path spending?

A script-path spend reveals the executed script leaf, the inputs needed to satisfy it, and a control block proving the leaf's commitment to the Taproot output. Other committed leaves do not need to be disclosed. Tapscript, specified by BIP342, defines the relevant script rules for tapscript leaves.

Script-path support requires more than accepting a bc1p address. A wallet needs correct script construction, control blocks, witness serialization, signature handling, and policy checks.

How is Taproot related to Schnorr?

BIP340 specifies Schnorr signatures over secp256k1, which Taproot uses for key-path authorization and for applicable signature checks in Tapscript. Schnorr signatures are a cryptographic building block; they do not themselves manage wallet permissions or automate payments.

What can developers safely claim about a Taproot wallet?

Be precise about the tested capability:

  • P2TR receive: can derive and display valid version 1 receiving addresses.
  • P2TR destination send: can construct a transaction paying to a Taproot output.
  • Key-path spend: can spend controlled P2TR outputs using the appropriate Schnorr signing path.
  • Script-path spend: can satisfy and reveal a committed Taproot script branch.

These are distinct features. A wallet supporting the first two is not automatically a general-purpose Tapscript engine.

Primary references

  • BIP340 — Schnorr Signatures: https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
  • BIP341 — Taproot: https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki
  • BIP342 — Tapscript: https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki
  • BIP86 — Key Derivation for Single Key P2TR Outputs: https://github.com/bitcoin/bips/blob/master/bip-0086.mediawiki

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects