Skip to content
Permalink
Browse files

Add CPUchain support

  • Loading branch information...
minkcrypto committed Aug 31, 2019
1 parent 9d5793a commit 6920b1c62975d92831c93f7810b7fa6c3b158522
@@ -6,6 +6,7 @@ import (
"blockbook/bchain/coins/bellcoin"
"blockbook/bchain/coins/btc"
"blockbook/bchain/coins/btg"
"blockbook/bchain/coins/cpuchain"
"blockbook/bchain/coins/dash"
"blockbook/bchain/coins/dcr"
"blockbook/bchain/coins/digibyte"
@@ -99,6 +100,7 @@ func init() {
BlockChainFactories["Ravencoin"] = ravencoin.NewRavencoinRPC
BlockChainFactories["Ritocoin"] = ritocoin.NewRitocoinRPC
BlockChainFactories["Divi"] = divi.NewDiviRPC
BlockChainFactories["CPUchain"] = cpuchain.NewCPUchainRPC
}

// GetCoinNameFromConfig gets coin name and coin shortcut from config file
@@ -0,0 +1,64 @@
package cpuchain

import (
"blockbook/bchain/coins/btc"

"github.com/martinboehm/btcd/wire"
"github.com/martinboehm/btcutil/chaincfg"
)

// magic numbers
const (
MainnetMagic wire.BitcoinNet = 0xefbeadde
TestnetMagic wire.BitcoinNet = 0x0cb0cefa
)

// chain parameters
var (
MainNetParams chaincfg.Params
TestNetParams chaincfg.Params
)

func init() {
MainNetParams = chaincfg.MainNetParams
MainNetParams.Net = MainnetMagic
MainNetParams.PubKeyHashAddrID = []byte{28}
MainNetParams.ScriptHashAddrID = []byte{30}
MainNetParams.Bech32HRPSegwit = "cpu"

TestNetParams = chaincfg.TestNet3Params
TestNetParams.Net = TestnetMagic
TestNetParams.PubKeyHashAddrID = []byte{111}
TestNetParams.ScriptHashAddrID = []byte{196}
TestNetParams.Bech32HRPSegwit = "tcpu"
}

// CPUchainParser handle
type CPUchainParser struct {
*btc.BitcoinParser
}

// NewCPUchainParser returns new CPUchainParser instance
func NewCPUchainParser(params *chaincfg.Params, c *btc.Configuration) *CPUchainParser {
return &CPUchainParser{BitcoinParser: btc.NewBitcoinParser(params, c)}
}

// GetChainParams contains network parameters for the main CPUchain network,
// and the test CPUchain 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
}
}
@@ -0,0 +1,58 @@
package cpuchain

import (
"blockbook/bchain"
"blockbook/bchain/coins/btc"
"encoding/json"

"github.com/golang/glog"
)

// CPUchainRPC is an interface to JSON-RPC bitcoind service.
type CPUchainRPC struct {
*btc.BitcoinRPC
}

// NewCPUchainRPC returns new CPUchainRPC instance.
func NewCPUchainRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) {
b, err := btc.NewBitcoinRPC(config, pushHandler)
if err != nil {
return nil, err
}

s := &CPUchainRPC{
b.(*btc.BitcoinRPC),
}
s.RPCMarshaler = btc.JSONMarshalerV2{}
s.ChainConfig.SupportsEstimateFee = false

return s, nil
}

