@@ -12,6 +12,7 @@ use rayon::prelude::*;
1212use bitcoin:: consensus:: encode:: { deserialize, serialize} ;
1313#[ cfg( feature = "liquid" ) ]
1414use elements:: {
15+ confidential,
1516 encode:: { deserialize, serialize} ,
1617 AssetId ,
1718} ;
@@ -112,9 +113,9 @@ pub struct Utxo {
112113 pub value : Value ,
113114
114115 #[ cfg( feature = "liquid" ) ]
115- pub asset : elements :: confidential:: Asset ,
116+ pub asset : confidential:: Asset ,
116117 #[ cfg( feature = "liquid" ) ]
117- pub nonce : elements :: confidential:: Nonce ,
118+ pub nonce : confidential:: Nonce ,
118119 #[ cfg( feature = "liquid" ) ]
119120 pub witness : elements:: TxOutWitness ,
120121}
@@ -1104,7 +1105,7 @@ fn index_transaction(
11041105 TxHistoryInfo :: Funding ( FundingInfo {
11051106 txid,
11061107 vout : txo_index as u16 ,
1107- value : txo. value . to_sat ( ) ,
1108+ value : txo. value . amount_value ( ) ,
11081109 } ) ,
11091110 ) ;
11101111 rows. push ( history. into_row ( ) ) ;
@@ -1132,7 +1133,7 @@ fn index_transaction(
11321133 vin : txi_index as u16 ,
11331134 prev_txid : full_hash ( & txi. previous_output . txid [ ..] ) ,
11341135 prev_vout : txi. previous_output . vout as u16 ,
1135- value : prev_txo. value . to_sat ( ) ,
1136+ value : prev_txo. value . amount_value ( ) ,
11361137 } ) ,
11371138 ) ;
11381139 rows. push ( history. into_row ( ) ) ;
@@ -1642,3 +1643,25 @@ fn from_utxo_cache(utxos_cache: CachedUtxoMap, chain: &ChainQuery) -> UtxoMap {
16421643 } )
16431644 . collect ( )
16441645}
1646+
1647+ // Get the amount value as gets stored in the DB and mempool tracker.
1648+ // For bitcoin it is the Amount's inner u64, for elements it is the confidential::Value itself.
1649+ pub trait GetAmountVal {
1650+ #[ cfg( not( feature = "liquid" ) ) ]
1651+ fn amount_value ( self ) -> u64 ;
1652+ #[ cfg( feature = "liquid" ) ]
1653+ fn amount_value ( self ) -> confidential:: Value ;
1654+ }
1655+
1656+ #[ cfg( not( feature = "liquid" ) ) ]
1657+ impl GetAmountVal for bitcoin:: Amount {
1658+ fn amount_value ( self ) -> u64 {
1659+ self . to_sat ( )
1660+ }
1661+ }
1662+ #[ cfg( feature = "liquid" ) ]
1663+ impl GetAmountVal for confidential:: Value {
1664+ fn amount_value ( self ) -> confidential:: Value {
1665+ self
1666+ }
1667+ }
0 commit comments