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 SIGHASH Types Explained: ALL, NONE, SINGLE, and ANYONECANPAY

permalink THAMER
#anyonecanpay#bitcoin-sighash#sighash-all#sighash-single

Bitcoin transaction signatures do not simply sign a transaction ID. They authorize a precisely defined message derived from transaction data and a signature hash mode. The signed fields depend on the spending rules: legacy Script, SegWit version 0, and Taproot do not use identical message construction.

What does SIGHASH_ALL commit to?

SIGHASH_ALL is the ordinary mode. It commits to all outputs and, subject to the applicable signature algorithm, the transaction's input information. This prevents an intermediary from freely changing recipients or amounts without invalidating the signature. The exact message includes additional context such as locktime and, in SegWit v0, the amount of the spent output.

SIGHASH_NONE and SIGHASH_SINGLE

SIGHASH_NONE does not commit to any transaction outputs, allowing them to change. SIGHASH_SINGLE commits to the output corresponding to the signed input's index rather than all outputs. These modes are specialized tools and can be unsafe when their flexibility is not intended.

Legacy SIGHASH_SINGLE has a historical out-of-range behavior; Taproot instead makes a SIGHASH_SINGLE signature invalid when the corresponding output does not exist. Implementations must use the rules of the actual script version.

What does ANYONECANPAY change?

The ANYONECANPAY flag limits commitment to the current input rather than all inputs. It can be combined with ALL, NONE, or SINGLE. It does not, by itself, mean that any party can spend the signed input: the signature still must satisfy that input's spending conditions.

Why does Taproot have SIGHASH_DEFAULT?

Taproot introduces SIGHASH_DEFAULT (0x00), which has ALL-like semantics for a Taproot signature. A 64-byte Schnorr signature uses the default hash type; a 65-byte signature carries an explicit nonzero hash-type byte. Not every historical hash-type value is valid in Taproot.

Implementation checklist

Determine the script version before constructing a signature message. Check output-index requirements for SINGLE, confirm that the spent output amount and script information are correct, and never assume a legacy sighash routine works for Taproot.

Primary references

BIP143 — Transaction Signature Verification for Version 0 Witness Program: https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki
BIP341 — Taproot: https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki
BIP342 — Validation of Taproot Scripts: https://github.com/bitcoin/bips/blob/master/bip-0342.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