use { super::*, bitcoin::blockdata::{ opcodes, script::{self, Instruction, Instructions}, }, }; pub(crate) const PROTOCOL_ID: [u8; 3] = *b"ord"; pub(crate) const BODY_TAG: [u8; 0] = []; pub(crate) const CONTENT_TYPE_TAG: [u8; 1] = [1]; pub(crate) const POINTER_TAG: [u8; 1] = [2]; pub(crate) const PARENT_TAG: [u8; 1] = [3]; pub(crate) const METADATA_TAG: [u8; 1] = [5]; pub(crate) const METAPROTOCOL_TAG: [u8; 1] = [7]; pub(crate) const CONTENT_ENCODING_TAG: [u8; 1] = [9]; type Result = std::result::Result; type RawEnvelope = Envelope>>; pub(crate) type ParsedEnvelope = Envelope; #[derive(Debug, Default, PartialEq, Clone)] pub(crate) struct Envelope { pub(crate) payload: T, pub(crate) input: u32, pub(crate) offset: u32, pub(crate) pushnum: bool, } fn remove_field(fields: &mut BTreeMap<&[u8], Vec<&[u8]>>, field: &[u8]) -> Option> { let values = fields.get_mut(field)?; if values.is_empty() { None } else { let value = values.remove(0).to_vec();