@@ -921,24 +921,13 @@ func (s *swapClientServer) GetLoopInQuote(ctx context.Context,
921921 "deposits: %w" , err )
922922 }
923923
924- // TODO(hieblmi): add params to deposit for multi-address
925- // support.
926- params , err := s .staticAddressManager .GetStaticAddressParameters (
927- ctx ,
928- )
929- if err != nil {
930- return nil , fmt .Errorf ("unable to retrieve static " +
931- "address parameters: %w" , err )
932- }
933-
934924 info , err := s .lnd .Client .GetInfo (ctx )
935925 if err != nil {
936926 return nil , fmt .Errorf ("unable to get lnd info: %w" ,
937927 err )
938928 }
939929 selectedDeposits , err := loopin .SelectDeposits (
940- selectedAmount , deposits , params .Expiry ,
941- info .BlockHeight ,
930+ selectedAmount , deposits , info .BlockHeight ,
942931 )
943932 if err != nil {
944933 return nil , fmt .Errorf ("unable to select deposits: %w" ,
@@ -1780,6 +1769,11 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
17801769 return nil , err
17811770 }
17821771
1772+ lndInfo , err := s .lnd .Client .GetInfo (ctx )
1773+ if err != nil {
1774+ return nil , err
1775+ }
1776+
17831777 // Deposits filtered by state or outpoints.
17841778 var filteredDeposits []* looprpc.Deposit
17851779 if len (outpoints ) > 0 {
@@ -1791,7 +1785,7 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
17911785 }
17921786 return false
17931787 }
1794- filteredDeposits = filter (allDeposits , network , f )
1788+ filteredDeposits = filter (allDeposits , network , lndInfo , f )
17951789
17961790 if len (outpoints ) != len (filteredDeposits ) {
17971791 return nil , fmt .Errorf ("not all outpoints found in " +
@@ -1807,24 +1801,7 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
18071801
18081802 return d .IsInState (toServerState (req .StateFilter ))
18091803 }
1810- filteredDeposits = filter (allDeposits , network , f )
1811- }
1812-
1813- // Calculate the blocks until expiry for each deposit.
1814- lndInfo , err := s .lnd .Client .GetInfo (ctx )
1815- if err != nil {
1816- return nil , err
1817- }
1818-
1819- bestBlockHeight := int64 (lndInfo .BlockHeight )
1820- params , err := s .staticAddressManager .GetStaticAddressParameters (ctx )
1821- if err != nil {
1822- return nil , err
1823- }
1824- for i := 0 ; i < len (filteredDeposits ); i ++ {
1825- filteredDeposits [i ].BlocksUntilExpiry =
1826- filteredDeposits [i ].ConfirmationHeight +
1827- int64 (params .Expiry ) - bestBlockHeight
1804+ filteredDeposits = filter (allDeposits , network , lndInfo , f )
18281805 }
18291806
18301807 return & looprpc.ListStaticAddressDepositsResponse {
@@ -1911,13 +1888,6 @@ func (s *swapClientServer) ListStaticAddressSwaps(ctx context.Context,
19111888 return nil , err
19121889 }
19131890
1914- addrParams , err := s .staticAddressManager .GetStaticAddressParameters (
1915- ctx ,
1916- )
1917- if err != nil {
1918- return nil , err
1919- }
1920-
19211891 // Fetch all deposits at once and index them by swap hash for a quick
19221892 // lookup.
19231893 allDeposits , err := s .depositManager .GetAllDeposits (ctx )
@@ -1956,7 +1926,7 @@ func (s *swapClientServer) ListStaticAddressSwaps(ctx context.Context,
19561926 for _ , d := range ds {
19571927 state := toClientDepositState (d .GetState ())
19581928 blocksUntilExpiry := d .ConfirmationHeight +
1959- int64 (addrParams .Expiry ) -
1929+ int64 (d . AddressParams .Expiry ) -
19601930 int64 (lndInfo .BlockHeight )
19611931
19621932 pd := & looprpc.Deposit {
@@ -2098,7 +2068,7 @@ func (s *swapClientServer) GetStaticAddressSummary(ctx context.Context,
20982068 }
20992069 }
21002070
2101- deprecatedParams , err := s .staticAddressManager .GetStaticAddressParameters (ctx )
2071+ deprecatedParams , err := s .staticAddressManager .GetLegacyParameters (ctx )
21022072 if err != nil {
21032073 return nil , err
21042074 }
@@ -2196,7 +2166,7 @@ func (s *swapClientServer) StaticAddressLoopIn(ctx context.Context,
21962166type filterFunc func (deposits * deposit.Deposit ) bool
21972167
21982168func filter (deposits []* deposit.Deposit , network * chaincfg.Params ,
2199- f filterFunc ) []* looprpc.Deposit {
2169+ lndInfo * lndclient. Info , f filterFunc ) []* looprpc.Deposit {
22002170
22012171 var clientDeposits []* looprpc.Deposit
22022172 for _ , d := range deposits {
@@ -2222,6 +2192,9 @@ func filter(deposits []*deposit.Deposit, network *chaincfg.Params,
22222192 ConfirmationHeight : d .ConfirmationHeight ,
22232193 SwapHash : swapHash ,
22242194 StaticAddress : staticAddr ,
2195+ BlocksUntilExpiry : d .ConfirmationHeight +
2196+ int64 (d .AddressParams .Expiry ) -
2197+ int64 (lndInfo .BlockHeight ),
22252198 }
22262199
22272200 clientDeposits = append (clientDeposits , deposit )
0 commit comments