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