@@ -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 {}
@@ -1788,13 +1790,14 @@ func (s *swapClientServer) GetStaticAddressSummary(ctx context.Context,
1788
1790
}
1789
1791
1790
1792
var (
1791
- totalNumDeposits = len (allDeposits )
1792
- valueUnconfirmed int64
1793
- valueDeposited int64
1794
- valueExpired int64
1795
- valueWithdrawn int64
1796
- valueLoopedIn int64
1797
- htlcTimeoutSwept int64
1793
+ totalNumDeposits = len (allDeposits )
1794
+ valueUnconfirmed int64
1795
+ valueDeposited int64
1796
+ valueExpired int64
1797
+ valueWithdrawn int64
1798
+ valueLoopedIn int64
1799
+ valueChannelsOpened int64
1800
+ htlcTimeoutSwept int64
1798
1801
)
1799
1802
1800
1803
// Value unconfirmed.
@@ -1826,6 +1829,9 @@ func (s *swapClientServer) GetStaticAddressSummary(ctx context.Context,
1826
1829
1827
1830
case deposit .HtlcTimeoutSwept :
1828
1831
htlcTimeoutSwept += value
1832
+
1833
+ case deposit .ChannelPublished :
1834
+ valueChannelsOpened += value
1829
1835
}
1830
1836
}
1831
1837
@@ -1850,6 +1856,7 @@ func (s *swapClientServer) GetStaticAddressSummary(ctx context.Context,
1850
1856
ValueExpiredSatoshis : valueExpired ,
1851
1857
ValueWithdrawnSatoshis : valueWithdrawn ,
1852
1858
ValueLoopedInSatoshis : valueLoopedIn ,
1859
+ ValueChannelsOpened : valueChannelsOpened ,
1853
1860
ValueHtlcTimeoutSweepsSatoshis : htlcTimeoutSwept ,
1854
1861
}, nil
1855
1862
}
@@ -1905,6 +1912,35 @@ func (s *swapClientServer) StaticAddressLoopIn(ctx context.Context,
1905
1912
}, nil
1906
1913
}
1907
1914
1915
+ // StaticOpenChannel initiates an open channel request using static address
1916
+ // deposits.
1917
+ func (s * swapClientServer ) StaticOpenChannel (ctx context.Context ,
1918
+ req * looprpc.OpenChannelRequest ) (* looprpc.StaticOpenChannelResponse ,
1919
+ error ) {
1920
+
1921
+ infof ("Static open channel request received" )
1922
+
1923
+ chanOpenTxHash , err := s .openChannelManager .DeliverOpenChannelRequest (
1924
+ ctx , req ,
1925
+ )
1926
+
1927
+ var (
1928
+ txHash string
1929
+ errMsg string
1930
+ )
1931
+ if chanOpenTxHash != nil {
1932
+ txHash = chanOpenTxHash .String ()
1933
+ }
1934
+ if err != nil {
1935
+ errMsg = err .Error ()
1936
+ }
1937
+
1938
+ return & looprpc.StaticOpenChannelResponse {
1939
+ ChannelOpenTxHash : txHash ,
1940
+ Error : errMsg ,
1941
+ }, nil
1942
+ }
1943
+
1908
1944
type filterFunc func (deposits * deposit.Deposit ) bool
1909
1945
1910
1946
func filter (deposits []* deposit.Deposit , f filterFunc ) []* looprpc.Deposit {
@@ -1952,6 +1988,12 @@ func toClientDepositState(state fsm.StateType) looprpc.DepositState {
1952
1988
case deposit .LoopedIn :
1953
1989
return looprpc .DepositState_LOOPED_IN
1954
1990
1991
+ case deposit .OpeningChannel :
1992
+ return looprpc .DepositState_OPENING_CHANNEL
1993
+
1994
+ case deposit .ChannelPublished :
1995
+ return looprpc .DepositState_CHANNEL_PUBLISHED
1996
+
1955
1997
case deposit .SweepHtlcTimeout :
1956
1998
return looprpc .DepositState_SWEEP_HTLC_TIMEOUT
1957
1999
@@ -2031,6 +2073,12 @@ func toServerState(state looprpc.DepositState) fsm.StateType {
2031
2073
case looprpc .DepositState_LOOPED_IN :
2032
2074
return deposit .LoopedIn
2033
2075
2076
+ case looprpc .DepositState_OPENING_CHANNEL :
2077
+ return deposit .OpeningChannel
2078
+
2079
+ case looprpc .DepositState_CHANNEL_PUBLISHED :
2080
+ return deposit .ChannelPublished
2081
+
2034
2082
case looprpc .DepositState_SWEEP_HTLC_TIMEOUT :
2035
2083
return deposit .SweepHtlcTimeout
2036
2084
0 commit comments