1#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
33#![cfg_attr(docsrs, feature(doc_notable_trait))]
35#![cfg_attr(bench, feature(test))]
36#![warn(missing_docs)]
38#![cfg_attr(fuzzing, allow(dead_code, unused_imports))]
40#![allow(clippy::needless_question_mark)] #![allow(clippy::manual_range_contains)] #![allow(clippy::needless_borrows_for_generic_args)] #![allow(deprecated)]
46
47#[cfg(target_pointer_width = "16")]
49compile_error!(
50 "rust-bitcoin currently only supports architectures with pointers wider than 16 bits, let us
51 know if you want 16-bit support. Note that we do NOT guarantee that we will implement it!"
52);
53
54#[cfg(bench)]
55extern crate test;
56
57#[macro_use]
58extern crate alloc;
59
60#[cfg(feature = "base64")]
61pub extern crate base64;
63
64pub extern crate base58;
66
67pub extern crate bech32;
69
70pub extern crate hashes;
72
73pub extern crate hex;
75
76pub extern crate io;
78
79#[cfg(feature = "ordered")]
81pub extern crate ordered;
82
83pub extern crate secp256k1;
86
87#[cfg(feature = "serde")]
88#[macro_use]
89extern crate actual_serde as serde;
90
91#[cfg(test)]
92#[macro_use]
93mod test_macros;
94mod internal_macros;
95#[cfg(feature = "serde")]
96mod serde_utils;
97
98#[macro_use]
99pub mod p2p;
100pub mod address;
101pub mod bip152;
102pub mod bip158;
103pub mod bip32;
104pub mod blockdata;
105pub mod consensus;
106pub(crate) mod crypto;
108pub mod dogecoin;
109pub mod error;
110pub mod hash_types;
111pub mod merkle_tree;
112pub mod network;
113pub mod policy;
114pub mod pow;
115pub mod psbt;
116pub mod sign_message;
117pub mod taproot;
118
119#[rustfmt::skip] #[doc(inline)]
121pub use crate::{
122 address::{Address, AddressType, KnownHrp},
123 amount::{Amount, Denomination, SignedAmount},
124 bip158::{FilterHash, FilterHeader},
125 bip32::XKeyIdentifier,
126 blockdata::block::{self, Block, BlockHash, TxMerkleNode, WitnessMerkleNode, WitnessCommitment},
127 blockdata::constants,
128 blockdata::fee_rate::FeeRate,
129 blockdata::locktime::{self, absolute, relative},
130 blockdata::opcodes::{self, Opcode},
131 blockdata::script::witness_program::{self, WitnessProgram},
132 blockdata::script::witness_version::{self, WitnessVersion},
133 blockdata::script::{self, Script, ScriptBuf, ScriptHash, WScriptHash},
134 blockdata::transaction::{self, OutPoint, Sequence, Transaction, TxIn, TxOut, Txid, Wtxid},
135 blockdata::weight::Weight,
136 blockdata::witness::{self, Witness},
137 consensus::encode::VarInt,
138 consensus::params,
139 crypto::ecdsa,
140 crypto::key::{self, PrivateKey, PubkeyHash, PublicKey, CompressedPublicKey, WPubkeyHash, XOnlyPublicKey},
141 crypto::sighash::{self, LegacySighash, SegwitV0Sighash, TapSighash, TapSighashTag},
142 merkle_tree::MerkleBlock,
143 network::{Network, NetworkKind},
144 pow::{CompactTarget, Target, Work},
145 psbt::Psbt,
146 sighash::{EcdsaSighashType, TapSighashType},
147 taproot::{TapBranchTag, TapLeafHash, TapLeafTag, TapNodeHash, TapTweakHash, TapTweakTag},
148};
149
150#[rustfmt::skip]
151#[allow(unused_imports)]
152mod prelude {
153 #[cfg(all(not(feature = "std"), not(test)))]
154 pub use alloc::{string::{String, ToString}, vec::Vec, boxed::Box, borrow::{Borrow, BorrowMut, Cow, ToOwned}, slice, rc};
155
156 #[cfg(all(not(feature = "std"), not(test), any(not(rust_v_1_60), target_has_atomic = "ptr")))]
157 pub use alloc::sync;
158
159 #[cfg(any(feature = "std", test))]
160 pub use std::{string::{String, ToString}, vec::Vec, boxed::Box, borrow::{Borrow, BorrowMut, Cow, ToOwned}, rc, sync};
161
162 #[cfg(all(not(feature = "std"), not(test)))]
163 pub use alloc::collections::{BTreeMap, BTreeSet, btree_map, BinaryHeap};
164
165 #[cfg(any(feature = "std", test))]
166 pub use std::collections::{BTreeMap, BTreeSet, btree_map, BinaryHeap};
167
168 pub use crate::io::sink;
169
170 pub use hex::DisplayHex;
171}
172
173pub mod amount {
174 use crate::consensus::{encode, Decodable, Encodable};
180 use crate::io::{Read, Write};
181
182 #[rustfmt::skip] #[doc(inline)]
184 pub use units::amount::{
185 Amount, CheckedSum, Denomination, Display, ParseAmountError, SignedAmount,
186 };
187 #[cfg(feature = "serde")]
188 pub use units::amount::serde;
189
190 impl Decodable for Amount {
191 #[inline]
192 fn consensus_decode<R: Read + ?Sized>(r: &mut R) -> Result<Self, encode::Error> {
193 Ok(Amount::from_sat(Decodable::consensus_decode(r)?))
194 }
195 }
196
197 impl Encodable for Amount {
198 #[inline]
199 fn consensus_encode<W: Write + ?Sized>(&self, w: &mut W) -> Result<usize, io::Error> {
200 self.to_sat().consensus_encode(w)
201 }
202 }
203}
204
205pub mod parse {
207 pub use units::parse::ParseIntError;
209}