pub fn try_kv_pair_as_derived_pubkey(
    key: &PSBTKey,
    val: &PSBTValue,
) -> Result<DerivedPubkey, PSBTError> {
    let pubkey = if key.len() == 34 {
        let mut pubkey = [0u8; 33];
        pubkey.copy_from_slice(&key[1..34]);
        VerifyingKey::from_sec1_bytes(&pubkey).map_err(Bip32Error::from)?
    } else if key.len() == 66 {
        panic!("unimplemented!")
    // let mut pubkey = [0u8; 65];
    // pubkey.copy_from_slice(&key[1..66]);
    // bip32::curve::Pubkey::from_pubkey_array_uncompressed(pubkey)?
    } else {
        return Err(PSBTError::WrongKeyLength {
            got: key.len(),
            expected: 34,
        });
    };

    let deriv = try_val_as_key_derivation(val)?;

    Ok(DerivedPubkey::new(pubkey, deriv))
}
/// Attempt to convert a KV pair into a derived pubkey struct
Attempt to convert a KV pair into a derived pubkey struct
Attempt to convert a KV pair into a derived pubkey struct
pub fn try_kv_pair_as_derived_pubkey(
    key: &PSBTKey,
    val: &PSBTValue,
) -> Result<DerivedPubkey, PSBTError> {
    let pubkey = if key.len() == 34 {
        let mut pubkey = [0u8; 33];
        pubkey.copy_from_slice(&key[1..34]);
        VerifyingKey::from_sec1_bytes(&pubkey).map_err(Bip32Error::from)?
    } else if key.len() == 66 {
        panic!("unimplemented!")
    // let mut pubkey = [0u8; 65];
    // pubkey.copy_from_slice(&key[1..66]);
    // bip32::curve::Pubkey::from_pubkey_array_uncompressed(pubkey)?
    } else {
        return Err(PSBTError::WrongKeyLength {
            got: key.len(),
            expected: 34,
        });
    };
    let deriv = try_val_as_key_derivation(val)?;
    Ok(DerivedPubkey::new(pubkey, deriv))
}
pub fn try_kv_pair_as_derived_pubkey ( key : & PSBTKey , val : & PSBTValue , ) -> Result < DerivedPubkey , PSBTError > { let pubkey = if key . len ( ) == 34 { let mut pubkey = [ 0u8 ; 33 ] ; pubkey . copy_from_slice ( & key [ 1 .. 34 ] ) ; VerifyingKey :: from_sec1_bytes ( & pubkey ) . map_err ( Bip32Error :: from ) ? } else if key . len ( ) == 66 { panic ! ( " " ) // let mut pubkey = [0u8; 65]; // pubkey.copy_from_slice(&key[1..66]); // bip32::curve::Pubkey::from_pubkey_array_uncompressed(pubkey)? } else { return Err ( PSBTError :: WrongKeyLength { got : key . len ( ) , expected : 34 , } ) ; } ; let deriv = try_val_as_key_derivation ( val ) ? ; Ok ( DerivedPubkey :: new ( pubkey , deriv ) ) }
Attempt to convert a KV pair into a derived pubkey struct
Attempt to convert a KV pair into a derived pubkey struct
key
&PSBTKey
val
&PSBTValue
key
&PSBTKey
val
&PSBTValue