#[macro_use]
extern crate amplify;
#[cfg(feature = "strict_encoding")]
#[macro_use]
extern crate strict_encoding;
#[cfg(feature = "serde")]
#[macro_use]
extern crate serde_crate as serde;
mod data;
mod keys;
mod maps;
mod coders;
#[cfg(feature = "client-side-validation")]
mod csval;
pub use coders::{Decode, DecodeError, Encode, PsbtError};
#[cfg(feature = "client-side-validation")]
pub use csval::*;
pub use data::{
Input, ModifiableFlags, Output, Prevout, Psbt, PsbtParseError, UnsignedTx, UnsignedTxIn,
};
pub use keys::{GlobalKey, InputKey, KeyPair, KeyType, OutputKey, PropKey};
pub use maps::{KeyAlreadyPresent, KeyData, KeyMap, Map, MapName, ValueData};
#[cfg(feature = "strict_encoding")]
pub const LIB_NAME_PSBT: &str = "Psbt";
#[derive(Copy, Clone, Eq, PartialEq, Debug, Display, Error)]
#[display("unsupported version of PSBT v{0}")]
pub struct PsbtUnsupportedVer(u32);
#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug, Display)]
#[cfg_attr(
feature = "serde",
derive(Serialize),
serde(crate = "serde_crate", rename_all = "camelCase")
)]
pub enum PsbtVer {
#[display("v0")]
V0 = 0,
#[display("v2")]
V2 = 2,
}
impl PsbtVer {
pub const fn try_from_standard_u32(v: u32) -> Result<Self, PsbtUnsupportedVer> {
Ok(match v {
0 => Self::V0,
2 => Self::V2,
wrong => return Err(PsbtUnsupportedVer(wrong)),
})
}
pub const fn to_standard_u32(&self) -> u32 { *self as u32 }
pub const fn max() -> Self {
match Self::V0 {
PsbtVer::V0 | PsbtVer::V2 => PsbtVer::V2,
}
}
}