Commit Graph

286 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
5d1574f566
Merge pull request #2522 from roeierez/cleanup_server_error
Cleanup in case of server failed to start
2021-04-22 13:00:22 -07:00
Olaoluwa Osuntokun
25dfbc4106
Merge pull request #5193 from wpaulino/neutrino-assume-valid
Use routing.assumechanvalid=true by default in Neutrino mode
2021-04-13 15:37:51 -07:00
Roei Erez
65ab3dbfc8 server: better way to clean chainControl resources
In this commit the location of where chain control services
are stopped is shifted to be closer to the point they are started.
Stopping of two services: "wallet" and "feeEstimator" that are started
inside the "newChainControlFromConfig" was shifted from server.go to
the cleanup function.

In addition the chainView.Stop was also removed from the server.Stop as
it is already handled by the router, where it is being started.
2021-04-13 13:45:28 +03:00
Wilmer Paulino
82fe5d9bba
build: update btcwallet dependency introducing pruned bitcoind support
This is achieved by some recent work within the BitcoindClient enabling
it to retrieve pruned blocks from its server's peers.
2021-04-06 14:55:14 -07:00
Johan T. Halseth
321141600e
mobile/bindings: update API for falafel v0.8.1 2021-04-06 10:49:50 +02:00
Johan T. Halseth
db28e7c891
lnd: consolidate WalletUnlocker- and AdminAuthOptions 2021-04-06 10:49:45 +02:00
Jonathan Underwood
786568fa46
cert: allow cert expiry to be set in config 2021-04-05 20:23:33 -07:00
Olaoluwa Osuntokun
1ccf6ed7d4
Merge pull request #5063 from Crypt-iQ/pprof_patch_03022021
lnd: optionally serve pprof on localhost for better security
2021-04-05 20:20:39 -07:00
Wilmer Paulino
f38bf4d7fa
lnwallet: expose required account parameter for WalletController methods 2021-04-05 15:41:05 -07:00
eugene
8b463fbc2b
lnd: optionally listen on localhost for better security
The --profile flag now accepts both a port and a host:port string.
If profile is set to a port, then pprof debugging information will
be served over localhost. Otherwise, we will attempt to serve pprof
information on the specified host:port (if we are allowed to listen
on it.)

We default to the safe option as if the port is connectable, anybody
can connect and see debugging information.

See: https://mmcloughlin.com/posts/your-pprof-is-showing
2021-04-01 12:14:24 -04:00
Oliver Gugger
368743c9cb
lnd: turn off channel validation for Neutrino by default
Downloading every block that contains a channel point takes a very long
time when syncing the graph on mainnet with Neutrino. Therefore it makes
sense to use routing.assumechanvalid=true since by using Neutrino a user
already accepts the different trust model.
Apparently the existence or meaning of the routing.assumechanvalid flag
is unknown to a lot of users and is overlooked.
This commit basically sets the default to routing.assumechanvalid=true
for Neutrino. Because the CLI library doesn't support setting a bool
value to false by the user if the default is true, we need to add an
additional flag that is the inverse of the routing one, just for the
case where a Neutrino user explicitly wants to turn on channel
validation.
2021-03-30 15:19:05 +02:00
Hampus Sjöberg
ada1bc701c signal: handle shutdown properly
This addresses issues related to the mobile lnd builds, where
calling `stopDaemon` and subsequently calling LndMobile's `Start`
results in crash.
2021-03-18 12:54:25 +01:00
Johan T. Halseth
9ef556624e
lnrpc: add StateService 2021-03-17 12:09:38 +01:00
Johan T. Halseth
ad6673c21d
lnd: close MacResponseChan when wallet is unlocked
After unification of the WalletUnlocker and RPC services on the same gRPC
server, the WalletUnlocker will no longer be shut down after the wallet
has been unlocked.

