@@ -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 {}
@@ -1732,13 +1734,14 @@ func (s *swapClientServer) GetStaticAddressSummary(ctx context.Context,
1732
1734
}
1733
1735
1734
1736
var (
1735
- totalNumDeposits = len (allDeposits )
1736
- valueUnconfirmed int64
1737
- valueDeposited int64
1738
- valueExpired int64
1739
- valueWithdrawn int64
1740
- valueLoopedIn int64
1741
- htlcTimeoutSwept int64
1737
+ totalNumDeposits = len (allDeposits )
1738
+ valueUnconfirmed int64
1739
+ valueDeposited int64
1740
+ valueExpired int64
1741
+ valueWithdrawn int64
1742
+ valueLoopedIn int64
1743
+ valueChannelsOpened int64
1744
+ htlcTimeoutSwept int64
1742
1745
)
1743
1746
1744
1747
// Value unconfirmed.
@@ -1770,6 +1773,9 @@ func (s *swapClientServer) GetStaticAddressSummary(ctx context.Context,
1770
1773
1771
1774
case deposit .HtlcTimeoutSwept :
1772
1775
htlcTimeoutSwept += value
1776
+
1777
+ case deposit .ChannelPublished :
1778
+ valueChannelsOpened += value
1773
1779
}
1774
1780
}
1775
1781
@@ -1794,6 +1800,7 @@ func (s *swapClientServer) GetStaticAddressSummary(ctx context.Context,
1794
1800
ValueExpiredSatoshis : valueExpired ,
1795
1801
ValueWithdrawnSatoshis : valueWithdrawn ,
1796
1802
ValueLoopedInSatoshis : valueLoopedIn ,
1803
+ ValueChannelsOpened : valueChannelsOpened ,
1797
1804
ValueHtlcTimeoutSweepsSatoshis : htlcTimeoutSwept ,
1798
1805
}, nil
1799
1806
}
@@ -1849,6 +1856,35 @@ func (s *swapClientServer) StaticAddressLoopIn(ctx context.Context,
1849
1856
}, nil
1850
1857
}
1851
1858
1859
+ // StaticOpenChannel initiates an open channel request using static address
1860
+ // deposits.
1861
+ func (s * swapClientServer ) StaticOpenChannel (ctx context.Context ,
1862
+ req * looprpc.OpenChannelRequest ) (* looprpc.StaticOpenChannelResponse ,
1863
+ error ) {
1864
+
1865
+ infof ("Static open channel request received" )
1866
+
1867
+ chanOpenTxHash , err := s .openChannelManager .DeliverOpenChannelRequest (
1868
+ ctx , req ,
1869
+ )
1870
+
1871
+ var (
1872
+ txHash string
1873
+ errMsg string
1874
+ )
1875
+ if chanOpenTxHash != nil {
1876
+ txHash = chanOpenTxHash .String ()
1877
+ }
1878
+ if err != nil {
1879
+ errMsg = err .Error ()
1880
+ }
1881
+
1882
+ return & looprpc.StaticOpenChannelResponse {
1883
+ ChannelOpenTxHash : txHash ,
1884
+ Error : errMsg ,
1885
+ }, nil
1886
+ }
1887
+
1852
1888
type filterFunc func (deposits * deposit.Deposit ) bool
1853
1889
1854
1890
func filter (deposits []* deposit.Deposit , f filterFunc ) []* looprpc.Deposit {
@@ -1896,6 +1932,12 @@ func toClientDepositState(state fsm.StateType) looprpc.DepositState {
1896
1932
case deposit .LoopedIn :
1897
1933
return looprpc .DepositState_LOOPED_IN
1898
1934
1935
+ case deposit .OpeningChannel :
1936
+ return looprpc .DepositState_OPENING_CHANNEL
1937
+
1938
+ case deposit .ChannelPublished :
1939
+ return looprpc .DepositState_CHANNEL_PUBLISHED
1940
+
1899
1941
case deposit .SweepHtlcTimeout :
1900
1942
return looprpc .DepositState_SWEEP_HTLC_TIMEOUT
1901
1943
@@ -1975,6 +2017,12 @@ func toServerState(state looprpc.DepositState) fsm.StateType {
1975
2017
case looprpc .DepositState_LOOPED_IN :
1976
2018
return deposit .LoopedIn
1977
2019
2020
+ case looprpc .DepositState_OPENING_CHANNEL :
2021
+ return deposit .OpeningChannel
2022
+
2023
+ case looprpc .DepositState_CHANNEL_PUBLISHED :
2024
+ return deposit .ChannelPublished
2025
+
1978
2026
case looprpc .DepositState_SWEEP_HTLC_TIMEOUT :
1979
2027
return deposit .SweepHtlcTimeout
1980
2028
0 commit comments