/// Extracts the data from an op return output.
/// Errors if no data or not an op return.
///
/// # Arguments
///
/// * `spk` - The script pubkey extracted from the output
///
/// # Errors
///
/// * Errors if the spk is not a properly formatted op return
Extracts the data from an op return output.
Errors if no data or not an op return.
Extracts the data from an op return output . Errors if no data or not an op return .
pub fn extract_op_return_data<'a>(
    spk: &'a ScriptPubkey<'a>,
) -> Result<OpReturnPayload<'a>, SPVError> {
    if spk[1] == 0x6a {
        let data_len = spk[2] as usize;
        if data_len + 3 > spk.len() {
            return Err(SPVError::ReadOverrun);
        }
        Ok(OpReturnPayload(&spk[3..3 + data_len]))
    } else {
        Err(SPVError::MalformattedOpReturnOutput)
    }
}
pub fn extract_op_return_data < ' a > ( spk : & ' a ScriptPubkey < ' a > , ) -> Result < OpReturnPayload < ' a > , SPVError > { if spk [ 1 ] == 0x6a { let data_len = spk [ 2 ] as usize ; if data_len + 3 > spk . len ( ) { return Err ( SPVError :: ReadOverrun ) ; } Ok ( OpReturnPayload ( & spk [ 3 .. 3 + data_len ] ) ) } else { Err ( SPVError :: MalformattedOpReturnOutput ) } }
Extracts the data from an op return output.
Extracts the data from an op return output .
spk
&'a ScriptPubkey<'a>
errors
Errors if the spk is not a properly formatted op return
Errors if the spk is not a properly formatted op return