Skip to content

Commit

Permalink
Fix inputs crash on empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
zolting committed Nov 22, 2024
1 parent 1215dab commit 4c37bf5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion blocks/bitcoin/src/inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ pub fn collect_transaction_inputs(transaction: &Transaction, timestamp: &BlockTi
for (index, input) in transaction.vin.iter().enumerate() {
let script_sig = input.script_sig.as_ref();

let witness_data = if input.txinwitness.len() > 0 { input.txinwitness.clone() } else { vec![String::new()] };

inputs.push(Input {
block_time: Some(timestamp.time),
block_date: timestamp.date.clone(),
Expand All @@ -30,7 +32,7 @@ pub fn collect_transaction_inputs(transaction: &Transaction, timestamp: &BlockTi
script_signature_asm: script_sig.map(|s| s.asm.clone()),
script_signature_hex: script_sig.map(|s| s.hex.clone()),
sequence: input.sequence,
witness_data: input.txinwitness.clone(),
witness_data,
});
}

Expand Down

0 comments on commit 4c37bf5

Please sign in to comment.