mirror of
https://github.com/alexgo-io/bitcoin-indexer.git
synced 2026-01-12 22:43:06 +08:00
fix: imitate overflow behavior
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user