mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-26 00:31:32 +02:00
multi: add testnet4 support
This commit is contained in:
parent
e5b9d9684a
commit
0aea482b51
@ -22,6 +22,14 @@ var BitcoinTestNetParams = BitcoinNetParams{
|
|||||||
CoinType: keychain.CoinTypeTestnet,
|
CoinType: keychain.CoinTypeTestnet,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BitcoinTestNet4Params contains parameters specific to the 4th version of the
|
||||||
|
// test network.
|
||||||
|
var BitcoinTestNet4Params = BitcoinNetParams{
|
||||||
|
Params: &bitcoinCfg.TestNet4Params,
|
||||||
|
RPCPort: "48334",
|
||||||
|
CoinType: keychain.CoinTypeTestnet,
|
||||||
|
}
|
||||||
|
|
||||||
// BitcoinMainNetParams contains parameters specific to the current Bitcoin
|
// BitcoinMainNetParams contains parameters specific to the current Bitcoin
|
||||||
// mainnet.
|
// mainnet.
|
||||||
var BitcoinMainNetParams = BitcoinNetParams{
|
var BitcoinMainNetParams = BitcoinNetParams{
|
||||||
@ -53,8 +61,9 @@ var BitcoinRegTestNetParams = BitcoinNetParams{
|
|||||||
CoinType: keychain.CoinTypeTestnet,
|
CoinType: keychain.CoinTypeTestnet,
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsTestnet tests if the givern params correspond to a testnet
|
// IsTestnet tests if the given params correspond to a testnet parameter
|
||||||
// parameter configuration.
|
// configuration.
|
||||||
func IsTestnet(params *BitcoinNetParams) bool {
|
func IsTestnet(params *BitcoinNetParams) bool {
|
||||||
return params.Params.Net == bitcoinWire.TestNet3
|
return params.Params.Net == bitcoinWire.TestNet3 ||
|
||||||
|
params.Params.Net == bitcoinWire.TestNet4
|
||||||
}
|
}
|
||||||
|
@ -838,6 +838,15 @@ var (
|
|||||||
0x01, 0xea, 0x33, 0x09, 0x00, 0x00, 0x00, 0x00,
|
0x01, 0xea, 0x33, 0x09, 0x00, 0x00, 0x00, 0x00,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// BitcoinTestnet4Genesis is the genesis hash of Bitcoin's testnet4
|
||||||
|
// chain.
|
||||||
|
BitcoinTestnet4Genesis = chainhash.Hash([chainhash.HashSize]byte{
|
||||||
|
0x43, 0xf0, 0x8b, 0xda, 0xb0, 0x50, 0xe3, 0x5b,
|
||||||
|
0x56, 0x7c, 0x86, 0x4b, 0x91, 0xf4, 0x7f, 0x50,
|
||||||
|
0xae, 0x72, 0x5a, 0xe2, 0xde, 0x53, 0xbc, 0xfb,
|
||||||
|
0xba, 0xf2, 0x84, 0xda, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
})
|
||||||
|
|
||||||
// BitcoinSignetGenesis is the genesis hash of Bitcoin's signet chain.
|
// BitcoinSignetGenesis is the genesis hash of Bitcoin's signet chain.
|
||||||
BitcoinSignetGenesis = chainhash.Hash([chainhash.HashSize]byte{
|
BitcoinSignetGenesis = chainhash.Hash([chainhash.HashSize]byte{
|
||||||
0xf6, 0x1e, 0xee, 0x3b, 0x63, 0xa3, 0x80, 0xa4,
|
0xf6, 0x1e, 0xee, 0x3b, 0x63, 0xa3, 0x80, 0xa4,
|
||||||
|
@ -286,7 +286,7 @@ func contextWithMetadata(ctx context.Context,
|
|||||||
func extractPathArgs(ctx *cli.Context) (string, string, error) {
|
func extractPathArgs(ctx *cli.Context) (string, string, error) {
|
||||||
network := strings.ToLower(ctx.GlobalString("network"))
|
network := strings.ToLower(ctx.GlobalString("network"))
|
||||||
switch network {
|
switch network {
|
||||||
case "mainnet", "testnet", "regtest", "simnet", "signet":
|
case "mainnet", "testnet", "testnet4", "regtest", "simnet", "signet":
|
||||||
default:
|
default:
|
||||||
return "", "", fmt.Errorf("unknown network: %v", network)
|
return "", "", fmt.Errorf("unknown network: %v", network)
|
||||||
}
|
}
|
||||||
@ -386,8 +386,9 @@ func Main() {
|
|||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "network, n",
|
Name: "network, n",
|
||||||
Usage: "The network lnd is running on, e.g. mainnet, " +
|
Usage: "The network lnd is running on; valid values " +
|
||||||
"testnet, etc.",
|
"are: mainnet, testnet, testnet4, regtest, " +
|
||||||
|
"signet and simnet.",
|
||||||
Value: "mainnet",
|
Value: "mainnet",
|
||||||
EnvVar: envVarNetwork,
|
EnvVar: envVarNetwork,
|
||||||
},
|
},
|
||||||
@ -555,9 +556,12 @@ func networkParams(ctx *cli.Context) (*chaincfg.Params, error) {
|
|||||||
case "mainnet":
|
case "mainnet":
|
||||||
return &chaincfg.MainNetParams, nil
|
return &chaincfg.MainNetParams, nil
|
||||||
|
|
||||||
case "testnet":
|
case "testnet", "testnet3":
|
||||||
return &chaincfg.TestNet3Params, nil
|
return &chaincfg.TestNet3Params, nil
|
||||||
|
|
||||||
|
case "testnet4":
|
||||||
|
return &chaincfg.TestNet4Params, nil
|
||||||
|
|
||||||
case "regtest":
|
case "regtest":
|
||||||
return &chaincfg.RegressionNetParams, nil
|
return &chaincfg.RegressionNetParams, nil
|
||||||
|
|
||||||
|
17
config.go
17
config.go
@ -1208,6 +1208,10 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
|||||||
numNets++
|
numNets++
|
||||||
cfg.ActiveNetParams = chainreg.BitcoinTestNetParams
|
cfg.ActiveNetParams = chainreg.BitcoinTestNetParams
|
||||||
}
|
}
|
||||||
|
if cfg.Bitcoin.TestNet4 {
|
||||||
|
numNets++
|
||||||
|
cfg.ActiveNetParams = chainreg.BitcoinTestNet4Params
|
||||||
|
}
|
||||||
if cfg.Bitcoin.RegTest {
|
if cfg.Bitcoin.RegTest {
|
||||||
numNets++
|
numNets++
|
||||||
cfg.ActiveNetParams = chainreg.BitcoinRegTestNetParams
|
cfg.ActiveNetParams = chainreg.BitcoinRegTestNetParams
|
||||||
@ -1265,8 +1269,8 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
|||||||
cfg.ActiveNetParams.Params = &chainParams
|
cfg.ActiveNetParams.Params = &chainParams
|
||||||
}
|
}
|
||||||
if numNets > 1 {
|
if numNets > 1 {
|
||||||
str := "The mainnet, testnet, regtest, simnet and signet " +
|
str := "The mainnet, testnet, testnet4, regtest, simnet and " +
|
||||||
"params can't be used together -- choose one " +
|
"signet params can't be used together -- choose one " +
|
||||||
"of the five"
|
"of the five"
|
||||||
|
|
||||||
return nil, mkErr(str)
|
return nil, mkErr(str)
|
||||||
@ -1275,9 +1279,10 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
|||||||
// The target network must be provided, otherwise, we won't
|
// The target network must be provided, otherwise, we won't
|
||||||
// know how to initialize the daemon.
|
// know how to initialize the daemon.
|
||||||
if numNets == 0 {
|
if numNets == 0 {
|
||||||
str := "either --bitcoin.mainnet, or bitcoin.testnet, " +
|
str := "either --bitcoin.mainnet, or --bitcoin.testnet, " +
|
||||||
"bitcoin.simnet, bitcoin.regtest or bitcoin.signet " +
|
"--bitcoin.testnet4, --bitcoin.simnet, " +
|
||||||
"must be specified"
|
"--bitcoin.regtest or --bitcoin.signet must be " +
|
||||||
|
"specified"
|
||||||
|
|
||||||
return nil, mkErr(str)
|
return nil, mkErr(str)
|
||||||
}
|
}
|
||||||
@ -2202,7 +2207,7 @@ func extractBitcoindRPCParams(networkName, bitcoindDataDir, bitcoindConfigPath,
|
|||||||
switch networkName {
|
switch networkName {
|
||||||
case "mainnet":
|
case "mainnet":
|
||||||
chainDir = ""
|
chainDir = ""
|
||||||
case "regtest", "testnet3", "signet":
|
case "regtest", "testnet3", "testnet4", "signet":
|
||||||
chainDir = networkName
|
chainDir = networkName
|
||||||
default:
|
default:
|
||||||
return "", "", "", "", fmt.Errorf("unexpected networkname %v", networkName)
|
return "", "", "", "", fmt.Errorf("unexpected networkname %v", networkName)
|
||||||
|
@ -17,6 +17,7 @@ type Chain struct {
|
|||||||
|
|
||||||
MainNet bool `long:"mainnet" description:"Use the main network"`
|
MainNet bool `long:"mainnet" description:"Use the main network"`
|
||||||
TestNet3 bool `long:"testnet" description:"Use the test network"`
|
TestNet3 bool `long:"testnet" description:"Use the test network"`
|
||||||
|
TestNet4 bool `long:"testnet4" description:"Use the testnet4 test network"`
|
||||||
SimNet bool `long:"simnet" description:"Use the simulation test network"`
|
SimNet bool `long:"simnet" description:"Use the simulation test network"`
|
||||||
RegTest bool `long:"regtest" description:"Use the regression test network"`
|
RegTest bool `long:"regtest" description:"Use the regression test network"`
|
||||||
SigNet bool `long:"signet" description:"Use the signet test network"`
|
SigNet bool `long:"signet" description:"Use the signet test network"`
|
||||||
|
@ -108,6 +108,14 @@ func CleanAndExpandPath(path string) string {
|
|||||||
// NormalizeNetwork returns the common name of a network type used to create
|
// NormalizeNetwork returns the common name of a network type used to create
|
||||||
// file paths. This allows differently versioned networks to use the same path.
|
// file paths. This allows differently versioned networks to use the same path.
|
||||||
func NormalizeNetwork(network string) string {
|
func NormalizeNetwork(network string) string {
|
||||||
|
// The 4th testnet isn't the "default" yet, so we'll want to explicitly
|
||||||
|
// point that to a "testnet4" directory.
|
||||||
|
if network == "testnet4" {
|
||||||
|
return network
|
||||||
|
}
|
||||||
|
|
||||||
|
// We want to collapse "testnet3" and "testnet" to the same "testnet"
|
||||||
|
// directory.
|
||||||
if strings.HasPrefix(network, "testnet") {
|
if strings.HasPrefix(network, "testnet") {
|
||||||
return "testnet"
|
return "testnet"
|
||||||
}
|
}
|
||||||
|
3
lnd.go
3
lnd.go
@ -194,6 +194,9 @@ func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg,
|
|||||||
case cfg.Bitcoin.TestNet3:
|
case cfg.Bitcoin.TestNet3:
|
||||||
network = "testnet"
|
network = "testnet"
|
||||||
|
|
||||||
|
case cfg.Bitcoin.TestNet4:
|
||||||
|
network = "testnet4"
|
||||||
|
|
||||||
case cfg.Bitcoin.MainNet:
|
case cfg.Bitcoin.MainNet:
|
||||||
network = "mainnet"
|
network = "mainnet"
|
||||||
|
|
||||||
|
@ -6265,8 +6265,8 @@ type GetInfoResponse struct {
|
|||||||
SyncedToChain bool `protobuf:"varint,9,opt,name=synced_to_chain,json=syncedToChain,proto3" json:"synced_to_chain,omitempty"`
|
SyncedToChain bool `protobuf:"varint,9,opt,name=synced_to_chain,json=syncedToChain,proto3" json:"synced_to_chain,omitempty"`
|
||||||
// Whether we consider ourselves synced with the public channel graph.
|
// Whether we consider ourselves synced with the public channel graph.
|
||||||
SyncedToGraph bool `protobuf:"varint,18,opt,name=synced_to_graph,json=syncedToGraph,proto3" json:"synced_to_graph,omitempty"`
|
SyncedToGraph bool `protobuf:"varint,18,opt,name=synced_to_graph,json=syncedToGraph,proto3" json:"synced_to_graph,omitempty"`
|
||||||
// Whether the current node is connected to testnet. This field is
|
// Whether the current node is connected to testnet or testnet4. This field is
|
||||||
// deprecated and the network field should be used instead
|
// deprecated and the network field should be used instead.
|
||||||
//
|
//
|
||||||
// Deprecated: Marked as deprecated in lightning.proto.
|
// Deprecated: Marked as deprecated in lightning.proto.
|
||||||
Testnet bool `protobuf:"varint,10,opt,name=testnet,proto3" json:"testnet,omitempty"`
|
Testnet bool `protobuf:"varint,10,opt,name=testnet,proto3" json:"testnet,omitempty"`
|
||||||
|
@ -2008,8 +2008,8 @@ message GetInfoResponse {
|
|||||||
bool synced_to_graph = 18;
|
bool synced_to_graph = 18;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Whether the current node is connected to testnet. This field is
|
Whether the current node is connected to testnet or testnet4. This field is
|
||||||
deprecated and the network field should be used instead
|
deprecated and the network field should be used instead.
|
||||||
*/
|
*/
|
||||||
bool testnet = 10 [deprecated = true];
|
bool testnet = 10 [deprecated = true];
|
||||||
|
|
||||||
|
@ -5196,7 +5196,7 @@
|
|||||||
},
|
},
|
||||||
"testnet": {
|
"testnet": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"title": "Whether the current node is connected to testnet. This field is\ndeprecated and the network field should be used instead"
|
"description": "Whether the current node is connected to testnet or testnet4. This field is\ndeprecated and the network field should be used instead."
|
||||||
},
|
},
|
||||||
"chains": {
|
"chains": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
@ -222,6 +222,8 @@ func (cfg *BaseNodeConfig) GenArgs() []string {
|
|||||||
switch cfg.NetParams {
|
switch cfg.NetParams {
|
||||||
case &chaincfg.TestNet3Params:
|
case &chaincfg.TestNet3Params:
|
||||||
args = append(args, "--bitcoin.testnet")
|
args = append(args, "--bitcoin.testnet")
|
||||||
|
case &chaincfg.TestNet4Params:
|
||||||
|
args = append(args, "--bitcoin.testnet4")
|
||||||
case &chaincfg.SimNetParams:
|
case &chaincfg.SimNetParams:
|
||||||
args = append(args, "--bitcoin.simnet")
|
args = append(args, "--bitcoin.simnet")
|
||||||
case &chaincfg.RegressionNetParams:
|
case &chaincfg.RegressionNetParams:
|
||||||
|
@ -621,6 +621,9 @@
|
|||||||
; Use Bitcoin's test network.
|
; Use Bitcoin's test network.
|
||||||
; bitcoin.testnet=false
|
; bitcoin.testnet=false
|
||||||
;
|
;
|
||||||
|
; Use Bitcoin's 4th version test network.
|
||||||
|
; bitcoin.testnet4=false
|
||||||
|
;
|
||||||
; Use Bitcoin's simulation test network
|
; Use Bitcoin's simulation test network
|
||||||
; bitcoin.simnet=false
|
; bitcoin.simnet=false
|
||||||
|
|
||||||
|
@ -2594,6 +2594,12 @@ func (s *server) Start() error {
|
|||||||
chainreg.BitcoinTestnetGenesis,
|
chainreg.BitcoinTestnetGenesis,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if s.cfg.Bitcoin.TestNet4 {
|
||||||
|
setSeedList(
|
||||||
|
s.cfg.Bitcoin.DNSSeeds,
|
||||||
|
chainreg.BitcoinTestnet4Genesis,
|
||||||
|
)
|
||||||
|
}
|
||||||
if s.cfg.Bitcoin.SigNet {
|
if s.cfg.Bitcoin.SigNet {
|
||||||
setSeedList(
|
setSeedList(
|
||||||
s.cfg.Bitcoin.DNSSeeds,
|
s.cfg.Bitcoin.DNSSeeds,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user