pub fn extract_output_at_index<'a>(
    vout: &'a Vout<'a>,
    index: usize,
) -> Result<TxOut<'a>, SPVError> {
    let n_outs = parse_compact_int(vout)?;
    if index >= n_outs.as_usize() {
        return Err(SPVError::ReadOverrun);
    }

    let mut length = 0;
    let mut offset = n_outs.serialized_length();

    for i in 0..=index {
        length = determine_output_length(&vout[offset..])?;
        if i != index {
            offset += length as usize
        }
    }

    if offset + length as usize > vout.len() {
        return Err(SPVError::ReadOverrun);
    }

    Ok(TxOut(&vout[offset..offset + length]))
}
/// Extracts the output at a given index in the TxIns vector.
///
/// Iterates over the vout. If you need to extract multiple,
/// write a custom function.
///
/// # Arguments
///
/// * `vout` - The vout from which to extract
/// * `index` - The 0-indexed location of the output to extract
///
/// # Errors
///
/// * Errors if CompactInt represents a number larger than 253.  Large CompactInts are not supported.
Extracts the output at a given index in the TxIns vector.
Iterates over the vout. If you need to extract multiple,
write a custom function.
Extracts the output at a given index in the TxIns vector . Iterates over the vout . If you need to extract multiple write a custom function .
pub fn extract_output_at_index<'a>(
    vout: &'a Vout<'a>,
    index: usize,
) -> Result<TxOut<'a>, SPVError> {
    let n_outs = parse_compact_int(vout)?;
    if index >= n_outs.as_usize() {
        return Err(SPVError::ReadOverrun);
    }
    let mut length = 0;
    let mut offset = n_outs.serialized_length();
    for i in 0..=index {
        length = determine_output_length(&vout[offset..])?;
        if i != index {
            offset += length as usize
        }
    }
    if offset + length as usize > vout.len() {
        return Err(SPVError::ReadOverrun);
    }
    Ok(TxOut(&vout[offset..offset + length]))
}
pub fn extract_output_at_index < ' a > ( vout : & ' a Vout < ' a > , index : usize , ) -> Result < TxOut < ' a > , SPVError > { let n_outs = parse_compact_int ( vout ) ? ; if index >= n_outs . as_usize ( ) { return Err ( SPVError :: ReadOverrun ) ; } let mut length = 0 ; let mut offset = n_outs . serialized_length ( ) ; for i in 0 ..= index { length = determine_output_length ( & vout [ offset .. ] ) ? ; if i != index { offset += length as usize } } if offset + length as usize > vout . len ( ) { return Err ( SPVError :: ReadOverrun ) ; } Ok ( TxOut ( & vout [ offset .. offset + length ] ) ) }
Extracts the output at a given index in the TxIns vector.
Extracts the output at a given index in the TxIns vector .
vout
&'a Vout<'a>
index
usize
vout
&'a Vout<'a>
index
usize
errors
Errors if CompactInt represents a number larger than 253.  Large CompactInts are not supported.
Errors if CompactInt represents a number larger than 253 . Large CompactInts are not supported .