Skip to content

Commit b278b66

Browse files
author
Ludo Galabru
committed
fix: sat offset computation
1 parent dbca70c commit b278b66

File tree

1 file changed

+7
-2
lines changed
  • components/chainhook-event-observer/src/hord/db

1 file changed

+7
-2
lines changed

components/chainhook-event-observer/src/hord/db/mod.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1325,13 +1325,16 @@ pub fn retrieve_satoshi_point_using_lazy_storage(
13251325
}
13261326

13271327
let fee = total_in - total_out;
1328-
accumulated_fees += fee;
1329-
if accumulated_fees > ordinal_offset {
1328+
if accumulated_fees + fee > ordinal_offset {
13301329
// We are looking at the right transaction
13311330
// Retraverse the inputs to select the index to be picked
1331+
let offset_within_fee = ordinal_offset - accumulated_fees;
1332+
total_out += offset_within_fee;
13321333
let mut sats_in = 0;
1334+
13331335
for input in tx.inputs.into_iter() {
13341336
sats_in += input.txin_value;
1337+
13351338
if sats_in >= total_out {
13361339
ordinal_offset = total_out - (sats_in - input.txin_value);
13371340
ordinal_block_number = input.block_height;
@@ -1340,6 +1343,8 @@ pub fn retrieve_satoshi_point_using_lazy_storage(
13401343
}
13411344
}
13421345
break;
1346+
} else {
1347+
accumulated_fees += fee;
13431348
}
13441349
}
13451350
} else {

0 commit comments

Comments
 (0)