pub struct Psbt {
pub psbt_version: PsbtVersion,
pub tx_version: u32,
pub fallback_locktime: Option<LockTime>,
pub inputs: Vec<Input>,
pub outputs: Vec<Output>,
pub xpub: BTreeMap<ExtendedPubKey, KeySource>,
pub proprietary: BTreeMap<ProprietaryKey, Vec<u8>>,
pub unknown: BTreeMap<Key, Vec<u8>>,
}
Fields
psbt_version: PsbtVersion
The version number of this PSBT. If omitted, the version number is 0.
tx_version: u32
Transaction version.
fallback_locktime: Option<LockTime>
Fallback locktime (used if none of the inputs specifies their locktime).
inputs: Vec<Input>
The corresponding key-value map for each input.
outputs: Vec<Output>
The corresponding key-value map for each output.
xpub: BTreeMap<ExtendedPubKey, KeySource>
A global map from extended public keys to the used key fingerprint and derivation path as defined by BIP 32
proprietary: BTreeMap<ProprietaryKey, Vec<u8>>
Global proprietary key-value pairs.
unknown: BTreeMap<Key, Vec<u8>>
Unknown global key-value pairs.
Implementations
sourceimpl Psbt
impl Psbt
sourcepub fn with(tx: Transaction, psbt_version: PsbtVersion) -> Result<Self, TxError>
pub fn with(tx: Transaction, psbt_version: PsbtVersion) -> Result<Self, TxError>
Checks that unsigned transaction does not have scriptSig’s or witness data
pub fn lock_time(&self) -> LockTime
sourcepub fn fee(&self) -> Result<u64, FeeError>
pub fn fee(&self) -> Result<u64, FeeError>
Returns fee for a transaction, or returns error reporting resolver problem or wrong transaction structure
sourcepub fn to_txid(&self) -> Txid
pub fn to_txid(&self) -> Txid
Returns transaction ID for an unsigned transaction. For SegWit transactions this is equal to the signed transaction id.
sourcepub fn to_unsigned_tx(&self) -> Transaction
pub fn to_unsigned_tx(&self) -> Transaction
Constructs transaction with empty scriptSig
and witness
sourcepub fn into_unsigned_tx(self) -> Transaction
pub fn into_unsigned_tx(self) -> Transaction
Returns transaction with empty scriptSig
and witness
sourcepub fn extract_signed_tx(&self) -> Transaction
pub fn extract_signed_tx(&self) -> Transaction
Extract the (partially) signed transaction from this PSBT by filling in the available signature information in place.
sourceimpl Psbt
impl Psbt
Extension trait for Psbt
for working with proprietary LNPBP4 keys.
sourcepub fn lnpbp4_protocol_info(
&self,
protocol_id: ProtocolId
) -> Result<Lnpbp4Info, Lnpbp4KeyError>
pub fn lnpbp4_protocol_info(
&self,
protocol_id: ProtocolId
) -> Result<Lnpbp4Info, Lnpbp4KeyError>
Returns an information about the given LNPBP4 ProtocolId
, if any.
Errors
If the key is present, but it’s value can’t be deserialized as a valid protocol information block.
sourcepub fn set_lnpbp4_protocol_info(
&mut self,
protocol_id: ProtocolId,
hash_tag: Option<String>,
inner_id: Option<Slice32>
) -> Result<bool, Lnpbp4KeyError>
pub fn set_lnpbp4_protocol_info(
&mut self,
protocol_id: ProtocolId,
hash_tag: Option<String>,
inner_id: Option<Slice32>
) -> Result<bool, Lnpbp4KeyError>
Adds LNPBP4 protocol information.
Returns
true
, if the protocol information was successfully added, false
if
it was already present.
Errors
If the key for the given ProtocolId
is already present and the
information was different.
sourceimpl Psbt
impl Psbt
pub fn construct<'inputs, 'outputs>(
descriptor: &Descriptor<DerivationAccount>,
inputs: impl IntoIterator<Item = &'inputs InputDescriptor>,
outputs: impl IntoIterator<Item = &'outputs (PubkeyScript, u64)>,
change_index: impl Into<UnhardenedIndex>,
fee: u64,
tapret: Option<&DfsPath>,
tx_resolver: &impl ResolveTx
) -> Result<Psbt, Error>
Trait Implementations
sourceimpl Deserialize for Psbt
impl Deserialize for Psbt
sourcefn deserialize(bytes: &[u8]) -> Result<Self, Error>
fn deserialize(bytes: &[u8]) -> Result<Self, Error>
Deserialize a value from raw data.
sourceimpl From<PartiallySignedTransaction> for Psbt
impl From<PartiallySignedTransaction> for Psbt
sourceimpl LexOrder for Psbt
impl LexOrder for Psbt
fn lex_order(&mut self)
fn lex_ordered(self) -> Self where
Self: Sized,
sourceimpl StrictDecode for Psbt
impl StrictDecode for Psbt
sourcefn strict_decode<D: Read>(d: D) -> Result<Self, Error>
fn strict_decode<D: Read>(d: D) -> Result<Self, Error>
Decode with the given std::io::Read
instance; must either
construct an instance or return implementation-specific error type. Read more
sourcefn strict_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
fn strict_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
Tries to deserialize byte array into the current type using
StrictDecode::strict_decode
. If there are some data remains in the
buffer once deserialization is completed, fails with
Error::DataNotEntirelyConsumed
. Use io::Cursor
over the buffer and
StrictDecode::strict_decode
to avoid such failures. Read more
sourcefn strict_file_load(path: impl AsRef<Path>) -> Result<Self, Error>
fn strict_file_load(path: impl AsRef<Path>) -> Result<Self, Error>
Reads data from file at path
and reconstructs object from it. Fails
with Error::DataNotEntirelyConsumed
if file contains remaining
data after the object reconstruction. Read more
sourceimpl StrictEncode for Psbt
impl StrictEncode for Psbt
sourcefn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>
fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>
Encode with the given std::io::Write
instance; must return result
with either amount of bytes encoded – or implementation-specific
error type. Read more
sourcefn strict_serialize(&self) -> Result<Vec<u8, Global>, Error>
fn strict_serialize(&self) -> Result<Vec<u8, Global>, Error>
Serializes data as a byte array using StrictEncode::strict_encode
function Read more
impl Eq for Psbt
impl StructuralEq for Psbt
impl StructuralPartialEq for Psbt
Auto Trait Implementations
impl RefUnwindSafe for Psbt
impl Send for Psbt
impl Sync for Psbt
impl Unpin for Psbt
impl UnwindSafe for Psbt
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more