@@ -1314,7 +1314,16 @@ async fn update_tables_from_transaction_inputs<T: ApiServerStorageWrite>(
1314
1314
)
1315
1315
. await ;
1316
1316
}
1317
- TxOutput :: Htlc ( _, _) => { } // TODO(HTLC)
1317
+ TxOutput :: Htlc ( _, htlc) => {
1318
+ let address =
1319
+ Address :: < Destination > :: new ( & chain_config, htlc. spend_key )
1320
+ . expect ( "Unable to encode destination" ) ;
1321
+
1322
+ address_transactions
1323
+ . entry ( address. clone ( ) )
1324
+ . or_default ( )
1325
+ . insert ( tx. get_id ( ) ) ;
1326
+ }
1318
1327
TxOutput :: LockThenTransfer ( output_value, destination, _)
1319
1328
| TxOutput :: Transfer ( output_value, destination) => {
1320
1329
let address = Address :: < Destination > :: new ( & chain_config, destination)
@@ -1729,7 +1738,27 @@ async fn update_tables_from_transaction_outputs<T: ApiServerStorageWrite>(
1729
1738
. expect ( "Unable to set locked utxo" ) ;
1730
1739
}
1731
1740
}
1732
- TxOutput :: Htlc ( _, _) => { } // TODO(HTLC)
1741
+ TxOutput :: Htlc ( output_value, htlc) => {
1742
+ let address = Address :: < Destination > :: new ( & chain_config, htlc. spend_key . clone ( ) )
1743
+ . expect ( "Unable to encode destination" ) ;
1744
+
1745
+ address_transactions. entry ( address. clone ( ) ) . or_default ( ) . insert ( transaction_id) ;
1746
+
1747
+ let token_decimals = match output_value {
1748
+ OutputValue :: Coin ( _) | OutputValue :: TokenV0 ( _) => None ,
1749
+ OutputValue :: TokenV1 ( token_id, _) => {
1750
+ Some ( token_decimals ( * token_id, & BTreeMap :: new ( ) , db_tx) . await ?. 1 )
1751
+ }
1752
+ } ;
1753
+
1754
+ let outpoint =
1755
+ UtxoOutPoint :: new ( OutPointSourceId :: Transaction ( transaction_id) , idx as u32 ) ;
1756
+ let utxo = Utxo :: new ( output. clone ( ) , token_decimals, false ) ;
1757
+ db_tx
1758
+ . set_utxo_at_height ( outpoint, utxo, address. as_str ( ) , block_height)
1759
+ . await
1760
+ . expect ( "Unable to set utxo" ) ;
1761
+ }
1733
1762
TxOutput :: CreateOrder ( _) => {
1734
1763
// TODO(orders)
1735
1764
}
@@ -1932,7 +1961,7 @@ fn get_tx_output_destination(txo: &TxOutput) -> Option<&Destination> {
1932
1961
| TxOutput :: Burn ( _)
1933
1962
| TxOutput :: DelegateStaking ( _, _)
1934
1963
| TxOutput :: DataDeposit ( _)
1964
+ | TxOutput :: Htlc ( _, _)
1935
1965
| TxOutput :: CreateOrder ( _) => None ,
1936
- TxOutput :: Htlc ( _, _) => None , // TODO(HTLC)
1937
1966
}
1938
1967
}
0 commit comments