psbt_v2/
lib.rs

1// SPDX-License-Identifier: CC0-1.0
2
3//! Partially Signed Bitcoin Transactions.
4//!
5//! Implementation of the Partially Signed Bitcoin Transaction Format as defined in [BIP-174] and
6//! PSBT version 2 as defined in [BIP-370].
7//!
8//! [BIP-174]: <https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki>
9//! [BIP-370]: <https://github.com/bitcoin/bips/blob/master/bip-0370.mediawiki>
10
11#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
12// Experimental features we need.
13#![cfg_attr(docsrs, feature(doc_auto_cfg))]
14// Coding conventions
15#![warn(missing_docs)]
16
17#[macro_use]
18extern crate alloc;
19
20#[cfg(feature = "serde")]
21#[macro_use]
22extern crate actual_serde as serde;
23
24/// Re-export of the `rust-bitcoin` crate.
25pub extern crate bitcoin;
26
27/// Re-export of the `rust-bitcoin` crate.
28#[cfg(feature = "miniscript")]
29pub extern crate miniscript;
30
31mod consts;
32mod error;
33#[macro_use]
34mod macros;
35#[cfg(feature = "serde")]
36mod serde_utils;
37mod sighash_type;
38
39pub mod raw;
40pub mod serialize;
41pub mod v0;
42pub mod v2;
43mod version;
44
45use bitcoin::io;
46
47#[rustfmt::skip]                // Keep pubic re-exports separate
48#[doc(inline)]
49pub use crate::{
50    error::{InconsistentKeySourcesError, FeeError, FundingUtxoError},
51    sighash_type::{PsbtSighashType, InvalidSighashTypeError, ParseSighashTypeError},
52    version::{Version, UnsupportedVersionError},
53};
54
55/// PSBT version 0 - the original PSBT version.
56pub const V0: Version = Version::ZERO;
57/// PSBT version 2 - the second PSBT version.
58pub const V2: Version = Version::TWO;
59
60#[rustfmt::skip]
61mod prelude {
62    #![allow(unused_imports)]
63
64    #[cfg(all(not(feature = "std"), not(test)))]
65    pub use alloc::{string::{String, ToString}, vec::Vec, boxed::Box, borrow::{Borrow, BorrowMut, Cow, ToOwned}, slice, rc};
66
67    #[cfg(all(not(feature = "std"), not(test), target_has_atomic = "ptr"))]
68    pub use alloc::sync;
69
70    #[cfg(any(feature = "std", test))]
71    pub use std::{string::{String, ToString}, vec::Vec, boxed::Box, borrow::{Borrow, BorrowMut, Cow, ToOwned}, slice, rc, sync};
72
73    #[cfg(all(not(feature = "std"), not(test)))]
74    pub use alloc::collections::{BTreeMap, BTreeSet, btree_map, BinaryHeap};
75
76    #[cfg(any(feature = "std", test))]
77    pub use std::collections::{BTreeMap, BTreeSet, btree_map, BinaryHeap};
78
79    pub use bitcoin::hex::DisplayHex;
80}