pub struct PartiallySignedTransaction {
    pub unsigned_tx: Transaction,
    pub version: u32,
    pub xpub: BTreeMap<ExtendedPubKey, KeySource>,
    pub proprietary: BTreeMap<ProprietaryKey, Vec<u8>>,
    pub unknown: BTreeMap<Key, Vec<u8>>,
    pub inputs: Vec<Input>,
    pub outputs: Vec<Output>,
}
Expand description

A Partially Signed Transaction.

Fields§

§unsigned_tx: Transaction

The unsigned transaction, scriptSigs and witnesses for each input must be empty.

§version: u32

The version number of this PSBT. If omitted, the version number is 0.

§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.

§inputs: Vec<Input>

The corresponding key-value map for each input in the unsigned transaction.

§outputs: Vec<Output>

The corresponding key-value map for each output in the unsigned transaction.

Implementations§

source§

impl PartiallySignedTransaction

source

pub fn serialize_hex(&self) -> String

Serialize a value as bytes in hex.

source

pub fn serialize(&self) -> Vec<u8>

Serialize as raw binary data

source

pub fn deserialize(bytes: &[u8]) -> Result<Self, Error>

Deserialize a value from raw binary data.

source§

impl PartiallySignedTransaction

source

pub fn iter_funding_utxos(&self) -> impl Iterator<Item = Result<&TxOut, Error>>

Returns an iterator for the funding UTXOs of the psbt

For each PSBT input that contains UTXO information Ok is returned containing that information. The order of returned items is same as the order of inputs.

Errors

The function returns error when UTXO information is not present or is invalid.

Panics

The function panics if the length of transaction inputs is not equal to the length of PSBT inputs.

source

pub fn from_unsigned_tx(tx: Transaction) -> Result<Self, Error>

Creates a PSBT from an unsigned transaction.

Errors

If transactions is not unsigned.

source

pub fn extract_tx(self) -> Transaction

Extracts the Transaction from a PSBT by filling in the available signature information.

source

pub fn combine(&mut self, other: Self) -> Result<(), Error>

Combines this PartiallySignedTransaction with other PSBT as described by BIP 174.

In accordance with BIP 174 this function is commutative i.e., A.combine(B) == B.combine(A)

source

pub fn sign<C, K>( &mut self, k: &K, secp: &Secp256k1<C> ) -> Result<SigningKeys, (SigningKeys, SigningErrors)>where C: Signing, K: GetKey,

Attempts to create all the required signatures for this PSBT using k.

NOTE: Taproot inputs are, as yet, not supported by this function. We currently only attempt to sign ECDSA inputs.

If you just want to sign an input with one specific key consider using sighash_ecdsa. This function does not support scripts that contain OP_CODESEPARATOR.

Returns

Either Ok(SigningKeys) or Err((SigningKeys, SigningErrors)), where

  • SigningKeys: A map of input index -> pubkey associated with secret key used to sign.
  • SigningKeys: A map of input index -> the error encountered while attempting to sign.

If an error is returned some signatures may already have been added to the PSBT. Since partial_sigs is a BTreeMap it is safe to retry, previous sigs will be overwritten.

source

pub fn sighash_ecdsa<T: Borrow<Transaction>>( &self, input_index: usize, cache: &mut SighashCache<T> ) -> Result<(Message, EcdsaSighashType), SignError>

Returns the sighash message to sign an ECDSA input along with the sighash type.

Uses the EcdsaSighashType from this input if one is specified. If no sighash type is specified uses EcdsaSighashType::All. This function does not support scripts that contain OP_CODESEPARATOR.

source

pub fn spend_utxo(&self, input_index: usize) -> Result<&TxOut, SignError>

Returns the spending utxo for this PSBT’s input at input_index.

source

pub fn fee(&self) -> Result<Amount, Error>

Calculates transaction fee.

‘Fee’ being the amount that will be paid for mining a transaction with the current inputs and outputs i.e., the difference in value of the total inputs and the total outputs.

Errors

Trait Implementations§

source§

impl Clone for PartiallySignedTransaction

source§

fn clone(&self) -> PartiallySignedTransaction

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 PartiallySignedTransaction

source§

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

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

impl<'de> Deserialize<'de> for PartiallySignedTransaction

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for PartiallySignedTransaction

Available on crate feature base64 only.
source§

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

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

impl FromStr for PartiallySignedTransaction

Available on crate feature base64 only.
§

type Err = PsbtParseError

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

fn from_str(s: &str) -> Result<Self, Self::Err>

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

impl Hash for PartiallySignedTransaction

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for PartiallySignedTransaction

source§

fn eq(&self, other: &PartiallySignedTransaction) -> 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 Serialize for PartiallySignedTransaction

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for PartiallySignedTransaction

source§

impl StructuralEq for PartiallySignedTransaction

source§

impl StructuralPartialEq for PartiallySignedTransaction

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere 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 Twhere 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 Twhere 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 Twhere 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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,