Options
All
  • Public
  • Public/Protected
  • All
Menu

@bitauth/libauth

Index

Enumerations

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

AnyCompilationEnvironment

AnyCompilationEnvironment<TransactionContext>: CompilationEnvironment<TransactionContext, string | false, string | false, string | false, string | false, string | false, string | false>

Any compilation environment, where each data type may use either a single or multiple operations.

Type parameters

  • TransactionContext

AnyCompilationEnvironmentIgnoreOperations

AnyCompilationEnvironmentIgnoreOperations<TransactionContext>: Omit<AnyCompilationEnvironment<TransactionContext>, "operations">

Any compilation environment where the type of the operations value is irrelevant.

Type parameters

  • TransactionContext

AuthenticationInstruction

AuthenticationInstruction<Opcodes>: AuthenticationInstructionPush<Opcodes> | AuthenticationInstructionOperation<Opcodes>

A properly-formed instruction used by an AuthenticationVirtualMachine.

Type parameters

  • Opcodes

AuthenticationInstructions

AuthenticationInstructions<Opcodes>: AuthenticationInstruction<Opcodes>[]

Type parameters

  • Opcodes

AuthenticationTemplateVariable

AuthenticationVirtualMachineIdentifier

AuthenticationVirtualMachineIdentifier: "BCH_2022_11_SPEC" | "BCH_2022_11" | "BCH_2022_05_SPEC" | "BCH_2022_05" | "BCH_2021_11_SPEC" | "BCH_2021_11" | "BCH_2021_05_SPEC" | "BCH_2021_05" | "BCH_2020_11_SPEC" | "BCH_2020_11" | "BCH_2020_05" | "BCH_2019_11" | "BCH_2019_05" | "BSV_2020_02" | "BSV_2018_11" | "BTC_2017_08"

Allowable identifiers for authentication virtual machine versions. The BCH prefix identifies the Bitcoin Cash network, the BSV prefix identifies the Bitcoin SV network, and the BTC prefix identifies the Bitcoin (Core) network.

Virtual machine versions may be marked with the SPEC suffix to indicate that they have not yet been deployed to a main network and are therefore only a draft specification. After deployment, when template compatibility is verified, templates should update their supported array to indicate compatibility with the live virtual machine version.

Base58AddressNetwork

Base58AddressNetwork: "mainnet" | "testnet" | "copay-bch"

The available networks for common Base58Address versions.

BytecodeGenerationCompletion

A successfully generated lockingBytecode (for an output) or unlockingBytecode (for an input). Because this bytecode generation was successful, the associated compilation directive in the transaction template can be replaced with this result for subsequent compilations. For example, if most inputs were successfully compiled, but some inputs require keys held by another entity, the transaction template can be updated such that only the final inputs contain compilation directives.

BytecodeGenerationResult

BytecodeGenerationResult<ProgramState>: { bytecode: Uint8Array; success: true } | CompilationResultError<ProgramState>

Type parameters

  • ProgramState

CashAddressAvailableSizes

CashAddressAvailableSizes: keyof typeof cashAddressBitToSize

CashAddressAvailableSizesInBits

CashAddressAvailableSizesInBits: keyof typeof cashAddressSizeToBit

CashAddressAvailableTypes

CashAddressAvailableTypes: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15

CompilationEnvironmentBCH

CompilationError

CompilationResult

CompilationResult<ProgramState>: CompilationResultSuccess<ProgramState> | CompilationResultError<ProgramState>

Type parameters

  • ProgramState

CompilationResultError

CompilationResultError<ProgramState>: CompilationResultParseError | CompilationResultResolveError | CompilationResultReduceError<ProgramState>

Type parameters

  • ProgramState

CompilerOperation

CompilerOperation<TransactionContext, CanBeSkipped, Data, Environment>: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped>

A compiler operation method which accepts the identifier being evaluated, the compilation data, and the compilation environment, and returns a CompilerOperationResult.

param

The full identifier used to describe this operation, e.g. owner.signature.all_outputs.

param

The CompilationData provided to the compiler

param

The CompilationEnvironment provided to the compiler

Type parameters

  • TransactionContext

    the type of the TransactionContext in CompilationData<TransactionContext> expected by this operation

  • CanBeSkipped: boolean

    if true, this operation may return CompilerOperationSkip to indicate that it cannot be applied and should be skipped

  • Data: CompilationData<TransactionContext>

    the type of the CompilationData expected by this operation

  • Environment: AnyCompilationEnvironment<TransactionContext>

    the type of the CompilationEnvironment expected by this operation

Type declaration

CompilerOperationError

An unsuccessful compiler operation result.

CompilerOperationResult

CompilerOperationResult<CanBeSkipped>: CanBeSkipped extends true ? CompilerOperationError | CompilerOperationSuccess | CompilerOperationSkip : CompilerOperationError | CompilerOperationSuccess

Type parameters

  • CanBeSkipped: boolean

CompilerOperationSuccess

A successful compiler operation result.

CompilerOperationSuccessSignatureType

A successful signature-generation compiler operation. This provides slightly more debugging information than CompilerOperationSuccessGeneric. The signing serialization or data message which was hashed to produce the to-be-signed message is also provided in the result.

CompilerOperationsKeyBCH

CompilerOperationsKeyBCH: "data_signature" | "public_key" | "schnorr_data_signature" | "schnorr_signature" | "signature"

CompilerOperationsKeysCommon

CompilerOperationsKeysCommon: "public_key" | "signature"

CompilerOperationsSigningSerializationCommon

Valid identifiers describing the various full and partial signing serializations available to the compiler.

CompilerOperationsSigningSerializationComponent

CompilerOperationsSigningSerializationComponent: "version" | "transaction_outpoints" | "transaction_outpoints_hash" | "transaction_sequence_numbers" | "transaction_sequence_numbers_hash" | "outpoint_transaction_hash" | "outpoint_index" | "covered_bytecode_length" | "covered_bytecode" | "output_value" | "sequence_number" | "corresponding_output" | "corresponding_output_hash" | "transaction_outputs" | "transaction_outputs_hash" | "locktime"

Valid identifiers for components of transaction signing serializations. Components are combined in various orders to produce each of the valid "full" signing serializations.

CompilerOperationsSigningSerializationFull

CompilerOperationsSigningSerializationFull: "full_all_outputs" | "full_all_outputs_single_input" | "full_corresponding_output" | "full_corresponding_output_single_input" | "full_no_outputs" | "full_no_outputs_single_input"

Valid identifiers for full transaction signing serialization algorithms. Each full serialization is double-sha256 hashed to produce the digest which is signed.

ExtendedScenarioDefinition

ExtendedScenarioDefinition: Required<Pick<ScenarioDefinition, "data">> & RequiredTwoLevels<Pick<ScenarioDefinition, "transaction">> & Required<Pick<ScenarioDefinition, "value">>

All scenarios extend the default scenario, so the data, transaction (and all transaction properties), and value properties are guaranteed to be defined in an extended scenario definition.

HdKeyNetwork

HdKeyNetwork: "mainnet" | "testnet"

The networks which can be referenced by an HD public or private key.

HdPrivateNode

A private node in a Hierarchical Deterministic (HD) key tree. To confirm the validity of this node, check the value of its valid property.

Note, HD nodes are network-independent. A network is required only when encoding the node as an HD key or using a derived public key in an address.

IdentifierResolutionFunction

IdentifierResolutionFunction: (identifier: string) => { bytecode: Uint8Array; status: true; type: opcode } | ({ bytecode: Uint8Array; status: true; type: variable } & ResolutionDebug & ResolutionSignature) | { bytecode: Uint8Array; source: ResolvedScript; status: true; type: script } | ({ entityOwnership?: undefined | string; error: string; recoverable: boolean; status: false; type: variable } & ResolutionDebug) | { error: string; scriptId: string; status: false; type: script } | { error: string; status: false; type: unknown }

A method which accepts a string and returns either the successfully resolved bytecode or an error. The string will never be empty (''), so resolution can skip checking the string's length.

Type declaration

Immutable

Immutable<T>:

A deep-readonly utility type. Can be removed when a built-in alternative is added to TypeScript. Derived from: https://github.com/microsoft/TypeScript/issues/13923#issuecomment-557509399

Type parameters

  • T

ImmutableArray

ImmutableArray<T>: keyof Immutable<T>[]

Type parameters

  • T

ImmutableMap

ImmutableMap<K, V>: ReadonlyMap<Immutable<K>, Immutable<V>>

Type parameters

  • K

  • V

ImmutableObject

ImmutableObject<T>: {}

Type parameters

  • T

Type declaration

ImmutablePrimitive

ImmutablePrimitive: undefined | null | boolean | string | number | Function

ImmutableSet

ImmutableSet<T>: ReadonlySet<Immutable<T>>

Type parameters

  • T

ImmutableUint8Array

ImmutableUint8Array: Readonly<ArrayLike<number>> & Iterable<number> & ImmutableObject<Uint8Array>

InputTemplate

InputTemplate<CompilerType, RequireEstimate, CompilationDataType>: Input<Uint8Array>

An input which may optionally use a CompilationDirectiveUnlocking as its unlockingBytecode property. During compilation, the final lockingBytecode will be generated from this directive.

If RequireEstimate is true, all input directives must include an estimate scenario ID. See estimateTransaction for details.

Type parameters

  • CompilerType

  • RequireEstimate

  • CompilationDataType

MakeOptional

MakeOptional<T, K>: Partial<Pick<T, K>> & Omit<T, K>

Type parameters

  • T

  • K: keyof T

Operation

Operation<ProgramState>: (state: ProgramState) => ProgramState

Operations define the behavior of an opcode in an InstructionSet.

Operations should be written as efficiently as possible, and may safely mutate the ProgramState. If needed, the AuthenticationVirtualMachine will clone the ProgramState before providing it to an operation.

Type parameters

  • ProgramState

Type declaration

    • (state: ProgramState): ProgramState
    • Parameters

      • state: ProgramState

      Returns ProgramState

OutputTemplate

OutputTemplate<CompilerType, EnableFeeEstimation, CompilationDataType>: Output<CompilationDirectiveLocking<CompilerType, CompilationDataType> | Uint8Array, EnableFeeEstimation extends true ? Uint8Array | undefined : Uint8Array>

An output which may optionally use a CompilationDirectiveLocking as its lockingBytecode property. During compilation, the final lockingBytecode will be generated from this directive.

If EnableFeeEstimation is true, the satoshis value may also be undefined (as estimated transactions always set output values to invalidSatoshis).

Type parameters

  • CompilerType

  • EnableFeeEstimation

  • CompilationDataType

ParseResult

ParseResult: { expected: string[]; index: SourcePosition; status: false } | { status: true; value: BtlScriptSegment }

ParsedAuthenticationInstruction

ParsedAuthenticationInstruction<Opcodes>: AuthenticationInstruction<Opcodes> | ParsedAuthenticationInstructionMalformed<Opcodes>

A potentially-malformed AuthenticationInstruction. If malformed is true, this could be either ParsedAuthenticationInstructionPushMalformedLength or ParsedAuthenticationInstructionPushMalformedData

If the final instruction is a push operation which requires more bytes than are available in the remaining portion of a serialized script, that instruction will have a malformed property with a value of true. .

Type parameters

  • Opcodes

ParsedAuthenticationInstructionMalformed

ParsedAuthenticationInstructionMalformed<Opcodes>: ParsedAuthenticationInstructionPushMalformedLength<Opcodes> | ParsedAuthenticationInstructionPushMalformedData<Opcodes>

Type parameters

  • Opcodes

ParsedAuthenticationInstructions

An array of authentication instructions which may end with a malformed instruction.

Implementation note: this type can be improved by only marking the final element as potentially malformed. This is waiting on: https://github.com/Microsoft/TypeScript/issues/1360

The following type can be used when it doesn't produce the error, A rest element must be last in a tuple type. [1256]:

export type ParsedAuthenticationInstructions<Opcodes = number> = [
  ...AuthenticationInstruction<Opcodes>,
  ParsedAuthenticationInstruction<Opcodes>
];

Type parameters

  • Opcodes

PrivateResults

PrivateResults<NodeType>: NodeType extends HdPrivateNodeKnownParent ? HdPrivateNodeKnownParent : HdPrivateNodeValid | childIndexExceedsMaximum | nextChildIndexRequiresHardenedAlgorithm

Type parameters

  • NodeType

PublicResults

PublicResults<NodeType>: NodeType extends HdPublicNodeKnownParent ? HdPublicNodeKnownParent : HdPublicNode | hardenedDerivationRequiresPrivateNode | nextChildIndexRequiresHardenedAlgorithm

Type parameters

  • NodeType

RecoveryId

RecoveryId: 0 | 1 | 2 | 3

RecursiveSegmentType

RecursiveSegmentType: "Push" | "Evaluation"

ReductionResults

ReductionResults<NodeType>: NodeType extends HdPrivateNodeValid ? PrivateResults<NodeType> : PublicResults<NodeType>

This type is a little complex because resulting HD nodes may not have a known parent (defined parentIdentifier) if the provided node does not have a known parent and the path is either m or M (returning the provided node).

Type parameters

  • NodeType

RequiredTwoLevels

RequiredTwoLevels<T>: {}

Type parameters

  • T

Type declaration

ResolvedSegment

ResolvedSegmentBytecode

ResolvedSegmentLiteralType

ResolvedSegmentLiteralType: "BigIntLiteral" | "BinaryLiteral" | "HexLiteral" | "UTF8Literal"

Result

Result<T>: Success<T> | Failure

Type parameters

  • T

ScenarioDefinition

ScenarioDefinition: Pick<AuthenticationTemplateScenario, "data" | "transaction" | "value">

The contents of an AuthenticationTemplateScenario without the name and description.

ScriptReductionTraceChildNode

ScriptReductionTraceChildNode<ProgramState>: ScriptReductionTraceNode | ScriptReductionTraceErrorNode | ScriptReductionTracePushNode<ProgramState> | ScriptReductionTraceEvaluationNode<ProgramState>

Type parameters

  • ProgramState

StringSegmentType

StringSegmentType: "Comment" | "Identifier" | "UTF8Literal" | "BigIntLiteral" | "BinaryLiteral" | "HexLiteral"

TestState

TestState<ProgramState>: (state: ProgramState) => string | true

Test a program state, returning an error message

Type parameters

  • ProgramState

Type declaration

    • (state: ProgramState): string | true
    • Parameters

      • state: ProgramState

      Returns string | true

TransactionContextBCH

TransactionContextBCH: TransactionContextCommon

TransactionGenerationAttempt

TransactionGenerationError

TransactionGenerationError: { completions: BytecodeGenerationCompletionOutput[]; errors: BytecodeGenerationErrorLocking[]; stage: "outputs"; success: false } | { completions: BytecodeGenerationCompletionInput[]; errors: BytecodeGenerationErrorUnlocking[]; stage: "inputs"; success: false }

TransactionTemplate

TransactionTemplate<CompilerType, EnableFeeEstimation, CompilationDataType>: Transaction<InputTemplate<CompilerType, EnableFeeEstimation, CompilationDataType>, OutputTemplate<CompilerType, EnableFeeEstimation, CompilationDataType>>

A Transaction which may optionally use compilation directives in place of lockingBytecode and unlockingBytecode instances. During transaction generation, these directives will be generated from these directives.

If EnableFeeEstimation is true, all input directives must include an estimate scenario ID, and the satoshis value of each output may also be undefined (as estimated transactions always set output values to invalidSatoshis).

Type parameters

  • CompilerType

  • EnableFeeEstimation

  • CompilationDataType

TransactionTemplateEstimated

TransactionTemplateEstimated<CompilerType>: TransactionTemplate<CompilerType, true> & { inputSatoshis: number }

A transaction template which enables fee estimation. The template must include an inputSatoshis value (the total satoshi value of all transaction inputs); all unlocking compilation directives must provide an estimate scenario ID which is used to estimate the size of the resulting unlocking bytecode; and the satoshis value of outputs is optional (all satoshi values will be set to impossibleSatoshis in the estimated transaction).

Type parameters

  • CompilerType

TransactionTemplateFixed

TransactionTemplateFixed<CompilerType>: TransactionTemplate<CompilerType>

A transaction template where all output amounts are provided (i.e. the values of each "change" output has been decided). To estimate the final transaction size given a transaction template (and from it, the required transaction fee), see estimateTransaction.

