@@ -32,6 +32,7 @@ import (
32
32
"github.com/lightninglabs/loop/staticaddr/address"
33
33
"github.com/lightninglabs/loop/staticaddr/deposit"
34
34
"github.com/lightninglabs/loop/staticaddr/loopin"
35
+ "github.com/lightninglabs/loop/staticaddr/openchannel"
35
36
"github.com/lightninglabs/loop/staticaddr/withdraw"
36
37
"github.com/lightninglabs/loop/swap"
37
38
"github.com/lightninglabs/loop/swapserverrpc"
@@ -97,6 +98,7 @@ type swapClientServer struct {
97
98
depositManager * deposit.Manager
98
99
withdrawalManager * withdraw.Manager
99
100
staticLoopInManager * loopin.Manager
101
+ openChannelManager * openchannel.Manager
100
102
assetClient * assets.TapdClient
101
103
swaps map [lntypes.Hash ]loop.SwapInfo
102
104
subscribers map [int ]chan <- interface {}
@@ -1974,13 +1976,14 @@ func (s *swapClientServer) GetStaticAddressSummary(ctx context.Context,
1974
1976
}
1975
1977
1976
1978
var (
1977
- totalNumDeposits = len (allDeposits )
1978
- valueUnconfirmed int64
1979
- valueDeposited int64
1980
- valueExpired int64
1981
- valueWithdrawn int64
1982
- valueLoopedIn int64
1983
- htlcTimeoutSwept int64
1979
+ totalNumDeposits = len (allDeposits )
1980
+ valueUnconfirmed int64
1981
+ valueDeposited int64
1982
+ valueExpired int64
1983
+ valueWithdrawn int64
1984
+ valueLoopedIn int64
1985
+ valueChannelsOpened int64
1986
+ htlcTimeoutSwept int64
1984
1987
)
1985
1988
1986
1989
// Value unconfirmed.
@@ -2012,6 +2015,9 @@ func (s *swapClientServer) GetStaticAddressSummary(ctx context.Context,
2012
2015
2013
2016
case deposit .HtlcTimeoutSwept :
2014
2017
htlcTimeoutSwept += value
2018
+
2019
+ case deposit .ChannelPublished :
2020
+ valueChannelsOpened += value
2015
2021
}
2016
2022
}
2017
2023
@@ -2036,6 +2042,7 @@ func (s *swapClientServer) GetStaticAddressSummary(ctx context.Context,
2036
2042
ValueExpiredSatoshis : valueExpired ,
2037
2043
ValueWithdrawnSatoshis : valueWithdrawn ,
2038
2044
ValueLoopedInSatoshis : valueLoopedIn ,
2045
+ ValueChannelsOpened : valueChannelsOpened ,
2039
2046
ValueHtlcTimeoutSweepsSatoshis : htlcTimeoutSwept ,
2040
2047
}, nil
2041
2048
}
@@ -2093,6 +2100,35 @@ func (s *swapClientServer) StaticAddressLoopIn(ctx context.Context,
2093
2100
}, nil
2094
2101
}
2095
2102
2103
+ // StaticOpenChannel initiates an open channel request using static address
2104
+ // deposits.
2105
+ func (s * swapClientServer ) StaticOpenChannel (ctx context.Context ,
2106
+ req * looprpc.OpenChannelRequest ) (* looprpc.StaticOpenChannelResponse ,
2107
+ error ) {
2108
+
2109
+ infof ("Static open channel request received" )
2110
+
2111
+ chanOpenTxHash , err := s .openChannelManager .DeliverOpenChannelRequest (
2112
+ ctx , req ,
2113
+ )
2114
+
2115
+ var (
2116
+ txHash string
2117
+ errMsg string
2118
+ )
2119
+ if chanOpenTxHash != nil {
2120
+ txHash = chanOpenTxHash .String ()
2121
+ }
2122
+ if err != nil {
2123
+ errMsg = err .Error ()
2124
+ }
2125
+
2126
+ return & looprpc.StaticOpenChannelResponse {
2127
+ ChannelOpenTxHash : txHash ,
2128
+ Error : errMsg ,
2129
+ }, nil
2130
+ }
2131
+
2096
2132
type filterFunc func (deposits * deposit.Deposit ) bool
2097
2133
2098
2134
func filter (deposits []* deposit.Deposit , f filterFunc ) []* looprpc.Deposit {
@@ -2146,6 +2182,12 @@ func toClientDepositState(state fsm.StateType) looprpc.DepositState {
2146
2182
case deposit .LoopedIn :
2147
2183
return looprpc .DepositState_LOOPED_IN
2148
2184
2185
+ case deposit .OpeningChannel :
2186
+ return looprpc .DepositState_OPENING_CHANNEL
2187
+
2188
+ case deposit .ChannelPublished :
2189
+ return looprpc .DepositState_CHANNEL_PUBLISHED
2190
+
2149
2191
case deposit .SweepHtlcTimeout :
2150
2192
return looprpc .DepositState_SWEEP_HTLC_TIMEOUT
2151
2193
@@ -2225,6 +2267,12 @@ func toServerState(state looprpc.DepositState) fsm.StateType {
2225
2267
case looprpc .DepositState_LOOPED_IN :
2226
2268
return deposit .LoopedIn
2227
2269
2270
+ case looprpc .DepositState_OPENING_CHANNEL :
2271
+ return deposit .OpeningChannel
2272
+
2273
+ case looprpc .DepositState_CHANNEL_PUBLISHED :
2274
+ return deposit .ChannelPublished
2275
+
2228
2276
case looprpc .DepositState_SWEEP_HTLC_TIMEOUT :
2229
2277
return deposit .SweepHtlcTimeout
2230
2278
0 commit comments