@@ -1966,6 +1966,10 @@ func (s *swapClientServer) ListStaticAddressSwaps(ctx context.Context,
19661966
19671967 var clientSwaps []* looprpc.StaticAddressLoopInSwap
19681968 for _ , swp := range swaps {
1969+ if swp == nil {
1970+ continue
1971+ }
1972+
19691973 chainParams , err := s .network .ChainParams ()
19701974 if err != nil {
19711975 return nil , fmt .Errorf ("error getting chain params" )
@@ -2005,13 +2009,19 @@ func (s *swapClientServer) ListStaticAddressSwaps(ctx context.Context,
20052009 if swp .SelectedAmount > 0 {
20062010 swapAmount = swp .SelectedAmount
20072011 }
2012+ costServer := staticAddressLoopInSwapServerCost (swp )
2013+ initiationTime := staticAddressLoopInTimestamp (swp .InitiationTime )
2014+ lastUpdateTime := staticAddressLoopInTimestamp (swp .LastUpdateTime )
20082015 swap := & looprpc.StaticAddressLoopInSwap {
20092016 SwapHash : swp .SwapHash [:],
20102017 DepositOutpoints : swp .DepositOutpoints ,
20112018 State : state ,
20122019 SwapAmountSatoshis : int64 (swapAmount ),
20132020 PaymentRequestAmountSatoshis : payReqAmount ,
20142021 Deposits : protoDeposits ,
2022+ InitiationTime : initiationTime ,
2023+ LastUpdateTime : lastUpdateTime ,
2024+ CostServer : costServer ,
20152025 }
20162026
20172027 clientSwaps = append (clientSwaps , swap )
@@ -2022,6 +2032,31 @@ func (s *swapClientServer) ListStaticAddressSwaps(ctx context.Context,
20222032 }, nil
20232033}
20242034
2035+ func staticAddressLoopInTimestamp (t time.Time ) int64 {
2036+ if t .IsZero () {
2037+ return 0
2038+ }
2039+
2040+ return t .UnixNano ()
2041+ }
2042+
2043+ // staticAddressLoopInSwapServerCost returns the paid server cost using the
2044+ // legacy ListSwaps cost semantics. Static loop-ins currently only persist the
2045+ // accepted quote fee, and that fee is paid once the swap invoice settles.
2046+ // Timeout-path miner fees are not persisted, so cost_onchain and cost_offchain
2047+ // remain zero instead of returning an estimate as an actual cost.
2048+ func staticAddressLoopInSwapServerCost (swp * loopin.StaticAddressLoopIn ) int64 {
2049+ switch swp .GetState () {
2050+ case loopin .PaymentReceived , loopin .Succeeded ,
2051+ loopin .SucceededTransitioningFailed :
2052+
2053+ return int64 (swp .QuotedSwapFee )
2054+
2055+ default :
2056+ return 0
2057+ }
2058+ }
2059+
20252060// GetStaticAddressSummary returns a summary of static address-related
20262061// information. Amongst deposits and withdrawals and their total values, it also
20272062// includes a list of detailed deposit information filtered by their state.
0 commit comments