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// TODO: Do a no-std feature
23// #![cfg_attr(not(feature = "std"), no_std)]
24#![deny(
25    unsafe_code,
26    dead_code,
27    // missing_docs,
28    unused_variables,
29    unused_mut,
30    unused_imports,
31    non_upper_case_globals,
32    non_camel_case_types,
33    non_snake_case
34)]
35#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
36#![cfg_attr(docsrs, feature(doc_auto_cfg))]
37
38#[macro_use]
39extern crate amplify;
40// TODO: Make strict encoding optional dependency
41#[macro_use]
42extern crate strict_encoding;
43extern crate commit_verify;
44#[cfg(feature = "serde")]
45#[macro_use]
46extern crate serde;
47
48extern crate core;
49/// Re-export of `secp256k1` crate.
50pub extern crate secp256k1;
51
52mod block;
53pub mod opcodes;
54mod script;
55mod pubkeys;
56mod segwit;
57mod taproot;
58mod tx;
59mod hashtypes;
60mod sigtypes;
61mod timelocks;
62mod util;
63mod weights;
64#[cfg(feature = "stl")]
65pub mod stl;
66mod coding;
67mod sigcache;
68mod tapcode;
69
70pub use block::{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 tapcode::TapCode;
83pub use taproot::{
84    Annex, AnnexError, ControlBlock, FutureLeafVer, InternalKeypair, InternalPk, IntoTapHash,
85    InvalidLeafVer, InvalidParityValue, LeafScript, LeafVer, OutputPk, Parity, TapBranchHash,
86    TapLeafHash, TapMerklePath, TapNodeHash, TapScript, TapSighash, XOnlyPk, MIDSTATE_TAPSIGHASH,
87    TAPROOT_ANNEX_PREFIX, TAPROOT_LEAF_MASK, TAPROOT_LEAF_TAPSCRIPT,
88};
89pub use timelocks::{
90    InvalidTimelock, LockHeight, LockTime, LockTimestamp, SeqNo, TimeLockInterval,
91    TimelockParseError, LOCKTIME_THRESHOLD, SEQ_NO_CSV_DISABLE_MASK, SEQ_NO_CSV_TYPE_MASK,
92};
93pub use tx::{
94    BlockDataParseError, Outpoint, OutpointParseError, Sats, Tx, TxIn, TxOut, TxVer, Txid, Vout,
95};
96pub use util::NonStandardValue;
97pub use weights::{VBytes, Weight, WeightUnits};
98
99pub const LIB_NAME_BITCOIN: &str = "Bitcoin";