@@ -81,12 +81,38 @@ type Client struct {
8181 clientConfig
8282}
8383
84- // NewClient returns a new instance to initiate swaps with.
85- func NewClient (dbDir string , serverAddress , proxyAddress string , insecure bool ,
86- tlsPathServer string , lnd * lndclient.LndServices , maxLSATCost ,
87- maxLSATFee btcutil.Amount ) (* Client , func (), error ) {
84+ // ClientConfig is the exported configuration structure that is required to
85+ // instantiate the loop client.
86+ type ClientConfig struct {
87+ // ServerAddress is the loop server to connect to.
88+ ServerAddress string
89+
90+ // ProxyAddress is the SOCKS proxy that should be used to establish the
91+ // connection.
92+ ProxyAddress string
93+
94+ // Insecure skips TLS when set.
95+ Insecure bool
96+
97+ // TLSPathServer is the path to the TLS certificate that is required to
98+ // connect to the server.
99+ TLSPathServer string
100+
101+ // Lnd is an instance of the lnd proxy.
102+ Lnd * lndclient.LndServices
88103
89- store , err := loopdb .NewBoltSwapStore (dbDir , lnd .ChainParams )
104+ // MaxLsatCost is the maximum price we are willing to pay to the server
105+ // for the token.
106+ MaxLsatCost btcutil.Amount
107+
108+ // MaxLsatFee is the maximum that we are willing to pay in routing fees
109+ // to obtain the token.
110+ MaxLsatFee btcutil.Amount
111+ }
112+
113+ // NewClient returns a new instance to initiate swaps with.
114+ func NewClient (dbDir string , cfg * ClientConfig ) (* Client , func (), error ) {
115+ store , err := loopdb .NewBoltSwapStore (dbDir , cfg .Lnd .ChainParams )
90116 if err != nil {
91117 return nil , nil , err
92118 }
@@ -95,16 +121,13 @@ func NewClient(dbDir string, serverAddress, proxyAddress string, insecure bool,
95121 return nil , nil , err
96122 }
97123
98- swapServerClient , err := newSwapServerClient (
99- serverAddress , proxyAddress , insecure , tlsPathServer , lsatStore ,
100- lnd , maxLSATCost , maxLSATFee ,
101- )
124+ swapServerClient , err := newSwapServerClient (cfg , lsatStore )
102125 if err != nil {
103126 return nil , nil , err
104127 }
105128
106129 config := & clientConfig {
107- LndServices : lnd ,
130+ LndServices : cfg . Lnd ,
108131 Server : swapServerClient ,
109132 Store : store ,
110133 LsatStore : lsatStore ,
@@ -114,11 +137,11 @@ func NewClient(dbDir string, serverAddress, proxyAddress string, insecure bool,
114137 }
115138
116139 sweeper := & sweep.Sweeper {
117- Lnd : lnd ,
140+ Lnd : cfg . Lnd ,
118141 }
119142
120143 executor := newExecutor (& executorConfig {
121- lnd : lnd ,
144+ lnd : cfg . Lnd ,
122145 store : store ,
123146 sweeper : sweeper ,
124147 createExpiryTimer : config .CreateExpiryTimer ,
@@ -127,7 +150,7 @@ func NewClient(dbDir string, serverAddress, proxyAddress string, insecure bool,
127150 client := & Client {
128151 errChan : make (chan error ),
129152 clientConfig : * config ,
130- lndServices : lnd ,
153+ lndServices : cfg . Lnd ,
131154 sweeper : sweeper ,
132155 executor : executor ,
133156 resumeReady : make (chan struct {}),
0 commit comments