Type parameters

  • CompilerType

TypedLanguage

TypedLanguage<TLanguageSpec>: {}

Type parameters

  • TLanguageSpec

Type declaration

TypedRule

TypedRule<TLanguageSpec>: {}

Type parameters

  • TLanguageSpec

Type declaration

Uint16Bytes

Uint16Bytes: 2

Uint32Bytes

Uint32Bytes: 4

Uint8Bytes

Uint8Bytes: 1

WalletImportFormatType

WalletImportFormatType: "mainnet" | "testnet" | "mainnet-uncompressed" | "testnet-uncompressed"

The network and address format in which a WIF-encoded private key is expected to be used.

WIF-encoding is generally used to serialize private keys for Pay to Public Key (P2PKH) addresses – each WIF-encoded private key specifies the compression of the public key to use in the P2PKH address:

  • The values mainnet and testnet indicate that the address should use the compressed form of the derived public key (33 bytes, beginning with 0x02 or 0x03) on the respective network.
  • The less common mainnet-uncompressed and testnet-uncompressed values indicate that the address should use the uncompressed form of the public key (65 bytes beginning with 0x04) on the specified network.

Variables

Const SECP256K1_CONTEXT_NONE

SECP256K1_CONTEXT_NONE: number = SECP256K1_FLAGS_TYPE_CONTEXT

Const SECP256K1_CONTEXT_SIGN

SECP256K1_CONTEXT_SIGN: number = SECP256K1_FLAGS_TYPE_CONTEXT | SECP256K1_FLAGS_BIT_CONTEXT_SIGN

Const SECP256K1_CONTEXT_VERIFY

SECP256K1_CONTEXT_VERIFY: number = SECP256K1_FLAGS_TYPE_CONTEXT | SECP256K1_FLAGS_BIT_CONTEXT_VERIFY

Flags to pass to secp256k1_context_create.

Const SECP256K1_EC_COMPRESSED

SECP256K1_EC_COMPRESSED: number = SECP256K1_FLAGS_TYPE_COMPRESSION | SECP256K1_FLAGS_BIT_COMPRESSION

Flag to pass to secp256k1_ec_pubkey_serialize and secp256k1_ec_privkey_export.

Const SECP256K1_EC_UNCOMPRESSED

SECP256K1_EC_UNCOMPRESSED: number = SECP256K1_FLAGS_TYPE_COMPRESSION

Const SECP256K1_FLAGS_BIT_COMPRESSION

SECP256K1_FLAGS_BIT_COMPRESSION: number = 1 << 8

Const SECP256K1_FLAGS_BIT_CONTEXT_SIGN

SECP256K1_FLAGS_BIT_CONTEXT_SIGN: number = 1 << 9

Const SECP256K1_FLAGS_BIT_CONTEXT_VERIFY

SECP256K1_FLAGS_BIT_CONTEXT_VERIFY: number = 1 << 8

The higher bits contain the actual data. Do not use directly.

Const SECP256K1_FLAGS_TYPE_COMPRESSION

SECP256K1_FLAGS_TYPE_COMPRESSION: number = 1 << 1

Const SECP256K1_FLAGS_TYPE_CONTEXT

SECP256K1_FLAGS_TYPE_CONTEXT: number = 1 << 0

All flags' lower 8 bits indicate what they're for. Do not use directly.

Const _

_: any = Parsimmon.prototype

Const asciiCaseInsensitiveBits

asciiCaseInsensitiveBits: 31 = 31

In ASCII, each pair of upper and lower case characters share the same 5 least significant bits.

Const asciiLowerCaseStart

asciiLowerCaseStart: 96 = 96

Const authenticationScriptParser

authenticationScriptParser: {} = P.createLanguage({script: (r) =>P.seqMap(P.optWhitespace,r.expression.sepBy(P.optWhitespace),P.optWhitespace,(_, expressions) => expressions).node('Script'),expression: (r) =>P.alt(r.comment,r.push,r.evaluation,r.utf8,r.binary,r.hex,r.bigint,r.identifier),comment: (r) =>P.alt(r.singleLineComment, r.multiLineComment).node('Comment'),singleLineComment: () =>P.seqMap(P.string('//').desc("the start of a single-line comment ('//')"),P.regexp(/[^\n]*/u),(__, comment) => comment.trim()),multiLineComment: () =>P.seqMap(P.string('/*').desc("the start of a multi-line comment ('/*')"),P.regexp(/[\s\S]*?\*\//u).desc("the end of this multi-line comment ('*/')"),(__, comment) => comment.slice(0, -'*/'.length).trim()),push: (r) =>P.seqMap(P.string('<').desc("the start of a push statement ('<')"),r.script,P.string('>').desc("the end of this push statement ('>')"),(_, push) => push).node('Push'),evaluation: (r) =>P.seqMap(P.string('$').desc("the start of an evaluation ('$')"),P.string('(').desc("the opening parenthesis of this evaluation ('(')"),r.script,P.string(')').desc("the closing parenthesis of this evaluation (')')"),(_, __, evaluation) => evaluation).node('Evaluation'),identifier: () =>P.regexp(/[a-zA-Z_][.a-zA-Z0-9_-]*/u).desc('a valid identifier').node('Identifier'),utf8: () =>P.alt(P.seqMap(P.string('"').desc('a double quote (")'),P.regexp(/[^"]*/u),P.string('"').desc('a closing double quote (")'),(__, literal) => literal),P.seqMap(P.string("'").desc("a single quote (')"),P.regexp(/[^']*/u),P.string("'").desc("a closing single quote (')"),(__, literal) => literal)).node('UTF8Literal'),hex: () =>P.seqMap(P.string('0x').desc("a hex literal ('0x...')"),P.regexp(/[0-9a-f]_*(?:_*[0-9a-f]_*[0-9a-f]_*)*[0-9a-f]/iu).desc('a valid hexadecimal string'),(__, literal) => literal).node('HexLiteral'),binary: () =>P.seqMap(P.string('0b').desc("a binary literal ('0b...')"),P.regexp(/[01]+(?:[01_]*[01]+)*/iu).desc('a string of binary digits'),(__, literal) => literal).node('BinaryLiteral'),bigint: () =>P.regexp(/-?[0-9]+(?:[0-9_]*[0-9]+)*/u).desc('an integer literal').node('BigIntLiteral'),})

Type declaration

Const authenticationTemplateVariableTypes

authenticationTemplateVariableTypes: ("HdKey" | "Key" | "WalletData" | "AddressData")[] = ['AddressData','HdKey','Key','WalletData',] as AuthenticationTemplateVariable['type'][]

Const base256WordLength

base256WordLength: 8 = 8

Const base32WordLength

base32WordLength: 5 = 5

Const base58

base58: BaseConverter = createBaseConverter(bitcoinBase58Alphabet) as BaseConverter

Const base58ToBin

base58ToBin: (source: string) => Uint8Array | unknownCharacter = base58.decode

Convert a bitcoin-style base58-encoded string to a Uint8Array.

See createBaseConverter for format details.

param

a valid base58-encoded string to decode

Type declaration

Const base64GroupLength

base64GroupLength: 4 = 4

Const bech32CharacterSet

bech32CharacterSet: "qpzry9x8gf2tvdw0s3jn54khce6mua7l" = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"

The list of 32 symbols used in Bech32 encoding.

Const bech32CharacterSetIndex

bech32CharacterSetIndex: { 0: 15; 2: 10; 3: 17; 4: 21; 5: 20; 6: 26; 7: 30; 8: 7; 9: 5; a: 29; c: 24; d: 13; e: 25; f: 9; g: 8; h: 23; j: 18; k: 22; l: 31; m: 27; n: 19; p: 1; q: 0; r: 3; s: 16; t: 11; u: 28; v: 12; w: 14; x: 6; y: 4; z: 2 } = { q: 0, p: 1, z: 2, r: 3, y: 4, '9': 5, x: 6, '8': 7, g: 8, f: 9, '2': 10, t: 11, v: 12, d: 13, w: 14, '0': 15, s: 16, '3': 17, j: 18, n: 19, '5': 20, '4': 21, k: 22, h: 23, c: 24, e: 25, '6': 26, m: 27, u: 28, a: 29, '7': 30, l: 31 } as const

An object mapping each of the 32 symbols used in Bech32 encoding to their respective index in the character set.

Type declaration

  • 0: 15
  • 2: 10
  • 3: 17
  • 4: 21
  • 5: 20
  • 6: 26
  • 7: 30
  • 8: 7
  • 9: 5
  • a: 29
  • c: 24
  • d: 13
  • e: 25
  • f: 9
  • g: 8
  • h: 23
  • j: 18
  • k: 22
  • l: 31
  • m: 27
  • n: 19
  • p: 1
  • q: 0
  • r: 3
  • s: 16
  • t: 11
  • u: 28
  • v: 12
  • w: 14
  • x: 6
  • y: 4
  • z: 2

Const bech32GeneratorMostSignificantByte

bech32GeneratorMostSignificantByte: number[] = [0x98, 0x79, 0xf3, 0xae, 0x1e]

Const bech32GeneratorRemainingBytes

bech32GeneratorRemainingBytes: number[] = [0xf2bc8e61, 0xb76d99e2, 0x3e5fb3c4, 0x2eabe2a8, 0x4f43e470]

Const bigIntRegex

bigIntRegex: RegExp = /"<bigint: (?<bigint>[0-9]*)n>"/gu

Const binToBase58

binToBase58: (input: Uint8Array) => string = base58.encode

Convert a Uint8Array to a bitcoin-style base58-encoded string.

See createBaseConverter for format details.

param

the Uint8Array to base58 encode

Type declaration

    • (input: Uint8Array): string
    • Parameters

      • input: Uint8Array

      Returns string

Const binary

binary: 2 = 2

Const binaryByteWidth

binaryByteWidth: 8 = 8

Const bip32HmacSha512Key

bip32HmacSha512Key: Uint8Array = utf8ToBin('Bitcoin seed')

Const bitcoinABCOpcodes

bitcoinABCOpcodes: {} = Object.entries(generateBytecodeMap(OpcodesBCH)).reduce<{readonly [opcode: string]: Uint8Array;}>((acc, cur) => ({ ...acc, [cur[0].slice('OP_'.length)]: cur[1] }), {PUSHDATA1: Uint8Array.of(OpcodesBCH.OP_PUSHDATA_1), // eslint-disable-line @typescript-eslint/naming-conventionPUSHDATA2: Uint8Array.of(OpcodesBCH.OP_PUSHDATA_2), // eslint-disable-line @typescript-eslint/naming-conventionPUSHDATA4: Uint8Array.of(OpcodesBCH.OP_PUSHDATA_4), // eslint-disable-line @typescript-eslint/naming-convention})

Type declaration

  • [opcode: string]: Uint8Array

Const bitcoinBase58Alphabet

bitcoinBase58Alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"

Const cachedRipemd160

cachedRipemd160: { cache?: Promise<Ripemd160> }

Type declaration

Const cachedSecp256k1

cachedSecp256k1: { cache?: Promise<Secp256k1> }

Type declaration

Const cachedSha1

cachedSha1: { cache?: Promise<Sha1> }

Type declaration

  • Optional cache?: Promise<Sha1>

Const cachedSha256

cachedSha256: { cache?: Promise<Sha256> }

Type declaration

  • Optional cache?: Promise<Sha256>

Const cachedSha512

cachedSha512: { cache?: Promise<Sha512> }

Type declaration

  • Optional cache?: Promise<Sha512>

Const cashAddressBitToSize

cashAddressBitToSize: { 0: 160; 1: 192; 2: 224; 3: 256; 4: 320; 5: 384; 6: 448; 7: 512 } = {0: 160,1: 192,2: 224,3: 256,4: 320,5: 384,6: 448,7: 512,} as const

Type declaration

  • 0: 160
  • 1: 192
  • 2: 224
  • 3: 256
  • 4: 320
  • 5: 384
  • 6: 448
  • 7: 512

Const cashAddressReservedBitMask

cashAddressReservedBitMask: 128 = 128

Const cashAddressSizeBits

cashAddressSizeBits: 7 = 7

Const cashAddressSizeToBit

cashAddressSizeToBit: { 160: 0; 192: 1; 224: 2; 256: 3; 320: 4; 384: 5; 448: 6; 512: 7 } = {160: 0,192: 1,224: 2,256: 3,320: 4,384: 5,448: 6,512: 7,} as const

Type declaration

  • 160: 0
  • 192: 1
  • 224: 2
  • 256: 3
  • 320: 4
  • 384: 5
  • 448: 6
  • 512: 7

Const cashAddressTypeBitShift

cashAddressTypeBitShift: 3 = 3

Const cashAddressTypeBits

cashAddressTypeBits: 15 = 15

Const characterLength32BytePrivateKey

characterLength32BytePrivateKey: 64 = 64

Const chars

chars: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

Const compilerOperationAddressData

compilerOperationAddressData: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['bytecode'],environmentProperties: [],operation: (identifier, data) => {const { bytecode } = data;if (identifier in bytecode) {return { bytecode: bytecode[identifier], status: 'success' };}return {error: `Identifier "${identifier}" refers to an AddressData, but "${identifier}" was not provided in the CompilationData "bytecode".`,recoverable: true,status: 'error',};},})

Type declaration

Const compilerOperationAttemptBytecodeResolution

compilerOperationAttemptBytecodeResolution: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: true,dataProperties: ['bytecode'],environmentProperties: [],operation: (identifier, data) => {const { bytecode } = data;if ((bytecode[identifier] as Uint8Array | undefined) !== undefined) {return { bytecode: bytecode[identifier], status: 'success' };}return { status: 'skip' };},})

Type declaration

Const compilerOperationCurrentBlockHeight

compilerOperationCurrentBlockHeight: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['currentBlockHeight'],environmentProperties: [],operation: (_, data) => ({bytecode: bigIntToScriptNumber(BigInt(data.currentBlockHeight)),status: 'success',}),})

Type declaration

Const compilerOperationCurrentBlockTime

compilerOperationCurrentBlockTime: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['currentBlockTime'],environmentProperties: [],operation: (_, data) => {return {bytecode: numberToBinUint32LE(data.currentBlockTime),status: 'success',};},})

Type declaration

Const compilerOperationHdKeyEcdsaDataSignatureBCH

compilerOperationHdKeyEcdsaDataSignatureBCH: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationHelperHdKeyDataSignatureBCH({operationName: 'data_signature',secp256k1Method: 'signMessageHashDER',})

Type declaration

Const compilerOperationHdKeyEcdsaSignatureBCH

compilerOperationHdKeyEcdsaSignatureBCH: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationHelperHdKeySignatureBCH({operationName: 'signature',secp256k1Method: 'signMessageHashDER',})

Type declaration

Const compilerOperationHdKeyPublicKeyCommon

compilerOperationHdKeyPublicKeyCommon: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = attemptCompilerOperations([compilerOperationAttemptBytecodeResolution],compilerOperationRequires({canBeSkipped: false,dataProperties: ['hdKeys'],environmentProperties: ['entityOwnership','ripemd160','secp256k1','sha256','sha512','variables',],operation:// eslint-disable-next-line complexity(identifier, data, environment): CompilerOperationResult => {const { hdKeys } = data;const { hdPrivateKeys, addressIndex, hdPublicKeys } = hdKeys;const [variableId] = identifier.split('.');const entityId = environment.entityOwnership[variableId] as| string| undefined;if (entityId === undefined) {return compilerOperationHelperUnknownEntity(identifier, variableId);}if (addressIndex === undefined) {return compilerOperationHelperAddressIndex(identifier);}const entityHdPrivateKey =hdPrivateKeys === undefined ? undefined : hdPrivateKeys[entityId];/*** Guaranteed to be an `HdKey` if this method is reached in the compiler.*/const hdKey = environment.variables[variableId] as AuthenticationTemplateHdKey;if (entityHdPrivateKey !== undefined) {const privateResult = compilerOperationHelperDeriveHdPrivateNode({addressIndex,entityHdPrivateKey,entityId,environment,hdKey,identifier,});if (privateResult.status === 'error') return privateResult;return {bytecode: environment.secp256k1.derivePublicKeyCompressed(privateResult.bytecode),status: 'success',};}const entityHdPublicKey =hdPublicKeys === undefined ? undefined : hdPublicKeys[entityId];if (entityHdPublicKey === undefined) {return {error: `Identifier "${identifier}" refers to an HdKey owned by "${entityId}", but an HD private key or HD public key for this entity was not provided in the compilation data.`,recoverable: true,status: 'error',};}const addressOffset =hdKey.addressOffset ?? CompilerDefaults.hdKeyAddressOffset;const privateDerivationPath =hdKey.privateDerivationPath ??CompilerDefaults.hdKeyPrivateDerivationPath;const publicDerivationPath =hdKey.publicDerivationPath ?? privateDerivationPath.replace('m', 'M');const validPublicPathWithIndex = /^M(?:\/(?:[0-9]+|i))*$/u;if (!validPublicPathWithIndex.test(publicDerivationPath)) {return {error: `Could not generate ${identifier} – the path "${publicDerivationPath}" is not a valid "publicDerivationPath".`,status: 'error',};}const i = addressIndex + addressOffset;const instancePath = publicDerivationPath.replace('i', i.toString());const masterContents = decodeHdPublicKey(environment,entityHdPublicKey);if (typeof masterContents === 'string') {return {error: `Could not generate "${identifier}" – the HD public key provided for "${entityId}" could not be decoded: ${masterContents}`,status: 'error',};}const instanceNode = deriveHdPath(environment,masterContents.node,instancePath);if (typeof instanceNode === 'string') {return {error: `Could not generate "${identifier}" – the path "${instancePath}" could not be derived for entity "${entityId}": ${instanceNode}`,status: 'error',};}return { bytecode: instanceNode.publicKey, status: 'success' };},}))

Type declaration

Const compilerOperationHdKeySchnorrDataSignatureBCH

compilerOperationHdKeySchnorrDataSignatureBCH: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationHelperHdKeyDataSignatureBCH({operationName: 'schnorr_data_signature',secp256k1Method: 'signMessageHashSchnorr',})

Type declaration

Const compilerOperationHdKeySchnorrSignatureBCH

compilerOperationHdKeySchnorrSignatureBCH: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationHelperHdKeySignatureBCH({operationName: 'schnorr_signature',secp256k1Method: 'signMessageHashSchnorr',})

Type declaration

Const compilerOperationKeyEcdsaDataSignatureBCH

compilerOperationKeyEcdsaDataSignatureBCH: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationHelperKeyDataSignatureBCH({operationName: 'data_signature',secp256k1Method: 'signMessageHashDER',})

Type declaration

Const compilerOperationKeyEcdsaSignatureBCH

compilerOperationKeyEcdsaSignatureBCH: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationHelperKeySignatureBCH({operationName: 'signature',secp256k1Method: 'signMessageHashDER',})

Type declaration

Const compilerOperationKeyPublicKeyCommon

compilerOperationKeyPublicKeyCommon: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = attemptCompilerOperations([compilerOperationAttemptBytecodeResolution],compilerOperationRequires({canBeSkipped: false,dataProperties: ['keys'],environmentProperties: ['secp256k1'],operation: (identifier, data, environment) => {const { keys } = data;const { secp256k1 } = environment;const { privateKeys } = keys;const [variableId] = identifier.split('.');if (privateKeys !== undefined &&(privateKeys[variableId] as Uint8Array | undefined) !== undefined) {return {bytecode: secp256k1.derivePublicKeyCompressed(privateKeys[variableId]),status: 'success',};}return {error: `Identifier "${identifier}" refers to a public key, but no public or private keys for "${variableId}" were provided in the compilation data.`,recoverable: true,status: 'error',};},}))

Type declaration

Const compilerOperationKeySchnorrDataSignatureBCH

compilerOperationKeySchnorrDataSignatureBCH: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationHelperKeyDataSignatureBCH({operationName: 'schnorr_data_signature',secp256k1Method: 'signMessageHashSchnorr',})

Type declaration

Const compilerOperationKeySchnorrSignatureBCH

compilerOperationKeySchnorrSignatureBCH: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationHelperKeySignatureBCH({operationName: 'schnorr_signature',secp256k1Method: 'signMessageHashSchnorr',})

Type declaration

Const compilerOperationSigningSerializationCorrespondingOutput

compilerOperationSigningSerializationCorrespondingOutput: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['transactionContext'],environmentProperties: [],operation: (_, data) =>data.transactionContext.correspondingOutput === undefined? { bytecode: Uint8Array.of(), status: 'success' }: {bytecode: data.transactionContext.correspondingOutput,status: 'success',},})

Type declaration

Const compilerOperationSigningSerializationCorrespondingOutputHash

compilerOperationSigningSerializationCorrespondingOutputHash: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['transactionContext'],environmentProperties: ['sha256'],operation: (_, data, environment) =>data.transactionContext.correspondingOutput === undefined? { bytecode: Uint8Array.of(), status: 'success' }: {bytecode: environment.sha256.hash(environment.sha256.hash(data.transactionContext.correspondingOutput)),status: 'success',},})

Type declaration

Const compilerOperationSigningSerializationCoveredBytecode

compilerOperationSigningSerializationCoveredBytecode: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationHelperSigningSerializationCoveredBytecode(false)

Type declaration

Const compilerOperationSigningSerializationCoveredBytecodeLength

compilerOperationSigningSerializationCoveredBytecodeLength: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationHelperSigningSerializationCoveredBytecode(true)

Type declaration

Const compilerOperationSigningSerializationFullBCH

compilerOperationSigningSerializationFullBCH: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['transactionContext'],environmentProperties: ['sha256', 'sourceScriptIds', 'unlockingScripts'],operation: (identifier, data, environment): CompilerOperationResult => {const [, algorithmOrComponent, unknownPart] = identifier.split('.') as (| string| undefined)[];if (algorithmOrComponent === undefined) {return {error: `Invalid signing serialization operation. Include the desired component or algorithm, e.g. "signing_serialization.version".`,status: 'error',};}if (unknownPart !== undefined) {return {error: `Unknown component in "${identifier}" – the fragment "${unknownPart}" is not recognized.`,status: 'error',};}const signingSerializationType = getSigningSerializationType(algorithmOrComponent,'full_');if (signingSerializationType === undefined) {return {error: `Unknown signing serialization algorithm, "${algorithmOrComponent}".`,status: 'error',};}const { sha256, sourceScriptIds, unlockingScripts } = environment;const result = compilerOperationHelperGenerateCoveredBytecode({data,environment,identifier,sourceScriptIds,unlockingScripts,});if ('error' in result) {return result;}const { transactionContext } = data;return {bytecode: generateSigningSerializationBCH({correspondingOutput: transactionContext.correspondingOutput,coveredBytecode: result,locktime: transactionContext.locktime,outpointIndex: transactionContext.outpointIndex,outpointTransactionHash: transactionContext.outpointTransactionHash,outputValue: transactionContext.outputValue,sequenceNumber: transactionContext.sequenceNumber,sha256,signingSerializationType,transactionOutpoints: transactionContext.transactionOutpoints,transactionOutputs: transactionContext.transactionOutputs,transactionSequenceNumbers:transactionContext.transactionSequenceNumbers,version: transactionContext.version,}),status: 'success',};},})

Type declaration

Const compilerOperationSigningSerializationLocktime

compilerOperationSigningSerializationLocktime: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['transactionContext'],environmentProperties: [],operation: (_, data) => ({bytecode: numberToBinUint32LE(data.transactionContext.locktime),status: 'success',}),})

Type declaration

Const compilerOperationSigningSerializationOutpointIndex

compilerOperationSigningSerializationOutpointIndex: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['transactionContext'],environmentProperties: [],operation: (_, data) => ({bytecode: numberToBinUint32LE(data.transactionContext.outpointIndex),status: 'success',}),})

Type declaration

Const compilerOperationSigningSerializationOutpointTransactionHash

compilerOperationSigningSerializationOutpointTransactionHash: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['transactionContext'],environmentProperties: [],operation: (_, data) => ({bytecode: data.transactionContext.outpointTransactionHash,status: 'success',}),})

Type declaration

Const compilerOperationSigningSerializationOutputValue

compilerOperationSigningSerializationOutputValue: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['transactionContext'],environmentProperties: [],operation: (_, data) => ({bytecode: data.transactionContext.outputValue,status: 'success',}),})

Type declaration

Const compilerOperationSigningSerializationSequenceNumber

compilerOperationSigningSerializationSequenceNumber: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['transactionContext'],environmentProperties: [],operation: (_, data) => ({bytecode: numberToBinUint32LE(data.transactionContext.sequenceNumber),status: 'success',}),})

Type declaration

Const compilerOperationSigningSerializationTransactionOutpoints

compilerOperationSigningSerializationTransactionOutpoints: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['transactionContext'],environmentProperties: [],operation: (_, data) => ({bytecode: data.transactionContext.transactionOutpoints,status: 'success',}),})

Type declaration

Const compilerOperationSigningSerializationTransactionOutpointsHash

compilerOperationSigningSerializationTransactionOutpointsHash: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['transactionContext'],environmentProperties: ['sha256'],operation: (_, data, environment) => ({bytecode: environment.sha256.hash(environment.sha256.hash(data.transactionContext.transactionOutpoints)),status: 'success',}),})

Type declaration

Const compilerOperationSigningSerializationTransactionOutputs

compilerOperationSigningSerializationTransactionOutputs: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['transactionContext'],environmentProperties: [],operation: (_, data) => ({bytecode: data.transactionContext.transactionOutputs,status: 'success',}),})

Type declaration

Const compilerOperationSigningSerializationTransactionOutputsHash

compilerOperationSigningSerializationTransactionOutputsHash: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['transactionContext'],environmentProperties: ['sha256'],operation: (_, data, environment) => ({bytecode: environment.sha256.hash(environment.sha256.hash(data.transactionContext.transactionOutputs)),status: 'success',}),})

Type declaration

Const compilerOperationSigningSerializationTransactionSequenceNumbers

compilerOperationSigningSerializationTransactionSequenceNumbers: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['transactionContext'],environmentProperties: [],operation: (_, data) => ({bytecode: data.transactionContext.transactionSequenceNumbers,status: 'success',}),})

Type declaration

Const compilerOperationSigningSerializationTransactionSequenceNumbersHash

compilerOperationSigningSerializationTransactionSequenceNumbersHash: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['transactionContext'],environmentProperties: ['sha256'],operation: (_, data, environment) => ({bytecode: environment.sha256.hash(environment.sha256.hash(data.transactionContext.transactionSequenceNumbers)),status: 'success',}),})

Type declaration

Const compilerOperationSigningSerializationVersion

compilerOperationSigningSerializationVersion: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['transactionContext'],environmentProperties: [],operation: (_, data) => ({bytecode: numberToBinUint32LE(data.transactionContext.version),status: 'success',}),})

Type declaration

Const compilerOperationWalletData

