multi: update lnd, loop and faraday

With this commit we update lnd, loop and faraday to the newest versions
that include TLS and macaroon authentication.
This commit is contained in:
Oliver Gugger 2020-10-08 09:34:39 +02:00
parent 5afdf2051f
commit b36f8aefed
No known key found for this signature in database
GPG key ID: 8E4256593F177720
5 changed files with 52 additions and 89 deletions

View file

@ -13,6 +13,7 @@ import (
"github.com/jessevdk/go-flags"
"github.com/lightninglabs/faraday"
"github.com/lightninglabs/faraday/frdrpc"
"github.com/lightninglabs/lndclient"
"github.com/lightninglabs/loop/loopd"
"github.com/lightningnetwork/lnd"
@ -53,6 +54,8 @@ type Config struct {
Lnd *lnd.Config `group:"lnd" namespace:"lnd"`
Faraday *faraday.Config `group:"faraday" namespace:"faraday"`
Loop *loopd.Config `group:"loop" namespace:"loop"`
frdrpcCfg *frdrpc.Config
}
// lndConnectParams returns the connection parameters to connect to the local

8
go.mod
View file

@ -6,11 +6,11 @@ require (
github.com/grpc-ecosystem/grpc-gateway v1.14.3
github.com/improbable-eng/grpc-web v0.12.0
github.com/jessevdk/go-flags v1.4.0
github.com/lightninglabs/faraday v0.2.0-alpha.0.20200901065614-d72fdaeff888
github.com/lightninglabs/faraday v0.2.1-alpha.0.20200918072230-7ec3f67ed2f0
github.com/lightninglabs/lndclient v0.11.0-0
github.com/lightninglabs/loop v0.8.1-beta.0.20200831113239-d4d9aa102455
github.com/lightningnetwork/lnd v0.11.0-beta
github.com/lightningnetwork/lnd/cert v1.0.2
github.com/lightninglabs/loop v0.9.0-beta.0.20200918101140-4bb59f87bf95
github.com/lightningnetwork/lnd v0.11.1-beta.rc3
github.com/lightningnetwork/lnd/cert v1.0.3
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f
github.com/mwitkow/grpc-proxy v0.0.0-20181017164139-0f1106ef9c76
github.com/prometheus/client_golang v1.5.1 // indirect

18
go.sum
View file

@ -38,8 +38,12 @@ github.com/btcsuite/btcutil v1.0.2 h1:9iZ1Terx9fMIOtq1VrwdqfsATL9MC2l8ZrUY6YZ2ut
github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts=
github.com/btcsuite/btcutil/psbt v1.0.2 h1:gCVY3KxdoEVU7Q6TjusPO+GANIwVgr9yTLqM+a6CZr8=
github.com/btcsuite/btcutil/psbt v1.0.2/go.mod h1:LVveMu4VaNSkIRTZu2+ut0HDBRuYjqGocxDMNS1KuGQ=
github.com/btcsuite/btcutil/psbt v1.0.3-0.20200826194809-5f93e33af2b0 h1:3Zumkyl6PWyHuVJ04me0xeD9CnPOhNgeGpapFbzy7O4=
github.com/btcsuite/btcutil/psbt v1.0.3-0.20200826194809-5f93e33af2b0/go.mod h1:LVveMu4VaNSkIRTZu2+ut0HDBRuYjqGocxDMNS1KuGQ=
github.com/btcsuite/btcwallet v0.11.1-0.20200814001439-1d31f4ea6fc5 h1:1We7EuizBnX/17Q6O2dkeToyehxzUHo62Wv1c0ncr7c=
github.com/btcsuite/btcwallet v0.11.1-0.20200814001439-1d31f4ea6fc5/go.mod h1:YkEbJaCyN6yncq5gEp2xG0OKDwus2QxGCEXTNF27w5I=
github.com/btcsuite/btcwallet v0.11.1-0.20200904022754-2c5947a45222 h1:rh1FQAhh+BeR29twIFDM0RLOFpDK62tsABtUkWctTXw=
github.com/btcsuite/btcwallet v0.11.1-0.20200904022754-2c5947a45222/go.mod h1:owv9oZqM0HnUW+ByF7VqOgfs2eb0ooiePW/+Tl/i/Nk=
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.0 h1:KGHMW5sd7yDdDMkCZ/JpP0KltolFsQcB973brBnfj4c=
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.0/go.mod h1:VufDts7bd/zs3GV13f/lXc/0lXrPnvxD/NvmpG/FEKU=
github.com/btcsuite/btcwallet/wallet/txrules v1.0.0 h1:2VsfS0sBedcM5KmDzRMT3+b6xobqWveZGvjb+jFez5w=
@ -198,14 +202,14 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lightninglabs/faraday v0.2.0-alpha.0.20200901065614-d72fdaeff888 h1:kKruI0ZGCW0Ky4q2pt6jO7oSArNBgE+Ps3k6n7j/J6Y=
github.com/lightninglabs/faraday v0.2.0-alpha.0.20200901065614-d72fdaeff888/go.mod h1:tFhh0ScstVI9GgYpJ4Tp+1Bw/DjUOJxlfIuZnfvThe8=
github.com/lightninglabs/faraday v0.2.1-alpha.0.20200918072230-7ec3f67ed2f0 h1:uTOep9wjoQsaYAo2cYI4Ze2HrollwSKQkPpJrkyVw6c=
github.com/lightninglabs/faraday v0.2.1-alpha.0.20200918072230-7ec3f67ed2f0/go.mod h1:lcUCN2tzfYydxjGQATRx32kFthr+36nsxYUv8QAhb8g=
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf h1:HZKvJUHlcXI/f/O0Avg7t8sqkPo78HFzjmeYFl6DPnc=
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf/go.mod h1:vxmQPeIQxPf6Jf9rM8R+B4rKBqLA2AjttNxkFBL2Plk=
github.com/lightninglabs/lndclient v0.11.0-0 h1:tCvhlN/NNC/PeCjifONq/f8vU/6ZJS1ivXhpIfw6JfY=
github.com/lightninglabs/lndclient v0.11.0-0/go.mod h1:8/cTKNwgL87NX123gmlv3Xh6p1a7pvzu+40Un3PhHiI=
github.com/lightninglabs/loop v0.8.1-beta.0.20200831113239-d4d9aa102455 h1:RWIxymisZYA02aqEAIunvZxNgcSu+hS3LG4KAxvk2SU=
github.com/lightninglabs/loop v0.8.1-beta.0.20200831113239-d4d9aa102455/go.mod h1:b1cG1mLbPUjWEN5ZQi6pfNeNWCYm5H48NdjkycyifS8=
github.com/lightninglabs/loop v0.9.0-beta.0.20200918101140-4bb59f87bf95 h1:LepMeUc7zJWkgqQK8EHcpXy/G74fny45rd4tT75+Lm4=
github.com/lightninglabs/loop v0.9.0-beta.0.20200918101140-4bb59f87bf95/go.mod h1:xRwAE8TIaU4sqVrqFUPvGvdMaKNZz3489jjRjN7BwqE=
github.com/lightninglabs/neutrino v0.11.0/go.mod h1:CuhF0iuzg9Sp2HO6ZgXgayviFTn1QHdSTJlMncK80wg=
github.com/lightninglabs/neutrino v0.11.1-0.20200316235139-bffc52e8f200 h1:j4iZ1XlUAPQmW6oSzMcJGILYsRHNs+4O3Gk+2Ms5Dww=
github.com/lightninglabs/neutrino v0.11.1-0.20200316235139-bffc52e8f200/go.mod h1:MlZmoKa7CJP3eR1s5yB7Rm5aSyadpKkxqAwLQmog7N0=
@ -213,10 +217,12 @@ github.com/lightninglabs/protobuf-hex-display v1.3.3-0.20191212020323-b444784ce7
github.com/lightninglabs/protobuf-hex-display v1.3.3-0.20191212020323-b444784ce75d/go.mod h1:KDb67YMzoh4eudnzClmvs2FbiLG9vxISmLApUkCa4uI=
github.com/lightningnetwork/lightning-onion v1.0.2-0.20200501022730-3c8c8d0b89ea h1:oCj48NQ8u7Vz+MmzHqt0db6mxcFZo3Ho7M5gCJauY/k=
github.com/lightningnetwork/lightning-onion v1.0.2-0.20200501022730-3c8c8d0b89ea/go.mod h1:rigfi6Af/KqsF7Za0hOgcyq2PNH4AN70AaMRxcJkff4=
github.com/lightningnetwork/lnd v0.11.0-beta h1:pUAT7FMHqS+iarNxyRtgj96XKCGAWwmb6ZdiUBy78ts=
github.com/lightningnetwork/lnd v0.11.0-beta/go.mod h1:CzArvT7NFDLhVyW06+NJWSuWFmE6Ea+AjjA3txUBqTM=
github.com/lightningnetwork/lnd/cert v1.0.2 h1:g2rEu+sM2Uyz0bpfuvwri/ks6R/26H5iY1NcGbpDJ+c=
github.com/lightningnetwork/lnd v0.11.1-beta.rc3 h1:f5xXgMiOx+3ez/dOTdRqZfYMtqqoz/+5kjwk5hdzAWk=
github.com/lightningnetwork/lnd v0.11.1-beta.rc3/go.mod h1:PGIgxy8aH70Li33YVYkHSaCM8m8LjEevk5h1Dpldrr4=
github.com/lightningnetwork/lnd/cert v1.0.2/go.mod h1:fmtemlSMf5t4hsQmcprSoOykypAPp+9c+0d0iqTScMo=
github.com/lightningnetwork/lnd/cert v1.0.3 h1:/K2gjzLgVI8we2IIPKc0ztWTEa85uds5sWXi1K6mOT0=
github.com/lightningnetwork/lnd/cert v1.0.3/go.mod h1:3MWXVLLPI0Mg0XETm9fT4N9Vyy/8qQLmaM5589bEggM=
github.com/lightningnetwork/lnd/clock v1.0.1 h1:QQod8+m3KgqHdvVMV+2DRNNZS1GRFir8mHZYA+Z2hFo=
github.com/lightningnetwork/lnd/clock v1.0.1/go.mod h1:KnQudQ6w0IAMZi1SgvecLZQZ43ra2vpDNj7H/aasemg=
github.com/lightningnetwork/lnd/queue v1.0.1/go.mod h1:vaQwexir73flPW43Mrm7JOgJHmcEFBWWSl9HlyASoms=

View file

@ -1,90 +1,21 @@
package terminal
import "gopkg.in/macaroon-bakery.v2/bakery"
var (
// faradayPermissions is a map of all faraday RPC methods and their
// required macaroon permissions.
//
// TODO(guggero): Move to faraday repo once macaroons are enabled there
// and use more application specific permissions.
faradayPermissions = map[string][]bakery.Op{
"/frdrpc.FaradayServer/OutlierRecommendations": {{
Entity: "offchain",
Action: "read",
}},
"/frdrpc.FaradayServer/ThresholdRecommendations": {{
Entity: "offchain",
Action: "read",
}},
"/frdrpc.FaradayServer/RevenueReport": {{
Entity: "offchain",
Action: "read",
}},
"/frdrpc.FaradayServer/ChannelInsights": {{
Entity: "offchain",
Action: "read",
}},
}
// loopPermissions is a map of all loop RPC methods and their required
// macaroon permissions.
//
// TODO(guggero): Move to loop repo once macaroons are enabled there
// and use more application specific permissions.
loopPermissions = map[string][]bakery.Op{
"/looprpc.SwapClient/LoopOut": {{
Entity: "offchain",
Action: "read",
}},
"/looprpc.SwapClient/LoopIn": {{
Entity: "offchain",
Action: "read",
}},
"/looprpc.SwapClient/Monitor": {{
Entity: "offchain",
Action: "read",
}},
"/looprpc.SwapClient/ListSwaps": {{
Entity: "offchain",
Action: "read",
}},
"/looprpc.SwapClient/SwapInfo": {{
Entity: "offchain",
Action: "read",
}},
"/looprpc.SwapClient/LoopOutTerms": {{
Entity: "offchain",
Action: "read",
}},
"/looprpc.SwapClient/LoopOutQuote": {{
Entity: "offchain",
Action: "read",
}},
"/looprpc.SwapClient/GetLoopInTerms": {{
Entity: "offchain",
Action: "read",
}},
"/looprpc.SwapClient/GetLoopInQuote": {{
Entity: "offchain",
Action: "read",
}},
"/looprpc.SwapClient/GetLsatTokens": {{
Entity: "offchain",
Action: "read",
}},
}
import (
"github.com/lightninglabs/faraday/frdrpc"
"github.com/lightninglabs/loop/loopd"
"gopkg.in/macaroon-bakery.v2/bakery"
)
// getSubserverPermissions returns a merged map of all subserver macaroon
// permissions.
func getSubserverPermissions() map[string][]bakery.Op {
mapSize := len(faradayPermissions) + len(loopPermissions)
mapSize := len(frdrpc.RequiredPermissions) +
len(loopd.RequiredPermissions)
result := make(map[string][]bakery.Op, mapSize)
for key, value := range faradayPermissions {
for key, value := range frdrpc.RequiredPermissions {
result[key] = value
}
for key, value := range loopPermissions {
for key, value := range loopd.RequiredPermissions {
result[key] = value
}
return result

View file

@ -19,6 +19,8 @@ import (
restProxy "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/improbable-eng/grpc-web/go/grpcweb"
"github.com/jessevdk/go-flags"
"github.com/lightninglabs/faraday"
"github.com/lightninglabs/faraday/chain"
"github.com/lightninglabs/faraday/frdrpc"
"github.com/lightninglabs/lndclient"
"github.com/lightninglabs/loop/loopd"
@ -149,11 +151,15 @@ func (g *LightningTerminal) Run() error {
// Create the instances of our subservers now so we can hook them up to
// lnd once it's fully started.
g.faradayServer = frdrpc.NewRPCServer(&frdrpc.Config{})
g.cfg.frdrpcCfg = &frdrpc.Config{}
g.faradayServer = frdrpc.NewRPCServer(g.cfg.frdrpcCfg)
g.loopServer = loopd.New(g.cfg.Loop, nil)
// Hook interceptor for os signals.
signal.Intercept()
err = signal.Intercept()
if err != nil {
return fmt.Errorf("could not intercept signals: %v", err)
}
// Call the "real" main in a nested manner so the defers will properly
// be executed in the case of a graceful shutdown.
@ -242,6 +248,23 @@ func (g *LightningTerminal) startSubservers() error {
return err
}
g.cfg.Faraday.Network = string(network)
if err := faraday.ValidateConfig(g.cfg.Faraday); err != nil {
return err
}
g.cfg.frdrpcCfg.FaradayDir = g.cfg.Faraday.FaradayDir
g.cfg.frdrpcCfg.MacaroonPath = g.cfg.Faraday.MacaroonPath
// If the client chose to connect to a bitcoin client, get one now.
if g.cfg.Faraday.ChainConn {
g.cfg.frdrpcCfg.BitcoinClient, err = chain.NewBitcoinClient(
g.cfg.Faraday.Bitcoin,
)
if err != nil {
return err
}
}
// The main RPC listener of lnd might need some time to start, it could
// be that we run into a connection refused a few times. We use the
// basic client connection to find out if the RPC server is started yet