pub fn from_raw_psbt(raw_psbt: &[u8]) -> Result<Self, TransactionSerialisationError> {
        let psbt = Decodable::consensus_decode(raw_psbt)?;
        let psbt = utils::psbt_common_sanity_checks(psbt)?;

        // Unvault + CPFP txos
        let output_count = psbt.global.unsigned_tx.output.len();
        if output_count != 2 {
            return Err(PsbtValidationError::InvalidOutputCount(output_count).into());
        }

        for output in psbt.outputs.iter() {
            if output.bip32_derivation.is_empty() {
                return Err(PsbtValidationError::InvalidOutputField(output.clone()).into());
            }
        }

        let input_count = psbt.global.unsigned_tx.input.len();
        // We for now have 1 unvault == 1 deposit
        if input_count != 1 {
            return Err(PsbtValidationError::InvalidInputCount(input_count).into());
        }
        let input = &psbt.inputs[0];
        if input.final_script_witness.is_none() {
            if input.sighash_type != Some(SigHashType::All) {
                return Err(PsbtValidationError::InvalidSighashType(input.clone()).into());
            }

            if input.bip32_derivation.is_empty() {
                return Err(PsbtValidationError::InvalidInputField(input.clone()).into());
            }

            if let Some(ref ws) = input.witness_script {
                if ws.to_v0_p2wsh()
                    != input
                        .witness_utxo
                        .as_ref()
                        .expect("Check in sanity checks")
                        .script_pubkey
                {
                    return Err(PsbtValidationError::InvalidInWitnessScript(input.clone()).into());
                }
            } else {
                return Err(PsbtValidationError::MissingInWitnessScript(input.clone()).into());
            }
        }

        // NOTE: the Unvault transaction cannot get larger than MAX_STANDARD_TX_WEIGHT

        Ok(UnvaultTransaction(psbt))
    }
/// Parse an Unvault transaction from a PSBT
Parse an Unvault transaction from a PSBT
Parse an Unvault transaction from a PSBT
pub fn from_raw_psbt(raw_psbt: &[u8]) -> Result<Self, TransactionSerialisationError> {
        let psbt = Decodable::consensus_decode(raw_psbt)?;
        let psbt = utils::psbt_common_sanity_checks(psbt)?;
        // Unvault + CPFP txos
        let output_count = psbt.global.unsigned_tx.output.len();
        if output_count != 2 {
            return Err(PsbtValidationError::InvalidOutputCount(output_count).into());
        }
        for output in psbt.outputs.iter() {
            if output.bip32_derivation.is_empty() {
                return Err(PsbtValidationError::InvalidOutputField(output.clone()).into());
            }
        }
        let input_count = psbt.global.unsigned_tx.input.len();
        // We for now have 1 unvault == 1 deposit
        if input_count != 1 {
            return Err(PsbtValidationError::InvalidInputCount(input_count).into());
        }
        let input = &psbt.inputs[0];
        if input.final_script_witness.is_none() {
            if input.sighash_type != Some(SigHashType::All) {
                return Err(PsbtValidationError::InvalidSighashType(input.clone()).into());
            }
            if input.bip32_derivation.is_empty() {
                return Err(PsbtValidationError::InvalidInputField(input.clone()).into());
            }
            if let Some(ref ws) = input.witness_script {
                if ws.to_v0_p2wsh()
                    != input
                        .witness_utxo
                        .as_ref()
                        .expect("Check in sanity checks")
                        .script_pubkey
                {
                    return Err(PsbtValidationError::InvalidInWitnessScript(input.clone()).into());
                }
            } else {
                return Err(PsbtValidationError::MissingInWitnessScript(input.clone()).into());
            }
        }
        // NOTE: the Unvault transaction cannot get larger than MAX_STANDARD_TX_WEIGHT
        Ok(UnvaultTransaction(psbt))
    }
pub fn from_raw_psbt ( raw_psbt : & [ u8 ] ) -> Result < Self , TransactionSerialisationError > { let psbt = Decodable :: consensus_decode ( raw_psbt ) ? ; let psbt = utils :: psbt_common_sanity_checks ( psbt ) ? ; // Unvault + CPFP txos let output_count = psbt . global . unsigned_tx . output . len ( ) ; if output_count != 2 { return Err ( PsbtValidationError :: InvalidOutputCount ( output_count ) . into ( ) ) ; } for output in psbt . outputs . iter ( ) { if output . bip32_derivation . is_empty ( ) { return Err ( PsbtValidationError :: InvalidOutputField ( output . clone ( ) ) . into ( ) ) ; } } let input_count = psbt . global . unsigned_tx . input . len ( ) ; // We for now have 1 unvault == 1 deposit if input_count != 1 { return Err ( PsbtValidationError :: InvalidInputCount ( input_count ) . into ( ) ) ; } let input = & psbt . inputs [ 0 ] ; if input . final_script_witness . is_none ( ) { if input . sighash_type != Some ( SigHashType :: All ) { return Err ( PsbtValidationError :: InvalidSighashType ( input . clone ( ) ) . into ( ) ) ; } if input . bip32_derivation . is_empty ( ) { return Err ( PsbtValidationError :: InvalidInputField ( input . clone ( ) ) . into ( ) ) ; } if let Some ( ref ws ) = input . witness_script { if ws . to_v0_p2wsh ( ) != input . witness_utxo . as_ref ( ) . expect ( " " ) . script_pubkey { return Err ( PsbtValidationError :: InvalidInWitnessScript ( input . clone ( ) ) . into ( ) ) ; } } else { return Err ( PsbtValidationError :: MissingInWitnessScript ( input . clone ( ) ) . into ( ) ) ; } } // NOTE: the Unvault transaction cannot get larger than MAX_STANDARD_TX_WEIGHT Ok ( UnvaultTransaction ( psbt ) ) }
Parse an Unvault transaction from a PSBT
Parse an Unvault transaction from a PSBT
raw_psbt
&[u8]