compilerOperationWalletData: (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped> = compilerOperationRequires({canBeSkipped: false,dataProperties: ['bytecode'],environmentProperties: [],operation: (identifier, data) => {const { bytecode } = data;if (identifier in bytecode) {return { bytecode: bytecode[identifier], status: 'success' };}return {error: `Identifier "${identifier}" refers to a WalletData, but "${identifier}" was not provided in the CompilationData "bytecode".`,recoverable: true,status: 'error',};},})

Type declaration

Const correspondingOutput

correspondingOutput: 1 = 1

Const defaultStringifySpacing

defaultStringifySpacing: 2 = 2

Const empty

empty: 0 = 0

Const eof

eof: any = Parsimmon(function (input: any, i: any) {if (i < input.length) {return makeFailure(i, 'EOF');}return makeSuccess(i, null);})

Const finiteFieldOrder

finiteFieldOrder: 32 = 32

Const halfHmacSha512Length

halfHmacSha512Length: 32 = 32

Const hasNonHexCharacter

hasNonHexCharacter: RegExp = /[^a-fA-F0-9]/u

Const hexByteWidth

hexByteWidth: 2 = 2

Const hexadecimal

hexadecimal: 16 = 16

Const index

index: any = Parsimmon(function (input: any, i: any) {return makeSuccess(i, makeLineColumnIndex(input, i));})

Const instructionSetBCHCurrentStrict

instructionSetBCHCurrentStrict: BCH_2020_05_STRICT = InstructionSetBCH.BCH_2020_05_STRICT

The current strict virtual machine version used by the Bitcoin Cash (BCH) network.

Const invalidSatoshis

invalidSatoshis: Uint8Array = Uint8Array.from([255, 255, 255, 255, 255, 255, 255, 255])

The maximum uint64 value – an impossibly large, intentionally invalid value for satoshis. See Transaction.satoshis for details.

Const locktimeByteLength

locktimeByteLength: 4 = 4

Const maximumLocktimeDate

maximumLocktimeDate: Date = new Date(maximumLocktimeTimestamp * msPerLocktimeSecond)

The maximum Date (inclusive) which can be encoded by a transaction's locktime.

Const maximumLocktimeTimestamp

maximumLocktimeTimestamp: 4294967295 = 4294967295

The maximum Unix timestamp (inclusive) which can be encoded by a transaction's locktime.

Const minimumLocktimeDate

minimumLocktimeDate: Date = new Date(minimumLocktimeTimestamp * msPerLocktimeSecond)

The minimum Date (inclusive) which can be encoded by a transaction's locktime.

Const minimumLocktimeTimestamp

minimumLocktimeTimestamp: 500000000 = 500000000

The minimum Unix timestamp (inclusive) which can be encoded by a transaction's locktime.

Const msPerLocktimeSecond

msPerLocktimeSecond: 1000 = 1000

Const nonBase64Chars

nonBase64Chars: RegExp = new RegExp(`[^${chars}=]`, 'u')

Const nonBech32Characters

nonBech32Characters: RegExp = new RegExp(`[^${bech32CharacterSet}]`, 'u')

Const normalMaximumScriptNumberByteLength

normalMaximumScriptNumberByteLength: 4 = 4

Const nullHashLength

nullHashLength: 32 = 32

Const op1NegateValue

op1NegateValue: -1 = -1

Const optWhitespace

optWhitespace: Parser<string> = regexp(/\s*/u).desc('optional whitespace')

Const outpointTransactionHashFill

outpointTransactionHashFill: 5 = 5

Const outputValueLength

outputValueLength: 8 = 8

Const payloadSeparator

payloadSeparator: 0 = 0

Const pushByteOpcodes

pushByteOpcodes: keyof OpcodesCommon[] = [OpcodesCommon.OP_PUSHBYTES_1,OpcodesCommon.OP_PUSHBYTES_2,OpcodesCommon.OP_PUSHBYTES_3,OpcodesCommon.OP_PUSHBYTES_4,OpcodesCommon.OP_PUSHBYTES_5,OpcodesCommon.OP_PUSHBYTES_6,OpcodesCommon.OP_PUSHBYTES_7,OpcodesCommon.OP_PUSHBYTES_8,OpcodesCommon.OP_PUSHBYTES_9,OpcodesCommon.OP_PUSHBYTES_10,OpcodesCommon.OP_PUSHBYTES_11,OpcodesCommon.OP_PUSHBYTES_12,OpcodesCommon.OP_PUSHBYTES_13,OpcodesCommon.OP_PUSHBYTES_14,OpcodesCommon.OP_PUSHBYTES_15,OpcodesCommon.OP_PUSHBYTES_16,OpcodesCommon.OP_PUSHBYTES_17,OpcodesCommon.OP_PUSHBYTES_18,OpcodesCommon.OP_PUSHBYTES_19,OpcodesCommon.OP_PUSHBYTES_20,OpcodesCommon.OP_PUSHBYTES_21,OpcodesCommon.OP_PUSHBYTES_22,OpcodesCommon.OP_PUSHBYTES_23,OpcodesCommon.OP_PUSHBYTES_24,OpcodesCommon.OP_PUSHBYTES_25,OpcodesCommon.OP_PUSHBYTES_26,OpcodesCommon.OP_PUSHBYTES_27,OpcodesCommon.OP_PUSHBYTES_28,OpcodesCommon.OP_PUSHBYTES_29,OpcodesCommon.OP_PUSHBYTES_30,OpcodesCommon.OP_PUSHBYTES_31,OpcodesCommon.OP_PUSHBYTES_32,OpcodesCommon.OP_PUSHBYTES_33,OpcodesCommon.OP_PUSHBYTES_34,OpcodesCommon.OP_PUSHBYTES_35,OpcodesCommon.OP_PUSHBYTES_36,OpcodesCommon.OP_PUSHBYTES_37,OpcodesCommon.OP_PUSHBYTES_38,OpcodesCommon.OP_PUSHBYTES_39,OpcodesCommon.OP_PUSHBYTES_40,OpcodesCommon.OP_PUSHBYTES_41,OpcodesCommon.OP_PUSHBYTES_42,OpcodesCommon.OP_PUSHBYTES_43,OpcodesCommon.OP_PUSHBYTES_44,OpcodesCommon.OP_PUSHBYTES_45,OpcodesCommon.OP_PUSHBYTES_46,OpcodesCommon.OP_PUSHBYTES_47,OpcodesCommon.OP_PUSHBYTES_48,OpcodesCommon.OP_PUSHBYTES_49,OpcodesCommon.OP_PUSHBYTES_50,OpcodesCommon.OP_PUSHBYTES_51,OpcodesCommon.OP_PUSHBYTES_52,OpcodesCommon.OP_PUSHBYTES_53,OpcodesCommon.OP_PUSHBYTES_54,OpcodesCommon.OP_PUSHBYTES_55,OpcodesCommon.OP_PUSHBYTES_56,OpcodesCommon.OP_PUSHBYTES_57,OpcodesCommon.OP_PUSHBYTES_58,OpcodesCommon.OP_PUSHBYTES_59,OpcodesCommon.OP_PUSHBYTES_60,OpcodesCommon.OP_PUSHBYTES_61,OpcodesCommon.OP_PUSHBYTES_62,OpcodesCommon.OP_PUSHBYTES_63,OpcodesCommon.OP_PUSHBYTES_64,OpcodesCommon.OP_PUSHBYTES_65,OpcodesCommon.OP_PUSHBYTES_66,OpcodesCommon.OP_PUSHBYTES_67,OpcodesCommon.OP_PUSHBYTES_68,OpcodesCommon.OP_PUSHBYTES_69,OpcodesCommon.OP_PUSHBYTES_70,OpcodesCommon.OP_PUSHBYTES_71,OpcodesCommon.OP_PUSHBYTES_72,OpcodesCommon.OP_PUSHBYTES_73,OpcodesCommon.OP_PUSHBYTES_74,OpcodesCommon.OP_PUSHBYTES_75,]

Const pushNumberOpcodes

pushNumberOpcodes: keyof OpcodesCommon[] = [OpcodesCommon.OP_1NEGATE,OpcodesCommon.OP_1,OpcodesCommon.OP_2,OpcodesCommon.OP_3,OpcodesCommon.OP_4,OpcodesCommon.OP_5,OpcodesCommon.OP_6,OpcodesCommon.OP_7,OpcodesCommon.OP_8,OpcodesCommon.OP_9,OpcodesCommon.OP_10,OpcodesCommon.OP_11,OpcodesCommon.OP_12,OpcodesCommon.OP_13,OpcodesCommon.OP_14,OpcodesCommon.OP_15,OpcodesCommon.OP_16,]

Const sha256BlockByteLength

sha256BlockByteLength: 64 = 64

Const sha256HashLength

sha256HashLength: 32 = 32

Const sha512BlockByteLength

sha512BlockByteLength: 128 = 128

Const transactionOutpoints

transactionOutpoints: 2 = 2

Const transactionOutputs

transactionOutputs: 3 = 3

Const transactionSequenceNumbers

transactionSequenceNumbers: 4 = 4

Const uint16Bytes

uint16Bytes: 2 = 2

Const uint32Bytes

uint32Bytes: 4 = 4

Const uint8ArrayRegex

uint8ArrayRegex: RegExp = /"<Uint8Array: 0x(?<hex>[0-9a-f]*)>"/gu

Const uint8Bytes

uint8Bytes: 1 = 1

Const whitespace

whitespace: Parser<string> = regexp(/\s+/u).desc('whitespace')

Functions

Parsimmon

  • Parsimmon(action: any): any

Const addressContentsToLockingBytecode

  • addressContentsToLockingBytecode(addressContents: AddressContents): Uint8Array
  • Get the locking bytecode for a valid AddressContents object. See lockingBytecodeToAddressContents for details.

    For AddressContents of type AddressType.unknown, this method returns the payload without modification.

    Parameters

    Returns Uint8Array

Const alignMemory

  • alignMemory(factor: number, size: number): number

Const allErrorsAreRecoverable

  • allErrorsAreRecoverable(errors: CompilationError[]): errors is CompilationErrorRecoverable[]
  • Verify that every error in the provided array can be resolved by providing additional variables in the compilation data (rather than deeper issues, like problems with the authentication template or wallet implementation).

    Note, errors are only recoverable if the "entity ownership" of each missing identifier is known (specified in CompilationData's entityOwnership).

    Parameters

    Returns errors is CompilationErrorRecoverable[]

alt

  • alt(...params: any[]): any

anchoredRegexp

  • anchoredRegexp(re: any): RegExp

Const applyError

Const areEqual

  • areEqual(a: Uint8Array, b: Uint8Array): boolean

Const arithmeticOperations

  • arithmeticOperations<Opcodes, State, Errors>(flags: { requireMinimalEncoding: boolean }): { [OpcodesCommon.OP_0NOTEQUAL]: (Anonymous function); [OpcodesCommon.OP_1ADD]: (Anonymous function); [OpcodesCommon.OP_1SUB]: (Anonymous function); [OpcodesCommon.OP_ABS]: (Anonymous function); [OpcodesCommon.OP_ADD]: (Anonymous function); [OpcodesCommon.OP_BOOLAND]: (Anonymous function); [OpcodesCommon.OP_BOOLOR]: (Anonymous function); [OpcodesCommon.OP_GREATERTHANOREQUAL]: (Anonymous function); [OpcodesCommon.OP_GREATERTHAN]: (Anonymous function); [OpcodesCommon.OP_LESSTHANOREQUAL]: (Anonymous function); [OpcodesCommon.OP_LESSTHAN]: (Anonymous function); [OpcodesCommon.OP_MAX]: (Anonymous function); [OpcodesCommon.OP_MIN]: (Anonymous function); [OpcodesCommon.OP_NEGATE]: (Anonymous function); [OpcodesCommon.OP_NOT]: (Anonymous function); [OpcodesCommon.OP_NUMEQUALVERIFY]: (Anonymous function); [OpcodesCommon.OP_NUMEQUAL]: (Anonymous function); [OpcodesCommon.OP_NUMNOTEQUAL]: (Anonymous function); [OpcodesCommon.OP_SUB]: (Anonymous function); [OpcodesCommon.OP_WITHIN]: (Anonymous function) }
  • Type parameters

    Parameters

    • flags: { requireMinimalEncoding: boolean }
      • requireMinimalEncoding: boolean

    Returns { [OpcodesCommon.OP_0NOTEQUAL]: (Anonymous function); [OpcodesCommon.OP_1ADD]: (Anonymous function); [OpcodesCommon.OP_1SUB]: (Anonymous function); [OpcodesCommon.OP_ABS]: (Anonymous function); [OpcodesCommon.OP_ADD]: (Anonymous function); [OpcodesCommon.OP_BOOLAND]: (Anonymous function); [OpcodesCommon.OP_BOOLOR]: (Anonymous function); [OpcodesCommon.OP_GREATERTHANOREQUAL]: (Anonymous function); [OpcodesCommon.OP_GREATERTHAN]: (Anonymous function); [OpcodesCommon.OP_LESSTHANOREQUAL]: (Anonymous function); [OpcodesCommon.OP_LESSTHAN]: (Anonymous function); [OpcodesCommon.OP_MAX]: (Anonymous function); [OpcodesCommon.OP_MIN]: (Anonymous function); [OpcodesCommon.OP_NEGATE]: (Anonymous function); [OpcodesCommon.OP_NOT]: (Anonymous function); [OpcodesCommon.OP_NUMEQUALVERIFY]: (Anonymous function); [OpcodesCommon.OP_NUMEQUAL]: (Anonymous function); [OpcodesCommon.OP_NUMNOTEQUAL]: (Anonymous function); [OpcodesCommon.OP_SUB]: (Anonymous function); [OpcodesCommon.OP_WITHIN]: (Anonymous function) }

    • [OpcodesCommon.OP_0NOTEQUAL]: (Anonymous function)
    • [OpcodesCommon.OP_1ADD]: (Anonymous function)
    • [OpcodesCommon.OP_1SUB]: (Anonymous function)
    • [OpcodesCommon.OP_ABS]: (Anonymous function)
    • [OpcodesCommon.OP_ADD]: (Anonymous function)
    • [OpcodesCommon.OP_BOOLAND]: (Anonymous function)
    • [OpcodesCommon.OP_BOOLOR]: (Anonymous function)
    • [OpcodesCommon.OP_GREATERTHANOREQUAL]: (Anonymous function)
    • [OpcodesCommon.OP_GREATERTHAN]: (Anonymous function)
    • [OpcodesCommon.OP_LESSTHANOREQUAL]: (Anonymous function)
    • [OpcodesCommon.OP_LESSTHAN]: (Anonymous function)
    • [OpcodesCommon.OP_MAX]: (Anonymous function)
    • [OpcodesCommon.OP_MIN]: (Anonymous function)
    • [OpcodesCommon.OP_NEGATE]: (Anonymous function)
    • [OpcodesCommon.OP_NOT]: (Anonymous function)
    • [OpcodesCommon.OP_NUMEQUALVERIFY]: (Anonymous function)
    • [OpcodesCommon.OP_NUMEQUAL]: (Anonymous function)
    • [OpcodesCommon.OP_NUMNOTEQUAL]: (Anonymous function)
    • [OpcodesCommon.OP_SUB]: (Anonymous function)
    • [OpcodesCommon.OP_WITHIN]: (Anonymous function)

Const assembleBitcoinABCScript

  • assembleBitcoinABCScript(abcScript: string): Uint8Array
  • Convert a string from Bitcoin ABC's script_tests.json text-format to bytecode. The string must be valid – this method attempts to convert all unmatched tokens to BigInts.

    privateremarks

    This method doesn't use compileScript because of a slight incompatibility in the languages. In BTL, BigIntLiterals are a primitive type, and must be surrounded by a push statement (e.g. <100>) to push a number to the stack. In the script_tests.json text-format, numbers are assumed to be pushed. We could implement a transformation after the compiler's parse step, but because this format doesn't require any other features of the compiler, we opt to implement this as a simple method.

    Parameters

    • abcScript: string

      the script in Bitcoin ABC's script_tests.json text format

    Returns Uint8Array

Const assembleBytecode

Const assembleBytecodeBCH

Const assembleBytecodeBTC

Const attemptCashAddressFormatErrorCorrection

  • Attempt to correct up to 2 errors in a CashAddress. The CashAddress must be properly formed (include a prefix and only contain Bech32 characters).

    Improper use of this method carries the risk of lost funds.

    It is strongly advised that this method only be used under explicit user control. With enough errors, this method is likely to find a plausible correction for any address (but for which no private key exists). This is effectively equivalent to burning the funds.

    Only 2 substitution errors can be corrected (or a single swap) – deletions and insertions (errors which shift many other characters and change the length of the payload) can never be safely corrected and will produce an error.

    Errors can be corrected in both the prefix and the payload, but attempting to correct errors in the prefix prior to this method can improve results, e.g. for bchtest:qq2azmyyv6dtgczexyalqar70q036yund53jvfde0x, the string bchtest:qq2azmyyv6dtgczexyalqar70q036yund53jvfdecc can be corrected, while typo:qq2azmyyv6dtgczexyalqar70q036yund53jvfdecc can not.

    privateremarks

    Derived from: https://github.com/deadalnix/cashaddressed

    Parameters

    • address: string

      the CashAddress on which to attempt error correction

    Returns invalidCharacters | invalidFormat | tooManyErrors | { address: string; corrections: number[] }

Const attemptCompilerOperation

  • attemptCompilerOperation<TransactionContext, Environment>(__namedParameters: { data: CompilationData<TransactionContext>; environment: Environment; identifier: string; matchingOperations: undefined | {} | ((identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped>); operationExample: string; operationId: undefined | string; variableId: string; variableType: string }): CompilerOperationResult<true>
  • Type parameters

    Parameters

    • __namedParameters: { data: CompilationData<TransactionContext>; environment: Environment; identifier: string; matchingOperations: undefined | {} | ((identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped>); operationExample: string; operationId: undefined | string; variableId: string; variableType: string }
      • data: CompilationData<TransactionContext>
      • environment: Environment
      • identifier: string
      • matchingOperations: undefined | {} | ((identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped>)
      • operationExample: string
      • operationId: undefined | string
      • variableId: string
      • variableType: string

    Returns CompilerOperationResult<true>

Const attemptCompilerOperations

  • Attempt a series of compiler operations, skipping to the next operation if the current operation returns a CompilerOperationSkip (indicating it failed and can be skipped). The finalOperation may not be skipped, and must either return CompilerOperationSuccess or CompilerOperationError.

    Type parameters

    • TransactionContext

    Parameters

    • operations: CompilerOperation<TransactionContext, true>[]

      an array of skippable operations to try

    • finalOperation: CompilerOperation<TransactionContext>

      a final, un-skippable operation

    Returns CompilerOperation<TransactionContext>

Const authenticationInstructionIsMalformed

  • authenticationInstructionIsMalformed<Opcodes>(instruction: ParsedAuthenticationInstruction<Opcodes>): instruction is ParsedAuthenticationInstructionMalformed<Opcodes>

Const authenticationInstructionsAreMalformed

  • authenticationInstructionsAreMalformed<Opcodes>(instructions: ParsedAuthenticationInstructions<Opcodes>): instructions is ParsedAuthenticationInstructionMalformed<Opcodes>[]

Const authenticationInstructionsAreNotMalformed

  • authenticationInstructionsAreNotMalformed<Opcodes>(instructions: ParsedAuthenticationInstructions<Opcodes>): instructions is AuthenticationInstruction<Opcodes>[]

Const authenticationTemplateToCompilationEnvironment

  • authenticationTemplateToCompilationEnvironment(template: AuthenticationTemplate): Pick<CompilationEnvironment, "entityOwnership" | "scenarios" | "scripts" | "variables" | "unlockingScripts" | "lockingScriptTypes" | "unlockingScriptTimeLockTypes">
  • Create a partial CompilationEnvironment from an AuthenticationTemplate by extracting and formatting the scripts and variables properties.

    Note, if this AuthenticationTemplate might be malformed, first validate it with validateAuthenticationTemplate.

    Parameters

    • template: AuthenticationTemplate

      the AuthenticationTemplate from which to extract the compilation environment

    Returns Pick<CompilationEnvironment, "entityOwnership" | "scenarios" | "scripts" | "variables" | "unlockingScripts" | "lockingScriptTypes" | "unlockingScriptTimeLockTypes">

Const authenticationTemplateToCompilationEnvironmentVirtualizedTests

Const authenticationTemplateToCompilerBCH

Const base58AddressToLockingBytecode

Const base64ToBin

  • base64ToBin(validBase64: string): Uint8Array
  • Convert a base64-encoded string to a Uint8Array.

    Note, this method always completes. If validBase64 is not valid base64, an incorrect result will be returned. If validBase64 is potentially malformed, check it with isBase64 before calling this method.

    Parameters

    • validBase64: string

      a valid base64-encoded string to decode

    Returns Uint8Array

Const bech32PaddedToBin

Const bigIntToBinUint256BEClamped

  • bigIntToBinUint256BEClamped(value: bigint): Uint8Array
  • Encode a positive BigInt into an unsigned 32-byte big-endian Uint8Array. This can be used to encoded numbers for cryptographic primitives like private keys, public keys, curve parameters, and signature points.

    Negative values will return the same result as 0, values higher than 2^256-1 will return the maximum expressible unsigned 256-bit value (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff).

    Parameters

    • value: bigint

      the BigInt to encode

    Returns Uint8Array

Const bigIntToBinUint64LE

  • bigIntToBinUint64LE(value: bigint): Uint8Array
  • Encode a positive BigInt as an 8-byte Uint64LE Uint8Array.

    This method will return an incorrect result for values outside of the range 0 to 0xffff_ffff_ffff_ffff.

    Parameters

    • value: bigint

      the number to encode

    Returns Uint8Array

Const bigIntToBinUint64LEClamped

  • bigIntToBinUint64LEClamped(value: bigint): Uint8Array
  • Encode a positive BigInt as an 8-byte Uint64LE Uint8Array, clamping the results. (Values exceeding 0xffff_ffff_ffff_ffff return the same result as 0xffff_ffff_ffff_ffff, negative values return the same result as 0.)

    Parameters

    • value: bigint

      the number to encode

    Returns Uint8Array

Const bigIntToBinUintLE

  • bigIntToBinUintLE(value: bigint): Uint8Array
  • Encode a positive BigInt as little-endian Uint8Array. Negative values will return the same result as 0.

    Parameters

    • value: bigint

      the number to encode

    Returns Uint8Array

Const bigIntToBitcoinVarInt

  • bigIntToBitcoinVarInt(value: bigint): Uint8Array
  • Encode a positive BigInt as a Bitcoin VarInt (Variable-length integer).

    Note: the maximum value of a Bitcoin VarInt is 0xffff_ffff_ffff_ffff. This method will return an incorrect result for values outside of the range 0 to 0xffff_ffff_ffff_ffff.

    Parameters

    • value: bigint

      the BigInt to encode (no larger than 0xffff_ffff_ffff_ffff)

    Returns Uint8Array

Const bigIntToScriptNumber

  • bigIntToScriptNumber(integer: bigint): Uint8Array
  • Convert a BigInt into the "Script Number" format. See parseBytesAsScriptNumber for more information.

    Parameters

    • integer: bigint

      the BigInt to encode as a Script Number

    Returns Uint8Array

Const binStringToBin

  • binStringToBin(binaryDigits: string): Uint8Array
  • Decode a binary-encoded string into a Uint8Array.

    E.g.: binStringToBin('0010101001100100')new Uint8Array([42, 100])

    Note, this method always completes. If binaryDigits is not divisible by 8, the final byte will be parsed as if it were prepended with 0s (e.g. 1 is interpreted as 00000001). If binaryDigits is potentially malformed, check it with isBinString before calling this method.

    Parameters

    • binaryDigits: string

    Returns Uint8Array

Const binToBase64

  • binToBase64(bytes: Uint8Array): string
  • Convert a Uint8Array to a base64-encoded string.

    Parameters

    • bytes: Uint8Array

      the Uint8Array to base64 encode

    Returns string

Const binToBech32Padded

  • binToBech32Padded(bytes: Immutable<Uint8Array>): string
  • Convert a Uint8Array to a padded bech32-encoded string (without a checksum), adding padding bits as necessary to convert all bytes to 5-bit integers.

    This method is the reverse of bech32PaddedToBin.

    Parameters

    • bytes: Immutable<Uint8Array>

      the Uint8Array to bech32 encode

    Returns string

Const binToBigIntUint256BE

  • binToBigIntUint256BE(bin: Uint8Array): bigint
  • Decode an unsigned, 32-byte big-endian Uint8Array into a BigInt. This can be used to decode Uint8Array-encoded cryptographic primitives like private keys, public keys, curve parameters, and signature points.

    If starting from a hex value, consider using the BigInt constructor instead:

    BigInt(`0x${hex}`)

    Parameters

    • bin: Uint8Array

      the Uint8Array to decode

    Returns bigint

Const binToBigIntUint64LE

  • binToBigIntUint64LE(bin: Uint8Array): bigint
  • Decode an 8-byte Uint64LE Uint8Array into a BigInt.

    Throws if bin is shorter than 8 bytes.

    Parameters

    • bin: Uint8Array

      the Uint8Array to decode

    Returns bigint

Const binToBigIntUintBE

  • binToBigIntUintBE(bin: Uint8Array, bytes?: number): bigint
  • Decode a big-endian Uint8Array of any length into a BigInt. If starting from a hex value, consider using the BigInt constructor instead:

    BigInt(`0x${hex}`)

    The bytes parameter can be set to constrain the expected length (default: bin.length). This method throws if bin.length is not equal to bytes.

    Parameters

    • bin: Uint8Array

      the Uint8Array to decode

    • Default value bytes: number = bin.length

      the number of bytes to read (default: bin.length)

    Returns bigint

Const binToBigIntUintLE

  • binToBigIntUintLE(bin: Uint8Array, bytes?: number): bigint
  • Decode a little-endian Uint8Array of any length into a BigInt.

    The bytes parameter can be set to constrain the expected length (default: bin.length). This method throws if bin.length is not equal to bytes.

    Parameters

    • bin: Uint8Array

      the Uint8Array to decode

    • Default value bytes: number = bin.length

      the number of bytes to read (default: bin.length)

    Returns bigint

Const binToBinString

  • binToBinString(bytes: Uint8Array): string
  • Encode a Uint8Array into a binary-encoded string.

    E.g.: binToBinString(Uint8Array.from([42, 100]))'0010101001100100'

    Parameters

    • bytes: Uint8Array

      a Uint8Array to encode

    Returns string

Const binToFixedLength

  • binToFixedLength(bin: Uint8Array, bytes: number): Uint8Array
  • Fill a new Uint8Array of a specific byte-length with the contents of a given Uint8Array, truncating or padding the Uint8Array with zeros.

    Parameters

    • bin: Uint8Array

      the Uint8Array to resize

    • bytes: number

      the desired byte-length

    Returns Uint8Array

Const binToHex

  • binToHex(bytes: Uint8Array): string
  • Encode a Uint8Array into a hexadecimal-encoded string.

    E.g.: binToHex(new Uint8Array([42, 100, 255]))'2a64ff'

    Parameters

    • bytes: Uint8Array

      a Uint8Array to encode

    Returns string

Const binToNumberUint16LE

  • binToNumberUint16LE(bin: Uint8Array): number
  • Decode a 2-byte Uint16LE Uint8Array into a number.

    Throws if bin is shorter than 2 bytes.

    Parameters

    • bin: Uint8Array

      the Uint8Array to decode

    Returns number

Const binToNumberUint32LE

  • binToNumberUint32LE(bin: Uint8Array): number
  • Decode a 4-byte Uint32LE Uint8Array into a number.

    Throws if bin is shorter than 4 bytes.

    Parameters

    • bin: Uint8Array

      the Uint8Array to decode

    Returns number

Const binToNumberUintLE

  • binToNumberUintLE(bin: Uint8Array, bytes?: number): number
  • Decode a little-endian Uint8Array of any length into a number. For numbers larger than Number.MAX_SAFE_INTEGER (9007199254740991), use binToBigIntUintLE.

    The bytes parameter can be set to constrain the expected length (default: bin.length). This method throws if bin.length is not equal to bytes.

    privateremarks

    We avoid a bitwise strategy here because JavaScript uses 32-bit signed integers for bitwise math, so larger numbers are converted incorrectly. E.g. 2147483648 << 8 is 0, while 2147483648n << 8n is 549755813888n.

    Parameters

    • bin: Uint8Array

      the Uint8Array to decode

    • Default value bytes: number = bin.length

      the number of bytes to read (default: bin.length)

    Returns number

Const binToUtf8

  • binToUtf8(bytes: Uint8Array): string
  • Decode a Uint8Array as a UTF-8 string.

    Parameters

    • bytes: Uint8Array

      the Uint8Array to decode

    Returns string

Const bitcoinCashOperations

  • bitcoinCashOperations<Opcodes, State>(__namedParameters: { flags: { opReverseBytes: boolean; requireBugValueZero: boolean; requireMinimalEncoding: boolean; requireNullSignatureFailures: boolean }; secp256k1: { verifySignatureDERLowS: Secp256k1["verifySignatureDERLowS"]; verifySignatureSchnorr: Secp256k1["verifySignatureSchnorr"] }; sha256: { hash: Sha256["hash"] } }): { [OpcodesBCH.OP_AND]: (Anonymous function); [OpcodesBCH.OP_BIN2NUM]: (Anonymous function); [OpcodesBCH.OP_CAT]: (Anonymous function); [OpcodesBCH.OP_CHECKDATASIGVERIFY]: (Anonymous function); [OpcodesBCH.OP_CHECKDATASIG]: (Anonymous function); [OpcodesBCH.OP_DIV]: (Anonymous function); [OpcodesBCH.OP_MOD]: (Anonymous function); [OpcodesBCH.OP_NUM2BIN]: (Anonymous function); [OpcodesBCH.OP_OR]: (Anonymous function); [OpcodesBCH.OP_SPLIT]: (Anonymous function); [OpcodesBCH.OP_XOR]: (Anonymous function) } | { [OpcodesBCH.OP_REVERSEBYTES]: (Anonymous function) }
  • Type parameters

    Parameters

    • __namedParameters: { flags: { opReverseBytes: boolean; requireBugValueZero: boolean; requireMinimalEncoding: boolean; requireNullSignatureFailures: boolean }; secp256k1: { verifySignatureDERLowS: Secp256k1["verifySignatureDERLowS"]; verifySignatureSchnorr: Secp256k1["verifySignatureSchnorr"] }; sha256: { hash: Sha256["hash"] } }
      • flags: { opReverseBytes: boolean; requireBugValueZero: boolean; requireMinimalEncoding: boolean; requireNullSignatureFailures: boolean }
        • opReverseBytes: boolean
        • requireBugValueZero: boolean
        • requireMinimalEncoding: boolean
        • requireNullSignatureFailures: boolean
      • secp256k1: { verifySignatureDERLowS: Secp256k1["verifySignatureDERLowS"]; verifySignatureSchnorr: Secp256k1["verifySignatureSchnorr"] }
        • verifySignatureDERLowS: Secp256k1["verifySignatureDERLowS"]
        • verifySignatureSchnorr: Secp256k1["verifySignatureSchnorr"]
      • sha256: { hash: Sha256["hash"] }
        • hash: Sha256["hash"]

    Returns { [OpcodesBCH.OP_AND]: (Anonymous function); [OpcodesBCH.OP_BIN2NUM]: (Anonymous function); [OpcodesBCH.OP_CAT]: (Anonymous function); [OpcodesBCH.OP_CHECKDATASIGVERIFY]: (Anonymous function); [OpcodesBCH.OP_CHECKDATASIG]: (Anonymous function); [OpcodesBCH.OP_DIV]: (Anonymous function); [OpcodesBCH.OP_MOD]: (Anonymous function); [OpcodesBCH.OP_NUM2BIN]: (Anonymous function); [OpcodesBCH.OP_OR]: (Anonymous function); [OpcodesBCH.OP_SPLIT]: (Anonymous function); [OpcodesBCH.OP_XOR]: (Anonymous function) } | { [OpcodesBCH.OP_REVERSEBYTES]: (Anonymous function) }

Const bitwiseOperation

  • bitwiseOperation<State>(combine: (a: Uint8Array, b: Uint8Array) => Uint8Array): (Anonymous function)

Const bitwiseOperations

  • bitwiseOperations<Opcodes, State, Errors>(): { [OpcodesCommon.OP_EQUALVERIFY]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_EQUAL]: (state: ProgramState) => ProgramState }
  • Type parameters

    Returns { [OpcodesCommon.OP_EQUALVERIFY]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_EQUAL]: (state: ProgramState) => ProgramState }

    • [OpcodesCommon.OP_EQUALVERIFY]: (state: ProgramState) => ProgramState
        • (state: ProgramState): ProgramState
        • Parameters

          • state: ProgramState

          Returns ProgramState

    • [OpcodesCommon.OP_EQUAL]: (state: ProgramState) => ProgramState
        • (state: ProgramState): ProgramState
        • Parameters

          • state: ProgramState

          Returns ProgramState

Const booleanToScriptNumber

  • booleanToScriptNumber(value: boolean): Uint8Array
  • Convert a boolean into Script Number format (the type used to express boolean values emitted by several operations).

    Parameters

    • value: boolean

      the boolean value to convert

    Returns Uint8Array

Const cashAddressChecksumToUint5Array

  • cashAddressChecksumToUint5Array(checksum: number): number[]
  • Convert the checksum returned by cashAddressPolynomialModulo to an array of 5-bit positive integers which can be Base32 encoded.

    Parameters

    • checksum: number

      a 40 bit checksum returned by cashAddressPolynomialModulo

    Returns number[]

Const cashAddressPolynomialModulo

  • cashAddressPolynomialModulo(v: keyof number[]): number
  • Perform the CashAddress polynomial modulo operation, which is based on the Bech32 polynomial modulo operation, but the returned checksum is 40 bits, rather than 30.

    A.K.A. PolyMod

    remarks

    Notes from Bitcoin ABC: This function will compute what 8 5-bit values to XOR into the last 8 input values, in order to make the checksum 0. These 8 values are packed together in a single 40-bit integer. The higher bits correspond to earlier values.

    The input is interpreted as a list of coefficients of a polynomial over F = GF(32), with an implicit 1 in front. If the input is [v0,v1,v2,v3,v4], that polynomial is v(x) = 1x^5 + v0x^4 + v1x^3 + v2x^2 + v3*x + v4. The implicit 1 guarantees that [v0,v1,v2,...] has a distinct checksum from [0,v0,v1,v2,...].

    The output is a 40-bit integer whose 5-bit groups are the coefficients of the remainder of v(x) mod g(x), where g(x) is the cashaddr generator, x^8

    • [19]x^7 + [3]x^6 + [25]x^5 + [11]x^4 + [25]x^3 + [3]x^2 + [19]*x
    • [1]. g(x) is chosen in such a way that the resulting code is a BCH code, guaranteeing detection of up to 4 errors within a window of 1025 characters. Among the various possible BCH codes, one was selected to in fact guarantee detection of up to 5 errors within a window of 160 characters and 6 errors within a window of 126 characters. In addition, the code guarantee the detection of a burst of up to 8 errors.

    Note that the coefficients are elements of GF(32), here represented as decimal numbers between []. In this finite field, addition is just XOR of the corresponding numbers. For example, [27] + [13] = [27 ^ 13] = [22]. Multiplication is more complicated, and requires treating the bits of values themselves as coefficients of a polynomial over a smaller field, GF(2), and multiplying those polynomials mod a^5 + a^3 + 1. For example, [5] * [26] = (a^2 + 1) * (a^4 + a^3 + a) = (a^4 + a^3 + a) * a^2 + (a^4 + a^3 + a) = a^6 + a^5 + a^4 + a = a^3 + 1 (mod a^5 + a^3 + 1) = [9].

    During the course of the loop below, c contains the bit-packed coefficients of the polynomial constructed from just the values of v that were processed so far, mod g(x). In the above example, c initially corresponds to 1 mod (x), and after processing 2 inputs of v, it corresponds to x^2 + v0*x + v1 mod g(x). As 1 mod g(x) = 1, that is the starting value for c.

    privateremarks

    Derived from the bitcore-lib-cash implementation, which does not require BigInt: https://github.com/bitpay/bitcore

    Parameters

    • v: keyof number[]

      Array of 5-bit integers over which the checksum is to be computed

    Returns number

Const cashAddressPolynomialToCashAddress

  • cashAddressPolynomialToCashAddress(polynomial: keyof number[]): string
  • Convert a CashAddress polynomial to CashAddress string format.

    remarks

    CashAddress polynomials take the form:

    [lowest 5 bits of each prefix character] 0 [payload + checksum]

    This method remaps the 5-bit integers in the prefix location to the matching ASCII lowercase characters, replaces the separator with :, and then Bech32 encodes the remaining payload and checksum.

    Parameters

    • polynomial: keyof number[]

      an array of 5-bit integers representing the terms of a CashAddress polynomial

    Returns string

Const cashAddressToLockingBytecode

Const checkLimitsCommon

Const cloneAuthenticationProgramStateCommon

  • cloneAuthenticationProgramStateCommon<Opcodes, State, Errors>(state: State): { alternateStack: Uint8Array[]; correspondingOutput: undefined | Uint8Array; executionStack: boolean[]; instructions: (AuthenticationInstructionPush<Opcodes> | AuthenticationInstructionOperation<Opcodes>)[]; ip: number; lastCodeSeparator: number; locktime: number; operationCount: number; outpointIndex: number; outpointTransactionHash: Uint8Array; outputValue: Uint8Array; sequenceNumber: number; signatureOperationsCount: number; signedMessages: Uint8Array[]; stack: Uint8Array[]; transactionOutpoints: Uint8Array; transactionOutputs: Uint8Array; transactionSequenceNumbers: Uint8Array; version: number }
  • Note: this implementation does not safely clone elements within array properties. Mutating values within arrays will mutate those values in cloned program states.

    Type parameters

    Parameters

    • state: State

    Returns { alternateStack: Uint8Array[]; correspondingOutput: undefined | Uint8Array; executionStack: boolean[]; instructions: (AuthenticationInstructionPush<Opcodes> | AuthenticationInstructionOperation<Opcodes>)[]; ip: number; lastCodeSeparator: number; locktime: number; operationCount: number; outpointIndex: number; outpointTransactionHash: Uint8Array; outputValue: Uint8Array; sequenceNumber: number; signatureOperationsCount: number; signedMessages: Uint8Array[]; stack: Uint8Array[]; transactionOutpoints: Uint8Array; transactionOutputs: Uint8Array; transactionSequenceNumbers: Uint8Array; version: number }

    • alternateStack: Uint8Array[]
    • correspondingOutput: undefined | Uint8Array
    • executionStack: boolean[]
    • instructions: (AuthenticationInstructionPush<Opcodes> | AuthenticationInstructionOperation<Opcodes>)[]
    • ip: number
    • lastCodeSeparator: number
    • locktime: number
    • operationCount: number
    • outpointIndex: number
    • outpointTransactionHash: Uint8Array
    • outputValue: Uint8Array
    • sequenceNumber: number
    • signatureOperationsCount: number
    • signedMessages: Uint8Array[]
    • stack: Uint8Array[]
    • transactionOutpoints: Uint8Array
    • transactionOutputs: Uint8Array
    • transactionSequenceNumbers: Uint8Array
    • version: number

Const cloneStack

  • cloneStack(stack: keyof Readonly<Uint8Array>[]): Uint8Array[]

Const combineOperations

  • combineOperations<State>(firstOperation: Operation<State>, secondOperation: Operation<State>): (Anonymous function)

Const commonOperations

  • commonOperations<Opcodes, State, Errors>(__namedParameters: { flags: { disallowUpgradableNops: boolean; requireBugValueZero: boolean; requireMinimalEncoding: boolean; requireNullSignatureFailures: boolean }; ripemd160: { hash: Ripemd160["hash"] }; secp256k1: { verifySignatureDERLowS: Secp256k1["verifySignatureDERLowS"]; verifySignatureSchnorr: Secp256k1["verifySignatureSchnorr"] }; sha1: { hash: Sha1["hash"] }; sha256: { hash: Sha256["hash"] } }): {}
  • Type parameters

    Parameters

    • __namedParameters: { flags: { disallowUpgradableNops: boolean; requireBugValueZero: boolean; requireMinimalEncoding: boolean; requireNullSignatureFailures: boolean }; ripemd160: { hash: Ripemd160["hash"] }; secp256k1: { verifySignatureDERLowS: Secp256k1["verifySignatureDERLowS"]; verifySignatureSchnorr: Secp256k1["verifySignatureSchnorr"] }; sha1: { hash: Sha1["hash"] }; sha256: { hash: Sha256["hash"] } }
      • flags: { disallowUpgradableNops: boolean; requireBugValueZero: boolean; requireMinimalEncoding: boolean; requireNullSignatureFailures: boolean }
        • disallowUpgradableNops: boolean
        • requireBugValueZero: boolean
        • requireMinimalEncoding: boolean
        • requireNullSignatureFailures: boolean
      • ripemd160: { hash: Ripemd160["hash"] }
        • hash: Ripemd160["hash"]
      • secp256k1: { verifySignatureDERLowS: Secp256k1["verifySignatureDERLowS"]; verifySignatureSchnorr: Secp256k1["verifySignatureSchnorr"] }
        • verifySignatureDERLowS: Secp256k1["verifySignatureDERLowS"]
        • verifySignatureSchnorr: Secp256k1["verifySignatureSchnorr"]
      • sha1: { hash: Sha1["hash"] }
        • hash: Sha1["hash"]
      • sha256: { hash: Sha256["hash"] }
        • hash: Sha256["hash"]

    Returns {}

Const compileBtl

  • compileBtl(script: string): string | Uint8Array
  • Perform a simplified compilation on a Bitauth Templating Language (BTL) script containing only hex literals, bigint literals, UTF8 literals, and push statements. Scripts may not contain variables/operations, evaluations, or opcode identifiers (use hex literals instead).

    This is useful for accepting complex user input in advanced interfaces, especially for AddressData and WalletData.

    Returns the compiled bytecode as a Uint8Array, or throws an error message.

    Parameters

    • script: string

      a simple BTL script containing no variables or evaluations

    Returns string | Uint8Array

Const compileInputTemplate

Const compileOutputTemplate

Const compileScript

Const compileScriptContents

  • compileScriptContents<ProgramState, TransactionContext>(__namedParameters: { data: CompilationData<TransactionContext>; environment: CompilationEnvironment<TransactionContext, "public_key" | "signature", "version" | "transaction_outpoints" | "transaction_outpoints_hash" | "transaction_sequence_numbers" | "transaction_sequence_numbers_hash" | "outpoint_transaction_hash" | "outpoint_index" | "covered_bytecode_length" | "covered_bytecode" | "output_value" | "sequence_number" | "corresponding_output" | "corresponding_output_hash" | "transaction_outputs" | "transaction_outputs_hash" | "locktime" | "full_all_outputs" | "full_all_outputs_single_input" | "full_corresponding_output" | "full_corresponding_output_single_input" | "full_no_outputs" | "full_no_outputs_single_input", false, false, false, false>; script: string }): CompilationResult<ProgramState>
  • This method is generally for internal use. The compileScript method is the recommended API for direct compilation.

    Type parameters

    Parameters

    • __namedParameters: { data: CompilationData<TransactionContext>; environment: CompilationEnvironment<TransactionContext, "public_key" | "signature", "version" | "transaction_outpoints" | "transaction_outpoints_hash" | "transaction_sequence_numbers" | "transaction_sequence_numbers_hash" | "outpoint_transaction_hash" | "outpoint_index" | "covered_bytecode_length" | "covered_bytecode" | "output_value" | "sequence_number" | "corresponding_output" | "corresponding_output_hash" | "transaction_outputs" | "transaction_outputs_hash" | "locktime" | "full_all_outputs" | "full_all_outputs_single_input" | "full_corresponding_output" | "full_corresponding_output_single_input" | "full_no_outputs" | "full_no_outputs_single_input", false, false, false, false>; script: string }
      • data: CompilationData<TransactionContext>
      • environment: CompilationEnvironment<TransactionContext, "public_key" | "signature", "version" | "transaction_outpoints" | "transaction_outpoints_hash" | "transaction_sequence_numbers" | "transaction_sequence_numbers_hash" | "outpoint_transaction_hash" | "outpoint_index" | "covered_bytecode_length" | "covered_bytecode" | "output_value" | "sequence_number" | "corresponding_output" | "corresponding_output_hash" | "transaction_outputs" | "transaction_outputs_hash" | "locktime" | "full_all_outputs" | "full_all_outputs_single_input" | "full_corresponding_output" | "full_corresponding_output_single_input" | "full_no_outputs" | "full_no_outputs_single_input", false, false, false, false>
      • script: string

    Returns CompilationResult<ProgramState>

Const compileScriptP2shLocking

Const compileScriptP2shUnlocking

  • compileScriptP2shUnlocking<ProgramState>(__namedParameters: { lockingBytecode: Uint8Array; unlockingBytecode: Uint8Array }): CompilationResultSuccess<ProgramState>

Const compileScriptRaw

  • compileScriptRaw<ProgramState, TransactionContext>(__namedParameters: { data: CompilationData<TransactionContext>; environment: CompilationEnvironment<TransactionContext, "public_key" | "signature", "version" | "transaction_outpoints" | "transaction_outpoints_hash" | "transaction_sequence_numbers" | "transaction_sequence_numbers_hash" | "outpoint_transaction_hash" | "outpoint_index" | "covered_bytecode_length" | "covered_bytecode" | "output_value" | "sequence_number" | "corresponding_output" | "corresponding_output_hash" | "transaction_outputs" | "transaction_outputs_hash" | "locktime" | "full_all_outputs" | "full_all_outputs_single_input" | "full_corresponding_output" | "full_corresponding_output_single_input" | "full_no_outputs" | "full_no_outputs_single_input", false, false, false, false>; scriptId: string }): CompilationResult<ProgramState>
  • This method is generally for internal use. The compileScript method is the recommended API for direct compilation.

    Type parameters

    Parameters

    • __namedParameters: { data: CompilationData<TransactionContext>; environment: CompilationEnvironment<TransactionContext, "public_key" | "signature", "version" | "transaction_outpoints" | "transaction_outpoints_hash" | "transaction_sequence_numbers" | "transaction_sequence_numbers_hash" | "outpoint_transaction_hash" | "outpoint_index" | "covered_bytecode_length" | "covered_bytecode" | "output_value" | "sequence_number" | "corresponding_output" | "corresponding_output_hash" | "transaction_outputs" | "transaction_outputs_hash" | "locktime" | "full_all_outputs" | "full_all_outputs_single_input" | "full_corresponding_output" | "full_corresponding_output_single_input" | "full_no_outputs" | "full_no_outputs_single_input", false, false, false, false>; scriptId: string }
      • data: CompilationData<TransactionContext>
      • environment: CompilationEnvironment<TransactionContext, "public_key" | "signature", "version" | "transaction_outpoints" | "transaction_outpoints_hash" | "transaction_sequence_numbers" | "transaction_sequence_numbers_hash" | "outpoint_transaction_hash" | "outpoint_index" | "covered_bytecode_length" | "covered_bytecode" | "output_value" | "sequence_number" | "corresponding_output" | "corresponding_output_hash" | "transaction_outputs" | "transaction_outputs_hash" | "locktime" | "full_all_outputs" | "full_all_outputs_single_input" | "full_corresponding_output" | "full_corresponding_output_single_input" | "full_no_outputs" | "full_no_outputs_single_input", false, false, false, false>
      • scriptId: string

    Returns CompilationResult<ProgramState>

Const compilerOperationHelperAddressIndex

  • compilerOperationHelperAddressIndex(identifier: string): { error: string; status: "error" }

Const compilerOperationHelperCompileScript

  • compilerOperationHelperCompileScript<TransactionContext>(__namedParameters: { data: CompilationData<TransactionContext>; environment: CompilationEnvironment<TransactionContext, string | false, string | false, string | false, string | false, string | false, string | false>; targetScriptId: string }): false | Uint8Array | CompilerOperationErrorFatal
  • Returns false if the target script ID doesn't exist in the compilation environment (allows for the caller to generate the error message).

    If the compilation produced errors, returns a CompilerOperationErrorFatal.

    If the compilation was successful, returns the compiled bytecode as a Uint8Array.

    Type parameters

    • TransactionContext

    Parameters

    • __namedParameters: { data: CompilationData<TransactionContext>; environment: CompilationEnvironment<TransactionContext, string | false, string | false, string | false, string | false, string | false, string | false>; targetScriptId: string }
      • data: CompilationData<TransactionContext>
      • environment: CompilationEnvironment<TransactionContext, string | false, string | false, string | false, string | false, string | false, string | false>
      • targetScriptId: string

    Returns false | Uint8Array | CompilerOperationErrorFatal

Const compilerOperationHelperComputeDataSignatureBCH

  • compilerOperationHelperComputeDataSignatureBCH<Data, Environment>(__namedParameters: { data: Data; environment: Environment; identifier: string; operationName: string; privateKey: Uint8Array; sha256: { hash: Sha256["hash"] }; sign: (privateKey: Uint8Array, messageHash: Uint8Array) => Uint8Array }): CompilerOperationResult
  • Type parameters

    Parameters

    • __namedParameters: { data: Data; environment: Environment; identifier: string; operationName: string; privateKey: Uint8Array; sha256: { hash: Sha256["hash"] }; sign: (privateKey: Uint8Array, messageHash: Uint8Array) => Uint8Array }
      • data: Data
      • environment: Environment
      • identifier: string
      • operationName: string
      • privateKey: Uint8Array
      • sha256: { hash: Sha256["hash"] }
        • hash: Sha256["hash"]
      • sign: (privateKey: Uint8Array, messageHash: Uint8Array) => Uint8Array
          • (privateKey: Uint8Array, messageHash: Uint8Array): Uint8Array
          • Parameters

            • privateKey: Uint8Array
            • messageHash: Uint8Array

            Returns Uint8Array

    Returns CompilerOperationResult

Const compilerOperationHelperComputeSignatureBCH

  • compilerOperationHelperComputeSignatureBCH(__namedParameters: { coveredBytecode: Uint8Array; identifier: string; operationName: string; privateKey: Uint8Array; sha256: { hash: Sha256["hash"] }; sign: (privateKey: Uint8Array, messageHash: Uint8Array) => Uint8Array; transactionContext: TransactionContextCommon }): CompilerOperationResult
  • Parameters

    • __namedParameters: { coveredBytecode: Uint8Array; identifier: string; operationName: string; privateKey: Uint8Array; sha256: { hash: Sha256["hash"] }; sign: (privateKey: Uint8Array, messageHash: Uint8Array) => Uint8Array; transactionContext: TransactionContextCommon }
      • coveredBytecode: Uint8Array
      • identifier: string
      • operationName: string
      • privateKey: Uint8Array
      • sha256: { hash: Sha256["hash"] }
        • hash: Sha256["hash"]
      • sign: (privateKey: Uint8Array, messageHash: Uint8Array) => Uint8Array
          • (privateKey: Uint8Array, messageHash: Uint8Array): Uint8Array
          • Parameters

            • privateKey: Uint8Array
            • messageHash: Uint8Array

            Returns Uint8Array

      • transactionContext: TransactionContextCommon

    Returns CompilerOperationResult

Const compilerOperationHelperDeriveHdKeyPrivate

  • compilerOperationHelperDeriveHdKeyPrivate(__namedParameters: { environment: { entityOwnership: NonNullable<CompilationEnvironment["entityOwnership"]>; ripemd160: NonNullable<CompilationEnvironment["ripemd160"]>; secp256k1: NonNullable<CompilationEnvironment["secp256k1"]>; sha256: NonNullable<CompilationEnvironment["sha256"]>; sha512: NonNullable<CompilationEnvironment["sha512"]>; variables: NonNullable<CompilationEnvironment["variables"]> }; hdKeys: { addressIndex?: undefined | number; hdPrivateKeys?: undefined | {}; hdPublicKeys?: undefined | {} }; identifier: string }): CompilerOperationResult
  • Parameters

    • __namedParameters: { environment: { entityOwnership: NonNullable<CompilationEnvironment["entityOwnership"]>; ripemd160: NonNullable<CompilationEnvironment["ripemd160"]>; secp256k1: NonNullable<CompilationEnvironment["secp256k1"]>; sha256: NonNullable<CompilationEnvironment["sha256"]>; sha512: NonNullable<CompilationEnvironment["sha512"]>; variables: NonNullable<CompilationEnvironment["variables"]> }; hdKeys: { addressIndex?: undefined | number; hdPrivateKeys?: undefined | {}; hdPublicKeys?: undefined | {} }; identifier: string }
      • environment: { entityOwnership: NonNullable<CompilationEnvironment["entityOwnership"]>; ripemd160: NonNullable<CompilationEnvironment["ripemd160"]>; secp256k1: NonNullable<CompilationEnvironment["secp256k1"]>; sha256: NonNullable<CompilationEnvironment["sha256"]>; sha512: NonNullable<CompilationEnvironment["sha512"]>; variables: NonNullable<CompilationEnvironment["variables"]> }
        • entityOwnership: NonNullable<CompilationEnvironment["entityOwnership"]>
        • ripemd160: NonNullable<CompilationEnvironment["ripemd160"]>
        • secp256k1: NonNullable<CompilationEnvironment["secp256k1"]>
        • sha256: NonNullable<CompilationEnvironment["sha256"]>
        • sha512: NonNullable<CompilationEnvironment["sha512"]>
        • variables: NonNullable<CompilationEnvironment["variables"]>
      • hdKeys: { addressIndex?: undefined | number; hdPrivateKeys?: undefined | {}; hdPublicKeys?: undefined | {} }
        • Optional addressIndex?: undefined | number

          The current address index to be used for this compilation. The addressIndex gets added to each HdKeys addressOffset to calculate the dynamic index (i) used in each privateDerivationPath or publicDerivationPath.

          This is required for any compiler operation which requires derivation. Typically, the value is incremented by one for each address in a wallet.

        • Optional hdPrivateKeys?: undefined | {}

          A map of entity IDs to master HD private keys. These master HD private keys are used to derive each HdKey variable assigned to that entity (as specified in CompilationEnvironment.entityOwnership) according to its privateDerivationPath.

          HD private keys may be encoded for either mainnet or testnet (the network information is ignored).

          If both an HD private key (in hdPrivateKeys) and HD public key (in hdPublicKeys) are provided for the same entity in the same compilation (not recommended), only the HD private key is used.

        • Optional hdPublicKeys?: undefined | {}

          A map of entity IDs to HD public keys. These HD public keys are used to derive public keys for each HdKey variable assigned to that entity (as specified in CompilationEnvironment.entityOwnership) according to its publicDerivationPath.

          HD public keys may be encoded for either mainnet or testnet (the network information is ignored).

          If both an HD private key (in hdPrivateKeys) and HD public key (in hdPublicKeys) are provided for the same entity in the same compilation (not recommended), the HD private key is used.

      • identifier: string

    Returns CompilerOperationResult

Const compilerOperationHelperDeriveHdPrivateNode

  • compilerOperationHelperDeriveHdPrivateNode(__namedParameters: { addressIndex: number; entityHdPrivateKey: string; entityId: string; environment: { ripemd160: NonNullable<CompilationEnvironment["ripemd160"]>; secp256k1: NonNullable<CompilationEnvironment["secp256k1"]>; sha256: NonNullable<CompilationEnvironment["sha256"]>; sha512: NonNullable<CompilationEnvironment["sha512"]> }; hdKey: AuthenticationTemplateHdKey; identifier: string }): CompilerOperationResult
  • Parameters

    • __namedParameters: { addressIndex: number; entityHdPrivateKey: string; entityId: string; environment: { ripemd160: NonNullable<CompilationEnvironment["ripemd160"]>; secp256k1: NonNullable<CompilationEnvironment["secp256k1"]>; sha256: NonNullable<CompilationEnvironment["sha256"]>; sha512: NonNullable<CompilationEnvironment["sha512"]> }; hdKey: AuthenticationTemplateHdKey; identifier: string }
      • addressIndex: number
      • entityHdPrivateKey: string
      • entityId: string
      • environment: { ripemd160: NonNullable<CompilationEnvironment["ripemd160"]>; secp256k1: NonNullable<CompilationEnvironment["secp256k1"]>; sha256: NonNullable<CompilationEnvironment["sha256"]>; sha512: NonNullable<CompilationEnvironment["sha512"]> }
        • ripemd160: NonNullable<CompilationEnvironment["ripemd160"]>
        • secp256k1: NonNullable<CompilationEnvironment["secp256k1"]>
        • sha256: NonNullable<CompilationEnvironment["sha256"]>
        • sha512: NonNullable<CompilationEnvironment["sha512"]>
      • hdKey: AuthenticationTemplateHdKey
      • identifier: string

    Returns CompilerOperationResult

Const compilerOperationHelperGenerateCoveredBytecode

  • compilerOperationHelperGenerateCoveredBytecode<TransactionContext>(__namedParameters: { data: CompilationData<TransactionContext>; environment: CompilationEnvironment<TransactionContext, string | false, string | false, string | false, string | false, string | false, string | false>; identifier: string; sourceScriptIds: string[]; unlockingScripts: {} }): CompilerOperationErrorFatal | Uint8Array
  • Returns either the properly generated coveredBytecode or a CompilerOperationErrorFatal.

    Type parameters

    • TransactionContext

    Parameters

    • __namedParameters: { data: CompilationData<TransactionContext>; environment: CompilationEnvironment<TransactionContext, string | false, string | false, string | false, string | false, string | false, string | false>; identifier: string; sourceScriptIds: string[]; unlockingScripts: {} }
      • data: CompilationData<TransactionContext>
      • environment: CompilationEnvironment<TransactionContext, string | false, string | false, string | false, string | false, string | false, string | false>
      • identifier: string
      • sourceScriptIds: string[]
      • unlockingScripts: {}
        • [unlockingScriptId: string]: string

    Returns CompilerOperationErrorFatal | Uint8Array

Const compilerOperationHelperHdKeyDataSignatureBCH

  • compilerOperationHelperHdKeyDataSignatureBCH(__namedParameters: { operationName: string; secp256k1Method: "derivePublicKeyCompressed" | "signMessageHashSchnorr" | "signMessageHashDER" | "addTweakPrivateKey" | "addTweakPublicKeyCompressed" }): (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped>
  • Parameters

    • __namedParameters: { operationName: string; secp256k1Method: "derivePublicKeyCompressed" | "signMessageHashSchnorr" | "signMessageHashDER" | "addTweakPrivateKey" | "addTweakPublicKeyCompressed" }
      • operationName: string
      • secp256k1Method: "derivePublicKeyCompressed" | "signMessageHashSchnorr" | "signMessageHashDER" | "addTweakPrivateKey" | "addTweakPublicKeyCompressed"

    Returns (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped>

Const compilerOperationHelperHdKeySignatureBCH

  • compilerOperationHelperHdKeySignatureBCH(__namedParameters: { operationName: string; secp256k1Method: "derivePublicKeyCompressed" | "signMessageHashSchnorr" | "signMessageHashDER" | "addTweakPrivateKey" | "addTweakPublicKeyCompressed" }): (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped>
  • Parameters

    • __namedParameters: { operationName: string; secp256k1Method: "derivePublicKeyCompressed" | "signMessageHashSchnorr" | "signMessageHashDER" | "addTweakPrivateKey" | "addTweakPublicKeyCompressed" }
      • operationName: string
      • secp256k1Method: "derivePublicKeyCompressed" | "signMessageHashSchnorr" | "signMessageHashDER" | "addTweakPrivateKey" | "addTweakPublicKeyCompressed"

    Returns (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped>

Const compilerOperationHelperKeyDataSignatureBCH

  • compilerOperationHelperKeyDataSignatureBCH(__namedParameters: { operationName: string; secp256k1Method: "derivePublicKeyCompressed" | "signMessageHashSchnorr" | "signMessageHashDER" | "addTweakPrivateKey" | "addTweakPublicKeyCompressed" }): (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped>
  • Parameters

    • __namedParameters: { operationName: string; secp256k1Method: "derivePublicKeyCompressed" | "signMessageHashSchnorr" | "signMessageHashDER" | "addTweakPrivateKey" | "addTweakPublicKeyCompressed" }
      • operationName: string
      • secp256k1Method: "derivePublicKeyCompressed" | "signMessageHashSchnorr" | "signMessageHashDER" | "addTweakPrivateKey" | "addTweakPublicKeyCompressed"

    Returns (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped>

Const compilerOperationHelperKeySignatureBCH

  • compilerOperationHelperKeySignatureBCH(__namedParameters: { operationName: string; secp256k1Method: "derivePublicKeyCompressed" | "signMessageHashSchnorr" | "signMessageHashDER" | "addTweakPrivateKey" | "addTweakPublicKeyCompressed" }): (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped>
  • Parameters

    • __namedParameters: { operationName: string; secp256k1Method: "derivePublicKeyCompressed" | "signMessageHashSchnorr" | "signMessageHashDER" | "addTweakPrivateKey" | "addTweakPublicKeyCompressed" }
      • operationName: string
      • secp256k1Method: "derivePublicKeyCompressed" | "signMessageHashSchnorr" | "signMessageHashDER" | "addTweakPrivateKey" | "addTweakPublicKeyCompressed"

    Returns (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped>

Const compilerOperationHelperSigningSerializationCoveredBytecode

  • compilerOperationHelperSigningSerializationCoveredBytecode(returnLength: boolean): (identifier: string, data: Data, environment: Environment) => CompilerOperationResult<CanBeSkipped>

Const compilerOperationHelperUnknownEntity

  • compilerOperationHelperUnknownEntity(identifier: string, variableId: string): { error: string; status: "error" }

Const compilerOperationRequires

  • compilerOperationRequires<CanBeSkipped, RequiredDataProperties, RequiredEnvironmentProperties, TransactionContext>(__namedParameters: { canBeSkipped: CanBeSkipped; dataProperties: RequiredDataProperties[]; environmentProperties: RequiredEnvironmentProperties[]; operation: (identifier: string, data: Required<Pick<CompilationData<TransactionContext>, RequiredDataProperties>> & CompilationData<TransactionContext>, environment: Required<Pick<CompilationEnvironment<TransactionContext>, RequiredEnvironmentProperties>> & CompilationEnvironment<TransactionContext>) => CompilerOperationResult<CanBeSkipped> }): CompilerOperation<TransactionContext, CanBeSkipped>

Const conditionalFlowControlOperations

  • conditionalFlowControlOperations<Opcodes, State, Errors>(): { [OpcodesCommon.OP_RESERVED1]: (Anonymous function); [OpcodesCommon.OP_RESERVED2]: (Anonymous function); [OpcodesCommon.OP_RESERVED]: (Anonymous function); [OpcodesCommon.OP_RETURN]: (Anonymous function); [OpcodesCommon.OP_VERIFY]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_VER]: (Anonymous function) }
  • Type parameters

    Returns { [OpcodesCommon.OP_RESERVED1]: (Anonymous function); [OpcodesCommon.OP_RESERVED2]: (Anonymous function); [OpcodesCommon.OP_RESERVED]: (Anonymous function); [OpcodesCommon.OP_RETURN]: (Anonymous function); [OpcodesCommon.OP_VERIFY]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_VER]: (Anonymous function) }

    • [OpcodesCommon.OP_RESERVED1]: (Anonymous function)
    • [OpcodesCommon.OP_RESERVED2]: (Anonymous function)
    • [OpcodesCommon.OP_RESERVED]: (Anonymous function)
    • [OpcodesCommon.OP_RETURN]: (Anonymous function)
    • [OpcodesCommon.OP_VERIFY]: (state: ProgramState) => ProgramState
        • (state: ProgramState): ProgramState
        • Parameters

          • state: ProgramState

          Returns ProgramState

    • [OpcodesCommon.OP_VER]: (Anonymous function)

Const conditionallyEvaluate

Const containsRange

  • containsRange(outerRange: Range, innerRange: Range, exclusive?: boolean): boolean
  • Returns true if the outerRange fully contains the innerRange, otherwise, false.

    Parameters

    • outerRange: Range

      the bounds of the outer range

    • innerRange: Range

      the inner range to test

    • Default value exclusive: boolean = true

      disallow the innerRange from overlapping the outerRange (such that the outer start and end columns may not be equal) – defaults to true

    Returns boolean

Const crackHdPrivateNodeFromHdPublicNodeAndChildPrivateNode

  • crackHdPrivateNodeFromHdPublicNodeAndChildPrivateNode<PublicNode>(crypto: { sha512: { hash: Sha512["hash"] } }, parentPublicNode: PublicNode, childPrivateNode: { childIndex: number; privateKey: Uint8Array }): cannotCrackHardenedDerivation | (PublicNode extends HdPublicNodeKnownParent ? HdPrivateNodeKnownParent : HdPrivateNodeValid)
  • Derive the HD private node from a HD public node, given any non-hardened child private node.

    remarks

    This exploits the "non-hardened" BIP32 derivation algorithm. Because non-hardened derivation only requires knowledge of the "chain code" (rather than requiring knowledge of the parent private key) it's possible to calculate the value by which the parent private key is "tweaked" to arrive at the child private key. Since we have the child private key, we simply subtract this "tweaked" amount to get back to the parent private key.

    The BIP32 "hardened" derivation algorithm is designed to address this weakness. Using hardened derivation, child private nodes can be shared without risk of leaking the parent private node, but this comes at the cost of public node derivation. Given only a parent public node, it is not possible to derive hardened child public keys, so applications must choose between support for HD public node derivation or support for sharing child private nodes.

    Type parameters

    Parameters

    • crypto: { sha512: { hash: Sha512["hash"] } }

      an implementation of sha512

      • sha512: { hash: Sha512["hash"] }
        • hash: Sha512["hash"]
    • parentPublicNode: PublicNode

      the parent HD public node for which to derive a private node

    • childPrivateNode: { childIndex: number; privateKey: Uint8Array }

      any non-hardened child private node of the parent node (only the privateKey and the childIndex are required)

      • childIndex: number
      • privateKey: Uint8Array

    Returns cannotCrackHardenedDerivation | (PublicNode extends HdPublicNodeKnownParent ? HdPrivateNodeKnownParent : HdPrivateNodeValid)

Const createAuthenticationProgramEvaluationCommon

  • A common createAuthenticationProgram implementation for most compilers.

    Accepts the compiled contents of an evaluation and produces a AuthenticationProgramCommon which can be evaluated to produce the resulting program state.

    The precise shape of the authentication program produced by this method is critical to the determinism of BTL evaluations for the compiler in which it is used, it therefore must be standardized between compiler implementations.

    Parameters

    • evaluationBytecode: Uint8Array

      the compiled bytecode to incorporate in the created authentication program

    Returns AuthenticationProgramCommon

Const createAuthenticationProgramInternalStateCommon

Const createAuthenticationProgramStateCommon

Const createAuthenticationProgramStateCommonEmpty

Const createAuthenticationVirtualMachine

Const createBaseConverter

  • Create a BaseConverter, which exposes methods for encoding and decoding Uint8Arrays using bitcoin-style padding: each leading zero in the input is replaced with the zero-index character of the alphabet, then the remainder of the input is encoded as a large number in the specified alphabet.

    For example, using the alphabet 01, the input [0, 15] is encoded 01111 – a single 0 represents the leading padding, followed by the base2 encoded 0x1111 (15). With the same alphabet, the input [0, 0, 255] is encoded 0011111111 - only two 0 characters are required to represent both leading zeros, followed by the base2 encoded 0x11111111 (255).

    This is not compatible with RFC 3548's Base16, Base32, or Base64.

    If the alphabet is malformed, this method returns the error as a string.

    privateremarks

    Algorithm from the base-x implementation (which is derived from the original Satoshi implementation): https://github.com/cryptocoinjs/base-x

    Parameters

    • alphabet: string

      an ordered string which maps each index to a character, e.g. 0123456789.

    Returns BaseConversionError | BaseConverter

Const createCompiler

  • createCompiler<TransactionContext, Environment, Opcodes, ProgramState>(compilationEnvironment: Environment): Compiler<TransactionContext, Environment, ProgramState>

Const createCompilerBCH

  • createCompilerBCH<TransactionContext, Environment, ProgramState>(scriptsAndOverrides: Environment): Promise<Compiler<TransactionContext, Environment, ProgramState>>

Const createCompilerCommonSynchronous

  • createCompilerCommonSynchronous<Environment, ProgramState, Opcodes, Errors>(scriptsAndOverrides: Environment): Compiler<TransactionContextCommon, Environment, ProgramState>

Const createIdentifierResolver

  • createIdentifierResolver<TransactionContext>(__namedParameters: { data: CompilationData<TransactionContext>; environment: CompilationEnvironment<TransactionContext, "public_key" | "signature", "version" | "transaction_outpoints" | "transaction_outpoints_hash" | "transaction_sequence_numbers" | "transaction_sequence_numbers_hash" | "outpoint_transaction_hash" | "outpoint_index" | "covered_bytecode_length" | "covered_bytecode" | "output_value" | "sequence_number" | "corresponding_output" | "corresponding_output_hash" | "transaction_outputs" | "transaction_outputs_hash" | "locktime" | "full_all_outputs" | "full_all_outputs_single_input" | "full_corresponding_output" | "full_corresponding_output_single_input" | "full_no_outputs" | "full_no_outputs_single_input", false, false, false, false> }): IdentifierResolutionFunction
  • Return an IdentifierResolutionFunction for use in resolveScriptSegment.

    Type parameters

    • TransactionContext

    Parameters

    • __namedParameters: { data: CompilationData<TransactionContext>; environment: CompilationEnvironment<TransactionContext, "public_key" | "signature", "version" | "transaction_outpoints" | "transaction_outpoints_hash" | "transaction_sequence_numbers" | "transaction_sequence_numbers_hash" | "outpoint_transaction_hash" | "outpoint_index" | "covered_bytecode_length" | "covered_bytecode" | "output_value" | "sequence_number" | "corresponding_output" | "corresponding_output_hash" | "transaction_outputs" | "transaction_outputs_hash" | "locktime" | "full_all_outputs" | "full_all_outputs_single_input" | "full_corresponding_output" | "full_corresponding_output_single_input" | "full_no_outputs" | "full_no_outputs_single_input", false, false, false, false> }
      • data: CompilationData<TransactionContext>
      • environment: CompilationEnvironment<TransactionContext, "public_key" | "signature", "version" | "transaction_outpoints" | "transaction_outpoints_hash" | "transaction_sequence_numbers" | "transaction_sequence_numbers_hash" | "outpoint_transaction_hash" | "outpoint_index" | "covered_bytecode_length" | "covered_bytecode" | "output_value" | "sequence_number" | "corresponding_output" | "corresponding_output_hash" | "transaction_outputs" | "transaction_outputs_hash" | "locktime" | "full_all_outputs" | "full_all_outputs_single_input" | "full_corresponding_output" | "full_corresponding_output_single_input" | "full_no_outputs" | "full_no_outputs_single_input", false, false, false, false>

    Returns IdentifierResolutionFunction

Const createInstructionSetBCH

  • createInstructionSetBCH(__namedParameters: { flags: { disallowUpgradableNops: boolean; opReverseBytes: boolean; requireBugValueZero: boolean; requireMinimalEncoding: boolean; requireNullSignatureFailures: boolean }; ripemd160: { hash: Ripemd160["hash"] }; secp256k1: { verifySignatureDERLowS: Secp256k1["verifySignatureDERLowS"]; verifySignatureSchnorr: Secp256k1["verifySignatureSchnorr"] }; sha1: { hash: Sha1["hash"] }; sha256: { hash: Sha256["hash"] } }): InstructionSet<AuthenticationProgramBCH, AuthenticationProgramStateBCH>
  • Initialize a new instruction set for the BCH virtual machine.

    Parameters

    • __namedParameters: { flags: { disallowUpgradableNops: boolean; opReverseBytes: boolean; requireBugValueZero: boolean; requireMinimalEncoding: boolean; requireNullSignatureFailures: boolean }; ripemd160: { hash: Ripemd160["hash"] }; secp256k1: { verifySignatureDERLowS: Secp256k1["verifySignatureDERLowS"]; verifySignatureSchnorr: Secp256k1["verifySignatureSchnorr"] }; sha1: { hash: Sha1["hash"] }; sha256: { hash: Sha256["hash"] } }
      • flags: { disallowUpgradableNops: boolean; opReverseBytes: boolean; requireBugValueZero: boolean; requireMinimalEncoding: boolean; requireNullSignatureFailures: boolean }
        • Readonly disallowUpgradableNops: boolean
        • Readonly opReverseBytes: boolean
        • Readonly requireBugValueZero: boolean
        • Readonly requireMinimalEncoding: boolean
        • Readonly requireNullSignatureFailures: boolean
      • ripemd160: { hash: Ripemd160["hash"] }
        • hash: Ripemd160["hash"]
      • secp256k1: { verifySignatureDERLowS: Secp256k1["verifySignatureDERLowS"]; verifySignatureSchnorr: Secp256k1["verifySignatureSchnorr"] }
        • verifySignatureDERLowS: Secp256k1["verifySignatureDERLowS"]
        • verifySignatureSchnorr: Secp256k1["verifySignatureSchnorr"]
      • sha1: { hash: Sha1["hash"] }
        • hash: Sha1["hash"]
      • sha256: { hash: Sha256["hash"] }
        • hash: Sha256["hash"]

    Returns InstructionSet<AuthenticationProgramBCH, AuthenticationProgramStateBCH>

createLanguage

  • createLanguage<TLanguageSpec>(parsers: TypedRule<TLanguageSpec>): {}

Const createTestAuthenticationProgramBCH

  • createTestAuthenticationProgramBCH(__namedParameters: { lockingBytecode: Uint8Array; satoshis: Uint8Array; sha256: { hash: Sha256["hash"] }; unlockingBytecode: Uint8Array }): { inputIndex: number; sourceOutput: Output<Uint8Array, Uint8Array>; spendingTransaction: Transaction<Input<Uint8Array, Uint8Array>, Output<Uint8Array, Uint8Array>> }
  • Parameters

    • __namedParameters: { lockingBytecode: Uint8Array; satoshis: Uint8Array; sha256: { hash: Sha256["hash"] }; unlockingBytecode: Uint8Array }
      • lockingBytecode: Uint8Array
      • satoshis: Uint8Array
      • sha256: { hash: Sha256["hash"] }
        • hash: Sha256["hash"]
      • unlockingBytecode: Uint8Array

    Returns { inputIndex: number; sourceOutput: Output<Uint8Array, Uint8Array>; spendingTransaction: Transaction<Input<Uint8Array, Uint8Array>, Output<Uint8Array, Uint8Array>> }

    • inputIndex: number
    • sourceOutput: Output<Uint8Array, Uint8Array>
    • spendingTransaction: Transaction<Input<Uint8Array, Uint8Array>, Output<Uint8Array, Uint8Array>>

Const createTransactionContextCommon

Const createTransactionContextCommonEmpty

  • createTransactionContextCommonEmpty(): { correspondingOutput: Uint8Array; locktime: number; outpointIndex: number; outpointTransactionHash: Uint8Array; outputValue: Uint8Array; sequenceNumber: number; transactionOutpoints: Uint8Array; transactionOutputs: Uint8Array; transactionSequenceNumbers: Uint8Array; version: number }
  • This is a meaningless but complete TransactionContextCommon which uses 0 values for each property.

    Returns { correspondingOutput: Uint8Array; locktime: number; outpointIndex: number; outpointTransactionHash: Uint8Array; outputValue: Uint8Array; sequenceNumber: number; transactionOutpoints: Uint8Array; transactionOutputs: Uint8Array; transactionSequenceNumbers: Uint8Array; version: number }

    • correspondingOutput: Uint8Array
    • locktime: number
    • outpointIndex: number
    • outpointTransactionHash: Uint8Array
    • outputValue: Uint8Array
    • sequenceNumber: number
    • transactionOutpoints: Uint8Array
    • transactionOutputs: Uint8Array
    • transactionSequenceNumbers: Uint8Array
    • version: number

Const createTransactionContextCommonTesting

  • createTransactionContextCommonTesting(): { correspondingOutput: Uint8Array; locktime: number; outpointIndex: number; outpointTransactionHash: Uint8Array; outputValue: Uint8Array; sequenceNumber: number; transactionOutpoints: Uint8Array; transactionOutputs: Uint8Array; transactionSequenceNumbers: Uint8Array; version: number }
  • This is a meaningless but complete TransactionContextCommon which uses a different value for each property. This is useful for testing and debugging.

    Returns { correspondingOutput: Uint8Array; locktime: number; outpointIndex: number; outpointTransactionHash: Uint8Array; outputValue: Uint8Array; sequenceNumber: number; transactionOutpoints: Uint8Array; transactionOutputs: Uint8Array; transactionSequenceNumbers: Uint8Array; version: number }

    • correspondingOutput: Uint8Array
    • locktime: number
    • outpointIndex: number
    • outpointTransactionHash: Uint8Array
    • outputValue: Uint8Array
    • sequenceNumber: number
    • transactionOutpoints: Uint8Array
    • transactionOutputs: Uint8Array
    • transactionSequenceNumbers: Uint8Array
    • version: number

Const cryptoOperations

  • cryptoOperations<Opcodes, State, Errors>(__namedParameters: { flags: { requireBugValueZero: boolean; requireMinimalEncoding: boolean; requireNullSignatureFailures: boolean }; ripemd160: { hash: Ripemd160["hash"] }; secp256k1: { verifySignatureDERLowS: Secp256k1["verifySignatureDERLowS"]; verifySignatureSchnorr: Secp256k1["verifySignatureSchnorr"] }; sha1: { hash: Sha1["hash"] }; sha256: { hash: Sha256["hash"] } }): { [OpcodesCommon.OP_CHECKMULTISIGVERIFY]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_CHECKMULTISIG]: (Anonymous function); [OpcodesCommon.OP_CHECKSIGVERIFY]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_CHECKSIG]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_CODESEPARATOR]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_HASH160]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_HASH256]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_RIPEMD160]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_SHA1]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_SHA256]: (state: ProgramState) => ProgramState }
  • Type parameters

    Parameters

    • __namedParameters: { flags: { requireBugValueZero: boolean; requireMinimalEncoding: boolean; requireNullSignatureFailures: boolean }; ripemd160: { hash: Ripemd160["hash"] }; secp256k1: { verifySignatureDERLowS: Secp256k1["verifySignatureDERLowS"]; verifySignatureSchnorr: Secp256k1["verifySignatureSchnorr"] }; sha1: { hash: Sha1["hash"] }; sha256: { hash: Sha256["hash"] } }
      • flags: { requireBugValueZero: boolean; requireMinimalEncoding: boolean; requireNullSignatureFailures: boolean }
        • requireBugValueZero: boolean
        • requireMinimalEncoding: boolean
        • requireNullSignatureFailures: boolean
      • ripemd160: { hash: Ripemd160["hash"] }
        • hash: Ripemd160["hash"]
      • secp256k1: { verifySignatureDERLowS: Secp256k1["verifySignatureDERLowS"]; verifySignatureSchnorr: Secp256k1["verifySignatureSchnorr"] }
        • verifySignatureDERLowS: Secp256k1["verifySignatureDERLowS"]
        • verifySignatureSchnorr: Secp256k1["verifySignatureSchnorr"]
      • sha1: { hash: Sha1["hash"] }
        • hash: Sha1["hash"]
      • sha256: { hash: Sha256["hash"] }
        • hash: Sha256["hash"]

    Returns { [OpcodesCommon.OP_CHECKMULTISIGVERIFY]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_CHECKMULTISIG]: (Anonymous function); [OpcodesCommon.OP_CHECKSIGVERIFY]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_CHECKSIG]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_CODESEPARATOR]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_HASH160]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_HASH256]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_RIPEMD160]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_SHA1]: (state: ProgramState) => ProgramState; [OpcodesCommon.OP_SHA256]: (state: ProgramState) => ProgramState }

    • [OpcodesCommon.OP_CHECKMULTISIGVERIFY]: (state: ProgramState) => ProgramState
        • (state: ProgramState): ProgramState
        • Parameters

          • state: ProgramState

          Returns ProgramState

    • [OpcodesCommon.OP_CHECKMULTISIG]: (Anonymous function)
    • [OpcodesCommon.OP_CHECKSIGVERIFY]: (state: ProgramState) => ProgramState
        • (state: ProgramState): ProgramState
        • Parameters

          • state: ProgramState

          Returns ProgramState

    • [OpcodesCommon.OP_CHECKSIG]: (state: ProgramState) => ProgramState
        • (state: ProgramState): ProgramState
        • Parameters

          • state: ProgramState

          Returns ProgramState

    • [OpcodesCommon.OP_CODESEPARATOR]: (state: ProgramState) => ProgramState
        • (state: ProgramState): ProgramState
        • Parameters

          • state: ProgramState

          Returns ProgramState

    • [OpcodesCommon.OP_HASH160]: (state: ProgramState) => ProgramState
        • (state: ProgramState): ProgramState
        • Parameters

          • state: ProgramState

          Returns ProgramState

    • [OpcodesCommon.OP_HASH256]: (state: ProgramState) => ProgramState
        • (state: ProgramState): ProgramState
        • Parameters

          • state: ProgramState

          Returns ProgramState

    • [OpcodesCommon.OP_RIPEMD160]: (state: ProgramState) => ProgramState
        • (state: ProgramState): ProgramState
        • Parameters

          • state: ProgramState

          Returns ProgramState

    • [OpcodesCommon.OP_SHA1]: (state: ProgramState) => ProgramState
        • (state: ProgramState): ProgramState
        • Parameters

          • state: ProgramState

          Returns ProgramState

    • [OpcodesCommon.OP_SHA256]: (state: ProgramState) => ProgramState
        • (state: ProgramState): ProgramState
        • Parameters

          • state: ProgramState

          Returns ProgramState

