chainparams: create isTestnet function
Tests if passed parameters correspond to a testnet configuration.
This commit is contained in:
parent
35fc4f48f7
commit
b2a4901aff
@ -3,10 +3,11 @@ package main
|
|||||||
import (
|
import (
|
||||||
"github.com/lightningnetwork/lnd/keychain"
|
"github.com/lightningnetwork/lnd/keychain"
|
||||||
litecoinCfg "github.com/ltcsuite/ltcd/chaincfg"
|
litecoinCfg "github.com/ltcsuite/ltcd/chaincfg"
|
||||||
|
litecoinWire "github.com/ltcsuite/ltcd/wire"
|
||||||
"github.com/roasbeef/btcd/chaincfg"
|
"github.com/roasbeef/btcd/chaincfg"
|
||||||
bitcoinCfg "github.com/roasbeef/btcd/chaincfg"
|
bitcoinCfg "github.com/roasbeef/btcd/chaincfg"
|
||||||
"github.com/roasbeef/btcd/chaincfg/chainhash"
|
"github.com/roasbeef/btcd/chaincfg/chainhash"
|
||||||
"github.com/roasbeef/btcd/wire"
|
bitcoinWire "github.com/roasbeef/btcd/wire"
|
||||||
)
|
)
|
||||||
|
|
||||||
// activeNetParams is a pointer to the parameters specific to the currently
|
// activeNetParams is a pointer to the parameters specific to the currently
|
||||||
@ -82,7 +83,7 @@ var regTestNetParams = bitcoinNetParams{
|
|||||||
// abstract over _which_ chain (or fork) the parameters are for.
|
// abstract over _which_ chain (or fork) the parameters are for.
|
||||||
func applyLitecoinParams(params *bitcoinNetParams, litecoinParams *litecoinNetParams) {
|
func applyLitecoinParams(params *bitcoinNetParams, litecoinParams *litecoinNetParams) {
|
||||||
params.Name = litecoinParams.Name
|
params.Name = litecoinParams.Name
|
||||||
params.Net = wire.BitcoinNet(litecoinParams.Net)
|
params.Net = bitcoinWire.BitcoinNet(litecoinParams.Net)
|
||||||
params.DefaultPort = litecoinParams.DefaultPort
|
params.DefaultPort = litecoinParams.DefaultPort
|
||||||
params.CoinbaseMaturity = litecoinParams.CoinbaseMaturity
|
params.CoinbaseMaturity = litecoinParams.CoinbaseMaturity
|
||||||
|
|
||||||
@ -116,3 +117,14 @@ func applyLitecoinParams(params *bitcoinNetParams, litecoinParams *litecoinNetPa
|
|||||||
params.rpcPort = litecoinParams.rpcPort
|
params.rpcPort = litecoinParams.rpcPort
|
||||||
params.CoinType = litecoinParams.CoinType
|
params.CoinType = litecoinParams.CoinType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isTestnet tests if the given params correspond to a testnet
|
||||||
|
// parameter configuration.
|
||||||
|
func isTestnet(params *bitcoinNetParams) bool {
|
||||||
|
switch params.Params.Net {
|
||||||
|
case bitcoinWire.TestNet3, bitcoinWire.BitcoinNet(litecoinWire.TestNet4):
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user