diff --git a/bchain/coins/blockchain.go b/bchain/coins/blockchain.go index 7de87693..b490f8a5 100644 --- a/bchain/coins/blockchain.go +++ b/bchain/coins/blockchain.go @@ -9,6 +9,7 @@ import ( "blockbook/bchain/coins/digibyte" "blockbook/bchain/coins/dogecoin" "blockbook/bchain/coins/eth" + "blockbook/bchain/coins/fujicoin" "blockbook/bchain/coins/gamecredits" "blockbook/bchain/coins/grs" "blockbook/bchain/coins/liquid" @@ -63,6 +64,7 @@ func init() { BlockChainFactories["Groestlcoin"] = grs.NewGroestlcoinRPC BlockChainFactories["Groestlcoin Testnet"] = grs.NewGroestlcoinRPC BlockChainFactories["PIVX"] = pivx.NewPivXRPC + BlockChainFactories["Fujicoin"] = fujicoin.NewFujicoinRPC } // GetCoinNameFromConfig gets coin name and coin shortcut from config file diff --git a/bchain/coins/fujicoin/fujicoinparser.go b/bchain/coins/fujicoin/fujicoinparser.go new file mode 100644 index 00000000..3b66c86f --- /dev/null +++ b/bchain/coins/fujicoin/fujicoinparser.go @@ -0,0 +1,63 @@ +package fujicoin + +import ( + "blockbook/bchain/coins/btc" + + "github.com/martinboehm/btcd/wire" + "github.com/martinboehm/btcutil/chaincfg" +) + +const ( + MainnetMagic wire.BitcoinNet = 0x696a7566 + TestnetMagic wire.BitcoinNet = 0x66756a69 + RegtestMagic wire.BitcoinNet = 0x66756a69 +) + +var ( + MainNetParams chaincfg.Params + TestNetParams chaincfg.Params +) + +func init() { + MainNetParams = chaincfg.MainNetParams + MainNetParams.Net = MainnetMagic + MainNetParams.PubKeyHashAddrID = []byte{36} + MainNetParams.ScriptHashAddrID = []byte{16} + MainNetParams.Bech32HRPSegwit = "fc" + + TestNetParams = chaincfg.TestNet3Params + TestNetParams.Net = TestnetMagic + TestNetParams.PubKeyHashAddrID = []byte{74} + TestNetParams.ScriptHashAddrID = []byte{196} + TestNetParams.Bech32HRPSegwit = "tfc" +} + +// FujicoinParser handle +type FujicoinParser struct { + *btc.BitcoinParser +} + +// NewFujicoinParser returns new FujicoinParser instance +func NewFujicoinParser(params *chaincfg.Params, c *btc.Configuration) *FujicoinParser { + return &FujicoinParser{BitcoinParser: btc.NewBitcoinParser(params, c)} +} + +// GetChainParams contains network parameters for the main Fujicoin network, +// and the test Fujicoin 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 + } +} diff --git a/bchain/coins/fujicoin/fujicoinparser_test.go b/bchain/coins/fujicoin/fujicoinparser_test.go new file mode 100644 index 00000000..c3be219e --- /dev/null +++ b/bchain/coins/fujicoin/fujicoinparser_test.go @@ -0,0 +1,208 @@ +// +build unittest + +package fujicoin + +import ( + "blockbook/bchain" + "blockbook/bchain/coins/btc" + "encoding/hex" + "math/big" + "os" + "reflect" + "testing" + + "github.com/martinboehm/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 + } + tests := []struct { + name string + args args + want string + wantErr bool + }{ + { + name: "pubkeyhash1", + args: args{address: "FgKfZA7QB5xHGTtpPqTF1RQRyHCCTr5NXg"}, + want: "76a9147a5ab68256ac6bd8dc6d78b6b94af69e414dffd588ac", + wantErr: false, + }, + { + name: "pubkeyhash2", + args: args{address: "FsjXKBTE9nQinJnc1r2iLEb8SX7ok1eC7V"}, + want: "76a914f787334ddbda3e65fe7d579f03842b5607cf0db888ac", + wantErr: false, + }, + { + name: "scripthash1", + args: args{address: "7ojX5QT534BBDPwNoYXjx1MdbHWS2ueMk3"}, + want: "a914e9ec22a509631fa3c8c09ebb1b41f59c81ec669f87", + wantErr: false, + }, + { + name: "scripthash2", + args: args{address: "7XJah1ejjogvQS7UkfiH577R1yzkVzNBn4"}, + want: "a91435b2bd909a0b9b6ca35fef9276675f568f42a4e387", + wantErr: false, + }, + { + name: "witness_v0_keyhash", + args: args{address: "fc1q2ze0qtna2a42qqam3k9xsu3xamrrcp8rsczdve"}, + want: "001450b2f02e7d576aa003bb8d8a687226eec63c04e3", + wantErr: false, + }, + } + parser := NewFujicoinParser(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) + } + }) + } +} + +var ( + testTx1 bchain.Tx + + testTxPacked1 = "0023f3648bc2d3dd5c0100000001ec5666d4e842926c6e872fd7f12a87183b298464716dec1b03fc956777e06a70010000006a473044022062949ffe184af6bdc8d77e07c2caf1bd4e36d977bc27e24ab6d24c9e735d76b802201f42950f6fa005126f1fbd5cb9d6f0838d94adb70a05517b3eebd144a0ec2fd6012102534f95a0a13bbc3e261f966edd057a1dc9819a4e6bb21d81a633d5500d184a7bfeffffff0200e876481700000017a9146b8a69f8b43bc06b886c0668c93197be5152e8598740494d552e0000001976a914df783f980b38d7a64cee23202af95609b547fde888ac62f32300" +) + +func init() { + testTx1 = bchain.Tx{ + Hex: "0100000001ec5666d4e842926c6e872fd7f12a87183b298464716dec1b03fc956777e06a70010000006a473044022062949ffe184af6bdc8d77e07c2caf1bd4e36d977bc27e24ab6d24c9e735d76b802201f42950f6fa005126f1fbd5cb9d6f0838d94adb70a05517b3eebd144a0ec2fd6012102534f95a0a13bbc3e261f966edd057a1dc9819a4e6bb21d81a633d5500d184a7bfeffffff0200e876481700000017a9146b8a69f8b43bc06b886c0668c93197be5152e8598740494d552e0000001976a914df783f980b38d7a64cee23202af95609b547fde888ac62f32300", + Blocktime: 1546286958, + Txid: "7367db1a3073146f0b6060ce4a6dbb96b67b7aadcbaa450bff8d7dedda52ec13", + LockTime: 2356066, + Version: 1, + Vin: []bchain.Vin{ + { + ScriptSig: bchain.ScriptSig{ + Hex: "473044022062949ffe184af6bdc8d77e07c2caf1bd4e36d977bc27e24ab6d24c9e735d76b802201f42950f6fa005126f1fbd5cb9d6f0838d94adb70a05517b3eebd144a0ec2fd6012102534f95a0a13bbc3e261f966edd057a1dc9819a4e6bb21d81a633d5500d184a7b", + }, + Txid: "706ae0776795fc031bec6d716484293b18872af1d72f876e6c9242e8d46656ec", + Vout: 1, + Sequence: 4294967294, + }, + }, + Vout: []bchain.Vout{ + { + ValueSat: *big.NewInt(100000000000), + N: 0, + ScriptPubKey: bchain.ScriptPubKey{ + Hex: "a9146b8a69f8b43bc06b886c0668c93197be5152e85987", + Addresses: []string{ + "7cDGsS8Dum191ZMD19UaLzstMtf29YMXBL", + }, + }, + }, + { + ValueSat: *big.NewInt(198999624000), + N: 1, + ScriptPubKey: bchain.ScriptPubKey{ + Hex: "76a914df783f980b38d7a64cee23202af95609b547fde888ac", + Addresses: []string{ + "FqYKBhEF4zKkDGkVyufGVGajhttuD4Usc2", + }, + }, + }, + }, + } +} + +func Test_PackTx(t *testing.T) { + type args struct { + tx bchain.Tx + height uint32 + blockTime int64 + parser *FujicoinParser + } + tests := []struct { + name string + args args + want string + wantErr bool + }{ + { + name: "fujicoin-1", + args: args{ + tx: testTx1, + height: 2356068, + blockTime: 1546286958, + parser: NewFujicoinParser(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 *FujicoinParser + } + tests := []struct { + name string + args args + want *bchain.Tx + want1 uint32 + wantErr bool + }{ + { + name: "fujicoin-1", + args: args{ + packedTx: testTxPacked1, + parser: NewFujicoinParser(GetChainParams("main"), &btc.Configuration{}), + }, + want: &testTx1, + want1: 2356068, + 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/fujicoin/fujicoinrpc.go b/bchain/coins/fujicoin/fujicoinrpc.go new file mode 100644 index 00000000..16c562cc --- /dev/null +++ b/bchain/coins/fujicoin/fujicoinrpc.go @@ -0,0 +1,57 @@ +package fujicoin + +import ( + "blockbook/bchain" + "blockbook/bchain/coins/btc" + "encoding/json" + + "github.com/golang/glog" +) + +// FujicoinRPC is an interface to JSON-RPC bitcoind service. +type FujicoinRPC struct { + *btc.BitcoinRPC +} + +// NewFujicoinRPC returns new FujicoinRPC instance. +func NewFujicoinRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) { + b, err := btc.NewBitcoinRPC(config, pushHandler) + if err != nil { + return nil, err + } + + s := &FujicoinRPC{ + b.(*btc.BitcoinRPC), + } + s.RPCMarshaler = btc.JSONMarshalerV2{} + s.ChainConfig.SupportsEstimateFee = false + + return s, nil +} + +// Initialize initializes FujicoinRPC instance. +func (b *FujicoinRPC) Initialize() error { + chainName, err := b.GetChainInfoAndInitializeMempool(b) + if err != nil { + return err + } + + glog.Info("Chain name ", chainName) + params := GetChainParams(chainName) + + // always create parser + b.Parser = NewFujicoinParser(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/build/docker/deb/gpg-keys/fujicoin-releases.asc b/build/docker/deb/gpg-keys/fujicoin-releases.asc new file mode 100644 index 00000000..00e787b8 --- /dev/null +++ b/build/docker/deb/gpg-keys/fujicoin-releases.asc @@ -0,0 +1,41 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +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 +=/dIu +-----END PGP PUBLIC KEY BLOCK----- diff --git a/configs/coins/fujicoin.json b/configs/coins/fujicoin.json new file mode 100644 index 00000000..b0f02543 --- /dev/null +++ b/configs/coins/fujicoin.json @@ -0,0 +1,63 @@ +{ + "coin": { + "name": "Fujicoin", + "shortcut": "FJC", + "label": "Fujicoin", + "alias": "fujicoin" + }, + "ports": { + "backend_rpc": 8048, + "backend_message_queue": 38348, + "blockbook_internal": 9048, + "blockbook_public": 9148 + }, + "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-fujicoin", + "package_revision": "satoshilabs-1", + "system_user": "fujicoin", + "version": "0.16.3", + "binary_url": "https://www.fujicoin.org/fujicoin/3.0/fujicoin-3.0-v0.16.3.tar.gz", + "verification_type": "gpg-sha256", + "verification_source": "https://www.fujicoin.org/fujicoin/3.0/SHA256SUMS.asc", + "extract_command": "tar -C backend -xf", + "exclude_files": [ + ], + "exec_command_template": "{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/fujicoind -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": { + } + }, + "blockbook": { + "package_name": "blockbook-fujicoin", + "system_user": "blockbook-fujicoin", + "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": "Motty", + "package_maintainer_email": "fujicoin@gmail.com" + } +} diff --git a/docs/ports.md b/docs/ports.md index a06d1050..eb86ccd2 100644 --- a/docs/ports.md +++ b/docs/ports.md @@ -20,6 +20,7 @@ | Groestlcoin | 9045 | 9145 | 8045 | 38345 | | Bitcoin Cash SV | 9046 | 9146 | 8046 | 38346 | | Liquid | 9047 | 9147 | 8047 | 38347 | +| Fujicoin | 9048 | 9148 | 8048 | 38348 | | PIVX | 9049 | 9149 | 8049 | 38349 | | Bitcoin Testnet | 19030 | 19130 | 18030 | 48330 | | Bitcoin Cash Testnet | 19031 | 19131 | 18031 | 48331 | diff --git a/tests/rpc/testdata/fujicoin.json b/tests/rpc/testdata/fujicoin.json new file mode 100644 index 00000000..8790806d --- /dev/null +++ b/tests/rpc/testdata/fujicoin.json @@ -0,0 +1,46 @@ +{ + "blockHeight": 2356068, + "blockHash": "e6fdbcc2fe720aa54eecc8a2df8e50f9f2be21927fee87375a1d38bcb537c4ce", + "blockTime": 1546286958, + "blockTxs": [ + "2ebd98c5debc1e403c87966e00db42590b6bedaeb6b2fd640b942ad18032ce62", + "88e23fb129d2b7566702396a6b35696ed445d5fe8ab3a526901bf2efe107a46c", + "7367db1a3073146f0b6060ce4a6dbb96b67b7aadcbaa450bff8d7dedda52ec13" + ], + "txDetails": { + "7367db1a3073146f0b6060ce4a6dbb96b67b7aadcbaa450bff8d7dedda52ec13": { + "hex": "0100000001ec5666d4e842926c6e872fd7f12a87183b298464716dec1b03fc956777e06a70010000006a473044022062949ffe184af6bdc8d77e07c2caf1bd4e36d977bc27e24ab6d24c9e735d76b802201f42950f6fa005126f1fbd5cb9d6f0838d94adb70a05517b3eebd144a0ec2fd6012102534f95a0a13bbc3e261f966edd057a1dc9819a4e6bb21d81a633d5500d184a7bfeffffff0200e876481700000017a9146b8a69f8b43bc06b886c0668c93197be5152e8598740494d552e0000001976a914df783f980b38d7a64cee23202af95609b547fde888ac62f32300", + "txid": "7367db1a3073146f0b6060ce4a6dbb96b67b7aadcbaa450bff8d7dedda52ec13", + "blocktime": 1546286958, + "time": 1546286958, + "locktime": 2356066, + "version": 1, + "vin": [ + { + "txid": "706ae0776795fc031bec6d716484293b18872af1d72f876e6c9242e8d46656ec", + "vout": 1, + "scriptSig": { + "hex": "473044022062949ffe184af6bdc8d77e07c2caf1bd4e36d977bc27e24ab6d24c9e735d76b802201f42950f6fa005126f1fbd5cb9d6f0838d94adb70a05517b3eebd144a0ec2fd6012102534f95a0a13bbc3e261f966edd057a1dc9819a4e6bb21d81a633d5500d184a7b" + }, + "sequence": 4294967294 + } + ], + "vout": [ + { + "value": 1000.00000000, + "n": 0, + "scriptPubKey": { + "hex": "a9146b8a69f8b43bc06b886c0668c93197be5152e85987" + } + }, + { + "value": 1989.99624000, + "n": 1, + "scriptPubKey": { + "hex": "76a914df783f980b38d7a64cee23202af95609b547fde888ac" + } + } + ] + } + } +} \ No newline at end of file diff --git a/tests/sync/testdata/fujicoin.json b/tests/sync/testdata/fujicoin.json new file mode 100644 index 00000000..b9e74378 --- /dev/null +++ b/tests/sync/testdata/fujicoin.json @@ -0,0 +1,385 @@ +{ + "connectBlocks": { + "syncRanges": [ + {"lower": 2372312, "upper": 2372332} + ], + "blocks": { + "2372330": { + "height": 2372330, + "hash": "354df7109a84ad6ac1a8bc14dab9ace57d1c33e8c49b9435893ce2f5cc67b8a8", + "noTxs": 3, + "txDetails": [ + { + "txid": "6078ef606db367eebcbb4fb084d4c240197a8b3bd34bcc176285383c008432c9", + "version": 2, + "vin": [ + { + "txid": "ed5ecb9b184a3b14e00b1b20014d384ba0a9661613acd47499205fd533ee749f", + "vout": 6, + "scriptSig": { + "hex": "160014e6c49905b01eb9ab81497fac923703ba6e982302" + }, + "sequence": 4294967294 + }, + { + "txid": "969fb6ee4fb94182313fa420058f1a5390f80ca4317d30284128447c415ea9d5", + "vout": 1, + "scriptSig": { + "hex": "4730440220214e8ff8c4b9518efc84976736595a4e9746fa4503c528e343737e5ef0dcb23f022058ee990517cacd692016e3dc671a50ec919261c10a70ba2170b668758a344123012102acfe4d8d3ec9bc53edc8d1613bf8278adb98575b5f7df51c3d3ba135399a24b3" + }, + "sequence": 4294967294 + }, + { + "txid": "267e4b9d700cb6abbe177355bbaa8a84e765560d224768dbccf619390d18a6de", + "vout": 1, + "scriptSig": { + "hex": "483045022100fa941aeca8754cf2ea3460dd0d666a9f3135f6eccda34845a61f67ba38e7ee94022033a2c74acf8976953b7a183fd3f9d89f74bbb76b1c536640cb909124abf55bcc012102acfe4d8d3ec9bc53edc8d1613bf8278adb98575b5f7df51c3d3ba135399a24b3" + }, + "sequence": 4294967294 + }, + { + "txid": "fbd5e0312f4a33541d1d610bb2d7f93d76842a884d53d613ccd5ee0e0e6679f2", + "vout": 1, + "scriptSig": { + "hex": "4730440220562a41b29bcf0fb1aae95d10c7b4302c67f7ff78b70329d859b7fe41c6fec8c102204f08c3a940f2321d54f307e4861c767e79194c258cbbae181649dfd9213196f8012102acfe4d8d3ec9bc53edc8d1613bf8278adb98575b5f7df51c3d3ba135399a24b3" + }, + "sequence": 4294967294 + } + ], + "vout": [ + { + "value": 275.76309377, + "n": 0, + "scriptPubKey": { + "hex": "76a91419bdcf6e05b7d19c0587ac46e66f895d8c9991d188ac" + } + }, + { + "value": 75.80355056, + "n": 1, + "scriptPubKey": { + "hex": "76a914a78e27c9b9b6c7477c418f06b502e4406efd9fb288ac" + } + }, + { + "value": 387.46877012, + "n": 2, + "scriptPubKey": { + "hex": "76a9149f1e42e5f872dce5c87acae53eed3e8d1905a1f488ac" + } + }, + { + "value": 0.00774449, + "n": 3, + "scriptPubKey": { + "hex": "a9142dba80d0781807c86b42329f837f0fcff78c948987" + } + }, + { + "value": 166.84627735, + "n": 4, + "scriptPubKey": { + "hex": "76a9146812ebd8b72b57ef6a612eaab1904fd49bbb35f188ac" + } + }, + { + "value": 486.80545257, + "n": 5, + "scriptPubKey": { + "hex": "a9149bc786641a703416b43429ffe6879b47d78f00f787" + } + }, + { + "value": 385.54800875, + "n": 6, + "scriptPubKey": { + "hex": "76a914d1269d2d57be5da78d2980126fd3d453fbd7fc4288ac" + } + }, + { + "value": 152.047841, + "n": 7, + "scriptPubKey": { + "hex": "76a914489e4b84b3f3172b13b56c38c59f91a85a5bb00f88ac" + } + }, + { + "value": 1326.39856109, + "n": 8, + "scriptPubKey": { + "hex": "76a9148c8574e96c78c9d9e67e0820ed698bd6d6f25af188ac" + } + }, + { + "value": 126.26207608, + "n": 9, + "scriptPubKey": { + "hex": "a9142b8ea5b19da0986a643f0677ed6db8987d2ece3387" + } + }, + { + "value": 152.96686187, + "n": 10, + "scriptPubKey": { + "hex": "76a914ec874e10bfd1ac7ffa8f39a191c62905368da9da88ac" + } + } + ], + "hex": "020000000001049f74ee33d55f209974d4ac131666a9a04b384d01201b0be0143b4a189bcb5eed0600000017160014e6c49905b01eb9ab81497fac923703ba6e982302feffffffd5a95e417c44284128307d31a40cf890531a8f0520a43f318241b94feeb69f96010000006a4730440220214e8ff8c4b9518efc84976736595a4e9746fa4503c528e343737e5ef0dcb23f022058ee990517cacd692016e3dc671a50ec919261c10a70ba2170b668758a344123012102acfe4d8d3ec9bc53edc8d1613bf8278adb98575b5f7df51c3d3ba135399a24b3feffffffdea6180d3919f6ccdb6847220d5665e7848aaabb557317beabb60c709d4b7e26010000006b483045022100fa941aeca8754cf2ea3460dd0d666a9f3135f6eccda34845a61f67ba38e7ee94022033a2c74acf8976953b7a183fd3f9d89f74bbb76b1c536640cb909124abf55bcc012102acfe4d8d3ec9bc53edc8d1613bf8278adb98575b5f7df51c3d3ba135399a24b3fefffffff279660e0eeed5cc13d6534d882a84763df9d7b20b611d1d54334a2f31e0d5fb010000006a4730440220562a41b29bcf0fb1aae95d10c7b4302c67f7ff78b70329d859b7fe41c6fec8c102204f08c3a940f2321d54f307e4861c767e79194c258cbbae181649dfd9213196f8012102acfe4d8d3ec9bc53edc8d1613bf8278adb98575b5f7df51c3d3ba135399a24b3feffffff0b8116ad6b060000001976a91419bdcf6e05b7d19c0587ac46e66f895d8c9991d188acf009d3c3010000001976a914a78e27c9b9b6c7477c418f06b502e4406efd9fb288ac546c7e05090000001976a9149f1e42e5f872dce5c87acae53eed3e8d1905a1f488ac31d10b000000000017a9142dba80d0781807c86b42329f837f0fcff78c94898717377be2030000001976a9146812ebd8b72b57ef6a612eaab1904fd49bbb35f188ace92b96550b00000017a9149bc786641a703416b43429ffe6879b47d78f00f787eb920bfa080000001976a914d1269d2d57be5da78d2980126fd3d453fbd7fc4288ace497468a030000001976a914489e4b84b3f3172b13b56c38c59f91a85a5bb00f88aced95f3e11e0000001976a9148c8574e96c78c9d9e67e0820ed698bd6d6f25af188ac78a394f00200000017a9142b8ea5b19da0986a643f0677ed6db8987d2ece33876be8c08f030000001976a914ec874e10bfd1ac7ffa8f39a191c62905368da9da88ac0247304402206cbe7047ac6e00f8eea5136557e247d57b125b5b35f5f21833af817da599b89202201568379bac8fe72847b15b9d0761df3dfa5ba150e625ead695d8912c66c83692012103f0c90bb12b28e30bb7e582382fa06a7377cf9144e8d29c52e76d34c182706ee0000000e9322400", + "time": 1547262687, + "blocktime": 1547262687 + }, + { + "txid": "e563bcb60c8955e3c2047ab8c97ea0d085e9dca813f90e258e797f7d1aacfeba", + "version": 2, + "vin": [ + { + "txid": "c1a80fb9cb9e62aecb1e4773acd32c541d35cc3f603f29df25cf1d05de8c2a60", + "vout": 4, + "scriptSig": { + "hex": "" + }, + "sequence": 4294967294 + }, + { + "txid": "4db8e7a38f5539b4eac678e8d639bcd7e3b7ef8fecd24898b69146c1709f0378", + "vout": 1, + "scriptSig": { + "hex": "473044022012fa00b7c17a8ec46d98c5a1a7635596ace8ca2e5767db59384900b934d085ca0220479bf09b6056182725dcb59e2bf1eea62a7b748d1cadda67a45ff0e715d72d25012102b315408fecfc99475cc4386ceab967743a32c1afd533c0c4318bb17b69606313" + }, + "sequence": 4294967294 + } + ], + "vout": [ + { + "value": 37.30283579, + "n": 0, + "scriptPubKey": { + "hex": "a9146276dfc37e0c03c1b751a95948a38f072d2aeda387" + } + }, + { + "value": 70.22410117, + "n": 1, + "scriptPubKey": { + "hex": "a91415073b87457051c803f74ea132060b64bff5647787" + } + }, + { + "value": 27.74664958, + "n": 2, + "scriptPubKey": { + "hex": "76a91478949f62da843f08d18087f5cf48ae36131d161988ac" + } + }, + { + "value": 48.56125884, + "n": 3, + "scriptPubKey": { + "hex": "a914b8a53b19a5c658a9dda188612e627a8946407f3f87" + } + }, + { + "value": 54.64646399, + "n": 4, + "scriptPubKey": { + "hex": "a914275000b011ea070ca916e8be6f27a51af696525287" + } + }, + { + "value": 92.1787937, + "n": 5, + "scriptPubKey": { + "hex": "a914b6eefdd46d4be77c6ca1780b2dede5d67bb3765f87" + } + }, + { + "value": 107.44984743, + "n": 6, + "scriptPubKey": { + "hex": "76a91406c099923ba4205343241838ca80af69b39c5cd688ac" + } + }, + { + "value": 124.31973681, + "n": 7, + "scriptPubKey": { + "hex": "a91458959d11af6be62dcf79cacc192ef7f8f0e3414487" + } + }, + { + "value": 104.29775064, + "n": 8, + "scriptPubKey": { + "hex": "a9142c1e522bf30b08960a9654b376e900b16798a78487" + } + }, + { + "value": 104.5843927, + "n": 9, + "scriptPubKey": { + "hex": "a914c36a8b244d457921ea2b32098056392e6ef8e08187" + } + }, + { + "value": 0.01010598, + "n": 10, + "scriptPubKey": { + "hex": "0014c00fb646db2a27354cc716d5a43b8a7204654040" + } + }, + { + "value": 87.80645941, + "n": 11, + "scriptPubKey": { + "hex": "76a914960d9cae115470c64e0f7b4b2300f52ff747f7ee88ac" + } + }, + { + "value": 50.91872989, + "n": 12, + "scriptPubKey": { + "hex": "a9147fd6e64ce9ae68f5aad6fce488cb389be26fafb387" + } + }, + { + "value": 115.38614648, + "n": 13, + "scriptPubKey": { + "hex": "00148c149c28c047217517835a5b27b2f8917573d555" + } + }, + { + "value": 53.30107362, + "n": 14, + "scriptPubKey": { + "hex": "a9147a1ad1c1089b43857c0919816435029dd9e8416187" + } + }, + { + "value": 26.86604944, + "n": 15, + "scriptPubKey": { + "hex": "76a9144160e5404fc96709b51716862afdbfc57027ba8a88ac" + } + }, + { + "value": 63.59971042, + "n": 16, + "scriptPubKey": { + "hex": "76a9146c475c62d8a58b2bff2ce95c35efcfd74887df2788ac" + } + } + ], + "hex": "02000000000102602a8cde051dcf25df293f603fcc351d542cd3ac73471ecbae629ecbb90fa8c10400000000feffffff78039f70c14691b69848d2ec8fefb7e3d7bc39d6e878c6eab439558fa3e7b84d010000006a473044022012fa00b7c17a8ec46d98c5a1a7635596ace8ca2e5767db59384900b934d085ca0220479bf09b6056182725dcb59e2bf1eea62a7b748d1cadda67a45ff0e715d72d25012102b315408fecfc99475cc4386ceab967743a32c1afd533c0c4318bb17b69606313feffffff113b9c57de0000000017a9146276dfc37e0c03c1b751a95948a38f072d2aeda387857991a20100000017a91415073b87457051c803f74ea132060b64bff5647787fe0662a5000000001976a91478949f62da843f08d18087f5cf48ae36131d161988acbc9972210100000017a914b8a53b19a5c658a9dda188612e627a8946407f3f87ffe2b7450100000017a914275000b011ea070ca916e8be6f27a51af6965252874aad6d250200000017a914b6eefdd46d4be77c6ca1780b2dede5d67bb3765f87a7747380020000001976a91406c099923ba4205343241838ca80af69b39c5cd688ac31dd00e50200000017a91458959d11af6be62dcf79cacc192ef7f8f0e3414487d8bca96d0200000017a9142c1e522bf30b08960a9654b376e900b16798a78487661e5f6f0200000017a914c36a8b244d457921ea2b32098056392e6ef8e08187a66b0f0000000000160014c00fb646db2a27354cc716d5a43b8a720465404035065e0b020000001976a914960d9cae115470c64e0f7b4b2300f52ff747f7ee88acddd07f2f0100000017a9147fd6e64ce9ae68f5aad6fce488cb389be26fafb3877849c1af020000001600148c149c28c047217517835a5b27b2f8917573d555e2fbb23d0100000017a9147a1ad1c1089b43857c0919816435029dd9e8416187905622a0000000001976a9144160e5404fc96709b51716862afdbfc57027ba8a88ace274157b010000001976a9146c475c62d8a58b2bff2ce95c35efcfd74887df2788ac02483045022100c0baf463929fde0d6655a6d11f6edd668b13319bd616387e5ba09630392663d9022030b93d8f9478e3e5509cde1b5c05a7c11583fe92e80a2e4a7b14ed54c6e03d490121038e76be54df92ad03635557f0534670459697f02220e7db4c735ac9193b83164300e9322400", + "blockhash": "24ff2c12c2fff0ad0deedd90b31befcdd5cc771fce257a4d39d071549b27913a", + "confirmations": 3, + "time": 1547262687, + "blocktime": 1547262687 + } + ] + }, + "2372314": { + "height": 2372314, + "hash": "bbabd94fcd915d7ba7f8925b80b29f05e0021edf5ae66bbd639fc81a6ce91135", + "noTxs": 3, + "txDetails": [ + { + "txid": "fc4524f96c31505468973b99f67e3aabcebb7a62f7aeb91b1e9ebff02f1df980", + "version": 2, + "vin": [ + { + "txid": "3c74bcabf1592182205456d928609b601331a4bad4eb888e24ef6315655aa371", + "vout": 1, + "scriptSig": { + "hex": "47304402202bb3aeecb0113a9ac2aa4747b92a00a417460239c7a3a22364fe14eabb7da43302200ea97b7ae680c77f90fe6568bc13bd33363f78672c18508f3f54abc0329826280121035e8c34b66f75fa8c59c1718dbaa79ae0b7f59d805b6ed6847c98208550e4e867" + }, + "sequence": 4294967294 + } + ], + "vout": [ + { + "value": 184.12968332, + "n": 0, + "scriptPubKey": { + "hex": "76a9140c61289f08acfc055391a51cd39285ef1c8583c988ac" + } + }, + { + "value": 0.4839623, + "n": 1, + "scriptPubKey": { + "hex": "76a9144f6a4726cc8fbff4e8d7289c73432ee9b5527f5888ac" + } + }, + { + "value": 253.874625, + "n": 2, + "scriptPubKey": { + "hex": "a9147e2056986a23af15009d08a909fa8da66fa10ab987" + } + }, + { + "value": 299.75133291, + "n": 3, + "scriptPubKey": { + "hex": "a914c1bc6179568127a0e9599d0edee15ab457e56b3587" + } + }, + { + "value": 323.40382893, + "n": 4, + "scriptPubKey": { + "hex": "76a9144cb3451fa24826310c4a0c03e5f3b74f1f70488488ac" + } + }, + { + "value": 107.54566411, + "n": 5, + "scriptPubKey": { + "hex": "a914d8eaa8f9baa49f3ceac7554d69b1c34809fa8efe87" + } + } + ], + "hex": "020000000171a35a651563ef248e88ebd4baa43113609b6028d9565420822159f1abbc743c010000006a47304402202bb3aeecb0113a9ac2aa4747b92a00a417460239c7a3a22364fe14eabb7da43302200ea97b7ae680c77f90fe6568bc13bd33363f78672c18508f3f54abc0329826280121035e8c34b66f75fa8c59c1718dbaa79ae0b7f59d805b6ed6847c98208550e4e867feffffff068c997f49040000001976a9140c61289f08acfc055391a51cd39285ef1c8583c988acc677e202000000001976a9144f6a4726cc8fbff4e8d7289c73432ee9b5527f5888ac64ef35e90500000017a9147e2056986a23af15009d08a909fa8da66fa10ab9876b3ca8fa0600000017a914c1bc6179568127a0e9599d0edee15ab457e56b3587ad14a387070000001976a9144cb3451fa24826310c4a0c03e5f3b74f1f70488488ac0ba905810200000017a914d8eaa8f9baa49f3ceac7554d69b1c34809fa8efe87d9322400", + "time": 1547261408, + "blocktime": 1547261408 + } + ] + } + } + }, + "handleFork": { + "syncRanges": [ + {"lower": 2372328, "upper": 2372332} + ], + "fakeBlocks": { + "2372330": { + "height": 2372330, + "hash": "3a4830c63a38871c17a3a33da08f11e53466dc2cf5c502c6cda2e703a5e56b54" + }, + "2372331": { + "height": 2372331, + "hash": "f153627ee953415433f920da2a858230fea4e62357a9ef934faedbec947f8684" + }, + "2372332": { + "height": 2372332, + "hash": "1cf8fbdcc498391ba17aa77273d367d33348339fd10261d45f6754b5ac2529c6" + } + }, + "realBlocks": { + "2372330": { + "height": 2372330, + "hash": "354df7109a84ad6ac1a8bc14dab9ace57d1c33e8c49b9435893ce2f5cc67b8a8" + }, + "2372331": { + "height": 2372331, + "hash": "73fb8b02ecc98065c4196e868b28b90637ac4d9da04944a66b55174da4f5a0b3" + }, + "2372332": { + "height": 2372332, + "hash": "ffb3f37799d949a804cf44f125f431c75094f12944545d6be8eaf40c7190f23b" + } + } + } +} diff --git a/tests/tests.json b/tests/tests.json index d12def39..4e95e37f 100644 --- a/tests/tests.json +++ b/tests/tests.json @@ -44,6 +44,11 @@ "rpc": ["GetBlock", "GetBlockHash", "GetTransaction", "EstimateFee", "GetBestBlockHash", "GetBestBlockHeight", "GetBlockHeader"] }, + "fujicoin": { + "rpc": ["GetBlock", "GetBlockHash", "GetTransaction", "GetTransactionForMempool", "MempoolSync", + "EstimateSmartFee", "EstimateFee", "GetBestBlockHash", "GetBestBlockHeight", "GetBlockHeader"], + "sync": ["ConnectBlocksParallel", "ConnectBlocks", "HandleFork"] + }, "gamecredits": { "rpc": ["GetBlock", "GetBlockHash", "GetTransaction", "GetTransactionForMempool", "MempoolSync", "EstimateSmartFee", "EstimateFee"],