Const dateToLocktime

  • Convert a JavaScript Date object to its equivalent transaction locktime representation. The date is rounded to the nearest second (the precision of locktime Dates).

    Note, a locktime values greater than or equal to 500000000 See Transaction.locktime for details.

    Parameters

    • date: Date

      the Date to convert to a locktime number

    Returns number | dateOutOfRange

Const dateToLocktimeBin

  • Convert a JavaScript Date object to its equivalent transaction locktime bytecode representation. The date is rounded to the nearest second (the precision of locktime Dates).

    Note: a block-based locktime can simply be encoded with numberToBinUint32LE (provided it is no larger than the maximum, 499999999).

    Parameters

    • date: Date

      the Date to convert to a locktime Uint8Array

    Returns Uint8Array | dateOutOfRange

Const decodeBase58Address

  • Decode and validate a Base58Address, strictly checking the version and payload length.

    For other address-like standards which closely follow the Base58Address format (but have alternative version byte requirements), use decodeBase58AddressFormat.

    remarks

    Because the Wallet Import Format (WIF) private key serialization format uses the Base58Address format, some libraries allow WIF key decoding via the same method as base58 address decoding. This method strictly accepts only Base58Address types, but WIF keys can be decoded with decodePrivateKeyWif.

    Parameters

    • sha256: { hash: Sha256["hash"] }

      an implementation of sha256 (a universal implementation is available via instantiateSha256)

      • hash: Sha256["hash"]
    • address: string

      the string to decode as a base58 address

    Returns unknownCharacter | tooShort | invalidChecksum | unknownAddressVersion | incorrectLength | { payload: Uint8Array; version: number }

