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
26// TODO: Do a no-std feature
27// #![cfg_attr(not(feature = "std"), no_std)]
28#![deny(
29    unsafe_code,
30    dead_code,
31    // missing_docs,
32    unused_variables,
33    unused_mut,
34    unused_imports,
35    non_upper_case_globals,
36    non_camel_case_types,
37    non_snake_case
38)]
39#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
40#![cfg_attr(docsrs, feature(doc_auto_cfg))]
41
42#[macro_use]
43extern crate amplify;
44// TODO: Make strict encoding optional dependency
45#[macro_use]
46extern crate strict_encoding;
47extern crate commit_verify;
48#[cfg(feature = "serde")]
49#[macro_use]
50extern crate serde;
51
52extern crate core;
53/// Re-export of `secp256k1` crate.
54pub extern crate secp256k1;
55
56mod block;
57pub mod opcodes;
58mod script;
59mod pubkeys;
60mod segwit;
61mod taproot;
62mod tx;
63mod hashtypes;
64mod sigtypes;
65mod timelocks;
66mod util;
67mod weights;
68#[cfg(feature = "stl")]
69pub mod stl;
70mod coding;
71mod sigcache;
72
73pub use block::{Block, BlockHash, BlockHeader, BlockMerkleRoot};
74pub use coding::{
75    ByteStr, ConsensusDataError, ConsensusDecode, ConsensusDecodeError, ConsensusEncode, LenVarInt,
76    VarInt, VarIntArray, VarIntBytes,
77};
78pub use hashtypes::{PubkeyHash, ScriptHash, WPubkeyHash, WScriptHash};
79pub use opcodes::OpCode;
80pub use pubkeys::{CompressedPk, InvalidPubkey, LegacyPk, PubkeyParseError, UncompressedPk};
81pub use script::{RedeemScript, ScriptBytes, ScriptPubkey, SigScript};
82pub use segwit::{SegwitError, Witness, WitnessProgram, WitnessScript, WitnessVer, Wtxid};
83pub use sigcache::{PrevoutMismatch, SighashCache, SighashError};
84pub use sigtypes::{Bip340Sig, LegacySig, ScriptCode, SigError, Sighash, SighashFlag, SighashType};
85pub use taproot::{
86    Annex, AnnexError, ControlBlock, FutureLeafVer, InternalKeypair, InternalPk, IntoTapHash,
87    InvalidLeafVer, InvalidParityValue, LeafScript, LeafVer, OutputPk, Parity, TapBranchHash,
88    TapCode, TapLeafHash, TapMerklePath, TapNodeHash, TapScript, TapSighash, XOnlyPk,
89    MIDSTATE_TAPSIGHASH, TAPROOT_ANNEX_PREFIX, TAPROOT_LEAF_MASK, TAPROOT_LEAF_TAPSCRIPT,
90};
91pub use timelocks::{
92    InvalidTimelock, LockHeight, LockTime, LockTimestamp, SeqNo, TimeLockInterval,
93    TimelockParseError, LOCKTIME_THRESHOLD, SEQ_NO_CSV_DISABLE_MASK, SEQ_NO_CSV_TYPE_MASK,
94};
95pub use tx::{
96    BlockDataParseError, Outpoint, OutpointParseError, Sats, Tx, TxIn, TxOut, TxVer, Txid, Vout,
97};
98pub use util::NonStandardValue;
99pub use weights::{VBytes, Weight, WeightUnits};
100
101pub const LIB_NAME_BITCOIN: &str = "Bitcoin";