From f108559d7c17e4c6beac9c5301a67317bd011aac Mon Sep 17 00:00:00 2001 From: Cronos <37080958+eabz@users.noreply.github.com> Date: Fri, 5 Apr 2019 16:18:24 -0600 Subject: [PATCH] Support Polis (#118) * Update .gitignore Intelij IDEA * Polis initial configuration * Remove polis-qt from excluded files * Fix * Update v1.4.10 * Test files * Fix * Add PackedTxInfo * Add Parsing Blocks test * Exclude polis-qt * Integration test data * Fix --- .gitignore | 3 +- bchain/coins/blockchain.go | 2 + bchain/coins/polis/polisparser.go | 78 +++++ bchain/coins/polis/polisparser_test.go | 308 ++++++++++++++++++ bchain/coins/polis/polisrpc.go | 56 ++++ bchain/coins/polis/testdata/block_dump.280000 | 1 + bchain/coins/polis/testdata/block_dump.50000 | 1 + configs/coins/polis.json | 66 ++++ docs/ports.md | 1 + tests/rpc/testdata/polis.json | 40 +++ tests/sync/testdata/polis.json | 78 +++++ tests/tests.json | 5 + 12 files changed, 638 insertions(+), 1 deletion(-) create mode 100644 bchain/coins/polis/polisparser.go create mode 100644 bchain/coins/polis/polisparser_test.go create mode 100644 bchain/coins/polis/polisrpc.go create mode 100644 bchain/coins/polis/testdata/block_dump.280000 create mode 100644 bchain/coins/polis/testdata/block_dump.50000 create mode 100644 configs/coins/polis.json create mode 100644 tests/rpc/testdata/polis.json create mode 100644 tests/sync/testdata/polis.json diff --git a/.gitignore b/.gitignore index 8d866cba..23e1078c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ build/ldb build/sst_dump build/*.deb .bin-image -.deb-image \ No newline at end of file +.deb-image +\.idea/ diff --git a/bchain/coins/blockchain.go b/bchain/coins/blockchain.go index 7b39eae4..c4662e4a 100644 --- a/bchain/coins/blockchain.go +++ b/bchain/coins/blockchain.go @@ -22,6 +22,7 @@ import ( "blockbook/bchain/coins/namecoin" "blockbook/bchain/coins/nuls" "blockbook/bchain/coins/pivx" + "blockbook/bchain/coins/polis" "blockbook/bchain/coins/qtum" "blockbook/bchain/coins/vertcoin" "blockbook/bchain/coins/xzc" @@ -74,6 +75,7 @@ func init() { BlockChainFactories["Groestlcoin Testnet"] = grs.NewGroestlcoinRPC BlockChainFactories["PIVX"] = pivx.NewPivXRPC BlockChainFactories["PIVX Testnet"] = pivx.NewPivXRPC + BlockChainFactories["Polis"] = polis.NewPolisRPC BlockChainFactories["Zcoin"] = xzc.NewZcoinRPC BlockChainFactories["Fujicoin"] = fujicoin.NewFujicoinRPC BlockChainFactories["Flo"] = flo.NewFloRPC diff --git a/bchain/coins/polis/polisparser.go b/bchain/coins/polis/polisparser.go new file mode 100644 index 00000000..7b56904b --- /dev/null +++ b/bchain/coins/polis/polisparser.go @@ -0,0 +1,78 @@ +package polis + +import ( + "blockbook/bchain/coins/btc" + "github.com/martinboehm/btcd/wire" + "github.com/martinboehm/btcutil/chaincfg" +) + +const ( + MainnetMagic wire.BitcoinNet = 0xbd6b0cbf + TestnetMagic wire.BitcoinNet = 0xffcae2ce + RegtestMagic wire.BitcoinNet = 0xdcb7c1fc +) + +var ( + MainNetParams chaincfg.Params + TestNetParams chaincfg.Params + RegtestParams chaincfg.Params +) + +func init() { + MainNetParams = chaincfg.MainNetParams + MainNetParams.Net = MainnetMagic + + // Address encoding magics + MainNetParams.PubKeyHashAddrID = []byte{55} // base58 prefix: P + MainNetParams.ScriptHashAddrID = []byte{56} // base58 prefix: 3 + + TestNetParams = chaincfg.TestNet3Params + TestNetParams.Net = TestnetMagic + + // Address encoding magics + TestNetParams.PubKeyHashAddrID = []byte{140} // base58 prefix: y + TestNetParams.ScriptHashAddrID = []byte{19} // base58 prefix: 8 or 9 + + RegtestParams = chaincfg.RegressionNetParams + RegtestParams.Net = RegtestMagic + + // Address encoding magics + RegtestParams.PubKeyHashAddrID = []byte{140} // base58 prefix: y + RegtestParams.ScriptHashAddrID = []byte{19} // base58 prefix: 8 or 9 +} + +// PolisParser handle +type PolisParser struct { + *btc.BitcoinParser +} + +// NewPolisParser returns new PolisParser instance +func NewPolisParser(params *chaincfg.Params, c *btc.Configuration) *PolisParser { + return &PolisParser{BitcoinParser: btc.NewBitcoinParser(params, c)} +} + +// GetChainParams contains network parameters for the main Polis network, +// the regression test Polis network, the test Polis network and +// the simulation test Polis network, in this order +func GetChainParams(chain string) *chaincfg.Params { + if !chaincfg.IsRegistered(&MainNetParams) { + err := chaincfg.Register(&MainNetParams) + if err == nil { + err = chaincfg.Register(&TestNetParams) + } + if err == nil { + err = chaincfg.Register(&RegtestParams) + } + if err != nil { + panic(err) + } + } + switch chain { + case "test": + return &TestNetParams + case "regtest": + return &RegtestParams + default: + return &MainNetParams + } +} diff --git a/bchain/coins/polis/polisparser_test.go b/bchain/coins/polis/polisparser_test.go new file mode 100644 index 00000000..b0888dda --- /dev/null +++ b/bchain/coins/polis/polisparser_test.go @@ -0,0 +1,308 @@ +// +build unittest + +package polis + +import ( + "bytes" + "fmt" + "blockbook/bchain" + "blockbook/bchain/coins/btc" + "encoding/hex" + "io/ioutil" + "math/big" + "os" + "path/filepath" + "reflect" + "testing" + "github.com/martinboehm/btcutil/chaincfg" +) + + +type testBlock struct { + size int + time int64 + txs []string +} + +var testParseBlockTxs = map[int]testBlock{ + // Simple POW block + 50000: { + size: 1393, + time: 1520175937, + txs: []string{ + "b68057244d6ad2df0017bad1cd8a24487e21404b52873c59876a484c93f5a69e", + "3d27b82972196ecce604c2923bc9105cd683352fd56f8ba052dee57a296a2d71", + "d22704ddad675d652a6b501694d9e026f19b41842946ea285490315cb944c674", + "7be2e53414c9480ea1590e40cfa8361ac7594f7435f919a6eeff96367b0dffa9", + "e2486a9610698888c4baad7001385e95aca053ab9fc7cc9d15280c9c835c975c", + }, + }, + // Simple POS block + 280000: { + size: 275, + time: 1549070495, + txs: []string{ + "9a820cb226364e852ec5d13bc3ead1ad127bf28ef2808919571200a1262b46b5", + "fcca99e281fa0c43085dfe82c24b4367ff21d3a148539e781c061fe29a793ab1", + }, + }, +} + +func TestMain(m *testing.M) { + c := m.Run() + chaincfg.ResetParams() + os.Exit(c) +} + +func helperLoadBlock(t *testing.T, height int) []byte { + name := fmt.Sprintf("block_dump.%d", height) + path := filepath.Join("testdata", name) + + d, err := ioutil.ReadFile(path) + if err != nil { + t.Fatal(err) + } + + d = bytes.TrimSpace(d) + + b := make([]byte, hex.DecodedLen(len(d))) + _, err = hex.Decode(b, d) + if err != nil { + t.Fatal(err) + } + + return b +} + +func TestParseBlock(t *testing.T) { + p := NewPolisParser(GetChainParams("main"), &btc.Configuration{}) + + for height, tb := range testParseBlockTxs { + b := helperLoadBlock(t, height) + + blk, err := p.ParseBlock(b) + if err != nil { + t.Errorf("ParseBlock() error %v", err) + } + + if blk.Size != tb.size { + t.Errorf("ParseBlock() block size: got %d, want %d", blk.Size, tb.size) + } + + if blk.Time != tb.time { + t.Errorf("ParseBlock() block time: got %d, want %d", blk.Time, tb.time) + } + + if len(blk.Txs) != len(tb.txs) { + t.Errorf("ParseBlock() number of transactions: got %d, want %d", len(blk.Txs), len(tb.txs)) + } + + for ti, tx := range tb.txs { + if blk.Txs[ti].Txid != tx { + t.Errorf("ParseBlock() transaction %d: got %s, want %s", ti, blk.Txs[ti].Txid, tx) + } + } + } +} + +func Test_GetAddrDescFromAddress_Mainnet(t *testing.T) { + type args struct { + address string + } + tests := []struct { + name string + args args + want string + wantErr bool + }{ + { + name: "P2PKH1", + args: args{address: "P9hRjWq6tMqhroxswc2f5jp2ND2py8YEnu"}, + want: "76a9140c26ca7967e6fe946f00bf81bcd3b86f43538edf88ac", + wantErr: false, + }, + } + parser := NewPolisParser(GetChainParams("main"), &btc.Configuration{}) + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := parser.GetAddrDescFromAddress(tt.args.address) + if (err != nil) != tt.wantErr { + t.Errorf("GetAddrDescFromAddress() error = %v, wantErr %v", err, tt.wantErr) + return + } + h := hex.EncodeToString(got) + if !reflect.DeepEqual(h, tt.want) { + t.Errorf("GetAddrDescFromAddress() = %v, want %v", h, tt.want) + } + }) + } +} + +func Test_GetAddressesFromAddrDesc(t *testing.T) { + type args struct { + script string + } + tests := []struct { + name string + args args + want []string + want2 bool + wantErr bool + }{ + { + name: "P2PKH1", + args: args{script: "76a9140c26ca7967e6fe946f00bf81bcd3b86f43538edf88ac"}, + want: []string{"P9hRjWq6tMqhroxswc2f5jp2ND2py8YEnu"}, + want2: true, + wantErr: false, + }, + } + + parser := NewPolisParser(GetChainParams("main"), &btc.Configuration{}) + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + b, _ := hex.DecodeString(tt.args.script) + got, got2, err := parser.GetAddressesFromAddrDesc(b) + if (err != nil) != tt.wantErr { + t.Errorf("GetAddressesFromAddrDesc() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetAddressesFromAddrDesc() = %v, want %v", got, tt.want) + } + if !reflect.DeepEqual(got2, tt.want2) { + t.Errorf("GetAddressesFromAddrDesc() = %v, want %v", got2, tt.want2) + } + }) + } +} + +var ( + testTx1 bchain.Tx + testTxPacked1 = "0004e3868bca91b06e020000000198160d0ba0168003897358f1a6d2a2499a8e93dc6d341613b960ed2083de3fe0010000006b483045022100c531bd672ed3cb1a9285191ac168f1627e6075a54f5cf4a22ee8ec717b9a047f0220068241d9cc10adf1ddcc30aef4e62863d663af50371ebc639d11532ddf6e636e012102182bc5cd0a82c43c7ed9c4acc4b735e04e7f3275b43ff2514b8a1beb1feb5493feffffff021e470d8d0e0000001976a914344bf2db193190967d3b8da659a3ce2fde5f44a588acb63dd7a4300000001976a91414c343cae45bbcf7a27b8284b8c328587f6cc45588ac85e30400" +) + +func init() { + testTx1 = bchain.Tx{ + Hex: "020000000198160d0ba0168003897358f1a6d2a2499a8e93dc6d341613b960ed2083de3fe0010000006b483045022100c531bd672ed3cb1a9285191ac168f1627e6075a54f5cf4a22ee8ec717b9a047f0220068241d9cc10adf1ddcc30aef4e62863d663af50371ebc639d11532ddf6e636e012102182bc5cd0a82c43c7ed9c4acc4b735e04e7f3275b43ff2514b8a1beb1feb5493feffffff021e470d8d0e0000001976a914344bf2db193190967d3b8da659a3ce2fde5f44a588acb63dd7a4300000001976a91414c343cae45bbcf7a27b8284b8c328587f6cc45588ac85e30400", + Blocktime: 1554132023, + Txid: "6882e77c916c5442d09e295b88fbb8a2fac6dbb988975bb00dbded088e0229a9", + LockTime: 320389, + Version: 2, + Vin: []bchain.Vin{ + { + ScriptSig: bchain.ScriptSig{ + Hex: "483045022100c531bd672ed3cb1a9285191ac168f1627e6075a54f5cf4a22ee8ec717b9a047f0220068241d9cc10adf1ddcc30aef4e62863d663af50371ebc639d11532ddf6e636e012102182bc5cd0a82c43c7ed9c4acc4b735e04e7f3275b43ff2514b8a1beb1feb5493", + }, + Txid: "e03fde8320ed60b91316346ddc938e9a49a2d2a6f1587389038016a00b0d1698", + Vout: 1, + Sequence: 4294967294, + }, + }, + Vout: []bchain.Vout{ + { + ValueSat: *big.NewInt(62495999774), + N: 0, + ScriptPubKey: bchain.ScriptPubKey{ + Hex: "76a914344bf2db193190967d3b8da659a3ce2fde5f44a588ac", + Addresses: []string{ + "PDMhGxFYTaomhzSqWKHbUzx7smYUZvZVjd", + }, + }, + }, + { + ValueSat: *big.NewInt(208923999670), + N: 1, + ScriptPubKey: bchain.ScriptPubKey{ + Hex: "76a91414c343cae45bbcf7a27b8284b8c328587f6cc45588ac", + Addresses: []string{ + "PAUxb3g3DZNrjgbRidZy3NC9TNhVrPRzAR", + }, + }, + }, + }, + } +} + +func Test_PackTx(t *testing.T) { + type args struct { + tx bchain.Tx + height uint32 + blockTime int64 + parser *PolisParser + } + tests := []struct { + name string + args args + want string + wantErr bool + }{ + { + name: "polis-1", + args: args{ + tx: testTx1, + height: 320390, + blockTime: 1554132023, + parser: NewPolisParser(GetChainParams("main"), &btc.Configuration{}), + }, + want: testTxPacked1, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := tt.args.parser.PackTx(&tt.args.tx, tt.args.height, tt.args.blockTime) + if (err != nil) != tt.wantErr { + t.Errorf("packTx() error = %v, wantErr %v", err, tt.wantErr) + return + } + h := hex.EncodeToString(got) + if !reflect.DeepEqual(h, tt.want) { + t.Errorf("packTx() = %v, want %v", h, tt.want) + } + }) + } +} + +func Test_UnpackTx(t *testing.T) { + type args struct { + packedTx string + parser *PolisParser + } + tests := []struct { + name string + args args + want *bchain.Tx + want1 uint32 + wantErr bool + }{ + { + name: "polis-1", + args: args{ + packedTx: testTxPacked1, + parser: NewPolisParser(GetChainParams("main"), &btc.Configuration{}), + }, + want: &testTx1, + want1: 320390, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + b, _ := hex.DecodeString(tt.args.packedTx) + got, got1, err := tt.args.parser.UnpackTx(b) + if (err != nil) != tt.wantErr { + t.Errorf("unpackTx() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("unpackTx() got = %v, want %v", got, tt.want) + } + if got1 != tt.want1 { + t.Errorf("unpackTx() got1 = %v, want %v", got1, tt.want1) + } + }) + } +} diff --git a/bchain/coins/polis/polisrpc.go b/bchain/coins/polis/polisrpc.go new file mode 100644 index 00000000..aa31f22e --- /dev/null +++ b/bchain/coins/polis/polisrpc.go @@ -0,0 +1,56 @@ +package polis + +import ( + "blockbook/bchain" + "blockbook/bchain/coins/btc" + "encoding/json" + + "github.com/golang/glog" +) + +// PolisRPC is an interface to JSON-RPC bitcoind service. +type PolisRPC struct { + *btc.BitcoinRPC +} + +// NewPolisRPC returns new PolisRPC instance. +func NewPolisRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) { + b, err := btc.NewBitcoinRPC(config, pushHandler) + if err != nil { + return nil, err + } + + s := &PolisRPC{ + b.(*btc.BitcoinRPC), + } + s.RPCMarshaler = btc.JSONMarshalerV1{} + s.ChainConfig.SupportsEstimateSmartFee = false + + return s, nil +} + +// Initialize initializes PolisRPC instance. +func (b *PolisRPC) Initialize() error { + chainName, err := b.GetChainInfoAndInitializeMempool(b) + if err != nil { + return err + } + + params := GetChainParams(chainName) + + // always create parser + b.Parser = NewPolisParser(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 +} diff --git a/bchain/coins/polis/testdata/block_dump.280000 b/bchain/coins/polis/testdata/block_dump.280000 new file mode 100644 index 00000000..7382ea24 --- /dev/null +++ b/bchain/coins/polis/testdata/block_dump.280000 @@ -0,0 +1 @@ +00000020dfc2afd28e72a76db82a40793e13f5fb1f7a2b95c81bf1c388129cdbc3052f0f53556fd7ecd06002359e20f52a6b9bd08f94d2e4441256499ce46e91741dbb7e9ff0545c56b24c1c000000000202000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0603c045040101ffffffff01000000000000000000000000000200000001bc90c3dcec40ef8855c547d60145db719265e17067e9a9f9d1c94a38b0a8a4c30200000000ffffffff030000000000000000000030ff66000000001976a914ba364eade2f5a3b6068c30fcde08378eaa2ff29e88ac0020aa44000000001976a9147d7c5860b78c814f802012563eb79dc398b3b14688ac00000000 \ No newline at end of file diff --git a/bchain/coins/polis/testdata/block_dump.50000 b/bchain/coins/polis/testdata/block_dump.50000 new file mode 100644 index 00000000..c2eb0361 --- /dev/null +++ b/bchain/coins/polis/testdata/block_dump.50000 @@ -0,0 +1 @@ +00000020df750da1e6ef1d07bacc08c386e7059b67bfb381395c7dfc9703000000000000f3f3e5d5ef207575e353dd7a1a59f18473a35a77419c5afae361d55709ad7892410b9c5ac176061a6c6b09400501000000010000000000000000000000000000000000000000000000000000000000000000ffffffff200350c30004410b9c5a0840056105567b02000d2f6e6f64655374726174756d2f0000000002f02a7515000000001976a9146629c9b161656be9637e0dd83153d7600084047b88acbfabd455000000001976a914f59d4ec7db19d17d6c43e75376ebb3848e0a24d288ac000000000100000003db65905855874c10d72d5a9b9e3fa7d541dae2240c9fe98028c63391847e930b010000006a473044022058fb25986162a2b59412d810b8ffe6100892599f6ecf82ce4293743ccc175c8f0220191855fc2ac4047db37784d5465a701a2d28f1f549bf359a26f684c9660d6cd40121036bb85d56ee2010121836af34dc42c4452895cddbfb5efb1211cde91cf267ef52feffffffe92f932936c37cc66e5cf2abe5e970ee2d64ec7873f1b06b7587f609ad6f5b6a010000006a47304402204d0159f20fee14b457f05e03cdacf0dcdbac332dbacd81712bb14e0c372450c4022022806cb0b8940f43a4af18a57b12c576fe135c1388eddc9e64e72875dba314e60121036bb85d56ee2010121836af34dc42c4452895cddbfb5efb1211cde91cf267ef52feffffffd38d7da8cb5576d58388e0d11a4c961a8a62ef7868488fe0a716139c0feffebd010000006b483045022100f2e12113349751239636e02c246bd4a6c636b2cc41e4e1dc3ec5a6db7fa02d0a022030c93a94c317a8ec1cf7ee9d437033b3c6dd97fa4b0deaeaa82cd9421941dfbb0121036bb85d56ee2010121836af34dc42c4452895cddbfb5efb1211cde91cf267ef52feffffff01c366b963000000001976a9141e1b579b13f646679ef8de4fee795830ea58d0f488ac4fc300000100000001f29f1bbf47d7052547f95413e81d6f9114a0d12e7cfc6272badcfaae672c27a9010000006a47304402202815ea3f59923df9d47ce70bc94387e838b43c2aa12a449222ede5849955db09022069588b99110035946dfb85f53be4316f21ed5e3321699e0d1c64ce2c07c60a2c012103424311c02421c52480177a3ecdc4c97d580798862fd490e821540b571abf7f79feffffff0260a50906000000001976a914a605e54f7c07dd797009e32d950f4d019ff5096e88ac3034040d000000001976a914af26b84931364f7eafbf86c5e4604e8b7e64a59d88ac4fc300000100000001f596f3280ee23d9f812a0983511e9ebe3508cfd6840a5810fe290a68dddff5d6000000006a47304402200ffe565761b4494b4d1cd8c535e816795f4f2be24f9667f454ab1eb905375fdb02202eb41f281cdd0f1ed17824c72926fe56c7508f93c2048ed5832913befa24ad2501210331ef0b98c08f2d0dbadbfb1262a330046e667f74d3a2d0428d51cba33cd068e8feffffff0278a62900000000001976a91495ec2efe8ce15ad80f92290cfa20f54e024f1d6388ac87acd902000000001976a914b024d8793d072b989b2d2f636f2494e98190bb5d88ac4fc300000100000001b0a5f838b6fd3d51ce2b48fc2c35fb4519be6332faf8979ba97d559727788bce000000006a4730440220089e42b35c10187e2e250abb4a448e044a0f24d7c7043b7f70acc54ec306903802206524b755d784ccadd9991a42e782412320566da925fb2492e6209be07d9a0011012102e9d115035383d4c97982642134104cdf580ea38eedbfeb2f836ef727e8cec869feffffff027c9c4d00000000001976a914ca23ff9efd82b1b0f2767573621908077bd9840588ac9537f007000000001976a914aedba9af0407cc64fbd4d3e9e715cc46e72105c088ac4fc30000 \ No newline at end of file diff --git a/configs/coins/polis.json b/configs/coins/polis.json new file mode 100644 index 00000000..18fd67b1 --- /dev/null +++ b/configs/coins/polis.json @@ -0,0 +1,66 @@ +{ + "coin": { + "name": "Polis", + "shortcut": "POLIS", + "label": "Polis", + "alias": "polis" + }, + "ports": { + "backend_rpc": 8067, + "backend_message_queue": 38367, + "blockbook_internal": 9067, + "blockbook_public": 9167 + }, + "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-polis", + "package_revision": "satoshilabs-1", + "system_user": "polis", + "version": "1.4.10", + "binary_url": "https://github.com/polispay/polis/releases/download/v1.4.10/poliscore-1.4.10-x86_64-linux-gnu.tar.gz", + "verification_type": "sha256", + "verification_source": "9688beeb4c789c2b20f4277f7363fcc986fb0e6cc75127179663272642fafcd3", + "extract_command": "tar -C backend --strip 1 -xf", + "exclude_files": [ + "bin/polis-qt" + ], + "exec_command_template": "{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/bin/polisd -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": { + "mempoolexpiry": 72 + } + }, + "blockbook": { + "package_name": "blockbook-polis", + "system_user": "blockbook-polis", + "internal_binding_template": ":{{.Ports.BlockbookInternal}}", + "public_binding_template": ":{{.Ports.BlockbookPublic}}", + "explorer_url": "", + "additional_params": "", + "block_chain": { + "parse": true, + "subversion": "/Polis Core:1.4.10/", + "mempool_workers": 8, + "mempool_sub_workers": 2, + "block_addresses_to_keep": 300, + "additional_params": {} + } + }, + "meta": { + "package_maintainer": "Cronos", + "package_maintainer_email": "eabz@polispay.org" + } +} diff --git a/docs/ports.md b/docs/ports.md index 91f5c727..84e5eaf5 100644 --- a/docs/ports.md +++ b/docs/ports.md @@ -27,6 +27,7 @@ | Bellcoin | 9052 | 9152 | 8052 | 38352 | | NULS | 9053 | 9153 | 8053 | 38353 | | Flo | 9066 | 9166 | 8066 | 38366 | +| Polis | 9067 | 9167 | 8067 | 38367 | | Qtum | 9088 | 9188 | 8088 | 38388 | | Bitcoin Testnet | 19030 | 19130 | 18030 | 48330 | | Bitcoin Cash Testnet | 19031 | 19131 | 18031 | 48331 | diff --git a/tests/rpc/testdata/polis.json b/tests/rpc/testdata/polis.json new file mode 100644 index 00000000..2de8281c --- /dev/null +++ b/tests/rpc/testdata/polis.json @@ -0,0 +1,40 @@ +{ + "blockHeight": 308506, + "blockHash": "7db10f77c97acf921cb57843b0155657b57de674cd914802ce3320f52d478dfe", + "blockTime": 1552686920, + "blockTxs": [ + "319a7c8bcec7951931b79eade2985362c41b827f3fd013dedfe9b1a96fa57a03", + "7780a2a8fb2356ecfaaf556ff53ba93a46cdce3bd93be8256a7e304f404600bc", + "17f243fa49f5316062d650b20ce37d6dd795e46ed9fd4f64c9b4ccf689915d9b", + "72270d839f189d1193953e1450a31b620ba255a6d664c8a9a0386f8b8e2800f1" + ], + "txDetails": { + "17f243fa49f5316062d650b20ce37d6dd795e46ed9fd4f64c9b4ccf689915d9b": { + "hex": "0200000001adc444b348621c06d881f6d1402fcb188316163c0c510d845b71cfc3a9ee1101010000006b483045022100e8378228debfddf315ebbc4a7455bfa3fceb8ae577c176e760f73c4be9ba781702201081481c27b72a9d2f8826f20e6289323276288a96181866821111c805d9305701210230ffa39fe697cc4d28d453ed84ed6545b9ce83a0863367b831dae54674488967ffffffff01f89bb0b0000000001976a914a738d8ab602e40c83c1d617aa3075b1954312d7988ac00000000", + "txid": "17f243fa49f5316062d650b20ce37d6dd795e46ed9fd4f64c9b4ccf689915d9b", + "blocktime": 1552686920, + "time": 1552686920, + "locktime": 0, + "version": 2, + "vin": [ + { + "txid": "0111eea9c3cf715b840d510c3c16168318cb2f40d1f681d8061c6248b344c4ad", + "vout": 1, + "sequence": 4294967295, + "scriptSig": { + "hex": "483045022100e8378228debfddf315ebbc4a7455bfa3fceb8ae577c176e760f73c4be9ba781702201081481c27b72a9d2f8826f20e6289323276288a96181866821111c805d9305701210230ffa39fe697cc4d28d453ed84ed6545b9ce83a0863367b831dae54674488967" + } + } + ], + "vout": [ + { + "value": 29.64364280, + "n": 0, + "scriptPubKey": { + "hex": "76a914a738d8ab602e40c83c1d617aa3075b1954312d7988ac" + } + } + ] + } + } +} diff --git a/tests/sync/testdata/polis.json b/tests/sync/testdata/polis.json new file mode 100644 index 00000000..ff96ebb8 --- /dev/null +++ b/tests/sync/testdata/polis.json @@ -0,0 +1,78 @@ +{ + "connectBlocks": { + "syncRanges": [ + {"lower": 248706, "upper": 248726} + ], + "blocks": { + "300900": { + "height": 300900, + "hash": "427125bf9fe38a04cbe6e23b1ccfdd9aa9aec2e32350300e6f5e96ecd24926bb", + "noTxs": 2, + "txDetails": [ + { + "hex": "02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff06036497040101ffffffff0100000000000000000000000000", + "txid": "25144a48788e97f64aebb7c9f79452be07d45d212068b83f90787f657c8f4051", + "version": 2, + "vin": [ + { + "coinbase": "036497040101", + "sequence": 4294967295 + } + ], + "vout": [ + { + "value": 0.00000000, + "n": 0, + "scriptPubKey": { + "hex": "" + } + } + ], + "time": 1551720401, + "blocktime": 1551720401 + }, + { + "hex": "02000000013cfcafa26d96e9735ae5dacbe7ab9e3e1e13c472ac63bc27ac5ee4c799d20d9f0100000000ffffffff030000000000000000006ca53bdf0a0000001976a914e744aa894a8de0f200f8a00f58d2367c7523cae788ac0020aa44000000001976a914fec8380fd18ca3ad8c1c42938e102ee3ffac6fc188ac00000000", + "txid": "5174a1980cee089ca868758ffd396d71e742f34d9c7bada21d294b54e6819a4f", + "version": 2, + "vin": [ + { + "txid": "9f0dd299c7e45eac27bc63ac72c4131e3e9eabe7cbdae55a73e9966da2affc3c", + "vout": 1, + "scriptSig": { + "hex": "" + }, + "sequence": 4294967295 + } + ], + "vout": [ + { + "value": 0.00000000, + "n": 0, + "scriptPubKey": { + "hex": "" + } + }, + { + "value": 466.94901100, + "n": 1, + "scriptPubKey": { + "hex": "76a914e744aa894a8de0f200f8a00f58d2367c7523cae788ac" + } + }, + { + "value": 11.52000000, + "n": 2, + "scriptPubKey": { + "hex": "76a914fec8380fd18ca3ad8c1c42938e102ee3ffac6fc188ac" + } + } + ], + "time": 1551720401, + "blocktime": 1551720401 + } + ] + } + } + } +} diff --git a/tests/tests.json b/tests/tests.json index 82a45ccb..69833495 100644 --- a/tests/tests.json +++ b/tests/tests.json @@ -116,6 +116,11 @@ "EstimateSmartFee", "EstimateFee", "GetBestBlockHash", "GetBestBlockHeight", "GetBlockHeader"], "sync": ["ConnectBlocksParallel", "ConnectBlocks", "HandleFork"] }, + "polis": { + "rpc": ["GetBlock", "GetBlockHash", "GetTransaction", "GetTransactionForMempool", "MempoolSync", + "EstimateSmartFee", "EstimateFee", "GetBestBlockHash", "GetBestBlockHeight", "GetBlockHeader"], + "sync": ["ConnectBlocksParallel", "ConnectBlocks"] + }, "zcoin": { "rpc": ["GetBlock", "GetBlockHash", "GetTransaction", "GetTransactionForMempool", "MempoolSync", "EstimateFee", "GetBestBlockHash", "GetBestBlockHeight", "GetBlockHeader"],