Const decodeBase58AddressFormat

  • Attempt to decode a Base58Address-formatted string. This is more lenient than decodeCashAddress, which also validates the address version.

    Returns the contents of the address or an error message as a string.

    Parameters

    • sha256: { hash: Sha256["hash"] }

      an implementation of sha256 (a universal implementation is available via instantiateSha256)

      • hash: Sha256["hash"]
    • address: string

      the string to decode as a base58 address

    Returns unknownCharacter | tooShort | invalidChecksum | { payload: Uint8Array; version: number }

Const decodeBech32

  • decodeBech32(validBech32: string): (0 | 2 | 16 | 1 | 8 | 4 | 3 | 6 | 18 | 12 | 31 | 7 | 10 | 15 | 9 | 5 | 11 | 13 | 14 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30)[]
  • Decode a Bech32-encoded string into an array of 5-bit integers.

    Note, this method always completes. If validBech32 is not valid bech32, an incorrect result will be returned. If validBech32 is potentially malformed, check it with isBech32 before calling this method.

    Parameters

    • validBech32: string

      the bech32-encoded string to decode

    Returns (0 | 2 | 16 | 1 | 8 | 4 | 3 | 6 | 18 | 12 | 31 | 7 | 10 | 15 | 9 | 5 | 11 | 13 | 14 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30)[]

Const decodeBitcoinSignature

  • decodeBitcoinSignature(encodedSignature: Uint8Array): { signature: Uint8Array; signingSerializationType: Uint8Array }
  • Split a bitcoin-encoded signature into a signature and signing serialization type.

    While a bitcoin-encoded signature only includes a single byte to encode the signing serialization type, a 3-byte forkId can be appended to the signing serialization to provide replay-protection between different forks. (See Bitcoin Cash's Replay Protected Sighash spec for details.)

    Parameters

    • encodedSignature: Uint8Array

    Returns { signature: Uint8Array; signingSerializationType: Uint8Array }

    • signature: Uint8Array
    • signingSerializationType: Uint8Array

Const decodeCashAddress

  • Decode and validate a CashAddress, strictly checking the version byte according to the CashAddress specification. This is important for error detection in CashAddresses.

    For other address-like standards which closely follow the CashAddress specification (but have alternative version byte requirements), use decodeCashAddressFormat.

    Note, this method requires that CashAddresses include a network prefix. To decode an address with an unknown prefix, try decodeCashAddressFormatWithoutPrefix.

    Parameters

    • address: string

      the CashAddress to decode

    Returns improperPadding | invalidCharacters | invalidChecksum | invalidFormat