build+lncfg: support pruned bitcoind backends (#5154)
* 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. * lncfg: add new PrunedNodeMaxPeers config option/flag
This commit is contained in:
10 files changed
+88
-37
No files matched your search
@@ -233,10 +233,19 @@ func NewBitcoindBackend(t *testing.T, minerAddr string,
|
|||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
|
|
||||||
host := fmt.Sprintf("127.0.0.1:%d", rpcPort)
|
host := fmt.Sprintf("127.0.0.1:%d", rpcPort)
|
||||||
conn, err := chain.NewBitcoindConn(
|
conn, err := chain.NewBitcoindConn(&chain.BitcoindConfig{
|
||||||
NetParams, host, "weks", "weks", zmqBlockHost, zmqTxHost,
|
ChainParams: NetParams,
|
||||||
100*time.Millisecond,
|
Host: host,
|
||||||
)
|
User: "weks",
|
||||||
|
Pass: "weks",
|
||||||
|
ZMQBlockHost: zmqBlockHost,
|
||||||
|
ZMQTxHost: zmqTxHost,
|
||||||
|
ZMQReadDeadline: 5 * time.Second,
|
||||||
|
// Fields only required for pruned nodes, not needed for these
|
||||||
|
// tests.
|
||||||
|
Dialer: nil,
|
||||||
|
PrunedModeMaxPeers: 0,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
bitcoind.Process.Kill()
|
bitcoind.Process.Kill()
|
||||||
bitcoind.Wait()
|
bitcoind.Wait()
|
||||||
|
|||||||
@@ -105,6 +105,11 @@ type Config struct {
|
|||||||
// DBTimeOut specifies the timeout value to use when opening the wallet
|
// DBTimeOut specifies the timeout value to use when opening the wallet
|
||||||
// database.
|
// database.
|
||||||
DBTimeOut time.Duration
|
DBTimeOut time.Duration
|
||||||
|
|
||||||
|
// Dialer is a function closure that will be used to establish outbound
|
||||||
|
// TCP connections to Bitcoin peers in the event of a pruned block being
|
||||||
|
// requested.
|
||||||
|
Dialer chain.Dialer
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -383,12 +388,17 @@ func NewChainControl(cfg *Config) (*ChainControl, error) {
|
|||||||
|
|
||||||
// Establish the connection to bitcoind and create the clients
|
// Establish the connection to bitcoind and create the clients
|
||||||
// required for our relevant subsystems.
|
// required for our relevant subsystems.
|
||||||
bitcoindConn, err := chain.NewBitcoindConn(
|
bitcoindConn, err := chain.NewBitcoindConn(&chain.BitcoindConfig{
|
||||||
cfg.ActiveNetParams.Params, bitcoindHost,
|
ChainParams: cfg.ActiveNetParams.Params,
|
||||||
bitcoindMode.RPCUser, bitcoindMode.RPCPass,
|
Host: bitcoindHost,
|
||||||
bitcoindMode.ZMQPubRawBlock, bitcoindMode.ZMQPubRawTx,
|
User: bitcoindMode.RPCUser,
|
||||||
5*time.Second,
|
Pass: bitcoindMode.RPCPass,
|
||||||
)
|
ZMQBlockHost: bitcoindMode.ZMQPubRawBlock,
|
||||||
|
ZMQTxHost: bitcoindMode.ZMQPubRawTx,
|
||||||
|
ZMQReadDeadline: 5 * time.Second,
|
||||||
|
Dialer: cfg.Dialer,
|
||||||
|
PrunedModeMaxPeers: bitcoindMode.PrunedNodeMaxPeers,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,6 +183,8 @@ var (
|
|||||||
defaultBitcoindEstimateMode = "CONSERVATIVE"
|
defaultBitcoindEstimateMode = "CONSERVATIVE"
|
||||||
bitcoindEstimateModes = [2]string{"ECONOMICAL", defaultBitcoindEstimateMode}
|
bitcoindEstimateModes = [2]string{"ECONOMICAL", defaultBitcoindEstimateMode}
|
||||||
|
|
||||||
|
defaultPrunedNodeMaxPeers = 4
|
||||||
|
|
||||||
defaultSphinxDbName = "sphinxreplay.db"
|
defaultSphinxDbName = "sphinxreplay.db"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -392,9 +394,10 @@ func DefaultConfig() Config {
|
|||||||
RPCCert: defaultBtcdRPCCertFile,
|
RPCCert: defaultBtcdRPCCertFile,
|
||||||
},
|
},
|
||||||
BitcoindMode: &lncfg.Bitcoind{
|
BitcoindMode: &lncfg.Bitcoind{
|
||||||
Dir: defaultBitcoindDir,
|
Dir: defaultBitcoindDir,
|
||||||
RPCHost: defaultRPCHost,
|
RPCHost: defaultRPCHost,
|
||||||
EstimateMode: defaultBitcoindEstimateMode,
|
EstimateMode: defaultBitcoindEstimateMode,
|
||||||
|
PrunedNodeMaxPeers: defaultPrunedNodeMaxPeers,
|
||||||
},
|
},
|
||||||
Litecoin: &lncfg.Chain{
|
Litecoin: &lncfg.Chain{
|
||||||
MinHTLCIn: chainreg.DefaultLitecoinMinHTLCInMSat,
|
MinHTLCIn: chainreg.DefaultLitecoinMinHTLCInMSat,
|
||||||
@@ -411,9 +414,10 @@ func DefaultConfig() Config {
|
|||||||
RPCCert: defaultLtcdRPCCertFile,
|
RPCCert: defaultLtcdRPCCertFile,
|
||||||
},
|
},
|
||||||
LitecoindMode: &lncfg.Bitcoind{
|
LitecoindMode: &lncfg.Bitcoind{
|
||||||
Dir: defaultLitecoindDir,
|
Dir: defaultLitecoindDir,
|
||||||
RPCHost: defaultRPCHost,
|
RPCHost: defaultRPCHost,
|
||||||
EstimateMode: defaultBitcoindEstimateMode,
|
EstimateMode: defaultBitcoindEstimateMode,
|
||||||
|
PrunedNodeMaxPeers: defaultPrunedNodeMaxPeers,
|
||||||
},
|
},
|
||||||
NeutrinoMode: &lncfg.Neutrino{
|
NeutrinoMode: &lncfg.Neutrino{
|
||||||
UserAgentName: neutrino.UserAgentName,
|
UserAgentName: neutrino.UserAgentName,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ require (
|
|||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
|
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
|
||||||
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
|
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
|
||||||
github.com/btcsuite/btcutil/psbt v1.0.3-0.20201208143702-a53e38424cce
|
github.com/btcsuite/btcutil/psbt v1.0.3-0.20201208143702-a53e38424cce
|
||||||
github.com/btcsuite/btcwallet v0.11.1-0.20210329233242-e0607006dce6
|
github.com/btcsuite/btcwallet v0.11.1-0.20210405201449-683061f79797
|
||||||
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.1-0.20210329233242-e0607006dce6
|
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.1-0.20210329233242-e0607006dce6
|
||||||
github.com/btcsuite/btcwallet/wallet/txrules v1.0.0
|
github.com/btcsuite/btcwallet/wallet/txrules v1.0.0
|
||||||
github.com/btcsuite/btcwallet/wallet/txsizes v1.0.1-0.20210329233242-e0607006dce6 // indirect
|
github.com/btcsuite/btcwallet/wallet/txsizes v1.0.1-0.20210329233242-e0607006dce6 // indirect
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+Ce
|
|||||||
github.com/btcsuite/btcd v0.0.0-20190629003639-c26ffa870fd8/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI=
|
github.com/btcsuite/btcd v0.0.0-20190629003639-c26ffa870fd8/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI=
|
||||||
github.com/btcsuite/btcd v0.0.0-20190824003749-130ea5bddde3/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI=
|
github.com/btcsuite/btcd v0.0.0-20190824003749-130ea5bddde3/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI=
|
||||||
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
|
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
|
||||||
github.com/btcsuite/btcd v0.20.1-beta.0.20200513120220-b470eee47728/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
|
|
||||||
github.com/btcsuite/btcd v0.21.0-beta.0.20201208033208-6bd4c64a54fa/go.mod h1:Sv4JPQ3/M+teHz9Bo5jBpkNcP0x6r7rdihlNL/7tTAs=
|
github.com/btcsuite/btcd v0.21.0-beta.0.20201208033208-6bd4c64a54fa/go.mod h1:Sv4JPQ3/M+teHz9Bo5jBpkNcP0x6r7rdihlNL/7tTAs=
|
||||||
|
github.com/btcsuite/btcd v0.21.0-beta.0.20210316172410-f86ae60936d7/go.mod h1:Sv4JPQ3/M+teHz9Bo5jBpkNcP0x6r7rdihlNL/7tTAs=
|
||||||
github.com/btcsuite/btcd v0.21.0-beta.0.20210401013323-36a96f6a0025 h1:aoVqvZk4mLyF3WZbqEVPq+vXnwL2wekZg4P4mjYJNLs=
|
github.com/btcsuite/btcd v0.21.0-beta.0.20210401013323-36a96f6a0025 h1:aoVqvZk4mLyF3WZbqEVPq+vXnwL2wekZg4P4mjYJNLs=
|
||||||
github.com/btcsuite/btcd v0.21.0-beta.0.20210401013323-36a96f6a0025/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA=
|
github.com/btcsuite/btcd v0.21.0-beta.0.20210401013323-36a96f6a0025/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA=
|
||||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
|
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
|
||||||
@@ -37,8 +37,8 @@ github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pY
|
|||||||
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o=
|
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o=
|
||||||
github.com/btcsuite/btcutil/psbt v1.0.3-0.20201208143702-a53e38424cce h1:3PRwz+js0AMMV1fHRrCdQ55akoomx4Q3ulozHC3BDDY=
|
github.com/btcsuite/btcutil/psbt v1.0.3-0.20201208143702-a53e38424cce h1:3PRwz+js0AMMV1fHRrCdQ55akoomx4Q3ulozHC3BDDY=
|
||||||
github.com/btcsuite/btcutil/psbt v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:LVveMu4VaNSkIRTZu2+ut0HDBRuYjqGocxDMNS1KuGQ=
|
github.com/btcsuite/btcutil/psbt v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:LVveMu4VaNSkIRTZu2+ut0HDBRuYjqGocxDMNS1KuGQ=
|
||||||
github.com/btcsuite/btcwallet v0.11.1-0.20210329233242-e0607006dce6 h1:5Y6ui667YQrFCxPYV4Pmf9jpEsIkcJxMKsXJzNsMU9o=
|
github.com/btcsuite/btcwallet v0.11.1-0.20210405201449-683061f79797 h1:FqPzyVNKoqE+qV57Cn8zpTfUy/G698M9b6dNprGj0cY=
|
||||||
github.com/btcsuite/btcwallet v0.11.1-0.20210329233242-e0607006dce6/go.mod h1:JBUz2SCnYLn2Dw9bcnqZYvKchnKVvWSLv8OUzihHTcc=
|
github.com/btcsuite/btcwallet v0.11.1-0.20210405201449-683061f79797/go.mod h1:CevOfPKvF6kHr+JXhWD3TtqLbsJrD1CzrtDqZ+5G6ss=
|
||||||
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.0/go.mod h1:VufDts7bd/zs3GV13f/lXc/0lXrPnvxD/NvmpG/FEKU=
|
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.0/go.mod h1:VufDts7bd/zs3GV13f/lXc/0lXrPnvxD/NvmpG/FEKU=
|
||||||
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.1-0.20210329233242-e0607006dce6 h1:mO7NxcfgLe75paLDHx+LWNG5BskiDQigHnSVT2KvNZA=
|
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.1-0.20210329233242-e0607006dce6 h1:mO7NxcfgLe75paLDHx+LWNG5BskiDQigHnSVT2KvNZA=
|
||||||
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.1-0.20210329233242-e0607006dce6/go.mod h1:VufDts7bd/zs3GV13f/lXc/0lXrPnvxD/NvmpG/FEKU=
|
github.com/btcsuite/btcwallet/wallet/txauthor v1.0.1-0.20210329233242-e0607006dce6/go.mod h1:VufDts7bd/zs3GV13f/lXc/0lXrPnvxD/NvmpG/FEKU=
|
||||||
|
|||||||
+8
-7
@@ -3,11 +3,12 @@ package lncfg
|
|||||||
// Bitcoind holds the configuration options for the daemon's connection to
|
// Bitcoind holds the configuration options for the daemon's connection to
|
||||||
// bitcoind.
|
// bitcoind.
|
||||||
type Bitcoind struct {
|
type Bitcoind struct {
|
||||||
Dir string `long:"dir" description:"The base directory that contains the node's data, logs, configuration file, etc."`
|
Dir string `long:"dir" description:"The base directory that contains the node's data, logs, configuration file, etc."`
|
||||||
RPCHost string `long:"rpchost" description:"The daemon's rpc listening address. If a port is omitted, then the default port for the selected chain parameters will be used."`
|
RPCHost string `long:"rpchost" description:"The daemon's rpc listening address. If a port is omitted, then the default port for the selected chain parameters will be used."`
|
||||||
RPCUser string `long:"rpcuser" description:"Username for RPC connections"`
|
RPCUser string `long:"rpcuser" description:"Username for RPC connections"`
|
||||||
RPCPass string `long:"rpcpass" default-mask:"-" description:"Password for RPC connections"`
|
RPCPass string `long:"rpcpass" default-mask:"-" description:"Password for RPC connections"`
|
||||||
ZMQPubRawBlock string `long:"zmqpubrawblock" description:"The address listening for ZMQ connections to deliver raw block notifications"`
|
ZMQPubRawBlock string `long:"zmqpubrawblock" description:"The address listening for ZMQ connections to deliver raw block notifications"`
|
||||||
ZMQPubRawTx string `long:"zmqpubrawtx" description:"The address listening for ZMQ connections to deliver raw transaction notifications"`
|
ZMQPubRawTx string `long:"zmqpubrawtx" description:"The address listening for ZMQ connections to deliver raw transaction notifications"`
|
||||||
EstimateMode string `long:"estimatemode" description:"The fee estimate mode. Must be either ECONOMICAL or CONSERVATIVE."`
|
EstimateMode string `long:"estimatemode" description:"The fee estimate mode. Must be either ECONOMICAL or CONSERVATIVE."`
|
||||||
|
PrunedNodeMaxPeers int `long:"pruned-node-max-peers" description:"The maximum number of peers lnd will choose from the backend node to retrieve pruned blocks from. This only applies to pruned nodes."`
|
||||||
}
|
}
|
||||||
@@ -543,6 +543,9 @@ func Main(cfg *Config, lisCfg ListenerCfg, interceptor signal.Interceptor) error
|
|||||||
NeutrinoCS: neutrinoCS,
|
NeutrinoCS: neutrinoCS,
|
||||||
ActiveNetParams: cfg.ActiveNetParams,
|
ActiveNetParams: cfg.ActiveNetParams,
|
||||||
FeeURL: cfg.FeeURL,
|
FeeURL: cfg.FeeURL,
|
||||||
|
Dialer: func(addr string) (net.Conn, error) {
|
||||||
|
return cfg.net.Dial("tcp", addr, cfg.ConnectionTimeout)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
activeChainControl, err := chainreg.NewChainControl(chainControlCfg)
|
activeChainControl, err := chainreg.NewChainControl(chainControlCfg)
|
||||||
|
|||||||
@@ -3323,11 +3323,19 @@ func runTests(t *testing.T, walletDriver *lnwallet.WalletDriver,
|
|||||||
host := fmt.Sprintf("127.0.0.1:%d", rpcPort)
|
host := fmt.Sprintf("127.0.0.1:%d", rpcPort)
|
||||||
var chainConn *chain.BitcoindConn
|
var chainConn *chain.BitcoindConn
|
||||||
err = wait.NoError(func() error {
|
err = wait.NoError(func() error {
|
||||||
chainConn, err = chain.NewBitcoindConn(
|
chainConn, err = chain.NewBitcoindConn(&chain.BitcoindConfig{
|
||||||
netParams, host, "weks", "weks",
|
ChainParams: netParams,
|
||||||
zmqBlockHost, zmqTxHost,
|
Host: host,
|
||||||
100*time.Millisecond,
|
User: "weks",
|
||||||
)
|
Pass: "weks",
|
||||||
|
ZMQBlockHost: zmqBlockHost,
|
||||||
|
ZMQTxHost: zmqTxHost,
|
||||||
|
ZMQReadDeadline: 5 * time.Second,
|
||||||
|
// Fields only required for pruned nodes, not
|
||||||
|
// needed for these tests.
|
||||||
|
Dialer: nil,
|
||||||
|
PrunedModeMaxPeers: 0,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -816,11 +816,19 @@ var interfaceImpls = []struct {
|
|||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
|
|
||||||
host := fmt.Sprintf("127.0.0.1:%d", rpcPort)
|
host := fmt.Sprintf("127.0.0.1:%d", rpcPort)
|
||||||
chainConn, err := chain.NewBitcoindConn(
|
chainConn, err := chain.NewBitcoindConn(&chain.BitcoindConfig{
|
||||||
&chaincfg.RegressionNetParams, host, "weks",
|
ChainParams: &chaincfg.RegressionNetParams,
|
||||||
"weks", zmqBlockHost, zmqTxHost,
|
Host: host,
|
||||||
100*time.Millisecond,
|
User: "weks",
|
||||||
)
|
Pass: "weks",
|
||||||
|
ZMQBlockHost: zmqBlockHost,
|
||||||
|
ZMQTxHost: zmqTxHost,
|
||||||
|
ZMQReadDeadline: 5 * time.Second,
|
||||||
|
// Fields only required for pruned nodes, not
|
||||||
|
// needed for these tests.
|
||||||
|
Dialer: nil,
|
||||||
|
PrunedModeMaxPeers: 0,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cleanUp2, nil, fmt.Errorf("unable to "+
|
return cleanUp2, nil, fmt.Errorf("unable to "+
|
||||||
"establish connection to bitcoind: %v",
|
"establish connection to bitcoind: %v",
|
||||||
|
|||||||
@@ -536,6 +536,10 @@ bitcoin.node=btcd
|
|||||||
; If unset, the default value is "CONSERVATIVE".
|
; If unset, the default value is "CONSERVATIVE".
|
||||||
; bitcoind.estimatemode=CONSERVATIVE
|
; bitcoind.estimatemode=CONSERVATIVE
|
||||||
|
|
||||||
|
; The maximum number of peers lnd will choose from the backend node to retrieve
|
||||||
|
; pruned blocks from. This only applies to pruned nodes.
|
||||||
|
; bitcoind.pruned-node-max-peers=4
|
||||||
|
|
||||||
[neutrino]
|
[neutrino]
|
||||||
|
|
||||||
; Connect only to the specified peers at startup. This creates a persistent
|
; Connect only to the specified peers at startup. This creates a persistent
|
||||||
@@ -706,6 +710,10 @@ litecoin.node=ltcd
|
|||||||
; If unset, the default value is "CONSERVATIVE".
|
; If unset, the default value is "CONSERVATIVE".
|
||||||
; litecoind.estimatemode=CONSERVATIVE
|
; litecoind.estimatemode=CONSERVATIVE
|
||||||
|
|
||||||
|
; The maximum number of peers lnd will choose from the backend node to retrieve
|
||||||
|
; pruned blocks from. This only applies to pruned nodes.
|
||||||
|
; litecoind.pruned-node-max-peers=4
|
||||||
|
|
||||||
[autopilot]
|
[autopilot]
|
||||||
|
|
||||||
; If the autopilot agent should be active or not. The autopilot agent will
|
; If the autopilot agent should be active or not. The autopilot agent will
|
||||||
|
|||||||
Reference in new issue
Block a user