In case --no-macaroons was used, this lead to the caller getting stuck
after unlocking the wallet, since we would wait for a response on the
MacResponseChan. Earlier we would close the MacResponseChan always
when shutting down the WalletUnlocker, but this is no longer done.

To fix this we close this channel after the wallet is unlocked,
regardless of which combination of --no-macaroons and --noseedbackup
that is being used.
2021-03-16 14:47:02 +01:00
Johan T. Halseth
2877511fce
rpcperms+lnd: gate RPC calls on RPC state
This commit makes us gate the calls to the RPC servers according to the
current RPC state. This ensures we won't try to call the RPC server
before it has been fully initialized, and that we won't call the
walletUnlocker after the wallet already has been unlocked.
2021-03-11 13:05:24 +01:00
Johan T. Halseth
4bbf5c4b6d
rpcserver: use same grpc server for both services
This commit achieves what we have been building up to: running the
WalletUnlockerService and the LightningService on the same gRPC server
simultaneously!

To achieve this, we first create the RPC server in a "interface only"
way, only creating the struct and setting the dependencies we have
available before the wallet has been unlocked. After the wallet has been
unlocked and we have created all the subsystems we need, we add those to
the RPC server, and start the sub-servers.

This means that the WalletUnlockerService and the LightningService both
will be registered and available at all times on the gRPC server.
However, before the wallet has been unlocked, the LightningService
should not be used since the RPC server is not yet ready to handle the
calls. Similarly, after the wallet has been unlocked, the
WalletUnlockerService should not be used. This we will ensure in
following commits.
2021-03-11 13:05:24 +01:00
Johan T. Halseth
82fb22eda2
lnd+rpc: define external subserver config only once
We don't have to define the external subserver config more than once, so
it is not needed to be defined for every listener. Instead we move it to
the ListenerConfig.
2021-03-11 13:05:24 +01:00
Johan T. Halseth
3c81a5dd73
rpcperms: add RPC interceptor chain
This adds a new package rpcperms which houses the InterceptorChain
struct.  This is a central place where we'll craft interceptors to use
for the GRPC server, which includes macaroon enforcement.

