/// Extracts the nth input from the vin (0-indexed).
///
/// Iterates over the vin. If you need to extract several,
/// write a custom function.
///
/// # Arguments
///
/// * `vin` - The vin as a tightly-packed u8 array
/// * `index` - The 0-indexed location of the input to extract
Extracts the nth input from the vin (0-indexed).
Iterates over the vin. If you need to extract several,
write a custom function.
Extracts the nth input from the vin ( 0 - indexed ) . Iterates over the vin . If you need to extract several write a custom function .
pub fn extract_input_at_index<'a>(vin: &'a Vin<'a>, index: usize) -> Result<TxIn<'a>, SPVError> {
    let n_ins = parse_compact_int(vin)?;
    if index >= n_ins.number() as usize {
        return Err(SPVError::ReadOverrun);
    }
    let mut length = 0;
    let mut offset = n_ins.serialized_length();
    for i in 0..=index {
        length = determine_input_length(&vin[offset..])?;
        if i != index {
            offset += length as usize;
        }
    }
    if offset + length > vin.len() {
        return Err(SPVError::ReadOverrun);
    }
    Ok(TxIn(&vin[offset..offset + length]))
}
pub fn extract_input_at_index < ' a > ( vin : & ' a Vin < ' a > , index : usize ) -> Result < TxIn < ' a > , SPVError > { let n_ins = parse_compact_int ( vin ) ? ; if index >= n_ins . number ( ) as usize { return Err ( SPVError :: ReadOverrun ) ; } let mut length = 0 ; let mut offset = n_ins . serialized_length ( ) ; for i in 0 ..= index { length = determine_input_length ( & vin [ offset .. ] ) ? ; if i != index { offset += length as usize ; } } if offset + length > vin . len ( ) { return Err ( SPVError :: ReadOverrun ) ; } Ok ( TxIn ( & vin [ offset .. offset + length ] ) ) }
Extracts the nth input from the vin (0-indexed).
Extracts the nth input from the vin ( 0 - indexed ) .
vin
&'a Vin<'a>
index
usize