From b078e5b1913c028c5c52c4625438d077b733e239 Mon Sep 17 00:00:00 2001 From: clothic Date: Fri, 18 Apr 2025 14:42:54 -0500 Subject: [PATCH] wip: audit --- crates/protorune/src/lib.rs | 7 ++++--- crates/protorune/src/protostone.rs | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/protorune/src/lib.rs b/crates/protorune/src/lib.rs index 244db8a74..4e5fe59f7 100644 --- a/crates/protorune/src/lib.rs +++ b/crates/protorune/src/lib.rs @@ -166,7 +166,7 @@ pub fn validate_rune_etch(tx: &Transaction, commitment: Vec, height: u64) -> .get_value(); // add 1 to follow the ordinals spec: https://github.com/ordinals/ord/blob/master/src/index/updater/rune_updater.rs#L454 - let confirmations = height - h + 1; + let confirmations = height.checked_sub(h).unwrap() + 1; if confirmations >= 6 { return Ok(true); } @@ -618,8 +618,9 @@ impl Protorune { .select(&tx_id.as_byte_array().to_vec()) .set_value(txindex as u32); for (_index, input) in transaction.input.iter().enumerate() { - tables::OUTPOINT_SPENDABLE_BY.select(&consensus_encode(&input.previous_output)?).nullify(); - + tables::OUTPOINT_SPENDABLE_BY + .select(&consensus_encode(&input.previous_output)?) + .nullify(); } for (index, output) in transaction.output.iter().enumerate() { let outpoint = OutPoint { diff --git a/crates/protorune/src/protostone.rs b/crates/protorune/src/protostone.rs index 719ddb67e..d1ff5ba8b 100644 --- a/crates/protorune/src/protostone.rs +++ b/crates/protorune/src/protostone.rs @@ -20,6 +20,7 @@ use std::fmt::Write; static mut PROTOCOLS: Option> = None; +// this will reset every time its called #[allow(static_mut_refs)] pub fn initialized_protocol_index() -> Result<()> { unsafe { PROTOCOLS = Some(HashSet::new()) }