This let us add the interceptor chain to the GRPC server before the
macaroon service is ready, allowing us to avoid tearing down the GRPC
server after the wallet has been unlocked.
2021-03-11 13:05:23 +01:00
Oliver Gugger
03a21367d3
lnd+walletunlocker: move history drop to unlocker
Apparently dropping the wallet transaction history only fully takes
effect after opening the wallet from scratch again. To do this cleanly,
we need to do it in the unlocker instead of lnd.
2020-12-15 21:34:12 +01:00
Yong
582b164c46
kvdb: add timeout options for bbolt (#4787)
* mod: bump btcwallet version to accept db timeout

* btcwallet: add DBTimeOut in config

* kvdb: add database timeout option for bbolt

This commit adds a DBTimeout option in bbolt config. The relevant
functions walletdb.Open/Create are updated to use this config. In
addition, the bolt compacter also applies the new timeout option.

* channeldb: add DBTimeout in db options

This commit adds the DBTimeout option for channeldb. A new unit
test file is created to test the default options. In addition,
the params used in kvdb.Create inside channeldb_test is updated
with a DefaultDBTimeout value.

* contractcourt+routing: use DBTimeout in kvdb

This commit touches multiple test files in contractcourt and routing.
The call of function kvdb.Create and kvdb.Open are now updated with
the new param DBTimeout, using the default value kvdb.DefaultDBTimeout.

* lncfg: add DBTimeout option in db config

The DBTimeout option is added to db config. A new unit test is
added to check the default DB config is created as expected.

* migration: add DBTimeout param in kvdb.Create/kvdb.Open

* keychain: update tests to use DBTimeout param

* htlcswitch+chainreg: add DBTimeout option

* macaroons: support DBTimeout config in creation

This commit adds the DBTimeout during the creation of macaroons.db.
The usage of kvdb.Create and kvdb.Open in its tests are updated with
a timeout value using kvdb.DefaultDBTimeout.

* walletunlocker: add dbTimeout option in UnlockerService

This commit adds a new param, dbTimeout, during the creation of
UnlockerService. This param is then passed to wallet.NewLoader
inside various service calls, specifying a timeout value to be
used when opening the bbolt. In addition, the macaroonService
is also called with this dbTimeout param.

* watchtower/wtdb: add dbTimeout param during creation

This commit adds the dbTimeout param for the creation of both
watchtower.db and wtclient.db.

* multi: add db timeout param for walletdb.Create

This commit adds the db timeout param for the function call
walletdb.Create. It touches only the test files found in chainntnfs,
lnwallet, and routing.

* lnd: pass DBTimeout config to relevant services

This commit enables lnd to pass the DBTimeout config to the following
services/config/functions,
  - chainControlConfig
  - walletunlocker
  - wallet.NewLoader
  - macaroons
  - watchtower
In addition, the usage of wallet.Create is updated too.

* sample-config: add dbtimeout option
2020-12-07 15:31:49 -08:00
Conner Fromknecht
e9b5b2d767
Merge pull request #4793 from murtyjones/cosmetic/add-newline-to-log
Cosmetic: Add newline to end of log statement
2020-12-01 16:44:24 -08:00
Oliver Gugger
76d2c49a17
lnd: fix Onion v2 support for Neutrino backends
With this commit we make it possible to use an Onion v2 hidden service
address as the Neutrino backend.
This failed before because an .onion address cannot be looked up and
converted into an IP address through the normal DNS resolving process,
even when using a Tor socks proxy.
Instead, we turn any v2 .onion address into a fake IPv6 representation
before giving it to Neutrino's address manager and turn it back into an
Onion host address when actually dialing.
2020-11-30 22:42:57 +01:00
Conner Fromknecht
82a238317c
lncfg+itest: expose configurable batch-commit-interval
This will permit a greater degree of tuning or customization depending
on various hardware/environmental factors.
2020-11-25 16:45:25 -08:00
Marty Jones
b06e0c648e Add newline to end of log statement 2020-11-23 08:37:42 -05:00
Oliver Gugger
f8907fdb47
multi: add AutoCompact option to bolt backend
With this commit we thread the new AutoCompact flags all the way through
to the bolt backend.
2020-11-13 10:19:49 +01:00
carla
61777c41e4
lnd: return missing shutdown parameter 2020-11-12 09:12:32 +02:00
Olaoluwa Osuntokun
58f72df94a
Merge pull request #4715 from guggero/reset-wallet
Implement btcwallet's "dropwtxmgr" command as --reset-wallet-transactions flag
2020-11-11 19:50:21 -08:00
Johan T. Halseth
5be7e710c7
RPC: Add --notls to disable TLS for RPC endpoints
Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
2020-11-11 09:37:52 +01:00
Johan T. Halseth
a2a924e1e5
rpcserver: move TLS listen config to closure 2020-11-11 09:37:52 +01:00
Oliver Gugger
e7aa9256ab
walletunlocker+lnd: implement stateless wallet initialization 2020-11-07 11:24:34 +01:00
Oliver Gugger
b685a97fcd
lnd: shutdown wallet unlocker after macaroon creation
Because we'll need to return the macaroon through the wallet unlocker
we cannot shut down its service before we have done so, otherwise
we'll end up in a deadlock. That's why we collect all shutdown
tasks and return them as a function that can be called after we've
initialized the macaroon service.
2020-11-07 11:24:34 +01:00
Oliver Gugger
71ba2a8e60
lnd: prepare for proper wallet unlocker cleanup
As a preparation for the next commit where we add proper wallet unlocker
shutdown handling, we move the calls that require cleanup down after the
creation of the wallet unlocker service itself.
2020-11-07 11:24:33 +01:00
Oliver Gugger
294cb4a966
macaroons: remember stateless init
To make sure no macaroons are created anywhere if the stateless
initialization was requested, we keep the requested initialization mode
in the memory of the macaroon service.
2020-11-07 11:24:33 +01:00
Oliver Gugger
a7c81eb595
lnd: drop wallet transactions if flag is set
To force a full chain rescan, the wallet can now be instructed to drop
its full transaction history on startup.
2020-11-04 09:12:24 +01:00
Eugene
bebe258e2d chainregistry+lnd: moving chainregistry+chainparams to new package 2020-10-29 15:24:14 -04:00
Eugene
46ef212de4 lnd+lncfg: move normalizeNetwork to lncfg 2020-10-29 15:20:00 -04:00
Eugene
4d238cfa2f lnd: export ChainControl, ChainRegistry 2020-10-29 15:20:00 -04:00
Eugene
f4fe76aaf1 chainreg: add Config, move chainparams.go
Creates a Config that initializes the chainregistry struct in the
lnd package. Also moves all of chainparams.go to the chainreg
package.
2020-10-29 15:19:58 -04:00
Eugene
933b959aa8 chainreg: export ChainCode to new pkg
Moves chainCode from the lnd package to the chainreg package,
where it is exported and can be used by other packages.
2020-10-29 15:19:57 -04:00
eugene
afb6ad295e lnd: move initNeutrinoBackend to lnd.go 2020-10-29 15:19:56 -04:00
MrManPew
72e4eab3b9
Update lnd.go 2020-10-01 18:02:16 -04:00
MrManPew
f5e0922c31
Show debug level at startup
I think it is efficient to also show the debug level at the startup. To verify that indeed the correct settings of the debuglevel started correctly. Especially when trying to capture rare bugs.
2020-09-27 12:39:20 -04:00
Oliver Gugger
00cb6fcc5d
lnd+config: allow Let's Encrypt listen IP to be set
To make it possible to request a Let's Encrypt certificate by using a
different IP address where the port 80 might still be free, we add the
IP part to its configuration as well instead of just the port.
This makes it possible to use an IPv6 address for the ACME request if
all available IPv4 addresses already have their port 80 occupied.
2020-09-17 09:54:23 +02:00
Johan T. Halseth
b8eb41f947
Merge pull request #4591 from hsjoberg/walletloader-unload
lnd: Call loader.UnloadWallet on shutdown
2020-09-15 13:54:46 +02:00
Joost Jager
403d72b468
lnrpc: lets encrypt
This commit enables lnd to request and renew a Let's Encrypt
certificate. This certificate is used both for the grpc as well as the
rest listeners. It allows clients to connect without having a copy of
the (public) server certificate.

Co-authored-by: Vegard Engen <vegard@engen.priv.no>
2020-09-15 09:59:09 +02:00
Joost Jager
999ffffa37
lnd: join imports to form three groups
In line with https://github.com/pavius/impi
2020-09-14 14:52:07 +02:00
Hampus Sjöberg
6dd1555e66 lnd: Call loader.UnloadWallet on shutdown
This is required to make restart work for LndMobile builds.
Not calling UnloadWallet would make `UnlockWallet` stall forever as
the file is already opened.
2020-09-14 12:32:48 +02:00
Oliver Gugger
8988a01d7e
lnd+rpcserver: allow external subservers to specify macaroon validator
Give the external subservers the possibility to also use their own
validator to check any macaroons attached to calls to their registered
gRPC URIs.
This allows them to have their own root key ID database and permission
entities.
2020-09-10 10:24:10 +02:00
Oliver Gugger
d4c4cf01f0
lnd+macaroons: specify location when creating macaroon service
To allow the macaroon service to be used in other projects, we want the
location to be passed in as a parameter instead of being hard coded.
2020-09-10 10:24:08 +02:00
Oliver Gugger
fac3c84806
Merge pull request #4551 from gkrizek/cors
lnd: Add CORS support to the WalletUnlocker proxy
2020-08-25 09:31:40 +02:00