Skip to content

Commit

Permalink
fix: imitate overflow behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalabru committed Feb 2, 2024
1 parent 22eb729 commit 306f850
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions components/ordhook-core/src/core/mod.rs
Expand Up @@ -59,6 +59,12 @@ pub enum SatPosition {
pub fn resolve_absolute_pointer(inputs: &Vec<u64>, absolute_pointer_value: u64) -> (usize, u64) {
let mut selected_index = 0;
let mut cumulated_input_value = 0;
// Check for overflow
let total: u64 = inputs.iter().sum();
if absolute_pointer_value > total {
return (0, 0)
}
// Identify the input + satoshi offset being inscribed
for (index, input_value) in inputs.iter().enumerate() {
if (cumulated_input_value + input_value) > absolute_pointer_value {
selected_index = index;
Expand Down
Expand Up @@ -21,6 +21,12 @@ pub fn parse_inscriptions_from_witness(
witness_bytes: Vec<Vec<u8>>,
txid: &str,
) -> Option<Vec<OrdinalInscriptionRevealData>> {

// Efficient debugging: Isolate one specific transaction
// if !txid.eq("aa2ab56587c7d6609c95157e6dff37c5c3fa6531702f41229a289a5613887077") {
// return None
// }

let witness = Witness::from_slice(&witness_bytes);
let tapscript = witness.tapscript()?;
let envelopes: Vec<Envelope<Inscription>> = RawEnvelope::from_tapscript(tapscript, input_index)
Expand Down

0 comments on commit 306f850

Please sign in to comment.