-
Notifications
You must be signed in to change notification settings - Fork 116
/
config.go
237 lines (163 loc) · 6.08 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
package taprootassets
import (
"fmt"
"net"
"net/url"
"time"
"github.com/lightninglabs/lndclient"
"github.com/lightninglabs/taproot-assets/address"
"github.com/lightninglabs/taproot-assets/monitoring"
"github.com/lightninglabs/taproot-assets/proof"
"github.com/lightninglabs/taproot-assets/rfq"
"github.com/lightninglabs/taproot-assets/tapchannel"
"github.com/lightninglabs/taproot-assets/tapdb"
"github.com/lightninglabs/taproot-assets/tapfreighter"
"github.com/lightninglabs/taproot-assets/tapgarden"
"github.com/lightninglabs/taproot-assets/universe"
"github.com/lightningnetwork/lnd"
"github.com/lightningnetwork/lnd/build"
"github.com/lightningnetwork/lnd/signal"
"golang.org/x/time/rate"
"google.golang.org/grpc"
)
// RPCConfig is a sub-config of the main server that packages up everything
// needed to start the RPC server.
type RPCConfig struct {
LisCfg *lnd.ListenerCfg
RPCListeners []net.Addr
RESTListeners []net.Addr
GrpcServerOpts []grpc.ServerOption
RestDialOpts []grpc.DialOption
RestListenFunc func(net.Addr) (net.Listener, error)
WSPingInterval time.Duration
WSPongWait time.Duration
RestCORS []string
NoMacaroons bool
MacaroonPath string
AllowPublicUniProofCourier bool
AllowPublicStats bool
LetsEncryptDir string
LetsEncryptListen string
LetsEncryptDomain string
LetsEncryptEmail string
}
// DatabaseConfig is the config that holds all the persistence related structs
// and interfaces needed for tapd to function.
type DatabaseConfig struct {
RootKeyStore *tapdb.RootKeyStore
MintingStore tapgarden.MintingStore
AssetStore *tapdb.AssetStore
TapAddrBook *tapdb.TapAddressBook
Multiverse *tapdb.MultiverseStore
FederationDB *tapdb.UniverseFederationDB
}
// UniversePublicAccessStatus is a type that indicates the status of public
// access to the universe server.
type UniversePublicAccessStatus string
const (
// UniversePublicAccessStatusNone indicates that no public access is
// granted.
UniversePublicAccessStatusNone UniversePublicAccessStatus = ""
// UniversePublicAccessStatusRead indicates that read access is granted.
UniversePublicAccessStatusRead UniversePublicAccessStatus = "r"
// UniversePublicAccessStatusWrite indicates that write access is
// granted.
UniversePublicAccessStatusWrite UniversePublicAccessStatus = "w"
// UniversePublicAccessStatusReadWrite indicates that read and write
// access is granted.
UniversePublicAccessStatusReadWrite UniversePublicAccessStatus = "rw"
)
// IsReadAccessGranted returns true if the status indicates that read access
// is granted.
func (s UniversePublicAccessStatus) IsReadAccessGranted() bool {
return s == UniversePublicAccessStatusRead ||
s == UniversePublicAccessStatusReadWrite
}
// IsWriteAccessGranted returns true if the status indicates that write access
// is granted.
func (s UniversePublicAccessStatus) IsWriteAccessGranted() bool {
return s == UniversePublicAccessStatusWrite ||
s == UniversePublicAccessStatusReadWrite
}
// ParseUniversePublicAccessStatus parses a string into a universe public access
// status.
func ParseUniversePublicAccessStatus(
s string) (UniversePublicAccessStatus, error) {
switch s {
case "rw", "wr":
return UniversePublicAccessStatusReadWrite, nil
case "r":
return UniversePublicAccessStatusRead, nil
case "w":
return UniversePublicAccessStatusWrite, nil
case "":
return UniversePublicAccessStatusNone, nil
default:
// This default case returns an error. It will capture the case
// where the CLI argument is present but unset (empty value).
return UniversePublicAccessStatusNone, fmt.Errorf("unknown "+
"universe public access status: %s", s)
}
}
// Config is the main config of the Taproot Assets server.
type Config struct {
DebugLevel string
// RuntimeID is a pseudo-random ID that is generated when the server
// starts. It is used to identify the server to itself, to avoid
// connecting to itself as a federation member.
RuntimeID int64
// EnableChannelFeatures indicates that tapd is running inside the
// Lightning Terminal daemon (litd) and can provide Taproot Asset
// channel functionality.
EnableChannelFeatures bool
ChainParams address.ChainParams
Lnd *lndclient.LndServices
SignalInterceptor signal.Interceptor
ReOrgWatcher *tapgarden.ReOrgWatcher
AssetMinter tapgarden.Planter
AssetCustodian *tapgarden.Custodian
ChainBridge tapgarden.ChainBridge
AddrBook *address.Book
// AddrBookDisableSyncer is a flag which, if true, will prevent the
// daemon from trying to sync issuance proofs for unknown assets when
// creating an address.
AddrBookDisableSyncer bool
DefaultProofCourierAddr *url.URL
ProofArchive proof.Archiver
AssetWallet tapfreighter.Wallet
CoinSelect *tapfreighter.CoinSelect
ChainPorter tapfreighter.Porter
UniverseArchive *universe.Archive
UniverseSyncer universe.Syncer
UniverseFederation *universe.FederationEnvoy
// UniFedSyncAllAssets is a flag that indicates whether the
// universe federation syncer should default to syncing all assets.
UniFedSyncAllAssets bool
RfqManager *rfq.Manager
UniverseStats universe.Telemetry
AuxLeafSigner *tapchannel.AuxLeafSigner
AuxFundingController *tapchannel.FundingController
AuxTrafficShaper *tapchannel.AuxTrafficShaper
AuxInvoiceManager *tapchannel.AuxInvoiceManager
AuxChanCloser *tapchannel.AuxChanCloser
AuxSweeper *tapchannel.AuxSweeper
// UniversePublicAccess is a field that indicates the status of public
// access (i.e. read/write) to the universe server.
//
// NOTE: This field does not influence universe federation syncing
// behaviour.
UniversePublicAccess UniversePublicAccessStatus
// UniverseQueriesPerSecond is the maximum number of queries per
// second across the set of active universe queries that is permitted.
// Anything above this starts to get rate limited.
UniverseQueriesPerSecond rate.Limit
// UniverseQueriesBurst is the burst budget for the universe query rate
// limiting.
UniverseQueriesBurst int
Prometheus monitoring.PrometheusConfig
// LogWriter is the root logger that all of the daemon's subloggers are
// hooked up to.
LogWriter *build.RotatingLogWriter
*RPCConfig
*DatabaseConfig
}