Skip to content

Commit 047a1c5

Browse files
committed
Refactor amount and witness handling in Indexer for conditional support of liquid feature
1 parent 5c027ae commit 047a1c5

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/new_index/schema.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use bitcoin::hashes::sha256d::Hash as Sha256dHash;
22
use bitcoin::hex::FromHex;
33
#[cfg(not(feature = "liquid"))]
44
use bitcoin::merkle_tree::MerkleBlock;
5-
use bitcoin::{Amount, Witness};
5+
use bitcoin::Amount;
66
use crypto::digest::Digest;
77
use crypto::sha2::Sha256;
88
use hex;
@@ -625,7 +625,10 @@ impl Indexer {
625625

626626
for (txo_index, txo) in tx.output.iter().enumerate() {
627627
if is_spendable(txo) {
628-
let amount = (txo.value as Amount).to_sat();
628+
#[cfg(not(feature = "liquid"))]
629+
let amount = txo.value.to_sat();
630+
#[cfg(feature = "liquid")]
631+
let amount = txo.value.explicit().unwrap_or(0);
629632
#[allow(deprecated)]
630633
if txo.script_pubkey.is_p2tr()
631634
&& amount >= self.iconfig.sp_min_dust.unwrap_or(1_000) as u64
@@ -666,9 +669,13 @@ impl Indexer {
666669

667670
let prev_txo = lookup_txo(&self.store.txstore_db, &txin.previous_output);
668671
if let Some(prev_txo) = prev_txo {
672+
#[cfg(not(feature = "liquid"))]
673+
let witness_vec = txin.witness.to_vec();
674+
#[cfg(feature = "liquid")]
675+
let witness_vec = txin.witness.script_witness.clone();
669676
match get_pubkey_from_input(
670677
&txin.script_sig.to_bytes(),
671-
&(txin.witness.clone() as Witness).to_vec(),
678+
&witness_vec,
672679
&prev_txo.script_pubkey.to_bytes(),
673680
) {
674681
Ok(Some(pubkey)) => pubkeys.push(pubkey),

0 commit comments

Comments
 (0)