@@ -931,24 +931,13 @@ func (s *swapClientServer) GetLoopInQuote(ctx context.Context,
931931 "deposits: %w" , err )
932932 }
933933
934- // TODO(hieblmi): add params to deposit for multi-address
935- // support.
936- params , err := s .staticAddressManager .GetStaticAddressParameters (
937- ctx ,
938- )
939- if err != nil {
940- return nil , fmt .Errorf ("unable to retrieve static " +
941- "address parameters: %w" , err )
942- }
943-
944934 info , err := s .lnd .Client .GetInfo (ctx )
945935 if err != nil {
946936 return nil , fmt .Errorf ("unable to get lnd info: %w" ,
947937 err )
948938 }
949939 selectedDeposits , err := loopin .SelectDeposits (
950- selectedAmount , deposits , params .Expiry ,
951- info .BlockHeight ,
940+ selectedAmount , deposits , info .BlockHeight ,
952941 )
953942 if err != nil {
954943 return nil , fmt .Errorf ("unable to select deposits: %w" ,
@@ -1792,6 +1781,11 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
17921781 return nil , err
17931782 }
17941783
1784+ lndInfo , err := s .lnd .Client .GetInfo (ctx )
1785+ if err != nil {
1786+ return nil , err
1787+ }
1788+
17951789 // Deposits filtered by state or outpoints.
17961790 var filteredDeposits []* looprpc.Deposit
17971791 if len (outpoints ) > 0 {
@@ -1803,7 +1797,7 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
18031797 }
18041798 return false
18051799 }
1806- filteredDeposits = filter (allDeposits , network , f )
1800+ filteredDeposits = filter (allDeposits , network , lndInfo , f )
18071801
18081802 if len (outpoints ) != len (filteredDeposits ) {
18091803 return nil , fmt .Errorf ("not all outpoints found in " +
@@ -1819,7 +1813,7 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
18191813
18201814 return d .IsInState (toServerState (req .StateFilter ))
18211815 }
1822- filteredDeposits = filter (allDeposits , network , f )
1816+ filteredDeposits = filter (allDeposits , network , lndInfo , f )
18231817 }
18241818
18251819 // Calculate the blocks until expiry for each deposit.
@@ -1912,13 +1906,6 @@ func (s *swapClientServer) ListStaticAddressSwaps(ctx context.Context,
19121906 return nil , err
19131907 }
19141908
1915- addrParams , err := s .staticAddressManager .GetStaticAddressParameters (
1916- ctx ,
1917- )
1918- if err != nil {
1919- return nil , err
1920- }
1921-
19221909 // Fetch all deposits at once and index them by swap hash for a quick
19231910 // lookup.
19241911 allDeposits , err := s .depositManager .GetAllDeposits (ctx )
@@ -1957,7 +1944,7 @@ func (s *swapClientServer) ListStaticAddressSwaps(ctx context.Context,
19571944 for _ , d := range ds {
19581945 state := toClientDepositState (d .GetState ())
19591946 blocksUntilExpiry := d .ConfirmationHeight +
1960- int64 (addrParams .Expiry ) -
1947+ int64 (d . AddressParams .Expiry ) -
19611948 int64 (lndInfo .BlockHeight )
19621949
19631950 pd := & looprpc.Deposit {
@@ -2102,7 +2089,7 @@ func (s *swapClientServer) GetStaticAddressSummary(ctx context.Context,
21022089 }
21032090 }
21042091
2105- deprecatedParams , err := s .staticAddressManager .GetStaticAddressParameters (ctx )
2092+ deprecatedParams , err := s .staticAddressManager .GetLegacyParameters (ctx )
21062093 if err != nil {
21072094 return nil , err
21082095 }
@@ -2186,8 +2173,19 @@ func (s *swapClientServer) StaticAddressLoopIn(ctx context.Context,
21862173 }
21872174
21882175 // Build a list of used deposits for the response.
2176+ network , err := s .network .ChainParams ()
2177+ if err != nil {
2178+ return nil , err
2179+ }
2180+
2181+ lndInfo , err := s .lnd .Client .GetInfo (ctx )
2182+ if err != nil {
2183+ return nil , err
2184+ }
2185+
21892186 usedDeposits := filter (
2190- loopIn .Deposits , func (d * deposit.Deposit ) bool { return true },
2187+ loopIn .Deposits , network , lndInfo ,
2188+ func (d * deposit.Deposit ) bool { return true },
21912189 )
21922190
21932191 err = s .populateBlocksUntilExpiry (ctx , usedDeposits )
@@ -2240,14 +2238,10 @@ func (s *swapClientServer) populateBlocksUntilExpiry(ctx context.Context,
22402238 }
22412239
22422240 bestBlockHeight := int64 (lndInfo .BlockHeight )
2243- params , err := s .staticAddressManager .GetStaticAddressParameters (ctx )
2244- if err != nil {
2245- return err
2246- }
22472241 for i := 0 ; i < len (deposits ); i ++ {
22482242 deposits [i ].BlocksUntilExpiry =
22492243 deposits [i ].ConfirmationHeight +
2250- int64 ( params . Expiry ) - bestBlockHeight
2244+ deposits [ i ]. BlocksUntilExpiry - bestBlockHeight
22512245 }
22522246 return nil
22532247}
@@ -2284,7 +2278,7 @@ func (s *swapClientServer) StaticOpenChannel(ctx context.Context,
22842278type filterFunc func (deposits * deposit.Deposit ) bool
22852279
22862280func filter (deposits []* deposit.Deposit , network * chaincfg.Params ,
2287- f filterFunc ) []* looprpc.Deposit {
2281+ lndInfo * lndclient. Info , f filterFunc ) []* looprpc.Deposit {
22882282
22892283 var clientDeposits []* looprpc.Deposit
22902284 for _ , d := range deposits {
@@ -2310,6 +2304,9 @@ func filter(deposits []*deposit.Deposit, network *chaincfg.Params,
23102304 ConfirmationHeight : d .ConfirmationHeight ,
23112305 SwapHash : swapHash ,
23122306 StaticAddress : staticAddr ,
2307+ BlocksUntilExpiry : d .ConfirmationHeight +
2308+ int64 (d .AddressParams .Expiry ) -
2309+ int64 (lndInfo .BlockHeight ),
23132310 }
23142311
23152312 clientDeposits = append (clientDeposits , deposit )
0 commit comments