// Initialize initializes CPUchainRPC instance.
func (b *CPUchainRPC) Initialize() error {
ci, err := b.GetChainInfo()
if err != nil {
return err
}
chainName := ci.Chain

glog.Info("Chain name ", chainName)
params := GetChainParams(chainName)

// always create parser
b.Parser = NewCPUchainParser(params, b.ChainConfig)

// 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)

return nil
}
@@ -0,0 +1 @@
00000020d5add6362e89ca36f34c908e030bb2467ab919cd7a961b2616aa756606000000dd88d513ccaf848da5a42d5b7af930f8ead36ed3b42b8c4b8c6b6b94ec512c95bf946a5d27980a1d10001de501010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff200362380104bf946a5d086000232f000000000d2f6e6f64655374726174756d2f00000000030000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf980010b27010000001976a914697ab38c1db7d672f5dbedff8936c290f906742c88ac80f0fa02000000001976a914fdcd08e6cb3451c95057130f94ef88b78a70b88e88ac0120000000000000000000000000000000000000000000000000000000000000000000000000
@@ -0,0 +1 @@
0000002010588a0622de0f5b07b03f65fc661efbcbc262c46218efe9924eb8b1040000000beb93211c662280d24e8b18edc2d5d63b13e91be4c905db2d997d7293ee6f30f3966a5d9ceb0a1deeeef9e702010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff200369380104f3966a5d0860007697000000000d2f6e6f64655374726174756d2f00000000030000000000000000266a24aa21a9ede177006e83279e577b138ece75a323e0fa913da994727d1166dbee18c5bf20b9cb751027010000001976a914697ab38c1db7d672f5dbedff8936c290f906742c88ac9afefa02000000001976a914fdcd08e6cb3451c95057130f94ef88b78a70b88e88ac01200000000000000000000000000000000000000000000000000000000000000000000000000200000003837669f694a699355c53550cb151a939e9626cabefaae45c98ef1a493986ee2e000000006a473044022035f1d62eb19f6b444170b1bc0db9d5133cd514403f289d7a1505a34be872882f02200420fc3a6b3b127b6ac12e516d32c6bb8e08733c1932c3b29e36538e2713d337012103eda5ae5990c8bf9155a14df837f42398f895d5a3c94d8ee7b51034d177b044f2feffffffc73fb3c2a22b1f4f960971c40502cdf37d54648ad43381324dd1ee2d5f065831020000006a473044022043ce48c511bbe514b44cd3c531259c382fe535b6ea405dcb42720cf3ddcbbadb02203693f81b0de34b7a6479babd0c74a5c907858d876b617cc031cdcae585a9c63e0121025e6cd086754c0264cecbab789fae6ab7e2b551030fb88d2bef5b32c1fd99ca02feffffffce4d953b655a1978c1b39653602514b436f6478f1eac9b816462ac4a448435e5000000006b483045022100e0f55692f19b2498fd4116f7e25cb80be29cf6f5198a2f7161cb3cf920984d370220524b0f63aff32f1f7364bc7393b6bbca956ed954eb9089d1279afc66d86108ca012103a8986d67d7c01ca1c02d0e86cc7b1b0c7a172c9cffd7729bc308d6fa8110b6aefeffffff046636021b000000001976a914add8a0089511e14059d632c7bd980e8db1be62fd88ac8efafe3c000000001976a914317ea248669f7ef786ef867ce90214cba9edef8a88ac303bae3b000000001976a9141abe5eab04d3dc3b7deeb16fe3ba3674205a907588ac9e192e72000000001976a914cd6d6c32dee3d00c9c1afcc3f93ce9a4f30333a188ac67380100
@@ -0,0 +1,30 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----

