Struct bpstd::Psbt

source ·
pub struct Psbt {
    pub version: PsbtVer,
    pub tx_version: TxVer,
    pub fallback_locktime: Option<LockTime>,
    pub xpubs: IndexMap<Xpub, XpubOrigin>,
    pub proprietary: IndexMap<PropKey, ValueData>,
    pub unknown: IndexMap<u8, IndexMap<ByteStr, ValueData>>,
    /* private fields */
}

Fields§

§version: PsbtVer

PSBT version

§tx_version: TxVer

Transaction version.

§fallback_locktime: Option<LockTime>

Fallback locktime (used if none of the inputs specifies their locktime).

§xpubs: IndexMap<Xpub, XpubOrigin>

A global map from extended public keys to the used key fingerprint and derivation path as defined by BIP 32

§proprietary: IndexMap<PropKey, ValueData>

Proprietary keys

§unknown: IndexMap<u8, IndexMap<ByteStr, ValueData>>

Unknown keys

Implementations§

source§

impl Psbt

source

pub fn create(version: PsbtVer) -> Psbt

source

pub fn from_tx(tx: impl Into<UnsignedTx>) -> Psbt

source

pub fn to_unsigned_tx(&self) -> UnsignedTx

source

pub fn txid(&self) -> Txid

source

pub fn input(&self, index: usize) -> Option<&Input>

source

pub fn input_mut(&mut self, index: usize) -> Option<&mut Input>

source

pub fn inputs(&self) -> impl Iterator<Item = &Input>

source

pub fn inputs_mut(&mut self) -> impl Iterator<Item = &mut Input>

source

pub fn output(&self, index: usize) -> Option<&Output>

source

pub fn output_mut(&mut self, index: usize) -> Option<&mut Output>

source

pub fn outputs(&self) -> impl Iterator<Item = &Output>

source

pub fn outputs_mut(&mut self) -> impl Iterator<Item = &mut Output>

source

pub fn lock_time(&self) -> LockTime

source

pub fn input_sum(&self) -> Sats

source

pub fn output_sum(&self) -> Sats

source

pub fn fee(&self) -> Option<Sats>

source

pub fn xpubs(&self) -> impl Iterator<Item = (&Xpub, &XpubOrigin)>

source

pub fn is_modifiable(&self) -> bool

source

pub fn are_inputs_modifiable(&self) -> bool

source

pub fn are_outputs_modifiable(&self) -> bool

source

pub fn construct_input<K, D>( &mut self, prevout: Prevout, descriptor: &D, terminal: Terminal, sequence: SeqNo, ) -> Result<&mut Input, Unmodifiable>
where D: Descriptor<K>,

source

pub fn construct_input_expect<K, D>( &mut self, prevout: Prevout, descriptor: &D, terminal: Terminal, sequence: SeqNo, ) -> &mut Input
where D: Descriptor<K>,

source

pub fn construct_output( &mut self, script_pubkey: ScriptPubkey, value: Sats, ) -> Result<&mut Output, Unmodifiable>

source

pub fn construct_output_expect( &mut self, script_pubkey: ScriptPubkey, value: Sats, ) -> &mut Output

source

pub fn construct_change<K, D>( &mut self, descriptor: &D, change_terminal: Terminal, value: Sats, ) -> Result<&mut Output, Unmodifiable>
where D: Descriptor<K>,

source

pub fn construct_change_expect<K, D>( &mut self, descriptor: &D, change_terminal: Terminal, value: Sats, ) -> &mut Output
where D: Descriptor<K>,

source

pub fn sort_outputs_by<K>( &mut self, f: impl FnMut(&Output) -> K, ) -> Result<(), Unmodifiable>
where K: Ord,

source

pub fn complete_construction(&mut self)

source§

impl Psbt

source

pub fn from_base64(s: &str) -> Result<Psbt, PsbtParseError>

source

pub fn from_base16(s: &str) -> Result<Psbt, PsbtParseError>

source

pub fn to_base64(&self) -> String

source

pub fn to_base64_ver(&self, version: PsbtVer) -> String

source

pub fn to_base16(&self) -> String

