pub trait PsbtExt {
    // Required methods
    fn finalize_mut<C: Verification>(
        &mut self,
        secp: &Secp256k1<C>
    ) -> Result<(), Vec<Error>>;
    fn finalize<C: Verification>(
        self,
        secp: &Secp256k1<C>
    ) -> Result<Psbt, (Psbt, Vec<Error>)>;
    fn finalize_mall_mut<C: Verification>(
        &mut self,
        secp: &Secp256k1<C>
    ) -> Result<(), Vec<Error>>;
    fn finalize_mall<C: Verification>(
        self,
        secp: &Secp256k1<C>
    ) -> Result<Psbt, (Psbt, Vec<Error>)>;
    fn finalize_inp_mut<C: Verification>(
        &mut self,
        secp: &Secp256k1<C>,
        index: usize
    ) -> Result<(), Error>;
    fn finalize_inp<C: Verification>(
        self,
        secp: &Secp256k1<C>,
        index: usize
    ) -> Result<Psbt, (Psbt, Error)>;
    fn finalize_inp_mall_mut<C: Verification>(
        &mut self,
        secp: &Secp256k1<C>,
        index: usize
    ) -> Result<(), Error>;
    fn finalize_inp_mall<C: Verification>(
        self,
        secp: &Secp256k1<C>,
        index: usize
    ) -> Result<Psbt, (Psbt, Error)>;
    fn extract<C: Verification>(
        &self,
        secp: &Secp256k1<C>
    ) -> Result<Transaction, Error>;
    fn update_desc(
        &mut self,
        input_index: usize,
        desc: &Descriptor<DescriptorPublicKey>,
        range: Option<Range<u32>>
    ) -> Result<(), UxtoUpdateError>;
    fn sighash_msg<T: Deref<Target = Transaction>>(
        &self,
        idx: usize,
        cache: &mut SighashCache<T>,
        tapleaf_hash: Option<TapLeafHash>
    ) -> Result<PsbtSighashMsg, SighashError>;
}
Expand description

Additional operations for miniscript descriptors for various psbt roles. Note that these APIs would generally error when used on scripts that are not miniscripts.

Required Methods§

source

fn finalize_mut<C: Verification>( &mut self, secp: &Secp256k1<C> ) -> Result<(), Vec<Error>>

Finalize the psbt. This function takes in a mutable reference to psbt and populates the final_witness and final_scriptsig for all miniscript inputs.

Finalizes all inputs that it can finalize, and returns an error for each input that it cannot finalize. Also performs a sanity interpreter check on the finalized psbt which involves checking the signatures/ preimages/timelocks.

Input finalization also fails if it is not possible to satisfy any of the inputs non-malleably See finalizer::finalize_mall if you want to allow malleable satisfactions

For finalizing individual inputs, see also PsbtExt::finalize_inp

Errors:
  • A vector of errors, one of each of failed finalized input
source

fn finalize<C: Verification>( self, secp: &Secp256k1<C> ) -> Result<Psbt, (Psbt, Vec<Error>)>

Same as PsbtExt::finalize_mut, but does not mutate the input psbt and returns a new psbt

Errors:
  • Returns a mutated psbt with all inputs finalize_mut could finalize
  • A vector of input errors, one of each of failed finalized input
source

fn finalize_mall_mut<C: Verification>( &mut self, secp: &Secp256k1<C> ) -> Result<(), Vec<Error>>

Same as PsbtExt::finalize_mut, but allows for malleable satisfactions

source

fn finalize_mall<C: Verification>( self, secp: &Secp256k1<C> ) -> Result<Psbt, (Psbt, Vec<Error>)>

Same as PsbtExt::finalize, but allows for malleable satisfactions

source

fn finalize_inp_mut<C: Verification>( &mut self, secp: &Secp256k1<C>, index: usize ) -> Result<(), Error>

Same as PsbtExt::finalize_mut, but only tries to finalize a single input leaving other inputs as is. Use this when not all of inputs that you are trying to satisfy are miniscripts

Errors:
  • Input error detailing why the finalization failed. The psbt is not mutated when the finalization fails
source

fn finalize_inp<C: Verification>( self, secp: &Secp256k1<C>, index: usize ) -> Result<Psbt, (Psbt, Error)>

Same as PsbtExt::finalize_inp_mut, but does not mutate the psbt and returns a new one

Errors:

Returns a tuple containing

  • Original psbt
  • Input Error detailing why the input finalization failed
source

