NAME

Bitcoin::Crypto::Constants - Bitcoin-related constant values

SYNOPSIS

use Bitcoin::Crypto::Constants (
	# these constants are grouped under :curve tag
	'CURVE_NAME',
	'CURVE_ORDER',
	'CURVE_GENERATOR',

	# these constants are grouped under :key tag
	'MAX_CHILD_KEYS',
	'KEY_MAX_LENGTH',
	'WIF_COMPRESSED_BYTE',

	# these constants are grouped under :witness tag
	'SEGWIT_WITNESS_VERSION',
	'TAPROOT_WITNESS_VERSION',
	'MAX_WITNESS_VERSION',

	# these constants are grouped under :bip44 tag
	'BIP44_PURPOSE',
	'BIP44_COMPAT_PURPOSE',
	'BIP44_SEGWIT_PURPOSE',
	'BIP44_TAPROOT_PURPOSE',

	# these constants are grouped under :coin tag
	'UNITS_PER_COIN',
	'MAX_MONEY',

	# these constants are grouped under :transaction tag
	'LOCKTIME_HEIGHT_THRESHOLD',
	'MAX_SEQUENCE_NO',
	'RBF_SEQUENCE_NO_THRESHOLD',
	'NULL_UTXO',

	# these constants are grouped under :sighash tag
	'SIGHASH_DEFAULT',
	'SIGHASH_ALL',
	'SIGHASH_NONE',
	'SIGHASH_SINGLE',
	'SIGHASH_ANYONECANPAY',

	# these constants are grouped under :script tag
	'SCRIPT_MAX_STACK_ELEMENTS',
	'SCRIPT_MAX_ELEMENT_SIZE',
	'SCRIPT_MAX_OPCODES',
	'SCRIPT_MAX_SIZE',
	'SCRIPT_MAX_MULTISIG_PUBKEYS',
	'TAPSCRIPT_LEAF_VERSION',

	# these constants are grouped under :psbt tag
	'PSBT_MAGIC',
	'PSBT_SEPARATOR',
	'PSBT_GLOBAL_MAP',
	'PSBT_INPUT_MAP',
	'PSBT_OUTPUT_MAP',

	# these constants are grouped under :bech32 tag
	'BECH32',
	'BECH32M',

	# these constants are ungrouped
	'USE_BIGINTS',
);

# or, if you are not sure...
use Bitcoin::Crypto::Constants qw(:all);

DESCRIPTION

This package contains named constants for all kinds of values used across Bitcoin. It is not uncommon to have a need to use these values in code which interacts with Bitcoin::Crypto.

Each constant can be accessed either by importing it (as shown above) or by calling a fully qualified name, like Bitcoin::Crypto::Constants::MAX_MONEY. For backward compatibility, the second form can also be used with lowercase name: Bitcoin::Crypto::Constants::max_money.

To avoid overly long import statements, constants are organized under tags. Unless there is a reason not to, it is recommended to import tags instead of each constant separately. The exception is the :all tag, which should be used sparingly.

TAGS

:all

Imports everything. Should generally be avoided to not clutter the namespace.

:curve

Contains basic secp256k1 curve data:

"CURVE_NAME", "CURVE_ORDER", "CURVE_GENERATOR"

:key

Contains values which may be required when dealing with keys:

"MAX_CHILD_KEYS", "KEY_MAX_LENGTH", "WIF_COMPRESSED_BYTE"

:witness

Contains values for witness versions:

"SEGWIT_WITNESS_VERSION", "TAPROOT_WITNESS_VERSION", "MAX_WITNESS_VERSION"

:bip44

Contains various BIP44 purpose values:

"BIP44_PURPOSE", "BIP44_COMPAT_PURPOSE", "BIP44_SEGWIT_PURPOSE", "BIP44_TAPROOT_PURPOSE"

:coin

Contains very basic coin constants:

"UNITS_PER_COIN", "MAX_MONEY"

:transaction

Contains constants used together with transactions:

"LOCKTIME_HEIGHT_THRESHOLD", "MAX_SEQUENCE_NO", "RBF_SEQUENCE_NO_THRESHOLD", "NULL_UTXO"

:sighash

Contains known sighash values:

"SIGHASH_DEFAULT", "SIGHASH_ALL", "SIGHASH_NONE", "SIGHASH_SINGLE", "SIGHASH_ANYONECANPAY"

:script

Contains values used during script creation and execution:

"SCRIPT_MAX_STACK_ELEMENTS", "SCRIPT_MAX_ELEMENT_SIZE", "SCRIPT_MAX_OPCODES", "SCRIPT_MAX_SIZE", "SCRIPT_MAX_MULTISIG_PUBKEYS", "TAPSCRIPT_LEAF_VERSION"

:psbt

Contains values useful for PSBTs:

"PSBT_MAGIC", "PSBT_SEPARATOR", "PSBT_GLOBAL_MAP", "PSBT_INPUT_MAP", "PSBT_OUTPUT_MAP"

:bech32

Contains values useful for BECH32:

"BECH32", "BECH32M"

CONSTANTS

CURVE_NAME

Curve name used by Bitcoin, secp256k1

CURVE_ORDER

A bytestring containing the secp256k1 curve order.

CURVE_GENERATOR

A bytestring with serialized uncompressed curve generator point for secp256k1.

MAX_CHILD_KEYS

Maximum number of keys which can be derived in extended key derivation. Values above it start being recognized as hardened instead, and start counting from 0.

KEY_MAX_LENGTH

The maximum byte length of a serialized private key.

WIF_COMPRESSED_BYTE

A magic byte which is used in WIFs to mark the key as compressed.

SEGWIT_WITNESS_VERSION

Numeric witness version used in SegWit (version 0) programs.

TAPROOT_WITNESS_VERSION

Numeric witness version used in Taproot (version 1) programs.

MAX_WITNESS_VERSION

Numeric maximum possible witness version.

BIP44_PURPOSE

Numeric base BIP44 purpose.

BIP44_COMPAT_PURPOSE

Numeric BIP44 compat SegWit purpose (BIP49)

BIP44_SEGWIT_PURPOSE

Numeric BIP44 native SegWit purpose (BIP84)

BIP44_TAPROOT_PURPOSE

Numeric BIP44 native SegWit purpose (BIP86)

UNITS_PER_COIN

Number of satoshis that equal a single coin.

MAX_MONEY

Number of satoshis that will ever exist.

LOCKTIME_HEIGHT_THRESHOLD

First number which will be understood as timestamp in locktime checks.

MAX_SEQUENCE_NO

Default and maximum possible "sequence_no" in Bitcoin::Crypto::Transaction::Input.

RBF_SEQUENCE_NO_THRESHOLD

Value which is used in finding out if a transaction has Replace-By-Fee enabled.

NULL_UTXO

An 2-element array reference which is an UTXO location for a coinbase transaction.

SIGHASH_DEFAULT

Default hashtype for digests - only used in Taproot. Functionally equal to SIGHASH_ALL.

SIGHASH_ALL

Hashtype for digesting all outputs of a transaction - default in pre-Taproot.

SIGHASH_NONE

Hashtype for digesting no transaction outputs.

SIGHASH_SINGLE

Hashtype for digesting only one output in a transaction, corresponding to this input.

SIGHASH_ANYONECANPAY

Hashtype for digesting only this input and no other inputs. Cannot be used standalone, must be binary-or'ed with other SIGHASH constants.

SCRIPT_MAX_STACK_ELEMENTS

Maximum number of elements which can be kept on a script stack and altstack together.

SCRIPT_MAX_ELEMENT_SIZE

Maximum byte size of a single stack element.

SCRIPT_MAX_OPCODES

Maximum non-push opcodes which can be used in a single script. Not applicable to Taproot.

SCRIPT_MAX_SIZE

Maximum script size in bytes. Not applicable to Taproot.

SCRIPT_MAX_MULTISIG_PUBKEYS

Maximum OP_CHECKMULTISIG public keys.

TAPSCRIPT_LEAF_VERSION

Tree leaf version number used in Taproot tapscript spends.

PSBT_MAGIC

A magic byte sequence which is required in PSBTs.

PSBT_SEPARATOR

A byte sequence which separates PSBT maps.

PSBT_GLOBAL_MAP

A value for making use of global PSBT maps.

PSBT_INPUT_MAP

A value for making use of input PSBT maps.

PSBT_OUTPUT_MAP

A value for making use of output PSBT maps.

BECH32

A value used for marking original bech32 serialization

BECH32M

A value used for marking bech32m serialization

USE_BIGINTS

Whether the module currently uses BigInts (32-bit architecture compatibility). Can be forced to a true value by setting BITCOIN_CRYPTO_USE_BIGINTS environmental variable.