RawEnvelope::from_transaction(transaction) .into_iter() .map(|envelope| envelope.into()) .collect() } } impl RawEnvelope { pub(crate) fn from_transaction(transaction: &Transaction) -> Vec { let mut envelopes = Vec::new(); for (i, input) in transaction.input.iter().enumerate() { if let Some(tapscript) = input.witness.tapscript() { if let Ok(input_envelopes) = Self::from_tapscript(tapscript, i) { envelopes.extend(input_envelopes); } } } envelopes } fn from_tapscript(tapscript: &Script, input: usize) -> Result> { let mut envelopes = Vec::new(); let mut instructions = tapscript.instructions(); while let Some(instruction) = instructions.next() { if instruction? == Instruction::PushBytes((&[]).into()) { if let Some(envelope) = Self::from_instructions(&mut instructions, input, envelopes.len())? { envelopes.push(envelope); } } } Ok(envelopes) }