64 lines
1.4 KiB
Go
64 lines
1.4 KiB
Go
package flo
|
|
|
|
import (
|
|
"blockbook/bchain/coins/btc"
|
|
|
|
"github.com/btcsuite/btcd/wire"
|
|
"github.com/jakm/btcutil/chaincfg"
|
|
)
|
|
|
|
const (
|
|
MainnetMagic wire.BitcoinNet = 0xf1a5c0fd
|
|
TestnetMagic wire.BitcoinNet = 0xf25ac0fd
|
|
RegtestMagic wire.BitcoinNet = 0xdab5bffa
|
|
)
|
|
|
|
var (
|
|
MainNetParams chaincfg.Params
|
|
TestNetParams chaincfg.Params
|
|
)
|
|
|
|
func init() {
|
|
MainNetParams = chaincfg.MainNetParams
|
|
MainNetParams.Net = MainnetMagic
|
|
MainNetParams.PubKeyHashAddrID = []byte{35}
|
|
MainNetParams.ScriptHashAddrID = []byte{94}
|
|
MainNetParams.Bech32HRPSegwit = "flo"
|
|
|
|
TestNetParams = chaincfg.TestNet3Params
|
|
TestNetParams.Net = TestnetMagic
|
|
TestNetParams.PubKeyHashAddrID = []byte{115}
|
|
TestNetParams.ScriptHashAddrID = []byte{198}
|
|
TestNetParams.Bech32HRPSegwit = "tflo"
|
|
}
|
|
|
|
// FloParser handle
|
|
type FloParser struct {
|
|
*btc.BitcoinParser
|
|
}
|
|
|
|
// NewFloParser returns new FloParser instance
|
|
func NewFloParser(params *chaincfg.Params, c *btc.Configuration) *FloParser {
|
|
return &FloParser{BitcoinParser: btc.NewBitcoinParser(params, c)}
|
|
}
|
|
|
|
// GetChainParams contains network parameters for the main Flo network,
|
|
// and the test Flo network
|
|
func GetChainParams(chain string) *chaincfg.Params {
|
|
if !chaincfg.IsRegistered(&MainNetParams) {
|
|
err := chaincfg.Register(&MainNetParams)
|
|
if err == nil {
|
|
err = chaincfg.Register(&TestNetParams)
|
|
}
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
switch chain {
|
|
case "test":
|
|
return &TestNetParams
|
|
default:
|
|
return &MainNetParams
|
|
}
|
|
}
|