@@ -1777,6 +1777,11 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
17771777 return nil , err
17781778 }
17791779
1780+ lndInfo , err := s .lnd .Client .GetInfo (ctx )
1781+ if err != nil {
1782+ return nil , err
1783+ }
1784+
17801785 // Deposits filtered by state or outpoints.
17811786 var filteredDeposits []* looprpc.Deposit
17821787 if len (outpoints ) > 0 {
@@ -1788,7 +1793,7 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
17881793 }
17891794 return false
17901795 }
1791- filteredDeposits = filter (allDeposits , network , f )
1796+ filteredDeposits = filter (allDeposits , network , lndInfo , f )
17921797
17931798 if len (outpoints ) != len (filteredDeposits ) {
17941799 return nil , fmt .Errorf ("not all outpoints found in " +
@@ -1804,24 +1809,7 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
18041809
18051810 return d .IsInState (toServerState (req .StateFilter ))
18061811 }
1807- filteredDeposits = filter (allDeposits , network , f )
1808- }
1809-
1810- // Calculate the blocks until expiry for each deposit.
1811- lndInfo , err := s .lnd .Client .GetInfo (ctx )
1812- if err != nil {
1813- return nil , err
1814- }
1815-
1816- bestBlockHeight := int64 (lndInfo .BlockHeight )
1817- params , err := s .staticAddressManager .GetStaticAddressParameters (ctx )
1818- if err != nil {
1819- return nil , err
1820- }
1821- for i := 0 ; i < len (filteredDeposits ); i ++ {
1822- filteredDeposits [i ].BlocksUntilExpiry =
1823- filteredDeposits [i ].ConfirmationHeight +
1824- int64 (params .Expiry ) - bestBlockHeight
1812+ filteredDeposits = filter (allDeposits , network , lndInfo , f )
18251813 }
18261814
18271815 return & looprpc.ListStaticAddressDepositsResponse {
@@ -1908,13 +1896,6 @@ func (s *swapClientServer) ListStaticAddressSwaps(ctx context.Context,
19081896 return nil , err
19091897 }
19101898
1911- addrParams , err := s .staticAddressManager .GetStaticAddressParameters (
1912- ctx ,
1913- )
1914- if err != nil {
1915- return nil , err
1916- }
1917-
19181899 // Fetch all deposits at once and index them by swap hash for a quick
19191900 // lookup.
19201901 allDeposits , err := s .depositManager .GetAllDeposits (ctx )
@@ -1953,7 +1934,7 @@ func (s *swapClientServer) ListStaticAddressSwaps(ctx context.Context,
19531934 for _ , d := range ds {
19541935 state := toClientDepositState (d .GetState ())
19551936 blocksUntilExpiry := d .ConfirmationHeight +
1956- int64 (addrParams .Expiry ) -
1937+ int64 (d . AddressParams .Expiry ) -
19571938 int64 (lndInfo .BlockHeight )
19581939
19591940 pd := & looprpc.Deposit {
@@ -2095,7 +2076,7 @@ func (s *swapClientServer) GetStaticAddressSummary(ctx context.Context,
20952076 }
20962077 }
20972078
2098- deprecatedParams , err := s .staticAddressManager .GetStaticAddressParameters (ctx )
2079+ deprecatedParams , err := s .staticAddressManager .GetLegacyParameters (ctx )
20992080 if err != nil {
21002081 return nil , err
21012082 }
@@ -2193,7 +2174,7 @@ func (s *swapClientServer) StaticAddressLoopIn(ctx context.Context,
21932174type filterFunc func (deposits * deposit.Deposit ) bool
21942175
21952176func filter (deposits []* deposit.Deposit , network * chaincfg.Params ,
2196- f filterFunc ) []* looprpc.Deposit {
2177+ lndInfo * lndclient. Info , f filterFunc ) []* looprpc.Deposit {
21972178
21982179 var clientDeposits []* looprpc.Deposit
21992180 for _ , d := range deposits {
@@ -2219,6 +2200,9 @@ func filter(deposits []*deposit.Deposit, network *chaincfg.Params,
22192200 ConfirmationHeight : d .ConfirmationHeight ,
22202201 SwapHash : swapHash ,
22212202 StaticAddress : staticAddr ,
2203+ BlocksUntilExpiry : d .ConfirmationHeight +
2204+ int64 (d .AddressParams .Expiry ) -
2205+ int64 (lndInfo .BlockHeight ),
22222206 }
22232207
22242208 clientDeposits = append (clientDeposits , deposit )
0 commit comments