{-
Id: stl:CaK1Puml-gQpFSBK-E06s9O3-W27jJMu-fcpa21K-6AQ2FZc#extend-crimson-cable
Name: Bitcoin
Version: 0.1.0
Description: Consensus library for bitcoin protocol
Author: Dr Maxim Orlovsky <orlovsky@lnp-bp.org>
Copyright (C) 2023-2024 LNP/BP Standards Association. All rights reserved.
License: Apache-2.0
-}
@context
typelib Bitcoin
import Std#delete-roman-hair
use Bool#oxygen-complex-duet
@mnemonic(fire-mouse-paint)
data Bip340Sig : sig [Byte ^ 64], sighash_type SighashType?
@mnemonic(corner-herbert-plume)
data Block : header BlockHeader, transactions [Tx ^ ..0xffffffff]
@mnemonic(super-david-graph)
data BlockHash : [Byte ^ 32]
@mnemonic(ricardo-flipper-urban)
data BlockHeader : version I32
, prevBlockHash BlockHash
, merkleRoot BlockMerkleRoot
, time U32
, bits U32
, nonce U32
@mnemonic(canada-century-jacket)
data BlockMerkleRoot : [Byte ^ 32]
@mnemonic(royal-anatomy-june)
data ByteStr : [Byte ^ ..0xffffffff]
@mnemonic(poncho-silver-bronze)
data CompressedPk : [Byte ^ 33]
@mnemonic(green-lima-song)
data ControlBlock : leafVersion LeafVer
, outputKeyParity Parity
, internalPk InternalPk
, merkleBranch TapMerklePath
@mnemonic(quality-donald-gemini)
data FutureLeafVer : U8
@mnemonic(almond-canvas-ecology)
data InternalPk : XOnlyPk
@mnemonic(forever-ariel-perform)
data LeafScript : version LeafVer, script ScriptBytes
@mnemonic(benefit-carbon-africa)
data LeafVer : U8
@mnemonic(clever-appear-nominal)
data LegacyPk : compressed Std.Bool, pubkey [Byte ^ 33]
@mnemonic(july-delete-maxwell)
data LegacySig : sig [Byte ^ ..0xff], sighash_type SighashType
@mnemonic(apple-north-select)
data LockHeight : U32
@mnemonic(lobster-liberal-jump)
data LockTime : U32
@mnemonic(effect-benefit-chemist)
data LockTimestamp : U32
@mnemonic(baggage-wisdom-radar)
data OpCode : pushBytes0 | pushBytes1 | pushBytes2 | pushBytes3
| pushBytes4 | pushBytes5 | pushBytes6 | pushBytes7
| pushBytes8 | pushBytes9 | pushBytes10 | pushBytes11
| pushBytes12 | pushBytes13 | pushBytes14 | pushBytes15
| pushBytes16 | pushBytes17 | pushBytes18 | pushBytes19
| pushBytes20 | pushBytes21 | pushBytes22 | pushBytes23
| pushBytes24 | pushBytes25 | pushBytes26 | pushBytes27
| pushBytes28 | pushBytes29 | pushBytes30 | pushBytes31
| pushBytes32 | pushBytes33 | pushBytes34 | pushBytes35
| pushBytes36 | pushBytes37 | pushBytes38 | pushBytes39
| pushBytes40 | pushBytes41 | pushBytes42 | pushBytes43
| pushBytes44 | pushBytes45 | pushBytes46 | pushBytes47
| pushBytes48 | pushBytes49 | pushBytes50 | pushBytes51
| pushBytes52 | pushBytes53 | pushBytes54 | pushBytes55
| pushBytes56 | pushBytes57 | pushBytes58 | pushBytes59
| pushBytes60 | pushBytes61 | pushBytes62 | pushBytes63
| pushBytes64 | pushBytes65 | pushBytes66 | pushBytes67
| pushBytes68 | pushBytes69 | pushBytes70 | pushBytes71
| pushBytes72 | pushBytes73 | pushByte764 | pushBytes75
| pushData1 | pushData2 | pushData4 | pushNumNeg1
| reserved | pushNum1 | pushNum2 | pushNum3
| pushNum4 | pushNum5 | pushNum6 | pushNum7
| pushNum8 | pushNum9 | pushNum10 | pushNum11
| pushNum12 | pushNum13 | pushNum14 | pushNum15
| pushNum16 | nop | ver | if
| notIf | verIf | verNotIf | else
| endIf | verify | return | toAltStack
| fromAltStack | drop2 | dup2 | dup3
| over2 | rot2 | swap2 | ifDup
| depth | drop | dup | nip
| over | pick | roll | rot
| swap | tuck | cat | subStr
| left | right | size | invert
| and | or | xor | equal
| equalVerify | reserved1 | reserved2 | add1
| sub1 | mul2 | div2 | negate
| abs | not | notEqual0 | add
| sub | mul | div | mod
| lShift | rShift | boolAnd | boolOr
| numEqual | numEqualVerify | numNotEqual | lessThan
| greaterThan | lessThanOrEqual | greaterThanOrEqual | min
| max | within | ripemd160 | sha1
| sha256 | hash160 | hash256 | codeSeparator
| checkSig | checkSigVerify | checkMultiSig | checkMultisigVerify
| nop1 | cltv | csv | nop4
| nop5 | nop6 | nop7 | nop8
| nop9 | nop10 | invalidOpCode#255
@mnemonic(shadow-scroll-before)
data Outpoint : txid Txid, vout Vout
@mnemonic(panic-nova-speed)
data OutputPk : XOnlyPk
@mnemonic(phrase-forest-cool)
data Parity : even | odd
@mnemonic(vodka-bogart-madonna)
data PubkeyHash : [Byte ^ 20]
@mnemonic(middle-season-baboon)
data RedeemScript : ScriptBytes
@mnemonic(metro-picasso-roger)
data Sats : U64
@mnemonic(equator-cockpit-gong)
data ScriptBytes : [Byte ^ ..0xffffffff]
@mnemonic(command-brave-album)
data ScriptHash : [Byte ^ 20]
@mnemonic(ribbon-paradox-rival)
data ScriptPubkey : ScriptBytes
@mnemonic(copper-verbal-ingrid)
data SeqNo : U32
@mnemonic(minute-alfred-gibson)
data SigScript : ScriptBytes
@mnemonic(exotic-diet-ford)
data SighashFlag : all#1 | none | single
@mnemonic(jazz-beatles-pasta)
data SighashType : flag SighashFlag, anyoneCanPay Std.Bool
@mnemonic(calypso-travel-script)
data TapBranchHash : [Byte ^ 32]
@mnemonic(nepal-model-alarm)
data TapCode : pushBytes0 | pushBytes1 | pushBytes2 | pushBytes3
| pushBytes4 | pushBytes5 | pushBytes6 | pushBytes7
| pushBytes8 | pushBytes9 | pushBytes10 | pushBytes11
| pushBytes12 | pushBytes13 | pushBytes14 | pushBytes15
| pushBytes16 | pushBytes17 | pushBytes18 | pushBytes19
| pushBytes20 | pushBytes21 | pushBytes22 | pushBytes23
| pushBytes24 | pushBytes25 | pushBytes26 | pushBytes27
| pushBytes28 | pushBytes29 | pushBytes30 | pushBytes31
| pushBytes32 | pushBytes33 | pushBytes34 | pushBytes35
| pushBytes36 | pushBytes37 | pushBytes38 | pushBytes39
| pushBytes40 | pushBytes41 | pushBytes42 | pushBytes43
| pushBytes44 | pushBytes45 | pushBytes46 | pushBytes47
| pushBytes48 | pushBytes49 | pushBytes50 | pushBytes51
| pushBytes52 | pushBytes53 | pushBytes54 | pushBytes55
| pushBytes56 | pushBytes57 | pushBytes58 | pushBytes59
| pushBytes60 | pushBytes61 | pushBytes62 | pushBytes63
| pushBytes64 | pushBytes65 | pushBytes66 | pushBytes67
| pushBytes68 | pushBytes69 | pushBytes70 | pushBytes71
| pushBytes72 | pushBytes73 | pushByte764 | pushBytes75
| pushData1 | pushData2 | pushData4 | pushNumNeg1
| success80 | pushNum1 | pushNum2 | pushNum3
| pushNum4 | pushNum5 | pushNum6 | pushNum7
| pushNum8 | pushNum9 | pushNum10 | pushNum11
| pushNum12 | pushNum13 | pushNum14 | pushNum15
| pushNum16 | nop | success98 | if
| notIf | verIf | verNotIf | else
| endIf | verify | return | toAltStack
| fromAltStack | drop2 | dup2 | dup3
| over2 | rot2 | swap2 | ifDup
| depth | drop | dup | nip
| over | pick | roll | rot
| swap | tuck | success126 | success127
| success128 | success129 | size | success131
| success132 | success133 | success134 | equal
| equalVerify | success137 | success138 | add1
| sub1 | success141 | success142 | negate
| abs | not | notEqual0 | add
| sub | success149 | success150 | success151
| success152 | success153 | boolAnd | boolOr
| numEqual | numEqualVerify | numNotEqual | lessThan
| greaterThan | lessThanOrEqual | greaterThanOrEqual | min
| max | within | ripemd160 | sha1
| sha256 | hash160 | hash256 | codeSeparator
| checkSig | checkSigVerify | nop1#176 | cltv
| csv | nop4 | nop5 | nop6
| nop7 | nop8 | nop9 | nop10
| checkSigAdd | invalidOpCode#255
@mnemonic(micro-brave-pretty)
data TapLeafHash : [Byte ^ 32]
@mnemonic(manual-mike-alien)
data TapMerklePath : [TapBranchHash ^ ..0x80]
@mnemonic(paprika-amanda-hunter)
data TapNodeHash : [Byte ^ 32]
@mnemonic(congo-bali-castro)
data TapScript : ScriptBytes
@mnemonic(distant-respond-green)
data TimeLockInterval : height U16
| time U16
@mnemonic(anvil-airport-broken)
data Tx : version TxVer
, inputs [TxIn ^ ..0xffffffff]
, outputs [TxOut ^ ..0xffffffff]
, lockTime LockTime
@mnemonic(person-atlanta-nickel)
data TxIn : prevOutput Outpoint
, sigScript SigScript
, sequence SeqNo
, witness Witness
@mnemonic(oscar-chief-truck)
data TxOut : value Sats, scriptPubkey ScriptPubkey
@mnemonic(nepal-symbol-uniform)
data TxVer : I32
@mnemonic(shallow-light-reverse)
data Txid : [Byte ^ 32]
@mnemonic(miracle-almanac-record)
data UncompressedPk : [Byte ^ 65]
@mnemonic(pogo-trivial-saturn)
data VBytes : U32
@mnemonic(orange-maximum-blitz)
data VarInt : U64
@mnemonic(brush-gloria-heroic)
data Vout : U32
@mnemonic(mexico-bikini-athena)
data WPubkeyHash : [Byte ^ 20]
@mnemonic(triton-regard-couple)
data WScriptHash : [Byte ^ 32]
@mnemonic(heart-pinball-jump)
data WeightUnits : U32
@mnemonic(ship-jessica-wizard)
data Witness : [ByteStr ^ ..0xffffffff]
@mnemonic(alias-vega-shock)
data WitnessProgram : version WitnessVer, program [Byte ^ 2..0x28]
@mnemonic(design-epoxy-metro)
data WitnessScript : ScriptBytes
@mnemonic(tower-medusa-eric)
data WitnessVer : v0 | v1#81 | v2 | v3
| v4 | v5 | v6 | v7
| v8 | v9 | v10 | v11
| v12 | v13 | v14 | v15
| v16
@mnemonic(manager-rocket-hammer)
data Wtxid : [Byte ^ 32]
@mnemonic(clever-swim-carpet)
data XOnlyPk : [Byte ^ 32]