fn finalize_inp_mall_mut<C: Verification>( &mut self, secp: &Secp256k1<C>, index: usize ) -> Result<(), Error>

Same as PsbtExt::finalize_inp_mut, but allows for malleable satisfactions

source

fn finalize_inp_mall<C: Verification>( self, secp: &Secp256k1<C>, index: usize ) -> Result<Psbt, (Psbt, Error)>

Same as PsbtExt::finalize_inp, but allows for malleable satisfactions

source

fn extract<C: Verification>( &self, secp: &Secp256k1<C> ) -> Result<Transaction, Error>

Psbt extractor as defined in BIP174 that takes in a psbt reference and outputs a extracted bitcoin::Transaction Also does the interpreter sanity check Will error if the final ScriptSig or final Witness are missing or the interpreter check fails.

source

fn update_desc( &mut self, input_index: usize, desc: &Descriptor<DescriptorPublicKey>, range: Option<Range<u32>> ) -> Result<(), UxtoUpdateError>

Update an psbt with the derived descriptor information. If the descriptor is

  • Sh: Update the redeem script
  • Wsh: Update the witness script
  • ShWsh/ShWpkh: Updates redeem script and witness script(in nested wsh case)
  • Tr: Update the control block maps, internal key and merkle root
Errors:
  • If the input Index out of bounds
  • If there is descriptor::ConversionError while deriving keys
  • Psbt does not have corresponding witness/non-witness utxo
  • Ranged descriptor not supplied with a range to call at
  • If the given descriptor cannot derive the output key.
source

fn sighash_msg<T: Deref<Target = Transaction>>( &self, idx: usize, cache: &mut SighashCache<T>, tapleaf_hash: Option<TapLeafHash> ) -> Result<PsbtSighashMsg, SighashError>

Get the sighash message(data to sign) at input index idx based on the sighash flag specified in the Psbt sighash field. If the input sighash flag psbt field is None the SchnorrSighashType::Default is chosen for for taproot spends, otherwise EcdsaSignatureHashType::All is chosen. If the utxo at idx is a taproot output, returns a PsbtSighashMsg::TapSighash variant. If the utxo at idx is a pre-taproot output, returns a PsbtSighashMsg::EcdsaSighash variant. The tapleaf_hash parameter can be used to specify which tapleaf script hash has to be computed. If tapleaf_hash is None, and the output is taproot output, the key spend hash is computed. This parameter must be set to None while computing sighash for pre-taproot outputs. The function also updates the sighash cache with transaction computed during sighash computation of this input

Arguments:
  • idx: The input index of psbt to sign
  • cache: The [sighash::SighashCache] for used to cache/read previously cached computations
  • tapleaf_hash: If the output is taproot, compute the sighash for this particular leaf.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl PsbtExt for PartiallySignedTransaction

source§

fn finalize_mut<C: Verification>( &mut self, secp: &Secp256k1<C> ) -> Result<(), Vec<Error>>

source§

fn finalize<C: Verification>( self, secp: &Secp256k1<C> ) -> Result<Psbt, (Psbt, Vec<Error>)>

source§

fn finalize_mall_mut<C: Verification>( &mut self, secp: &Secp256k1<C> ) -> Result<(), Vec<Error>>

source§

fn finalize_mall<C: Verification>( self, secp: &Secp256k1<C> ) -> Result<Psbt, (Psbt, Vec<Error>)>

source§

fn finalize_inp_mut<C: Verification>( &mut self, secp: &Secp256k1<C>, index: usize ) -> Result<(), Error>

source§

fn finalize_inp<C: Verification>( self, secp: &Secp256k1<C>, index: usize ) -> Result<Psbt, (Psbt, Error)>

source§

fn finalize_inp_mall_mut<C: Verification>( &mut self, secp: &Secp256k1<C>, index: usize ) -> Result<(), Error>

source§

fn finalize_inp_mall<C: Verification>( self, secp: &Secp256k1<C>, index: usize ) -> Result<Psbt, (Psbt, Error)>

source§

fn extract<C: Verification>( &self, secp: &Secp256k1<C> ) -> Result<Transaction, Error>

source§

fn update_desc( &mut self, input_index: usize, desc: &Descriptor<DescriptorPublicKey>, range: Option<Range<u32>> ) -> Result<(), UxtoUpdateError>

source§

fn sighash_msg<T: Deref<Target = Transaction>>( &self, idx: usize, cache: &mut SighashCache<T>, tapleaf_hash: Option<TapLeafHash> ) -> Result<PsbtSighashMsg, SighashError>

Implementors§