2016-07-14 04:37:50 +03:00
|
|
|
package main
|
|
|
|
|
2017-05-03 05:42:10 +03:00
|
|
|
import (
|
|
|
|
litecoinCfg "github.com/ltcsuite/ltcd/chaincfg"
|
2017-09-01 13:17:19 +03:00
|
|
|
"github.com/roasbeef/btcd/chaincfg"
|
2017-05-03 05:42:10 +03:00
|
|
|
bitcoinCfg "github.com/roasbeef/btcd/chaincfg"
|
2017-09-01 13:17:19 +03:00
|
|
|
"github.com/roasbeef/btcd/chaincfg/chainhash"
|
2017-05-03 05:42:10 +03:00
|
|
|
"github.com/roasbeef/btcd/wire"
|
|
|
|
)
|
2016-07-14 04:37:50 +03:00
|
|
|
|
|
|
|
// activeNetParams is a pointer to the parameters specific to the currently
|
|
|
|
// active bitcoin network.
|
2017-05-03 05:42:10 +03:00
|
|
|
var activeNetParams = bitcoinTestNetParams
|
2016-07-14 04:37:50 +03:00
|
|
|
|
2017-05-03 05:42:10 +03:00
|
|
|
// bitcoinNetParams couples the p2p parameters of a network with the
|
|
|
|
// corresponding RPC port of a daemon running on the particular network.
|
|
|
|
type bitcoinNetParams struct {
|
|
|
|
*bitcoinCfg.Params
|
2016-07-14 04:37:50 +03:00
|
|
|
rpcPort string
|
|
|
|
}
|
|
|
|
|
2017-05-03 05:42:10 +03:00
|
|
|
// litecoinNetParams couples the p2p parameters of a network with the
|
|
|
|
// corresponding RPC port of a daemon running on the particular network.
|
|
|
|
type litecoinNetParams struct {
|
|
|
|
*litecoinCfg.Params
|
|
|
|
rpcPort string
|
|
|
|
}
|
|
|
|
|
|
|
|
// bitcoinTestNetParams contains parameters specific to the 3rd version of the
|
|
|
|
// test network.
|
|
|
|
var bitcoinTestNetParams = bitcoinNetParams{
|
|
|
|
Params: &bitcoinCfg.TestNet3Params,
|
2016-07-14 04:37:50 +03:00
|
|
|
rpcPort: "18334",
|
|
|
|
}
|
|
|
|
|
2017-05-03 05:42:10 +03:00
|
|
|
// bitcoinSimNetParams contains parameters specific to the simulation test
|
|
|
|
// network.
|
|
|
|
var bitcoinSimNetParams = bitcoinNetParams{
|
|
|
|
Params: &bitcoinCfg.SimNetParams,
|
2016-07-14 04:37:50 +03:00
|
|
|
rpcPort: "18556",
|
|
|
|
}
|
2017-05-03 05:42:10 +03:00
|
|
|
|
|
|
|
// liteTestNetParams contains parameters specific to the 4th version of the
|
|
|
|
// test network.
|
|
|
|
var liteTestNetParams = litecoinNetParams{
|
|
|
|
Params: &litecoinCfg.TestNet4Params,
|
|
|
|
rpcPort: "19334",
|
|
|
|
}
|
|
|
|
|
2017-07-12 02:54:43 +03:00
|
|
|
// regTestNetParams contains parameters specific to a local regtest network.
|
|
|
|
var regTestNetParams = bitcoinNetParams{
|
|
|
|
Params: &bitcoinCfg.RegressionNetParams,
|
|
|
|
rpcPort: "18334",
|
|
|
|
}
|
|
|
|
|
2017-05-03 05:42:10 +03:00
|
|
|
// applyLitecoinParams applies the relevant chain configuration parameters that
|
|
|
|
// differ for litecoin to the chain parameters typed for btcsuite derivation.
|
|
|
|
// This function is used in place of using something like interface{} to
|
|
|
|
// abstract over _which_ chain (or fork) the parameters are for.
|
|
|
|
func applyLitecoinParams(params *bitcoinNetParams) {
|
|
|
|
params.Name = liteTestNetParams.Name
|
|
|
|
params.Net = wire.BitcoinNet(liteTestNetParams.Net)
|
|
|
|
params.DefaultPort = liteTestNetParams.DefaultPort
|
|
|
|
params.CoinbaseMaturity = liteTestNetParams.CoinbaseMaturity
|
|
|
|
|
|
|
|
copy(params.GenesisHash[:], liteTestNetParams.GenesisHash[:])
|
|
|
|
|
|
|
|
// Address encoding magics
|
|
|
|
params.PubKeyHashAddrID = liteTestNetParams.PubKeyHashAddrID
|
|
|
|
params.ScriptHashAddrID = liteTestNetParams.ScriptHashAddrID
|
|
|
|
params.PrivateKeyID = liteTestNetParams.PrivateKeyID
|
|
|
|
params.WitnessPubKeyHashAddrID = liteTestNetParams.WitnessPubKeyHashAddrID
|
|
|
|
params.WitnessScriptHashAddrID = liteTestNetParams.WitnessScriptHashAddrID
|
2017-09-01 12:11:45 +03:00
|
|
|
params.Bech32HRPSegwit = liteTestNetParams.Bech32HRPSegwit
|
2017-05-03 05:42:10 +03:00
|
|
|
|
|
|
|
copy(params.HDPrivateKeyID[:], liteTestNetParams.HDPrivateKeyID[:])
|
|
|
|
copy(params.HDPublicKeyID[:], liteTestNetParams.HDPublicKeyID[:])
|
|
|
|
|
|
|
|
params.HDCoinType = liteTestNetParams.HDCoinType
|
|
|
|
|
2017-09-01 13:17:19 +03:00
|
|
|
checkPoints := make([]chaincfg.Checkpoint, len(liteTestNetParams.Checkpoints))
|
|
|
|
for i := 0; i < len(liteTestNetParams.Checkpoints); i++ {
|
|
|
|
var chainHash chainhash.Hash
|
|
|
|
copy(chainHash[:], liteTestNetParams.Checkpoints[i].Hash[:])
|
|
|
|
|
|
|
|
checkPoints[i] = chaincfg.Checkpoint{
|
|
|
|
Height: liteTestNetParams.Checkpoints[i].Height,
|
|
|
|
Hash: &chainHash,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
params.Checkpoints = checkPoints
|
|
|
|
|
2017-05-03 05:42:10 +03:00
|
|
|
params.rpcPort = liteTestNetParams.rpcPort
|
|
|
|
}
|