mQENBF0cRAgBCADXtcd8brlS5sxy0ljaR0JRnzSY6ZPaL/uChDGZuqcwlmLmmtHC
IFK5WVDKGD13rP6pQe8ORDVSLmQMEcY4qpd97gUipXG/kvkt46oiaahV/yhl0n4n
snJharlpgpIO0MxuQmuUoZud37aSWHFvPvrjdL7Tltxc6+Bi8l/54qD51DrAMPPi
0rWVAejxWQJd253RVYRS7StTfhmw11JJMe9QQCDzs0hPAvhOIncI6iKnLR8GIJL9
gajp7m0KTQSBAyiM1lSm1RQQI81hJKIk3ya+Etd3yK5GKyB8UQ/fz02+o2apWi/K
s0JZosEENy7Tk8pfJ3bu9TeMHGsNRvEmS8Z7ABEBAAG0JU1pbiBLaGFuZyBBdW5n
IDxtaW5rY3J5cHRvQGdtYWlsLmNvbT6JAVQEEwEIAD4WIQQoqYeGoq6U/w7Kgcky
rPmS6UQDNAUCXRxECAIbAwUJE7++qAULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAK
CRAyrPmS6UQDNMAsCACOQWlZD/720D5R6QTxk9bliQJvlQSzT3iMNE15x9hL38rE
ilS4k1jOx0LAmAoU5ehrV+3ENm2CTNOJgJKDI54vITNAPNXvrtsPen8W5ho+8Z6Z
v0rMUUDYFzPxqKzy3biqJPeZpfQAW4ygyhKJh7ai7dwB6OS5YlBl5duIqzYoI9PA
dLpwXfYFJtRIyq6sPZdTG3/wnJ+WQWjR/s1JRbW6qFnFSSeDEOU5YgoiYVOkKxRv
i1hDou6HrwzpVFdVoKrisq9sicewaXog19mqsC8lZ/fXKaky3YZbwmWtNCFo0aSI
M2R95uAx36OZdQhzMhhUZq0NyinKoiaXA2gPDADCuQENBF0cRAgBCAC2QuVU8V6j
nXRIeUVFBdZg7H9d7+igE2TVfR4uPuVTYig8BNnsUG+PolqmP/+VVCIbWciQFWQ7
WDQZswmM7NTjb54BUjk9UZ8/Rdg2crHNVXBgcv3Ah7Tjto2DKDox/sbDrhUWpP6O
Wz0YVbqJF4nxdrOdDFDCNs8mU3PsI/FQNURQutoVq2DdvhOU+5xqrcrU5O+/HzR2
jnmgrZ8dyosS/RsgjZgt059IK0I+6rBNIm8AWrhoclmvB1tIljyx2864AiCFhRKH
raw11reB1UI/jQPvTeZ46XcpZ+Yft3AeZCo6AV9M2EwU5fbmew6wImZmPGZ4ukvm
jyc5EA9LtxMHABEBAAGJATwEGAEIACYWIQQoqYeGoq6U/w7KgckyrPmS6UQDNAUC
XRxECAIbDAUJE7++qAAKCRAyrPmS6UQDNA4LCADB7US8eliEoaPnKc0Uw+hA+epJ
SZ40af56wNIpiVscEH+Wpgi3qOzRu57D0adLHkf0XWrr17zDbmtOZum3wMCnyccL
GvHYIzFoXmawh2b9A3ZEyy7MmnMcaVLzA5fYtYjTGVdCuUfFq2azi+kDxhnm64sF
miLgS8XroenrYA7gnY5X5VCqSWuja+exE+B+JoBp4LgSMWLnOzbdiPfboFLhhvDP
TslbtDyNK/acIIfQneiugXrxDdrKS+Go+Z7PXAjt8o+58SxE3NlxOFsriTMJuR7B
n9F/2kBO4Q2bspQluRCdBwntITnfC+cA44MArk7yMn2wKZqeBCHloyseH2SF
=7/ya
-----END PGP PUBLIC KEY BLOCK-----
@@ -0,0 +1,70 @@
{
"coin": {
"name": "CPUchain",
"shortcut": "CPU",
"label": "CPUchain",
"alias": "CPUchain"
},
"ports": {
"backend_rpc": 19707,
"backend_message_queue": 38390,
"blockbook_internal": 9090,
"blockbook_public": 9190
},
"ipc": {
"rpc_url_template": "http://127.0.0.1:{{.Ports.BackendRPC}}",
"rpc_user": "rpc",
"rpc_pass": "rpc",
"rpc_timeout": 25,
"message_queue_binding_template": "tcp://127.0.0.1:{{.Ports.BackendMessageQueue}}"
},
"backend": {
"package_name": "backend-cpuchain",
"package_revision": "satoshilabs-1",
"system_user": "cpuchain",
"version": "0.16.3",
"binary_url": "https://github.com/cpuchain/cpuchain/releases/download/v0.16.3/cpuchain-0.16.3-x86_64-linux-gnu.tar.gz",
"verification_type": "gpg-sha256",
"verification_source": "https://github.com/cpuchain/cpuchain/releases/download/v0.16.3/SHA256SUMS.asc",
"extract_command": "tar -C backend --strip 1 -xf",
"exclude_files": [
"bin/cpuchain-qt"
],
"exec_command_template": "{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/bin/cpuchaind -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": true,
"server_config_file": "bitcoin_like.conf",
"client_config_file": "bitcoin_like_client.conf",
"additional_params": {
"whitelist": "127.0.0.1"
}
},
"blockbook": {
"package_name": "blockbook-cpuchain",
"system_user": "blockbook-cpuchain",
"internal_binding_template": ":{{.Ports.BlockbookInternal}}",
"public_binding_template": ":{{.Ports.BlockbookPublic}}",
"explorer_url": "",
"additional_params": "",
"block_chain": {
"parse": true,
"subversion": "/CPUchain:0.16.3/",
"mempool_workers": 8,
"mempool_sub_workers": 2,
"block_addresses_to_keep": 300,
"xpub_magic": 76067358,
"xpub_magic_segwit_p2sh": 77429938,
"xpub_magic_segwit_native": 78792518,
"slip44": 363,
"additional_params": {}
}
},
"meta": {
"package_maintainer": "Min Khang Aung",
"package_maintainer_email": "info@cpuchain.org"
}
}
@@ -37,6 +37,7 @@
| Polis | 9067 | 9167 | 8067 | 38367 |
| Qtum | 9088 | 9188 | 8088 | 38388 |
| Divi Project | 9089 | 9189 | 8089 | 38389 |
| CPUchain | 9090 | 9190 | 8090 | 38390 |
| Bitcoin Testnet | 19030 | 19130 | 18030 | 48330 |
| Bitcoin Cash Testnet | 19031 | 19131 | 18031 | 48331 |
| Zcash Testnet | 19032 | 19132 | 18032 | 48332 |
@@ -0,0 +1,107 @@
{
"blockHeight":79960,
"blockHash":"000000058e4ea8b9f687b4e40c32664fd328d8fcc7fe767d7436967c60f29b3f",
"blockTime":1567264853,
"blockTxs":[
"f960f14ac5fd9dbeda393a7ba308760d3864a486d1966fde56acfeda695e8bf4",
"c763ddc42f825ac090e12c77dd7705575b95e3fe53066ec90bb00627002f9916"
],
"txDetails":{
"c763ddc42f825ac090e12c77dd7705575b95e3fe53066ec90bb00627002f9916":{
"hex":"020000000512bdfdaa2164052fca8f7f112e61005a39c9f27a3fd6a3afc695102da749c550020000006a473044022044c3d2f6d7380486ccc2923761fbf064779fe03b726e6834caf942a4ec01c2d8022075aaeaf6cb76d548c99906a24197b733e85512f18bf6347452f4892ddee382eb012102da1d08a1d68dcba32bb2219ec6f80a7fdf2fab8ca9f5b8156a2b21fb36a2b05cfeffffff4bb9c45ef8dc996a5b3172481e7b68600bc38dabdb1d750a7798e5a05c4aa817040000006b483045022100bf1371418cc82702a60b2782dc832043b11ed13ec20fff156708a1d9da2390a20220091631b14b18f076479ab0f22d65bf2fde8bb574e800551dd69439db57cf511c012102be7ec4f4772cf0a54183f8c6b170d17f854a614d49e2d1072c6e2c25f34f5ef8feffffff5d8447c42f04714c066b17cf55b3323fb5674ad0d41b06dfb4b44e8a231260ce020000006b483045022100a397899722f20c42a647c6c95a8c1ef96868b3c19aef2e9666048067620a8e4702204c7bad050479588fc7f0bfa1a641f764e971fb532352e58ab7c8b4d4dea2baee012102da1d08a1d68dcba32bb2219ec6f80a7fdf2fab8ca9f5b8156a2b21fb36a2b05cfeffffffab71308f8af6439455c71a42f7406556e46f4c87478b5a84bd60bdd50747f0a9000000006b4830450221009c5dd8c78cdde9cbdce0c9a1d8f7696b162a3a6d61b49df24e3e02b0339947aa022064f77a50c616461b8e7d1a09e803ab414f7bf050ab062c4bd09217d7bb064b35012102a2422079534414b9e4727501ccece9306a9fe0fb27da2cfcf6d07f5067f27299feffffffea09f641971cac2659f64653b8654fb0cec8461c8adc2ea882cefccb15094d35020000006a47304402200cc2a4e25703b0e6f7e7922a159f6851a6005336ede5ba29c383ede90656a19d02203bbedf68938ef13459967e8141a45bc1948f840f67bf5e3219db3a5394349c48012102da1d08a1d68dcba32bb2219ec6f80a7fdf2fab8ca9f5b8156a2b21fb36a2b05cfeffffff0315cdfa3b000000001976a9149d79bcf021069e941857bdff8388c25011ba626a88acedad2f00000000001976a914765e478e7fc803d1c34310bfa99aefc05de2cc8088acaa6b663c000000001976a91467c0bd18101fc3ea9ce371eae467e0b235b4eca288ac0c380100",
"txid":"c763ddc42f825ac090e12c77dd7705575b95e3fe53066ec90bb00627002f9916",
"blocktime":1567264853,
"time":1567264853,
"locktime":79884,
"version":2,
"vin":[
{
"txid":"50c549a72d1095c6afa3d63f7af2c9395a00612e117f8fca2f056421aafdbd12",
"vout":2,
"scriptSig":{
"asm":"3044022044c3d2f6d7380486ccc2923761fbf064779fe03b726e6834caf942a4ec01c2d8022075aaeaf6cb76d548c99906a24197b733e85512f18bf6347452f4892ddee382eb[ALL] 02da1d08a1d68dcba32bb2219ec6f80a7fdf2fab8ca9f5b8156a2b21fb36a2b05c",
"hex":"473044022044c3d2f6d7380486ccc2923761fbf064779fe03b726e6834caf942a4ec01c2d8022075aaeaf6cb76d548c99906a24197b733e85512f18bf6347452f4892ddee382eb012102da1d08a1d68dcba32bb2219ec6f80a7fdf2fab8ca9f5b8156a2b21fb36a2b05c"
},
"sequence":4294967294
},
{
"txid":"17a84a5ca0e598770a751ddbab8dc30b60687b1e4872315b6a99dcf85ec4b94b",
"vout":4,
"scriptSig":{
"asm":"3045022100bf1371418cc82702a60b2782dc832043b11ed13ec20fff156708a1d9da2390a20220091631b14b18f076479ab0f22d65bf2fde8bb574e800551dd69439db57cf511c[ALL] 02be7ec4f4772cf0a54183f8c6b170d17f854a614d49e2d1072c6e2c25f34f5ef8",
"hex":"483045022100bf1371418cc82702a60b2782dc832043b11ed13ec20fff156708a1d9da2390a20220091631b14b18f076479ab0f22d65bf2fde8bb574e800551dd69439db57cf511c012102be7ec4f4772cf0a54183f8c6b170d17f854a614d49e2d1072c6e2c25f34f5ef8"
},
"sequence":4294967294
},
{
"txid":"ce6012238a4eb4b4df061bd4d04a67b53f32b355cf176b064c71042fc447845d",
"vout":2,
"scriptSig":{
"asm":"3045022100a397899722f20c42a647c6c95a8c1ef96868b3c19aef2e9666048067620a8e4702204c7bad050479588fc7f0bfa1a641f764e971fb532352e58ab7c8b4d4dea2baee[ALL] 02da1d08a1d68dcba32bb2219ec6f80a7fdf2fab8ca9f5b8156a2b21fb36a2b05c",
"hex":"483045022100a397899722f20c42a647c6c95a8c1ef96868b3c19aef2e9666048067620a8e4702204c7bad050479588fc7f0bfa1a641f764e971fb532352e58ab7c8b4d4dea2baee012102da1d08a1d68dcba32bb2219ec6f80a7fdf2fab8ca9f5b8156a2b21fb36a2b05c"
},
"sequence":4294967294
},
{
"txid":"a9f04707d5bd60bd845a8b47874c6fe4566540f7421ac7559443f68a8f3071ab",
"vout":0,
"scriptSig":{
"asm":"30450221009c5dd8c78cdde9cbdce0c9a1d8f7696b162a3a6d61b49df24e3e02b0339947aa022064f77a50c616461b8e7d1a09e803ab414f7bf050ab062c4bd09217d7bb064b35[ALL] 02a2422079534414b9e4727501ccece9306a9fe0fb27da2cfcf6d07f5067f27299",
"hex":"4830450221009c5dd8c78cdde9cbdce0c9a1d8f7696b162a3a6d61b49df24e3e02b0339947aa022064f77a50c616461b8e7d1a09e803ab414f7bf050ab062c4bd09217d7bb064b35012102a2422079534414b9e4727501ccece9306a9fe0fb27da2cfcf6d07f5067f27299"
},
"sequence":4294967294
},
{
"txid":"354d0915cbfcce82a82edc8a1c46c8ceb04f65b85346f65926ac1c9741f609ea",
"vout":2,
"scriptSig":{
"asm":"304402200cc2a4e25703b0e6f7e7922a159f6851a6005336ede5ba29c383ede90656a19d02203bbedf68938ef13459967e8141a45bc1948f840f67bf5e3219db3a5394349c48[ALL] 02da1d08a1d68dcba32bb2219ec6f80a7fdf2fab8ca9f5b8156a2b21fb36a2b05c",
"hex":"47304402200cc2a4e25703b0e6f7e7922a159f6851a6005336ede5ba29c383ede90656a19d02203bbedf68938ef13459967e8141a45bc1948f840f67bf5e3219db3a5394349c48012102da1d08a1d68dcba32bb2219ec6f80a7fdf2fab8ca9f5b8156a2b21fb36a2b05c"
},
"sequence":4294967294
}
],
"vout":[
{
"value":10.06292245,
"n":0,
"scriptPubKey":{
"asm":"OP_DUP OP_HASH160 9d79bcf021069e941857bdff8388c25011ba626a OP_EQUALVERIFY OP_CHECKSIG",
"hex":"76a9149d79bcf021069e941857bdff8388c25011ba626a88ac",
"reqSigs":1,
"type":"pubkeyhash",
"addresses":[
"CWpYVfaHU1ZxEujGeVZDJ6LwzEQEBiRdSm"
]
}
},
{
"value":0.03124717,
"n":1,
"scriptPubKey":{
"asm":"OP_DUP OP_HASH160 765e478e7fc803d1c34310bfa99aefc05de2cc80 OP_EQUALVERIFY OP_CHECKSIG",
"hex":"76a914765e478e7fc803d1c34310bfa99aefc05de2cc8088ac",
"reqSigs":1,
"type":"pubkeyhash",
"addresses":[
"CTFmFLGWaMjKcKXVy7MDWGEWUJehtErLTV"
]
}
},
{
"value":10.13345194,
"n":2,
"scriptPubKey":{
"asm":"OP_DUP OP_HASH160 67c0bd18101fc3ea9ce371eae467e0b235b4eca2 OP_EQUALVERIFY OP_CHECKSIG",
"hex":"76a91467c0bd18101fc3ea9ce371eae467e0b235b4eca288ac",
"reqSigs":1,
"type":"pubkeyhash",
"addresses":[
"CRvV4Wscfy8DovLt154patEBTwyzwWoxqr"
]
}
}
]
}
}
}

0 comments on commit 6920b1c

Please sign in to comment.
You can’t perform that action at this time.