fn sanity_check(psbt: &Psbt) -> Result<(), Error> {
    if psbt.unsigned_tx.input.len() != psbt.inputs.len() {
        return Err(Error::WrongInputCount {
            in_tx: psbt.unsigned_tx.input.len(),
            in_map: psbt.inputs.len(),
        });
    }

    // Check well-formedness of input data
    for (index, input) in psbt.inputs.iter().enumerate() {
        // TODO: fix this after https://github.com/rust-bitcoin/rust-bitcoin/issues/838
        let target_ecdsa_sighash_ty = match input.sighash_type {
            Some(psbt_hash_ty) => psbt_hash_ty
                .ecdsa_hash_ty()
                .map_err(|e| Error::InputError(InputError::NonStandardSighashType(e), index))?,
            None => EcdsaSighashType::All,
        };
        for (key, ecdsa_sig) in &input.partial_sigs {
            let flag = bitcoin::EcdsaSighashType::from_standard(ecdsa_sig.hash_ty as u32).map_err(
                |_| {
                    Error::InputError(
                        InputError::Interpreter(interpreter::Error::NonStandardSighash(
                            ecdsa_sig.to_vec(),
                        )),
                        index,
                    )
                },
            )?;
            if target_ecdsa_sighash_ty != flag {
                return Err(Error::InputError(
                    InputError::WrongSighashFlag {
                        required: target_ecdsa_sighash_ty,
                        got: flag,
                        pubkey: *key,
                    },
                    index,
                ));
            }
            // Signatures are well-formed in psbt partial sigs
        }
    }

    Ok(())
}
// Basic sanity checks on psbts.
// rust-bitcoin TODO: (Long term)
// Brainstorm about how we can enforce these in type system while having a nice API
Basic sanity checks on psbts.
rust-bitcoin TODO: (Long term)
Brainstorm about how we can enforce these in type system while having a nice API
Basic sanity checks on psbts . rust - bitcoin TODO : ( Long term ) Brainstorm about how we can enforce these in type system while having a nice API
fn sanity_check(psbt: &Psbt) -> Result<(), Error> {
    if psbt.unsigned_tx.input.len() != psbt.inputs.len() {
        return Err(Error::WrongInputCount {
            in_tx: psbt.unsigned_tx.input.len(),
            in_map: psbt.inputs.len(),
        });
    }
    // Check well-formedness of input data
    for (index, input) in psbt.inputs.iter().enumerate() {
        // TODO: fix this after https://github.com/rust-bitcoin/rust-bitcoin/issues/838
        let target_ecdsa_sighash_ty = match input.sighash_type {
            Some(psbt_hash_ty) => psbt_hash_ty
                .ecdsa_hash_ty()
                .map_err(|e| Error::InputError(InputError::NonStandardSighashType(e), index))?,
            None => EcdsaSighashType::All,
        };
        for (key, ecdsa_sig) in &input.partial_sigs {
            let flag = bitcoin::EcdsaSighashType::from_standard(ecdsa_sig.hash_ty as u32).map_err(
                |_| {
                    Error::InputError(
                        InputError::Interpreter(interpreter::Error::NonStandardSighash(
                            ecdsa_sig.to_vec(),
                        )),
                        index,
                    )
                },
            )?;
            if target_ecdsa_sighash_ty != flag {
                return Err(Error::InputError(
                    InputError::WrongSighashFlag {
                        required: target_ecdsa_sighash_ty,
                        got: flag,
                        pubkey: *key,
                    },
                    index,
                ));
            }
            // Signatures are well-formed in psbt partial sigs
        }
    }
    Ok(())
}
fn sanity_check ( psbt : & Psbt ) -> Result < ( ) , Error > { if psbt . unsigned_tx . input . len ( ) != psbt . inputs . len ( ) { return Err ( Error :: WrongInputCount { in_tx : psbt . unsigned_tx . input . len ( ) , in_map : psbt . inputs . len ( ) , } ) ; } // Check well-formedness of input data for ( index , input ) in psbt . inputs . iter ( ) . enumerate ( ) { // TODO: fix this after https://github.com/rust-bitcoin/rust-bitcoin/issues/838 let target_ecdsa_sighash_ty = match input . sighash_type { Some ( psbt_hash_ty ) => psbt_hash_ty . ecdsa_hash_ty ( ) . map_err ( | e | Error :: InputError ( InputError :: NonStandardSighashType ( e ) , index ) ) ? , None => EcdsaSighashType :: All , } ; for ( key , ecdsa_sig ) in & input . partial_sigs { let flag = bitcoin :: EcdsaSighashType :: from_standard ( ecdsa_sig . hash_ty as u32 ) . map_err ( | _ | { Error :: InputError ( InputError :: Interpreter ( interpreter :: Error :: NonStandardSighash ( ecdsa_sig . to_vec ( ) , ) ) , index , ) } , ) ? ; if target_ecdsa_sighash_ty != flag { return Err ( Error :: InputError ( InputError :: WrongSighashFlag { required : target_ecdsa_sighash_ty , got : flag , pubkey : * key , } , index , ) ) ; } // Signatures are well-formed in psbt partial sigs } } Ok ( ( ) ) }
Basic sanity checks on psbts.
Basic sanity checks on psbts .
psbt
&Psbt
psbt
&Psbt