2020-09-29 19:00:19 +02:00
|
|
|
package chainreg
|
2016-07-14 03:37:50 +02:00
|
|
|
|
2017-05-03 04:42:10 +02:00
|
|
|
import (
|
2018-06-05 03:34:16 +02:00
|
|
|
bitcoinCfg "github.com/btcsuite/btcd/chaincfg"
|
|
|
|
bitcoinWire "github.com/btcsuite/btcd/wire"
|
2018-07-18 04:23:47 +02:00
|
|
|
"github.com/lightningnetwork/lnd/keychain"
|
2017-05-03 04:42:10 +02:00
|
|
|
)
|
2016-07-14 03:37:50 +02:00
|
|
|
|
2020-09-29 19:00:19 +02:00
|
|
|
// BitcoinNetParams couples the p2p parameters of a network with the
|
2017-05-03 04:42:10 +02:00
|
|
|
// corresponding RPC port of a daemon running on the particular network.
|
2020-09-29 19:00:19 +02:00
|
|
|
type BitcoinNetParams struct {
|
2017-05-03 04:42:10 +02:00
|
|
|
*bitcoinCfg.Params
|
2020-09-29 19:00:19 +02:00
|
|
|
RPCPort string
|
2018-03-13 00:31:01 +01:00
|
|
|
CoinType uint32
|
2016-07-14 03:37:50 +02:00
|
|
|
}
|
|
|
|
|
2020-09-29 19:00:19 +02:00
|
|
|
// BitcoinTestNetParams contains parameters specific to the 3rd version of the
|
2017-05-03 04:42:10 +02:00
|
|
|
// test network.
|
2020-09-29 19:00:19 +02:00
|
|
|
var BitcoinTestNetParams = BitcoinNetParams{
|
2018-03-13 00:31:01 +01:00
|
|
|
Params: &bitcoinCfg.TestNet3Params,
|
2020-09-29 19:00:19 +02:00
|
|
|
RPCPort: "18334",
|
2018-03-13 00:31:01 +01:00
|
|
|
CoinType: keychain.CoinTypeTestnet,
|
2016-07-14 03:37:50 +02:00
|
|
|
}
|
|
|
|
|
2020-09-29 19:00:19 +02:00
|
|
|
// BitcoinMainNetParams contains parameters specific to the current Bitcoin
|
2018-03-15 10:00:44 +01:00
|
|
|
// mainnet.
|
2020-09-29 19:00:19 +02:00
|
|
|
var BitcoinMainNetParams = BitcoinNetParams{
|
2018-03-15 10:00:44 +01:00
|
|
|
Params: &bitcoinCfg.MainNetParams,
|
2020-09-29 19:00:19 +02:00
|
|
|
RPCPort: "8334",
|
2018-03-15 10:00:44 +01:00
|
|
|
CoinType: keychain.CoinTypeBitcoin,
|
|
|
|
}
|
|
|
|
|
2020-09-29 19:00:19 +02:00
|
|
|
// BitcoinSimNetParams contains parameters specific to the simulation test
|
2017-05-03 04:42:10 +02:00
|
|
|
// network.
|
2020-09-29 19:00:19 +02:00
|
|
|
var BitcoinSimNetParams = BitcoinNetParams{
|
2018-03-13 00:31:01 +01:00
|
|
|
Params: &bitcoinCfg.SimNetParams,
|
2020-09-29 19:00:19 +02:00
|
|
|
RPCPort: "18556",
|
2018-03-13 00:31:01 +01:00
|
|
|
CoinType: keychain.CoinTypeTestnet,
|
2016-07-14 03:37:50 +02:00
|
|
|
}
|
2017-05-03 04:42:10 +02:00
|
|
|
|
2020-12-24 16:46:13 +01:00
|
|
|
// BitcoinSigNetParams contains parameters specific to the signet test network.
|
|
|
|
var BitcoinSigNetParams = BitcoinNetParams{
|
|
|
|
Params: &bitcoinCfg.SigNetParams,
|
|
|
|
RPCPort: "38332",
|
|
|
|
CoinType: keychain.CoinTypeTestnet,
|
|
|
|
}
|
|
|
|
|
2020-09-29 19:00:19 +02:00
|
|
|
// BitcoinRegTestNetParams contains parameters specific to a local bitcoin
|
2018-11-29 22:53:01 +01:00
|
|
|
// regtest network.
|
2020-09-29 19:00:19 +02:00
|
|
|
var BitcoinRegTestNetParams = BitcoinNetParams{
|
2018-03-13 00:31:01 +01:00
|
|
|
Params: &bitcoinCfg.RegressionNetParams,
|
2020-09-29 19:00:19 +02:00
|
|
|
RPCPort: "18334",
|
2018-03-13 00:31:01 +01:00
|
|
|
CoinType: keychain.CoinTypeTestnet,
|
2017-07-12 01:54:43 +02:00
|
|
|
}
|
|
|
|
|
2020-09-29 19:00:19 +02:00
|
|
|
// IsTestnet tests if the givern params correspond to a testnet
|
2018-03-24 10:26:48 +01:00
|
|
|
// parameter configuration.
|
2020-09-29 19:00:19 +02:00
|
|
|
func IsTestnet(params *BitcoinNetParams) bool {
|
2023-08-03 18:43:36 +02:00
|
|
|
return params.Params.Net == bitcoinWire.TestNet3
|
2018-03-24 10:26:48 +01:00
|
|
|
}
|