}; fields.entry(tag).or_insert(value); } Self { fields, body } } } impl Runestone { pub fn from_transaction(transaction: &Transaction) -> Option { Self::decipher(transaction).ok().flatten() } fn decipher(transaction: &Transaction) -> Result> { let Some(payload) = Runestone::payload(transaction)? else { return Ok(None); }; let mut integers = Vec::new(); let mut i = 0; while i < payload.len() { let (integer, length) = varint::decode(&payload[i..])?; integers.push(integer); i += length; } let Message { mut fields, body } = Message::from_integers(&integers); let etching = fields.remove(&TAG_RUNE).map(|rune| Etching { divisibility: fields .remove(&TAG_DIVISIBILITY) .and_then(|divisibility| u8::try_from(divisibility).ok()) .and_then(|divisibility| (divisibility <= MAX_DIVISIBILITY).then_some(divisibility)) .unwrap_or_default(), limit: fields .remove(&TAG_LIMIT)