Skip to content

Commit c54b3df

Browse files
authored
Merge pull request #119 from lightninglabs/lnd-0.13
Bump lnd dependency to v0.13.0-beta.rc2
2 parents fae9e63 + 824df2d commit c54b3df

File tree

12 files changed

+220
-117
lines changed

12 files changed

+220
-117
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Faraday is a suite of tools built to help node operators and businesses run [lnd](https://github.com/lightningnetwork/lnd), the leading implementation of the [Lightning Network](https://github.com/lightningnetwork/lightning-rfc). Faraday’s tools decrease the operational overhead of running a Lightning node and make it easier to build businesses on Lightning. The current features in the Faraday suite provide insight into node channel performance and support for accounting with both on-chain and off-chain reports for lnd.
66
## LND
7-
Note that Faraday requires lnd to be built with **all of its subservers** and requires running at least v0.11.0. Download the [official release binary](https://github.com/lightningnetwork/lnd/releases/tag/v0.11.0-beta) or see the [instructions](https://github.com/lightningnetwork/lnd/blob/master/docs/INSTALL.md) in the lnd repo for more detailed installation instructions. If you choose to build lnd from source, following command to enable all the relevant subservers:
7+
Note that Faraday requires lnd to be built with **all of its subservers** and requires running at least v0.11.1. Download the [official release binary](https://github.com/lightningnetwork/lnd/releases/tag/v0.11.1-beta) or see the [instructions](https://github.com/lightningnetwork/lnd/blob/master/docs/INSTALL.md) in the lnd repo for more detailed installation instructions. If you choose to build lnd from source, following command to enable all the relevant subservers:
88

99
```
1010
make install tags="signrpc walletrpc chainrpc invoicesrpc"

cmd/faraday/log.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

cmd/faraday/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"fmt"
45
"os"
56

67
"github.com/lightninglabs/faraday"
@@ -10,7 +11,7 @@ import (
1011
// properly executed if os.Exit() is called.
1112
func main() {
1213
if err := faraday.Main(); err != nil {
13-
log.Infof("Error starting faraday: %v", err)
14+
_, _ = fmt.Fprintf(os.Stderr, "Error starting faraday: %v", err)
1415
}
1516

1617
os.Exit(1)

faraday.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/jessevdk/go-flags"
1111
"github.com/lightninglabs/lndclient"
12+
"github.com/lightningnetwork/lnd/build"
1213
"github.com/lightningnetwork/lnd/signal"
1314

1415
"github.com/lightninglabs/faraday/chain"
@@ -34,6 +35,14 @@ func Main() error {
3435
os.Exit(0)
3536
}
3637

38+
// Hook interceptor for os signals.
39+
shutdownInterceptor, err := signal.Intercept()
40+
if err != nil {
41+
return err
42+
}
43+
logWriter := build.NewRotatingLogWriter()
44+
SetupLoggers(logWriter, shutdownInterceptor)
45+
3746
if err := ValidateConfig(&config); err != nil {
3847
return fmt.Errorf("error validating config: %v", err)
3948
}
@@ -82,16 +91,13 @@ func Main() error {
8291

8392
server := frdrpc.NewRPCServer(cfg)
8493

85-
// Catch intercept signals, then start the server.
86-
if err := signal.Intercept(); err != nil {
87-
return err
88-
}
94+
// Start the server.
8995
if err := server.Start(); err != nil {
9096
return err
9197
}
9298

9399
// Run until the user terminates.
94-
<-signal.ShutdownChannel()
100+
<-shutdownInterceptor.ShutdownChannel()
95101
log.Infof("Received shutdown signal.")
96102

97103
if err := server.Stop(); err != nil {

frdrpc/macaroons.go

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/lightningnetwork/lnd/lnrpc"
1111
"github.com/lightningnetwork/lnd/macaroons"
12+
"github.com/lightningnetwork/lnd/rpcperms"
1213
"google.golang.org/grpc"
1314
"gopkg.in/macaroon-bakery.v2/bakery"
1415
)
@@ -154,15 +155,28 @@ func (s *RPCServer) stopMacaroonService() error {
154155

155156
// macaroonInterceptor creates gRPC server options with the macaroon security
156157
// interceptors.
157-
func (s *RPCServer) macaroonInterceptor() []grpc.ServerOption {
158-
unaryInterceptor := s.macaroonService.UnaryServerInterceptor(
159-
RequiredPermissions,
160-
)
161-
streamInterceptor := s.macaroonService.StreamServerInterceptor(
162-
RequiredPermissions,
163-
)
158+
func (s *RPCServer) macaroonInterceptor() ([]grpc.ServerOption, error) {
159+
interceptor := rpcperms.NewInterceptorChain(log, false)
160+
161+
err := interceptor.Start()
162+
if err != nil {
163+
return nil, err
164+
}
165+
166+
interceptor.SetWalletUnlocked()
167+
interceptor.AddMacaroonService(s.macaroonService)
168+
169+
for method, permissions := range RequiredPermissions {
170+
err := interceptor.AddPermission(method, permissions)
171+
if err != nil {
172+
return nil, err
173+
}
174+
}
175+
176+
unaryInterceptor := interceptor.MacaroonUnaryServerInterceptor()
177+
streamInterceptor := interceptor.MacaroonStreamServerInterceptor()
164178
return []grpc.ServerOption{
165179
grpc.UnaryInterceptor(unaryInterceptor),
166180
grpc.StreamInterceptor(streamInterceptor),
167-
}
181+
}, nil
168182
}

frdrpc/rpcserver.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ func (s *RPCServer) Start() error {
179179

180180
// First we add the security interceptor to our gRPC server options that
181181
// checks the macaroons for validity.
182-
serverOpts := s.macaroonInterceptor()
182+
serverOpts, err := s.macaroonInterceptor()
183+
if err != nil {
184+
return fmt.Errorf("error with macaroon interceptor: %v", err)
185+
}
183186

184187
// Add our TLS configuration and then create our server instance. It's
185188
// important that we let gRPC create the TLS listener and we don't just
@@ -190,7 +193,6 @@ func (s *RPCServer) Start() error {
190193
s.grpcServer = grpc.NewServer(serverOpts...)
191194

192195
// Start the gRPC RPCServer listening for HTTP/2 connections.
193-
var err error
194196
log.Info("Starting gRPC listener")
195197
s.rpcListener, err = net.Listen("tcp", s.cfg.RPCListen)
196198
if err != nil {

go.mod

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
module github.com/lightninglabs/faraday
22

33
require (
4-
github.com/btcsuite/btcd v0.21.0-beta.0.20201208033208-6bd4c64a54fa
4+
github.com/btcsuite/btcd v0.21.0-beta.0.20210429225535-ce697fe7e82b
55
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
6-
github.com/btcsuite/btcutil v1.0.2
7-
github.com/golang/protobuf v1.3.3
8-
github.com/google/go-cmp v0.3.1 // indirect
6+
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
7+
github.com/golang/protobuf v1.4.3
98
github.com/grpc-ecosystem/grpc-gateway v1.14.3
109
github.com/jessevdk/go-flags v1.4.0
11-
github.com/lightninglabs/lndclient v0.11.0-5
12-
github.com/lightninglabs/protobuf-hex-display v1.3.3-0.20191212020323-b444784ce75d
13-
github.com/lightningnetwork/lnd v0.12.0-beta.rc5
10+
github.com/lightninglabs/lndclient v0.11.1-5
11+
github.com/lightninglabs/protobuf-hex-display v1.4.3-hex-display
12+
github.com/lightningnetwork/lnd v0.13.0-beta.rc2
1413
github.com/lightningnetwork/lnd/cert v1.0.3
1514
github.com/shopspring/decimal v1.2.0
16-
github.com/stretchr/testify v1.5.1
15+
github.com/stretchr/testify v1.7.0
1716
github.com/urfave/cli v1.20.0
18-
golang.org/x/text v0.3.2 // indirect
1917
google.golang.org/grpc v1.29.1
2018
gopkg.in/macaroon-bakery.v2 v2.0.1
2119
gopkg.in/macaroon.v2 v2.1.0
2220
)
2321

22+
// Fix incompatibility of etcd go.mod package.
23+
// See https://github.com/etcd-io/etcd/issues/11154
24+
replace go.etcd.io/etcd => go.etcd.io/etcd v0.5.0-alpha.5.0.20201125193152-8a03d2e9614b
25+
2426
go 1.15

0 commit comments

Comments
 (0)