pub fn try_val_as_key_derivation(val: &PSBTValue) -> Result<KeyDerivation, PSBTError> {
    if val.is_empty() || val.len() % 4 != 0 {
        return Err(PSBTError::InvalidBip32Path);
    }
    let limit = (val.len() / 4) - 1;
    let mut deriv_bytes = &val.items()[..];

    let mut v = vec![];

    let root = KeyFingerprint::read_from(&mut deriv_bytes)?;
    for _ in 0..limit {
        v.push(ser::read_u32_le(&mut deriv_bytes)?)
    }

    Ok(KeyDerivation {
        root,
        path: v.into_iter().collect(),
    })
}
/// Check that a value can be interpreted as a bip32 fingerprint + derivation
Check that a value can be interpreted as a bip32 fingerprint + derivation
Check that a value can be interpreted as a bip32 fingerprint + derivation
pub fn try_val_as_key_derivation(val: &PSBTValue) -> Result<KeyDerivation, PSBTError> {
    if val.is_empty() || val.len() % 4 != 0 {
        return Err(PSBTError::InvalidBip32Path);
    }
    let limit = (val.len() / 4) - 1;
    let mut deriv_bytes = &val.items()[..];
    let mut v = vec![];
    let root = KeyFingerprint::read_from(&mut deriv_bytes)?;
    for _ in 0..limit {
        v.push(ser::read_u32_le(&mut deriv_bytes)?)
    }
    Ok(KeyDerivation {
        root,
        path: v.into_iter().collect(),
    })
}
pub fn try_val_as_key_derivation ( val : & PSBTValue ) -> Result < KeyDerivation , PSBTError > { if val . is_empty ( ) || val . len ( ) % 4 != 0 { return Err ( PSBTError :: InvalidBip32Path ) ; } let limit = ( val . len ( ) / 4 ) - 1 ; let mut deriv_bytes = & val . items ( ) [ .. ] ; let mut v = vec ! [ ] ; let root = KeyFingerprint :: read_from ( & mut deriv_bytes ) ? ; for _ in 0 .. limit { v . push ( ser :: read_u32_le ( & mut deriv_bytes ) ? ) } Ok ( KeyDerivation { root , path : v . into_iter ( ) . collect ( ) , } ) }
Check that a value can be interpreted as a bip32 fingerprint + derivation
Check that a value can be interpreted as a bip32 fingerprint + derivation
val
&PSBTValue
val
&PSBTValue