fn from_instructions( instructions: &mut Instructions, input: usize, offset: usize, ) -> Result> { if instructions.next().transpose()? != Some(Instruction::Op(opcodes::all::OP_IF)) { return Ok(None); } if instructions.next().transpose()? != Some(Instruction::PushBytes((&PROTOCOL_ID).into())) { return Ok(None); } let mut pushnum = false; let mut payload = Vec::new(); loop { match instructions.next().transpose()? { None => return Ok(None), Some(Instruction::Op(opcodes::all::OP_ENDIF)) => { return Ok(Some(Envelope { input: input.try_into().unwrap(), offset: offset.try_into().unwrap(), payload, pushnum, })); } Some(Instruction::Op(opcodes::all::OP_PUSHNUM_NEG1)) => { pushnum = true; payload.push(vec![0x81]); } Some(Instruction::Op(opcodes::all::OP_PUSHNUM_1)) => { pushnum = true; payload.push(vec![1]);