source

pub fn to_base16_ver(&self, version: PsbtVer) -> String

source§

impl Psbt

source

pub fn encode( &self, ver: PsbtVer, writer: &mut dyn Write, ) -> Result<usize, IoError>

source

pub fn encode_vec(&self, ver: PsbtVer, writer: &mut Vec<u8>) -> usize

source

pub fn serialize(&self, ver: PsbtVer) -> Vec<u8>

source

pub fn decode(reader: &mut impl Read) -> Result<Psbt, DecodeError>

source

pub fn deserialize(data: impl AsRef<[u8]>) -> Result<Psbt, PsbtError>

Trait Implementations§

source§

impl Clone for Psbt

source§

fn clone(&self) -> Psbt

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Psbt

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Default for Psbt

source§

fn default() -> Psbt

Returns the “default value” for a type. Read more
source§

impl Display for Psbt

PSBT displays Base64-encoded string. The selection of the version if the following:

  • by default, it uses version specified in the PSBT itself;
  • if zero {:0} is given and no width ({:0}) or a zero width ({:00}) is provided, than the PSBT is encoded as V0 even if the structure itself uses V2;
  • if a width equal to two is given like in {:2}, than zero flag is ignored (so {:02} also works that way) and PSBT is encoded as V2 even if the structure itself uses V1;
  • all other flags has no effect on the display.
source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl FromStr for Psbt

FromStr implementation parses both Base64 and Hex (Base16) encodings.

§

type Err = PsbtParseError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Psbt, <Psbt as FromStr>::Err>

Parses a string s to return a value of this type. Read more
source§

impl KeyMap for Psbt

§

type Keys = GlobalKey

source§

const PROPRIETARY_TYPE: <Psbt as KeyMap>::Keys = GlobalKey::Proprietary

source§

fn retrieve_key_pair<'enc>( &'enc self, version: PsbtVer, key_type: <Psbt as KeyMap>::Keys, ) -> Vec<KeyPair<<Psbt as KeyMap>::Keys, Box<dyn Encode + 'enc>, Box<dyn Encode + 'enc>>>

source§

fn insert_singular( &mut self, key_type: <Psbt as KeyMap>::Keys, value_data: ValueData, ) -> Result<(), PsbtError>

source§

fn insert_plural( &mut self, key_type: <Psbt as KeyMap>::Keys, key_data: ByteStr, value_data: ValueData, ) -> Result<(), PsbtError>

source§

fn encode_map( &self, version: PsbtVer, writer: &mut dyn Write, ) -> Result<usize, IoError>

source§

fn parse_map( &mut self, version: PsbtVer, map: Map<Self::Keys>, ) -> Result<(), PsbtError>

source§

fn has_proprietary(&self, key: &PropKey) -> bool

source§

fn proprietary(&self, key: &PropKey) -> Option<&ValueData>

source§

fn proprietary_mut(&mut self, key: &PropKey) -> Option<&mut ValueData>

source§

fn push_proprietary( &mut self, key: PropKey, value: impl Into<ValueData>, ) -> Result<(), KeyAlreadyPresent>

source§

fn remove_proprietary(&mut self, key: &PropKey) -> Option<ValueData>

source§

fn insert_proprietary(&mut self, prop_key: PropKey, value_data: ValueData)

source§

fn insert_unknown( &mut self, key_type: u8, key_data: ByteStr, value_data: ValueData, )

source§

impl LowerHex for Psbt

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl PartialEq for Psbt

source§

fn eq(&self, other: &Psbt) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Psbt

source§

impl StructuralPartialEq for Psbt

Auto Trait Implementations§

§

impl Freeze for Psbt

§

impl RefUnwindSafe for Psbt

§

impl Send for Psbt

§

impl Sync for Psbt

§

impl Unpin for Psbt

§

impl UnwindSafe for Psbt

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToHex for T
where T: LowerHex,

source§

fn to_hex(&self) -> String

Outputs the hash in hexadecimal form

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> VerifyEq for T
where T: Eq,

source§

fn verify_eq(&self, other: &T) -> bool

Verifies commit-equivalence of two instances of the same type.