Add PIVX Testnet (#110)
* fix PIVX MainnetMagic byte order * add PIVX Testnet * PIVX: zerocoin address labels
This commit is contained in:
parent
8efaa4ebc3
commit
818288cd16
@ -69,6 +69,7 @@ func init() {
|
||||
BlockChainFactories["Groestlcoin"] = grs.NewGroestlcoinRPC
|
||||
BlockChainFactories["Groestlcoin Testnet"] = grs.NewGroestlcoinRPC
|
||||
BlockChainFactories["PIVX"] = pivx.NewPivXRPC
|
||||
BlockChainFactories["PIVX Testnet"] = pivx.NewPivXRPC
|
||||
BlockChainFactories["Zcoin"] = xzc.NewZcoinRPC
|
||||
BlockChainFactories["Fujicoin"] = fujicoin.NewFujicoinRPC
|
||||
}
|
||||
|
||||
@ -20,19 +20,34 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
MainnetMagic wire.BitcoinNet = 0x90c4fde9
|
||||
// Net Magics
|
||||
MainnetMagic wire.BitcoinNet = 0xe9fdc490
|
||||
TestnetMagic wire.BitcoinNet = 0xba657645
|
||||
|
||||
// Zerocoin op codes
|
||||
OP_ZEROCOINMINT = 0xc1
|
||||
OP_ZEROCOINSPEND = 0xc2
|
||||
)
|
||||
|
||||
var (
|
||||
MainNetParams chaincfg.Params
|
||||
TestNetParams chaincfg.Params
|
||||
)
|
||||
|
||||
func init() {
|
||||
// PIVX mainnet Address encoding magics
|
||||
MainNetParams = chaincfg.MainNetParams
|
||||
MainNetParams.Net = MainnetMagic
|
||||
MainNetParams.PubKeyHashAddrID = []byte{30}
|
||||
MainNetParams.PubKeyHashAddrID = []byte{30} // starting with 'D'
|
||||
MainNetParams.ScriptHashAddrID = []byte{13}
|
||||
MainNetParams.PrivateKeyID = []byte{212}
|
||||
|
||||
// PIVX testnet Address encoding magics
|
||||
TestNetParams = chaincfg.TestNet3Params
|
||||
TestNetParams.Net = TestnetMagic
|
||||
TestNetParams.PubKeyHashAddrID = []byte{139} // starting with 'x' or 'y'
|
||||
TestNetParams.ScriptHashAddrID = []byte{19}
|
||||
TestNetParams.PrivateKeyID = []byte{239}
|
||||
}
|
||||
|
||||
// PivXParser handle
|
||||
@ -57,11 +72,19 @@ func NewPivXParser(params *chaincfg.Params, c *btc.Configuration) *PivXParser {
|
||||
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)
|
||||
}
|
||||
}
|
||||
return &MainNetParams
|
||||
switch chain {
|
||||
case "test":
|
||||
return &TestNetParams
|
||||
default:
|
||||
return &MainNetParams
|
||||
}
|
||||
}
|
||||
|
||||
// ParseBlock parses raw block to our Block struct
|
||||
@ -209,10 +232,11 @@ func (p *PivXParser) ParseTxFromJson(msg json.RawMessage) (*bchain.Tx, error) {
|
||||
|
||||
// outputScriptToAddresses converts ScriptPubKey to bitcoin addresses
|
||||
func (p *PivXParser) outputScriptToAddresses(script []byte) ([]string, bool, error) {
|
||||
if isZeroCoinSpendScript(script) || isZeroCoinMintScript(script) {
|
||||
hexScript := hex.EncodeToString(script)
|
||||
anonAddr := "Anonymous " + hexScript
|
||||
return []string{anonAddr}, false, nil
|
||||
if isZeroCoinSpendScript(script) {
|
||||
return []string{"Zerocoin Spend"}, false, nil
|
||||
}
|
||||
if isZeroCoinMintScript(script) {
|
||||
return []string{"Zerocoin Mint"}, false, nil
|
||||
}
|
||||
|
||||
rv, s, _ := p.BitcoinOutputScriptToAddressesFunc(script)
|
||||
@ -235,22 +259,10 @@ func (p *PivXParser) GetAddrDescForUnknownInput(tx *bchain.Tx, input int) bchain
|
||||
|
||||
// Checks if script is OP_ZEROCOINMINT
|
||||
func isZeroCoinMintScript(signatureScript []byte) bool {
|
||||
OP_ZEROCOINMINT := byte(0xc1)
|
||||
|
||||
if len(signatureScript) > 1 && signatureScript[0] == OP_ZEROCOINMINT {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
return len(signatureScript) > 1 && signatureScript[0] == OP_ZEROCOINMINT
|
||||
}
|
||||
|
||||
// Checks if script is OP_ZEROCOINSPEND
|
||||
func isZeroCoinSpendScript(signatureScript []byte) bool {
|
||||
OP_ZEROCOINSPEND := byte(0xc2)
|
||||
|
||||
if len(signatureScript) >= 100 && signatureScript[0] == OP_ZEROCOINSPEND {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
return len(signatureScript) >= 100 && signatureScript[0] == OP_ZEROCOINSPEND
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -43,8 +43,14 @@ func (b *PivXRPC) Initialize() error {
|
||||
// always create parser
|
||||
b.Parser = NewPivXParser(params, b.ChainConfig)
|
||||
|
||||
b.Testnet = false
|
||||
b.Network = "livenet"
|
||||
// parameters for getInfo request
|
||||
if params.Net == MainnetMagic {
|
||||
b.Testnet = false
|
||||
b.Network = "livenet"
|
||||
} else {
|
||||
b.Testnet = true
|
||||
b.Network = "testnet"
|
||||
}
|
||||
|
||||
glog.Info("rpc: block chain ", params.Name)
|
||||
|
||||
|
||||
63
configs/coins/pivx_testnet.json
Normal file
63
configs/coins/pivx_testnet.json
Normal file
@ -0,0 +1,63 @@
|
||||
{
|
||||
"coin": {
|
||||
"name": "PIVX Testnet",
|
||||
"shortcut": "tPIV",
|
||||
"label": "PIVX Testnet",
|
||||
"alias": "pivx_testnet"
|
||||
},
|
||||
"ports": {
|
||||
"backend_rpc": 18049,
|
||||
"backend_message_queue": 48349,
|
||||
"blockbook_internal": 19049,
|
||||
"blockbook_public": 19149
|
||||
},
|
||||
"ipc": {
|
||||
"rpc_url_template": "http://127.0.0.1:{{.Ports.BackendRPC}}",
|
||||
"rpc_user": "rpc",
|
||||
"rpc_pass": "pivxrpc",
|
||||
"rpc_timeout": 25,
|
||||
"message_queue_binding_template": "tcp://127.0.0.1:{{.Ports.BackendMessageQueue}}"
|
||||
},
|
||||
"backend": {
|
||||
"package_name": "backend-pivx",
|
||||
"package_revision": "satoshilabs-1",
|
||||
"system_user": "pivx",
|
||||
"version": "3.1.1",
|
||||
"binary_url": "https://github.com/PIVX-Project/PIVX/releases/download/v3.1.1/pivx-3.1.1-x86_64-linux-gnu.tar.gz",
|
||||
"verification_type": "sha256",
|
||||
"verification_source": "aac5b13beb9ff96b0ce62d2258d54166c756c8336672a67c7aae6b73a76b0c03",
|
||||
"extract_command": "tar -C backend --strip 1 -xf",
|
||||
"exclude_files": ["bin/pivx-qt"],
|
||||
"exec_command_template": "{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/bin/pivxd -datadir={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend -conf={{.Env.BackendInstallPath}}/{{.Coin.Alias}}/{{.Coin.Alias}}.conf -pid=/run/{{.Coin.Alias}}/{{.Coin.Alias}}.pid",
|
||||
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/*.log",
|
||||
"postinst_script_template": "",
|
||||
"service_type": "forking",
|
||||
"service_additional_params_template": "",
|
||||
"protect_memory": true,
|
||||
"mainnet": false,
|
||||
"server_config_file": "bitcoin_like.conf",
|
||||
"client_config_file": "bitcoin_like_client.conf",
|
||||
"additional_params": {
|
||||
"whitelist": "127.0.0.1"
|
||||
}
|
||||
},
|
||||
"blockbook": {
|
||||
"package_name": "blockbook-pivx-testnet",
|
||||
"system_user": "blockbook-pivx",
|
||||
"internal_binding_template": ":{{.Ports.BlockbookInternal}}",
|
||||
"public_binding_template": ":{{.Ports.BlockbookPublic}}",
|
||||
"explorer_url": "",
|
||||
"additional_params": "",
|
||||
"block_chain": {
|
||||
"parse": true,
|
||||
"mempool_workers": 8,
|
||||
"mempool_sub_workers": 2,
|
||||
"block_addresses_to_keep": 300,
|
||||
"additional_params": {}
|
||||
}
|
||||
},
|
||||
"meta": {
|
||||
"package_maintainer": "PIVX team",
|
||||
"package_maintainer_email": "random.zebra@protonmail.com"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user