@@ -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 {}
@@ -1725,13 +1727,14 @@ func (s *swapClientServer) GetStaticAddressSummary(ctx context.Context,
1725
1727
}
1726
1728
1727
1729
var (
1728
- totalNumDeposits = len (allDeposits )
1729
- valueUnconfirmed int64
1730
- valueDeposited int64
1731
- valueExpired int64
1732
- valueWithdrawn int64
1733
- valueLoopedIn int64
1734
- htlcTimeoutSwept int64
1730
+ totalNumDeposits = len (allDeposits )
1731
+ valueUnconfirmed int64
1732
+ valueDeposited int64
1733
+ valueExpired int64
1734
+ valueWithdrawn int64
1735
+ valueLoopedIn int64
1736
+ valueChannelsOpened int64
1737
+ htlcTimeoutSwept int64
1735
1738
)
1736
1739
1737
1740
// Value unconfirmed.
@@ -1763,6 +1766,9 @@ func (s *swapClientServer) GetStaticAddressSummary(ctx context.Context,
1763
1766
1764
1767
case deposit .HtlcTimeoutSwept :
1765
1768
htlcTimeoutSwept += value
1769
+
1770
+ case deposit .ChannelPublished :
1771
+ valueChannelsOpened += value
1766
1772
}
1767
1773
}
1768
1774
@@ -1787,6 +1793,7 @@ func (s *swapClientServer) GetStaticAddressSummary(ctx context.Context,
1787
1793
ValueExpiredSatoshis : valueExpired ,
1788
1794
ValueWithdrawnSatoshis : valueWithdrawn ,
1789
1795
ValueLoopedInSatoshis : valueLoopedIn ,
1796
+ ValueChannelsOpened : valueChannelsOpened ,
1790
1797
ValueHtlcTimeoutSweepsSatoshis : htlcTimeoutSwept ,
1791
1798
}, nil
1792
1799
}
@@ -1842,6 +1849,35 @@ func (s *swapClientServer) StaticAddressLoopIn(ctx context.Context,
1842
1849
}, nil
1843
1850
}
1844
1851
1852
+ // StaticOpenChannel initiates an open channel request using static address
1853
+ // deposits.
1854
+ func (s * swapClientServer ) StaticOpenChannel (ctx context.Context ,
1855
+ req * looprpc.OpenChannelRequest ) (* looprpc.StaticOpenChannelResponse ,
1856
+ error ) {
1857
+
1858
+ infof ("Static open channel request received" )
1859
+
1860
+ chanOpenTxHash , err := s .openChannelManager .DeliverOpenChannelRequest (
1861
+ ctx , req ,
1862
+ )
1863
+
1864
+ var (
1865
+ txHash string
1866
+ errMsg string
1867
+ )
1868
+ if chanOpenTxHash != nil {
1869
+ txHash = chanOpenTxHash .String ()
1870
+ }
1871
+ if err != nil {
1872
+ errMsg = err .Error ()
1873
+ }
1874
+
1875
+ return & looprpc.StaticOpenChannelResponse {
1876
+ ChannelOpenTxHash : txHash ,
1877
+ Error : errMsg ,
1878
+ }, nil
1879
+ }
1880
+
1845
1881
type filterFunc func (deposits * deposit.Deposit ) bool
1846
1882
1847
1883
func filter (deposits []* deposit.Deposit , f filterFunc ) []* looprpc.Deposit {
@@ -1889,6 +1925,12 @@ func toClientDepositState(state fsm.StateType) looprpc.DepositState {
1889
1925
case deposit .LoopedIn :
1890
1926
return looprpc .DepositState_LOOPED_IN
1891
1927
1928
+ case deposit .OpeningChannel :
1929
+ return looprpc .DepositState_OPENING_CHANNEL
1930
+
1931
+ case deposit .ChannelPublished :
1932
+ return looprpc .DepositState_CHANNEL_PUBLISHED
1933
+
1892
1934
case deposit .SweepHtlcTimeout :
1893
1935
return looprpc .DepositState_SWEEP_HTLC_TIMEOUT
1894
1936
@@ -1968,6 +2010,12 @@ func toServerState(state looprpc.DepositState) fsm.StateType {
1968
2010
case looprpc .DepositState_LOOPED_IN :
1969
2011
return deposit .LoopedIn
1970
2012
2013
+ case looprpc .DepositState_OPENING_CHANNEL :
2014
+ return deposit .OpeningChannel
2015
+
2016
+ case looprpc .DepositState_CHANNEL_PUBLISHED :
2017
+ return deposit .ChannelPublished
2018
+
1971
2019
case looprpc .DepositState_SWEEP_HTLC_TIMEOUT :
1972
2020
return deposit .SweepHtlcTimeout
1973
2021
0 commit comments