Advertisement
Guest User

rusty

a guest
Feb 27th, 2022
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.99 KB | None | 0 0
  1. impl PartiallySignedTransaction {
  2.     /// Returns a vector the funding utxos of a psbt
  3.     pub fn to_prevouts(&self) -> sighash::Prevouts {
  4.         let mut prev_outs : Vec<&TxOut> = Vec::new();
  5.         for i in 0..self.inputs.len() {
  6.             let psbt_input : Input = self.inputs[i];
  7.              // check for witness utxos
  8.                 if let Some(ref witness_utxo) = psbt_input.witness_utxo {
  9.                     prev_outs.push(&witness_utxo)
  10.                      // if no witness utxos then catch the non witness part of the input
  11.                 } else if let Some(ref non_witness_utxo) = psbt_input.non_witness_utxo {
  12.                      // get output index (vout) from the outpoint and use it to get the non_witness_utxo
  13.                     let vout: usize = self.unsigned_tx.input[i].previous_output.vout;
  14.                     prev_outs.push(&non_witness_utxo.output[vout])
  15.                 }
  16.             }
  17.             return prev_outs;
  18.         }
  19. ...
  20. ... other procedures ...
  21. ...
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement