func IsPubKeyHashAddrID(id byte) bool {
	_, ok := pubKeyHashAddrIDs[id]
	return ok
}
IsPubKeyHashAddrID returns whether the id is an identifier known to prefix a
pay-to-pubkey-hash address on any default or registered network.  This is
used when decoding an address string into a specific address type.  It is up
to the caller to check both this and IsScriptHashAddrID and decide whether an
address is a pubkey hash address, script hash address, neither, or
undeterminable (if both return true).
package chaincfg
import (
	"errors"
	"math"
	"math/big"
	"strings"
	"time"
	"github.com/soteria-dag/soterd/chaincfg/chainhash"
	"github.com/soteria-dag/soterd/wire"
)
var (
	bigOne = big.NewInt(1)
	mainPowLimit = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 224), bigOne)
	regressionPowLimit = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
	testNet1PowLimit = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 231), bigOne)
	simNetPowLimit = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
)
type DNSSeed struct {
	Host string
	HasFiltering bool
}
type ConsensusDeployment struct {
	BitNumber uint8
	StartTime uint64
	ExpireTime uint64
}
const (
	DeploymentTestDummy = iota
	DeploymentCSV
	DeploymentSegwit
	DefinedDeployments
)
type Params struct {
	Name string
	Net wire.SoterNet
	DefaultPort string
	DNSSeeds []DNSSeed
	GenesisBlock *wire.MsgBlock
	GenesisHash *chainhash.Hash
	PowLimit *big.Int
	PowLimitBits uint32
	BIP0034Height int32
	BIP0065Height int32
	BIP0066Height int32
	CoinbaseMaturity uint16
	SubsidyReductionInterval int32
	TargetTimespan time.Duration
	TargetTimePerBlock time.Duration
	RetargetAdjustmentFactor int64
	ReduceMinDifficulty bool
	MinDiffReductionTime time.Duration
	GenerateSupported bool
	RuleChangeActivationThreshold uint32
	MinerConfirmationWindow       uint32
	Deployments                   [DefinedDeployments]ConsensusDeployment
	RelayNonStdTxs bool
	Bech32HRPSegwit string
	PubKeyHashAddrID        byte  
	ScriptHashAddrID        byte  
	PrivateKeyID            byte  
	WitnessPubKeyHashAddrID byte  
	WitnessScriptHashAddrID byte  
	HDPrivateKeyID [4]byte
	HDPublicKeyID  [4]byte
	HDCoinType uint32
}
var MainNetParams = Params{
	Name:        "mainnet",
	Net:         wire.MainNet,
	DefaultPort: "8333",
	DNSSeeds: []DNSSeed{
		{"seed.bitcoin.sipa.be", true},
		{"dnsseed.bluematt.me", true},
		{"dnsseed.bitcoin.dashjr.org", false},
		{"seed.bitcoinstats.com", true},
		{"seed.bitnodes.io", false},
		{"seed.bitcoin.jonasschnelli.ch", true},
	},
	GenesisBlock:             &genesisBlock,
	GenesisHash:              &genesisHash,
	PowLimit:                 mainPowLimit,
	PowLimitBits:             0x1d00ffff,
	BIP0034Height:            227931,  
	BIP0065Height:            388381,  
	BIP0066Height:            363725,  
	CoinbaseMaturity:         100,
	SubsidyReductionInterval: 210000,
	TargetTimespan:           time.Hour * 24 * 14,  
	TargetTimePerBlock:       time.Minute * 10,     
	RetargetAdjustmentFactor: 4,                    
	ReduceMinDifficulty:      false,
	MinDiffReductionTime:     0,
	GenerateSupported:        false,
	RuleChangeActivationThreshold: 1916,  
	MinerConfirmationWindow:       2016,  
	Deployments: [DefinedDeployments]ConsensusDeployment{
		DeploymentTestDummy: {
			BitNumber:  28,
			StartTime:  1199145601,  
			ExpireTime: 1230767999,  
		},
		DeploymentCSV: {
			BitNumber:  0,
			StartTime:  1462060800,  
			ExpireTime: 1493596800,  
		},
		DeploymentSegwit: {
			BitNumber:  1,
			StartTime:  1479168000,  
			ExpireTime: 1510704000,  
		},
	},
	RelayNonStdTxs: false,
	Bech32HRPSegwit: "bc",  
	PubKeyHashAddrID:        0x00,  
	ScriptHashAddrID:        0x05,  
	PrivateKeyID:            0x80,  
	WitnessPubKeyHashAddrID: 0x06,  
	WitnessScriptHashAddrID: 0x0A,  
	HDPrivateKeyID: [4]byte{0x04, 0x88, 0xad, 0xe4},  
	HDPublicKeyID:  [4]byte{0x04, 0x88, 0xb2, 0x1e},  
	HDCoinType: 0,
}
var RegressionNetParams = Params{
	Name:        "regtest",
	Net:         wire.TestNet,
	DefaultPort: "18444",
	DNSSeeds:    []DNSSeed{},
	GenesisBlock:             &regTestGenesisBlock,
	GenesisHash:              &regTestGenesisHash,
	PowLimit:                 regressionPowLimit,
	PowLimitBits:             0x207fffff,
	CoinbaseMaturity:         100,
	BIP0034Height:            100000000,  
	BIP0065Height:            1351,       
	BIP0066Height:            1251,       
	SubsidyReductionInterval: 150,
	TargetTimespan:           time.Hour * 24 * 14,  
	TargetTimePerBlock:       time.Minute * 10,     
	RetargetAdjustmentFactor: 4,                    
	ReduceMinDifficulty:      true,
	MinDiffReductionTime:     time.Minute * 20,  
	GenerateSupported:        true,
	RuleChangeActivationThreshold: 108,  
	MinerConfirmationWindow:       144,
	Deployments: [DefinedDeployments]ConsensusDeployment{
		DeploymentTestDummy: {
			BitNumber:  28,
			StartTime:  0,              
			ExpireTime: math.MaxInt64,  
		},
		DeploymentCSV: {
			BitNumber:  0,
			StartTime:  0,              
			ExpireTime: math.MaxInt64,  
		},
		DeploymentSegwit: {
			BitNumber:  1,
			StartTime:  0,              
			ExpireTime: math.MaxInt64,  
		},
	},
	RelayNonStdTxs: true,
	Bech32HRPSegwit: "bcrt",  
	PubKeyHashAddrID: 0x6f,  
	ScriptHashAddrID: 0xc4,  
	PrivateKeyID:     0xef,  
	HDPrivateKeyID: [4]byte{0x04, 0x35, 0x83, 0x94},  
	HDPublicKeyID:  [4]byte{0x04, 0x35, 0x87, 0xcf},  
	HDCoinType: 1,
}
var TestNet1Params = Params{
	Name:        "testnet1",
	Net:         wire.TestNet1,
	DefaultPort: "5070",
	DNSSeeds: []DNSSeed{
		{"134.209.59.43", true},
		{"192.241.147.9", true},
	},
	GenesisBlock:             &testNet1GenesisBlock,
	GenesisHash:              &testNet1GenesisHash,
	PowLimit:                 testNet1PowLimit,
	PowLimitBits:             0x1d7fffff,
	BIP0034Height:            21111,   
	BIP0065Height:            581885,  
	BIP0066Height:            330776,  
	CoinbaseMaturity:         100,
	SubsidyReductionInterval: 210000,
	TargetTimespan:           time.Hour * 24 * 1,  
	TargetTimePerBlock:       time.Minute * 1,     
	RetargetAdjustmentFactor: 4,                    
	ReduceMinDifficulty:      true,
	MinDiffReductionTime:     time.Minute * 20,  
	GenerateSupported:        false,
	RuleChangeActivationThreshold: 1512,  
	MinerConfirmationWindow:       2016,
	Deployments: [DefinedDeployments]ConsensusDeployment{
		DeploymentTestDummy: {
			BitNumber:  28,
			StartTime:  1199145601,  
			ExpireTime: 1230767999,  
		},
		DeploymentCSV: {
			BitNumber:  0,
			StartTime:  1456790400,  
			ExpireTime: 1493596800,  
		},
		DeploymentSegwit: {
			BitNumber:  1,
			StartTime:  1462060800,  
			ExpireTime: 1493596800,  
		},
	},
	RelayNonStdTxs: true,
	Bech32HRPSegwit: "tb",  
	PubKeyHashAddrID:        0x6f,  
	ScriptHashAddrID:        0xc4,  
	WitnessPubKeyHashAddrID: 0x03,  
	WitnessScriptHashAddrID: 0x28,  
	PrivateKeyID:            0xef,  
	HDPrivateKeyID: [4]byte{0x04, 0x35, 0x83, 0x94},  
	HDPublicKeyID:  [4]byte{0x04, 0x35, 0x87, 0xcf},  
	HDCoinType: 1,
}
var SimNetParams = Params{
	Name:        "simnet",
	Net:         wire.SimNet,
	DefaultPort: "18555",
	DNSSeeds:    []DNSSeed{},  
	GenesisBlock:             &simNetGenesisBlock,
	GenesisHash:              &simNetGenesisHash,
	PowLimit:                 simNetPowLimit,
	PowLimitBits:             0x207fffff,
	BIP0034Height:            0,  
	BIP0065Height:            0,  
	BIP0066Height:            0,  
	CoinbaseMaturity:         100,
	SubsidyReductionInterval: 210000,
	TargetTimespan:           time.Hour * 24 * 14,  
	TargetTimePerBlock:       time.Minute * 10,     
	RetargetAdjustmentFactor: 4,                    
	ReduceMinDifficulty:      true,
	MinDiffReductionTime:     time.Minute * 20,  
	GenerateSupported:        true,
	RuleChangeActivationThreshold: 75,  
	MinerConfirmationWindow:       100,
	Deployments: [DefinedDeployments]ConsensusDeployment{
		DeploymentTestDummy: {
			BitNumber:  28,
			StartTime:  0,              
			ExpireTime: math.MaxInt64,  
		},
		DeploymentCSV: {
			BitNumber:  0,
			StartTime:  0,              
			ExpireTime: math.MaxInt64,  
		},
		DeploymentSegwit: {
			BitNumber:  1,
			StartTime:  0,              
			ExpireTime: math.MaxInt64,  
		},
	},
	RelayNonStdTxs: true,
	Bech32HRPSegwit: "sb",  
	PubKeyHashAddrID:        0x3f,  
	ScriptHashAddrID:        0x7b,  
	PrivateKeyID:            0x64,  
	WitnessPubKeyHashAddrID: 0x19,  
	WitnessScriptHashAddrID: 0x28,  
	HDPrivateKeyID: [4]byte{0x04, 0x20, 0xb9, 0x00},  
	HDPublicKeyID:  [4]byte{0x04, 0x20, 0xbd, 0x3a},  
	HDCoinType: 115,  
}
var (
	ErrDuplicateNet = errors.New("duplicate Soter network")
	ErrUnknownHDKeyID = errors.New("unknown hd private extended key bytes")
)
var (
	registeredNets       = make(map[wire.SoterNet]struct{})
	pubKeyHashAddrIDs    = make(map[byte]struct{})
	scriptHashAddrIDs    = make(map[byte]struct{})
	bech32SegwitPrefixes = make(map[string]struct{})
	hdPrivToPubKeyIDs    = make(map[[4]byte][]byte)
)
func (d DNSSeed) String() string {
	return d.Host
}
func Register(params *Params) error {
	if _, ok := registeredNets[params.Net]; ok {
		return ErrDuplicateNet
	}
	registeredNets[params.Net] = struct{}{}
	pubKeyHashAddrIDs[params.PubKeyHashAddrID] = struct{}{}
	scriptHashAddrIDs[params.ScriptHashAddrID] = struct{}{}
	hdPrivToPubKeyIDs[params.HDPrivateKeyID] = params.HDPublicKeyID[:]
	bech32SegwitPrefixes[params.Bech32HRPSegwit+"1"] = struct{}{}
	return nil
}
func mustRegister(params *Params) {
	if err := Register(params); err != nil {
		panic("failed to register network: " + err.Error())
	}
}