bc/
lib.rs

1// Bitcoin protocol consensus library.
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5// Written in 2019-2024 by
6//     Dr Maxim Orlovsky <orlovsky@lnp-bp.org>
7//
8// Copyright (C) 2019-2024 LNP/BP Standards Association. All rights reserved.
9//
10// Licensed under the Apache License, Version 2.0 (the "License");
11// you may not use this file except in compliance with the License.
12// You may obtain a copy of the License at
13//
14//     http://www.apache.org/licenses/LICENSE-2.0
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS,
18// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19// See the License for the specific language governing permissions and
20// limitations under the License.
21
22// Version 1.0:
23// TODO: Complete block data type implementation
24// TODO: Complete OpCode enumeration
25// TODO: Do a no-std feature
26
27// Coding conventions
28#![deny(
29    non_upper_case_globals,
30    non_camel_case_types,
31    non_snake_case,
32    unused_mut,
33    unused_imports,
34    dead_code,
35    // TODO: Uncomment missing_docs
36)]
37#![cfg_attr(docsrs, feature(doc_auto_cfg))]
38
39#[macro_use]
40extern crate amplify;
41// TODO: Make strict encoding optional dependency
42#[macro_use]
43extern crate strict_encoding;
44extern crate commit_verify;
45#[cfg(feature = "serde")]
46#[macro_use]
47extern crate serde_crate as serde;
48
49extern crate core;
50/// Re-export of `secp256k1` crate.
51pub extern crate secp256k1;
52
53mod block;
54pub mod opcodes;
55mod script;
56mod pubkeys;
57mod segwit;
58mod taproot;
59mod tx;
60mod hashtypes;
61mod sigtypes;
62mod timelocks;
63mod util;
64mod weights;
65#[cfg(feature = "stl")]
66pub mod stl;
67mod coding;
68mod sigcache;
69
70pub use block::{BlockHash, BlockHeader, BlockMerkleRoot};
71pub use coding::{
72    ByteStr, ConsensusDataError, ConsensusDecode, ConsensusDecodeError, ConsensusEncode, LenVarInt,
73    VarInt, VarIntArray, VarIntBytes,
74};
75pub use hashtypes::{PubkeyHash, ScriptHash, WPubkeyHash, WScriptHash};
76pub use opcodes::OpCode;
77pub use pubkeys::{CompressedPk, InvalidPubkey, LegacyPk, PubkeyParseError, UncompressedPk};
78pub use script::{RedeemScript, ScriptBytes, ScriptPubkey, SigScript};
79pub use segwit::{SegwitError, Witness, WitnessProgram, WitnessScript, WitnessVer, Wtxid};
80pub use sigcache::{PrevoutMismatch, SighashCache, SighashError};
81pub use sigtypes::{Bip340Sig, LegacySig, ScriptCode, SigError, Sighash, SighashFlag, SighashType};
82pub use taproot::{
83    Annex, AnnexError, ControlBlock, FutureLeafVer, InternalKeypair, InternalPk, IntoTapHash,
84    InvalidLeafVer, InvalidParityValue, LeafScript, LeafVer, OutputPk, Parity, TapBranchHash,
85    TapCode, TapLeafHash, TapMerklePath, TapNodeHash, TapScript, TapSighash, XOnlyPk,
86    MIDSTATE_TAPSIGHASH, TAPROOT_ANNEX_PREFIX, TAPROOT_LEAF_MASK, TAPROOT_LEAF_TAPSCRIPT,
87};
88pub use timelocks::{
89    InvalidTimelock, LockHeight, LockTime, LockTimestamp, SeqNo, TimelockParseError,
90    LOCKTIME_THRESHOLD, SEQ_NO_CSV_DISABLE_MASK, SEQ_NO_CSV_TYPE_MASK,
91};
92pub use tx::{
93    BlockDataParseError, Outpoint, OutpointParseError, Sats, Tx, TxIn, TxOut, TxVer, Txid, Vout,
94};
95pub use util::NonStandardValue;
96pub use weights::{VBytes, Weight, WeightUnits};
97
98pub const LIB_NAME_BITCOIN: &str = "Bitcoin";