United Monacoin params registration with implementation in other coins
This commit is contained in:
parent
23f111d1dc
commit
aea9d584f4
@ -6,8 +6,8 @@ import (
|
||||
"blockbook/bchain/coins/utils"
|
||||
"bytes"
|
||||
|
||||
"github.com/jakm/btcutil/chaincfg"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/jakm/btcutil/chaincfg"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -18,22 +18,17 @@ var (
|
||||
MainNetParams chaincfg.Params
|
||||
)
|
||||
|
||||
func initParams() {
|
||||
func init() {
|
||||
MainNetParams = chaincfg.MainNetParams
|
||||
MainNetParams.Net = MainnetMagic
|
||||
|
||||
MainNetParams.Bech32HRPSegwit = "my"
|
||||
|
||||
MainNetParams.PubKeyHashAddrID = []byte{50} // 0x32 - starts with M
|
||||
MainNetParams.ScriptHashAddrID = []byte{9} // 0x09 - starts with 4
|
||||
MainNetParams.PrivateKeyID = []byte{178} // 0xB2
|
||||
|
||||
MainNetParams.HDCoinType = 90
|
||||
MainNetParams.ScriptHashAddrID = []byte{9} // 0x09 - starts with 4
|
||||
MainNetParams.PrivateKeyID = []byte{178} // 0xB2
|
||||
|
||||
err := chaincfg.Register(&MainNetParams)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
MainNetParams.HDCoinType = 90
|
||||
}
|
||||
|
||||
// MyriadParser handle
|
||||
@ -48,8 +43,11 @@ func NewMyriadParser(params *chaincfg.Params, c *btc.Configuration) *MyriadParse
|
||||
|
||||
// GetChainParams contains network parameters for the main Myriad network
|
||||
func GetChainParams(chain string) *chaincfg.Params {
|
||||
if MainNetParams.Name == "" {
|
||||
initParams()
|
||||
if !chaincfg.IsRegistered(&MainNetParams) {
|
||||
err := chaincfg.Register(&MainNetParams)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
switch chain {
|
||||
default:
|
||||
|
||||
@ -7,10 +7,19 @@ import (
|
||||
"blockbook/bchain/coins/btc"
|
||||
"encoding/hex"
|
||||
"math/big"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/jakm/btcutil/chaincfg"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
c := m.Run()
|
||||
chaincfg.ResetParams()
|
||||
os.Exit(c)
|
||||
}
|
||||
|
||||
func Test_GetAddrDescFromAddress_Mainnet(t *testing.T) {
|
||||
type args struct {
|
||||
address string
|
||||
@ -57,9 +66,8 @@ func Test_GetAddrDescFromAddress_Mainnet(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var (
|
||||
testTx1 bchain.Tx
|
||||
testTx1 bchain.Tx
|
||||
testTxPacked1 = "00004e208ab194a1180100000001163465df9bb21d89e90056f11887a398d5a313aef71e3974306459661a91588c000000006b4830450220129c9e9a27406796f3f7d7edcc446037b38ddb3ef94745cec8e7cde618a811140221008eb3b893cdd3725e99b74c020867821e1f74199065260586f5ef3c22b133dd2a012103e2e23d38dc8fa493cde4077f650ab9f22eacafd14a10b123994f38c9f35dfee9ffffffff025e90ec28050000001976a9141cba92fe1510b8c73550fd4d3e0b44acdffcd12d88ac79c268ba0a0000001976a9142f86cdfa98cac89143cf9e3d309cc072caccdf6f88ac00000000"
|
||||
)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user