diff --git a/bchain/coins/blockchain.go b/bchain/coins/blockchain.go index 06be7605..f2f52971 100644 --- a/bchain/coins/blockchain.go +++ b/bchain/coins/blockchain.go @@ -48,7 +48,7 @@ import ( "github.com/trezor/blockbook/bchain/coins/vertcoin" "github.com/trezor/blockbook/bchain/coins/viacoin" "github.com/trezor/blockbook/bchain/coins/vipstarcoin" - "github.com/trezor/blockbook/bchain/coins/xzc" + "github.com/trezor/blockbook/bchain/coins/firo" "github.com/trezor/blockbook/bchain/coins/zec" "github.com/trezor/blockbook/common" ) @@ -94,7 +94,7 @@ func init() { BlockChainFactories["PIVX"] = pivx.NewPivXRPC BlockChainFactories["PIVX Testnet"] = pivx.NewPivXRPC BlockChainFactories["Polis"] = polis.NewPolisRPC - BlockChainFactories["Zcoin"] = xzc.NewZcoinRPC + BlockChainFactories["Firo"] = firo.NewFiroRPC BlockChainFactories["Fujicoin"] = fujicoin.NewFujicoinRPC BlockChainFactories["Flo"] = flo.NewFloRPC BlockChainFactories["Bellcoin"] = bellcoin.NewBellcoinRPC diff --git a/bchain/coins/xzc/zcoinmsgtx.go b/bchain/coins/firo/firomsgtx.go similarity index 82% rename from bchain/coins/xzc/zcoinmsgtx.go rename to bchain/coins/firo/firomsgtx.go index a4a3cc64..33a99eb7 100644 --- a/bchain/coins/xzc/zcoinmsgtx.go +++ b/bchain/coins/firo/firomsgtx.go @@ -1,4 +1,4 @@ -package xzc +package firo import ( "bytes" @@ -8,14 +8,14 @@ import ( "github.com/martinboehm/btcd/wire" ) -// ZcoinMsgTx encapsulate zcoin tx and extra -type ZcoinMsgTx struct { +// FiroMsgTx encapsulate firo tx and extra +type FiroMsgTx struct { wire.MsgTx Extra []byte } // TxHash calculate hash of transaction -func (msg *ZcoinMsgTx) TxHash() chainhash.Hash { +func (msg *FiroMsgTx) TxHash() chainhash.Hash { extraSize := uint64(len(msg.Extra)) sizeOfExtraSize := 0 if extraSize != 0 { @@ -36,8 +36,8 @@ func (msg *ZcoinMsgTx) TxHash() chainhash.Hash { return chainhash.DoubleHashH(buf.Bytes()) } -// XzcDecode to decode bitcoin tx and extra -func (msg *ZcoinMsgTx) XzcDecode(r io.Reader, pver uint32, enc wire.MessageEncoding) error { +// FiroDecode to decode bitcoin tx and extra +func (msg *FiroMsgTx) FiroDecode(r io.Reader, pver uint32, enc wire.MessageEncoding) error { if err := msg.MsgTx.BtcDecode(r, pver, enc); err != nil { return err } diff --git a/bchain/coins/xzc/zcoinparser.go b/bchain/coins/firo/firoparser.go similarity index 78% rename from bchain/coins/xzc/zcoinparser.go rename to bchain/coins/firo/firoparser.go index 45b66d79..f2c8bdcf 100644 --- a/bchain/coins/xzc/zcoinparser.go +++ b/bchain/coins/firo/firoparser.go @@ -1,4 +1,4 @@ -package xzc +package firo import ( "bytes" @@ -14,10 +14,13 @@ import ( ) const ( - OpZeroCoinMint = 0xc1 - OpZeroCoinSpend = 0xc2 - OpSigmaMint = 0xc3 - OpSigmaSpend = 0xc4 + OpZeroCoinMint = 0xc1 + OpZeroCoinSpend = 0xc2 + OpSigmaMint = 0xc3 + OpSigmaSpend = 0xc4 + OpLelantusMint = 0xc5 + OpLelantusJMint = 0xc6 + OpLelantusJoinSplit = 0xc7 MainnetMagic wire.BitcoinNet = 0xe3d9fef1 TestnetMagic wire.BitcoinNet = 0xcffcbeea @@ -60,21 +63,21 @@ func init() { RegtestParams.Net = RegtestMagic } -// ZcoinParser handle -type ZcoinParser struct { +// FiroParser handle +type FiroParser struct { *btc.BitcoinParser } -// NewZcoinParser returns new ZcoinParser instance -func NewZcoinParser(params *chaincfg.Params, c *btc.Configuration) *ZcoinParser { - return &ZcoinParser{ +// NewFiroParser returns new FiroParser instance +func NewFiroParser(params *chaincfg.Params, c *btc.Configuration) *FiroParser { + return &FiroParser{ BitcoinParser: btc.NewBitcoinParser(params, c), } } -// GetChainParams contains network parameters for the main Zcoin network, -// the regression test Zcoin network, the test Zcoin network and -// the simulation test Zcoin network, in this order +// GetChainParams contains network parameters for the main Firo network, +// the regression test Firo network, the test Firo network and +// the simulation test Firo network, in this order func GetChainParams(chain string) *chaincfg.Params { if !chaincfg.IsRegistered(&MainNetParams) { err := chaincfg.Register(&MainNetParams) @@ -99,7 +102,7 @@ func GetChainParams(chain string) *chaincfg.Params { } // GetAddressesFromAddrDesc returns addresses for given address descriptor with flag if the addresses are searchable -func (p *ZcoinParser) GetAddressesFromAddrDesc(addrDesc bchain.AddressDescriptor) ([]string, bool, error) { +func (p *FiroParser) GetAddressesFromAddrDesc(addrDesc bchain.AddressDescriptor) ([]string, bool, error) { if len(addrDesc) > 0 { switch addrDesc[0] { @@ -111,6 +114,12 @@ func (p *ZcoinParser) GetAddressesFromAddrDesc(addrDesc bchain.AddressDescriptor return []string{"Sigmamint"}, false, nil case OpSigmaSpend: return []string{"Sigmaspend"}, false, nil + case OpLelantusMint: + return []string{"LelantusMint"}, false, nil + case OpLelantusJMint: + return []string{"LelantusJMint"}, false, nil + case OpLelantusJoinSplit: + return []string{"LelantusJoinSplit"}, false, nil } } @@ -118,17 +127,17 @@ func (p *ZcoinParser) GetAddressesFromAddrDesc(addrDesc bchain.AddressDescriptor } // PackTx packs transaction to byte array using protobuf -func (p *ZcoinParser) PackTx(tx *bchain.Tx, height uint32, blockTime int64) ([]byte, error) { +func (p *FiroParser) PackTx(tx *bchain.Tx, height uint32, blockTime int64) ([]byte, error) { return p.BaseParser.PackTx(tx, height, blockTime) } // UnpackTx unpacks transaction from protobuf byte array -func (p *ZcoinParser) UnpackTx(buf []byte) (*bchain.Tx, uint32, error) { +func (p *FiroParser) UnpackTx(buf []byte) (*bchain.Tx, uint32, error) { return p.BaseParser.UnpackTx(buf) } -// TxFromZcoinMsgTx converts bitcoin wire Tx to bchain.Tx -func (p *ZcoinParser) TxFromZcoinMsgTx(t *ZcoinMsgTx, parseAddresses bool) bchain.Tx { +// TxFromFiroMsgTx converts bitcoin wire Tx to bchain.Tx +func (p *FiroParser) TxFromFiroMsgTx(t *FiroMsgTx, parseAddresses bool) bchain.Tx { btx := p.TxFromMsgTx(&t.MsgTx, parseAddresses) // NOTE: wire.MsgTx.TxHash() doesn't include extra @@ -138,7 +147,7 @@ func (p *ZcoinParser) TxFromZcoinMsgTx(t *ZcoinMsgTx, parseAddresses bool) bchai } // ParseBlock parses raw block to our Block struct -func (p *ZcoinParser) ParseBlock(b []byte) (*bchain.Block, error) { +func (p *FiroParser) ParseBlock(b []byte) (*bchain.Block, error) { reader := bytes.NewReader(b) // parse standard block header first @@ -193,7 +202,7 @@ func (p *ZcoinParser) ParseBlock(b []byte) (*bchain.Block, error) { txs := make([]bchain.Tx, ntx) for i := uint64(0); i < ntx; i++ { - tx := ZcoinMsgTx{} + tx := FiroMsgTx{} // read version and seek back var version uint32 = 0 @@ -215,13 +224,13 @@ func (p *ZcoinParser) ParseBlock(b []byte) (*bchain.Block, error) { enc = wire.BaseEncoding } - if err = tx.XzcDecode(reader, 0, enc); err != nil { + if err = tx.FiroDecode(reader, 0, enc); err != nil { return nil, err } - btx := p.TxFromZcoinMsgTx(&tx, false) + btx := p.TxFromFiroMsgTx(&tx, false) - if err = p.parseZcoinTx(&btx); err != nil { + if err = p.parseFiroTx(&btx); err != nil { return nil, err } @@ -238,7 +247,7 @@ func (p *ZcoinParser) ParseBlock(b []byte) (*bchain.Block, error) { } // ParseTxFromJson parses JSON message containing transaction and returns Tx struct -func (p *ZcoinParser) ParseTxFromJson(msg json.RawMessage) (*bchain.Tx, error) { +func (p *FiroParser) ParseTxFromJson(msg json.RawMessage) (*bchain.Tx, error) { var tx bchain.Tx err := json.Unmarshal(msg, &tx) if err != nil { @@ -255,12 +264,12 @@ func (p *ZcoinParser) ParseTxFromJson(msg json.RawMessage) (*bchain.Tx, error) { vout.JsonValue = "" } - p.parseZcoinTx(&tx) + p.parseFiroTx(&tx) return &tx, nil } -func (p *ZcoinParser) parseZcoinTx(tx *bchain.Tx) error { +func (p *FiroParser) parseFiroTx(tx *bchain.Tx) error { for i := range tx.Vin { vin := &tx.Vin[i] diff --git a/bchain/coins/xzc/zcoinparser_test.go b/bchain/coins/firo/firoparser_test.go similarity index 89% rename from bchain/coins/xzc/zcoinparser_test.go rename to bchain/coins/firo/firoparser_test.go index 78b7948e..e54c10e0 100644 --- a/bchain/coins/xzc/zcoinparser_test.go +++ b/bchain/coins/firo/firoparser_test.go @@ -1,6 +1,6 @@ // +build unittest -package xzc +package firo import ( "bytes" @@ -365,32 +365,32 @@ func TestMain(m *testing.M) { func TestGetAddrDesc(t *testing.T) { type args struct { tx bchain.Tx - parser *ZcoinParser + parser *FiroParser } tests := []struct { name string args args }{ { - name: "xzc-1", + name: "firo-1", args: args{ tx: testTx1, - parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), }, }, // FIXME: work around handle zerocoin spend as coinbase // { - // name: "xzc-2", + // name: "firo-2", // args: args{ // tx: testTx2, - // parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + // parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), // }, // }, { - name: "xzc-3", + name: "firo-3", args: args{ tx: testTx3, - parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), }, }, } @@ -448,7 +448,7 @@ func TestGetAddrDescFromVoutForMint(t *testing.T) { wantErr: false, }, } - parser := NewZcoinParser(GetChainParams("main"), &btc.Configuration{}) + parser := NewFiroParser(GetChainParams("main"), &btc.Configuration{}) for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -498,7 +498,7 @@ func TestGetAddressesFromAddrDescForMint(t *testing.T) { wantErr: false, }, } - parser := NewZcoinParser(GetChainParams("main"), &btc.Configuration{}) + parser := NewFiroParser(GetChainParams("main"), &btc.Configuration{}) for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -523,7 +523,7 @@ func TestPackTx(t *testing.T) { tx bchain.Tx height uint32 blockTime int64 - parser *ZcoinParser + parser *FiroParser } tests := []struct { name string @@ -532,68 +532,68 @@ func TestPackTx(t *testing.T) { wantErr bool }{ { - name: "xzc-1", + name: "firo-1", args: args{ tx: testTx1, height: 100002, blockTime: 1533980594, - parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), }, want: testTxPacked1, wantErr: false, }, // FIXME: work around handle zerocoin spend as coinbase // { - // name: "xzc-2", + // name: "firo-2", // args: args{ // tx: testTx2, // height: 11002, // blockTime: 1481277009, - // parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + // parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), // }, // want: testTxPacked2, // wantErr: true, // }, { - name: "xzc-3", + name: "firo-3", args: args{ tx: testTx3, height: 126202, blockTime: 1547091829, - parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), }, want: testTxPacked3, wantErr: false, }, { - name: "xzc-coinbase", + name: "firo-coinbase", args: args{ tx: testTx4, height: 100001, blockTime: 1533977563, - parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), }, want: testTxPacked4, wantErr: false, }, { - name: "xzc-quorum-commitment-tx", + name: "firo-quorum-commitment-tx", args: args{ tx: testTx5, height: 5268, blockTime: 1591752749, - parser: NewZcoinParser(GetChainParams("test"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("test"), &btc.Configuration{}), }, want: testTxPacked5, wantErr: false, }, { - name: "xzc-special-coinbase-tx", + name: "firo-special-coinbase-tx", args: args{ tx: testTx6, height: 5300, blockTime: 1591762049, - parser: NewZcoinParser(GetChainParams("test"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("test"), &btc.Configuration{}), }, want: testTxPacked6, wantErr: false, @@ -619,7 +619,7 @@ func TestPackTx(t *testing.T) { func TestUnpackTx(t *testing.T) { type args struct { packedTx string - parser *ZcoinParser + parser *FiroParser } tests := []struct { name string @@ -629,10 +629,10 @@ func TestUnpackTx(t *testing.T) { wantErr bool }{ { - name: "xzc-1", + name: "firo-1", args: args{ packedTx: testTxPacked1, - parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), }, want: &testTx1, want1: 100002, @@ -640,50 +640,50 @@ func TestUnpackTx(t *testing.T) { }, // FIXME: work around handle zerocoin spend as coinbase // { - // name: "xzc-2", + // name: "firo-2", // args: args{ // packedTx: testTxPacked2, - // parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + // parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), // }, // want: &testTx2, // want1: 11002, // wantErr: true, // }, { - name: "xzc-3", + name: "firo-3", args: args{ packedTx: testTxPacked3, - parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), }, want: &testTx3, want1: 126202, wantErr: false, }, { - name: "xzc-coinbase", + name: "firo-coinbase", args: args{ packedTx: testTxPacked4, - parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), }, want: &testTx4, want1: 100001, wantErr: false, }, { - name: "xzc-special-tx", + name: "firo-special-tx", args: args{ packedTx: testTxPacked5, - parser: NewZcoinParser(GetChainParams("test"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("test"), &btc.Configuration{}), }, want: &testTx5, want1: 5268, wantErr: false, }, { - name: "xzc-special-coinbase-tx", + name: "firo-special-coinbase-tx", args: args{ packedTx: testTxPacked6, - parser: NewZcoinParser(GetChainParams("test"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("test"), &btc.Configuration{}), }, want: &testTx6, want1: 5300, @@ -714,7 +714,7 @@ func TestUnpackTx(t *testing.T) { func TestParseBlock(t *testing.T) { type args struct { rawBlock string - parser *ZcoinParser + parser *FiroParser } tests := []struct { name string @@ -727,7 +727,7 @@ func TestParseBlock(t *testing.T) { name: "normal-block", args: args{ rawBlock: rawBlock1, - parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), }, want: &bchain.Block{ BlockHeader: bchain.BlockHeader{ @@ -742,7 +742,7 @@ func TestParseBlock(t *testing.T) { name: "spend-block", args: args{ rawBlock: rawBlock2, - parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), }, want: &bchain.Block{ BlockHeader: bchain.BlockHeader{ @@ -757,7 +757,7 @@ func TestParseBlock(t *testing.T) { name: "special-tx-block", args: args{ rawBlock: rawBlock3, - parser: NewZcoinParser(GetChainParams("test"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("test"), &btc.Configuration{}), }, want: &bchain.Block{ BlockHeader: bchain.BlockHeader{ @@ -796,7 +796,7 @@ func TestDecodeTransaction(t *testing.T) { type args struct { enc wire.MessageEncoding rawTransaction string - parser *ZcoinParser + parser *FiroParser privacyType byte // 0 as non privacy } tests := []struct { @@ -810,16 +810,16 @@ func TestDecodeTransaction(t *testing.T) { args: args{ enc: wire.WitnessEncoding, rawTransaction: rawTestTx1, - parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), }, want: testTx1, }, { - name: "coinbase-zcoinspend", + name: "coinbase-firospend", args: args{ enc: wire.WitnessEncoding, rawTransaction: rawTestTx2, - parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), privacyType: OpSigmaSpend, }, want: testTx2, @@ -829,7 +829,7 @@ func TestDecodeTransaction(t *testing.T) { args: args{ enc: wire.WitnessEncoding, rawTransaction: rawTestTx3, - parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), }, want: testTx3, }, @@ -838,7 +838,7 @@ func TestDecodeTransaction(t *testing.T) { args: args{ enc: wire.WitnessEncoding, rawTransaction: rawTestTx4, - parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), }, want: testTx4, }, @@ -847,7 +847,7 @@ func TestDecodeTransaction(t *testing.T) { args: args{ enc: wire.BaseEncoding, rawTransaction: rawTestTx5, - parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), }, want: testTx5, }, @@ -856,7 +856,7 @@ func TestDecodeTransaction(t *testing.T) { args: args{ enc: wire.WitnessEncoding, rawTransaction: rawTestTx5, - parser: NewZcoinParser(GetChainParams("main"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("main"), &btc.Configuration{}), }, wantErr: true, }, @@ -865,7 +865,7 @@ func TestDecodeTransaction(t *testing.T) { args: args{ enc: wire.WitnessEncoding, rawTransaction: rawTestTx6, - parser: NewZcoinParser(GetChainParams("test"), &btc.Configuration{}), + parser: NewFiroParser(GetChainParams("test"), &btc.Configuration{}), }, want: testTx6, }, @@ -876,8 +876,8 @@ func TestDecodeTransaction(t *testing.T) { b, _ := hex.DecodeString(tt.args.rawTransaction) r := bytes.NewReader(b) - msg := ZcoinMsgTx{} - err := msg.XzcDecode(r, 0, tt.args.enc) + msg := FiroMsgTx{} + err := msg.FiroDecode(r, 0, tt.args.enc) if tt.wantErr { if err == nil { @@ -891,8 +891,8 @@ func TestDecodeTransaction(t *testing.T) { t.Fatal(err) } - got := tt.args.parser.TxFromZcoinMsgTx(&msg, true) - if pErr := tt.args.parser.parseZcoinTx(&got); pErr != nil { + got := tt.args.parser.TxFromFiroMsgTx(&msg, true) + if pErr := tt.args.parser.parseFiroTx(&got); pErr != nil { t.Fatal(pErr) } diff --git a/bchain/coins/xzc/zcoinrpc.go b/bchain/coins/firo/firorpc.go similarity index 83% rename from bchain/coins/xzc/zcoinrpc.go rename to bchain/coins/firo/firorpc.go index e6043085..1ff861bf 100644 --- a/bchain/coins/xzc/zcoinrpc.go +++ b/bchain/coins/firo/firorpc.go @@ -1,4 +1,4 @@ -package xzc +package firo import ( "encoding/hex" @@ -10,19 +10,19 @@ import ( "github.com/trezor/blockbook/bchain/coins/btc" ) -type ZcoinRPC struct { +type FiroRPC struct { *btc.BitcoinRPC } -func NewZcoinRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) { +func NewFiroRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) { // init base implementation bc, err := btc.NewBitcoinRPC(config, pushHandler) if err != nil { return nil, err } - // init zcoin implementation - zc := &ZcoinRPC{ + // init firo implementation + zc := &FiroRPC{ BitcoinRPC: bc.(*btc.BitcoinRPC), } @@ -35,7 +35,7 @@ func NewZcoinRPC(config json.RawMessage, pushHandler func(bchain.NotificationTyp return zc, nil } -func (zc *ZcoinRPC) Initialize() error { +func (zc *FiroRPC) Initialize() error { ci, err := zc.GetChainInfo() if err != nil { return err @@ -45,7 +45,7 @@ func (zc *ZcoinRPC) Initialize() error { params := GetChainParams(chainName) // always create parser - zc.Parser = NewZcoinParser(params, zc.ChainConfig) + zc.Parser = NewFiroParser(params, zc.ChainConfig) // parameters for getInfo request if params.Net == MainnetMagic { @@ -61,7 +61,7 @@ func (zc *ZcoinRPC) Initialize() error { return nil } -func (zc *ZcoinRPC) GetBlock(hash string, height uint32) (*bchain.Block, error) { +func (zc *FiroRPC) GetBlock(hash string, height uint32) (*bchain.Block, error) { var err error if hash == "" { @@ -96,7 +96,7 @@ func (zc *ZcoinRPC) GetBlock(hash string, height uint32) (*bchain.Block, error) return block, nil } -func (zc *ZcoinRPC) GetBlockInfo(hash string) (*bchain.BlockInfo, error) { +func (zc *FiroRPC) GetBlockInfo(hash string) (*bchain.BlockInfo, error) { glog.V(1).Info("rpc: getblock (verbosity=true) ", hash) res := btc.ResGetBlockInfo{} @@ -117,7 +117,7 @@ func (zc *ZcoinRPC) GetBlockInfo(hash string) (*bchain.BlockInfo, error) { return &res.Result, nil } -func (zc *ZcoinRPC) GetBlockWithoutHeader(hash string, height uint32) (*bchain.Block, error) { +func (zc *FiroRPC) GetBlockWithoutHeader(hash string, height uint32) (*bchain.Block, error) { data, err := zc.GetBlockRaw(hash) if err != nil { return nil, err @@ -134,7 +134,7 @@ func (zc *ZcoinRPC) GetBlockWithoutHeader(hash string, height uint32) (*bchain.B return block, nil } -func (zc *ZcoinRPC) GetBlockRaw(hash string) ([]byte, error) { +func (zc *FiroRPC) GetBlockRaw(hash string) ([]byte, error) { glog.V(1).Info("rpc: getblock (verbosity=false) ", hash) res := btc.ResGetBlockRaw{} @@ -155,7 +155,7 @@ func (zc *ZcoinRPC) GetBlockRaw(hash string) ([]byte, error) { return hex.DecodeString(res.Result) } -func (zc *ZcoinRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error) { +func (zc *FiroRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error) { glog.V(1).Info("rpc: getrawtransaction nonverbose ", txid) res := btc.ResGetRawTransactionNonverbose{} @@ -183,7 +183,7 @@ func (zc *ZcoinRPC) GetTransactionForMempool(txid string) (*bchain.Tx, error) { return tx, nil } -func (zc *ZcoinRPC) GetTransaction(txid string) (*bchain.Tx, error) { +func (zc *FiroRPC) GetTransaction(txid string) (*bchain.Tx, error) { r, err := zc.getRawTransaction(txid) if err != nil { return nil, err @@ -198,14 +198,14 @@ func (zc *ZcoinRPC) GetTransaction(txid string) (*bchain.Tx, error) { return tx, nil } -func (zc *ZcoinRPC) GetTransactionSpecific(tx *bchain.Tx) (json.RawMessage, error) { +func (zc *FiroRPC) GetTransactionSpecific(tx *bchain.Tx) (json.RawMessage, error) { if csd, ok := tx.CoinSpecificData.(json.RawMessage); ok { return csd, nil } return zc.getRawTransaction(tx.Txid) } -func (zc *ZcoinRPC) getRawTransaction(txid string) (json.RawMessage, error) { +func (zc *FiroRPC) getRawTransaction(txid string) (json.RawMessage, error) { glog.V(1).Info("rpc: getrawtransaction ", txid) res := btc.ResGetRawTransaction{} diff --git a/bchain/coins/xzc/testdata/packedtxs.hex b/bchain/coins/firo/testdata/packedtxs.hex similarity index 100% rename from bchain/coins/xzc/testdata/packedtxs.hex rename to bchain/coins/firo/testdata/packedtxs.hex diff --git a/bchain/coins/xzc/testdata/rawblock.hex b/bchain/coins/firo/testdata/rawblock.hex similarity index 100% rename from bchain/coins/xzc/testdata/rawblock.hex rename to bchain/coins/firo/testdata/rawblock.hex diff --git a/bchain/coins/xzc/testdata/rawspend.hex b/bchain/coins/firo/testdata/rawspend.hex similarity index 100% rename from bchain/coins/xzc/testdata/rawspend.hex rename to bchain/coins/firo/testdata/rawspend.hex diff --git a/bchain/coins/xzc/testdata/spendtx.json b/bchain/coins/firo/testdata/spendtx.json similarity index 100% rename from bchain/coins/xzc/testdata/spendtx.json rename to bchain/coins/firo/testdata/spendtx.json diff --git a/bchain/coins/xzc/testdata/txs.hex b/bchain/coins/firo/testdata/txs.hex similarity index 100% rename from bchain/coins/xzc/testdata/txs.hex rename to bchain/coins/firo/testdata/txs.hex diff --git a/configs/coins/firo.json b/configs/coins/firo.json new file mode 100644 index 00000000..8ccc4742 --- /dev/null +++ b/configs/coins/firo.json @@ -0,0 +1,125 @@ +{ + "coin": { + "name": "Firo", + "shortcut": "FIRO", + "label": "Firo", + "alias": "firo" + }, + "ports": { + "backend_rpc": 8050, + "backend_message_queue": 38350, + "blockbook_internal": 9050, + "blockbook_public": 9150 + }, + "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-firo", + "package_revision": "satoshilabs-1", + "system_user": "firo", + "version": "0.14.1.2", + "binary_url": "https://github.com/firoorg/firo/releases/download/v0.14.1.2/firo-0.14.1.2-linux64.tar.gz", + "verification_type": "sha256", + "verification_source": "f2f3e92d891cfcea3b9232bdaf104fd1c7b6d21997a4e2c1297c7e8130c2e3e3", + "extract_command": "tar -C backend --strip 1 -xf", + "exclude_files": [ + "bin/tor", + "bin/tor-gencert", + "bin/torify", + "bin/tor-print-ed-signing-cert", + "bin/tor-resolve", + "bin/firo-qt", + "bin/firo-tx", + "etc/tor/torrc.sample", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/cmake/relic-config.cmake", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/chiabls/aggregationinfo.hpp", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/chiabls/bls.hpp", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/chiabls/chaincode.hpp", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/chiabls/extendedprivatekey.hpp", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/chiabls/extendedpublickey.hpp", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/chiabls/privatekey.hpp", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/chiabls/publickey.hpp", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/chiabls/signature.hpp", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/chiabls/test-utils.hpp", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/chiabls/util.hpp", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/low/relic_bn_low.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/low/relic_dv_low.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/low/relic_fb_low.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/low/relic_fp_low.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/low/relic_fpx_low.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_arch.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_bc.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_bench.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_bn.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_conf.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_core.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_cp.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_dv.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_eb.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_ec.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_ed.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_ep.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_epx.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_err.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_fb.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_fbx.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_fp.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_fpx.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_label.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_md.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_pc.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_pool.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_pp.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_rand.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_test.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_trace.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_types.h", + "home/ubuntu/build/firo/depends/x86_64-linux-gnu/include/relic_util.h", + "include/bitcoinconsensus.h", + "lib/libbitcoinconsensus.so", + "lib/libbitcoinconsensus.so.0", + "lib/libbitcoinconsensus.so.0.0.0", + "README.md", + "share/tor/geoip", + "share/tor/geoip6" + ], + "exec_command_template": "{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/bin/firod -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": { + "deprecatedrpc": "estimatefee" + } + }, + "blockbook": { + "package_name": "blockbook-firo", + "system_user": "blockbook-firo", + "internal_binding_template": ":{{.Ports.BlockbookInternal}}", + "public_binding_template": ":{{.Ports.BlockbookPublic}}", + "explorer_url": "", + "additional_params": "", + "block_chain": { + "mempool_workers": 8, + "mempool_sub_workers": 2, + "block_addresses_to_keep": 300, + "xpub_magic": 76067358, + "slip44": 136, + "additional_params": {} + } + }, + "meta": { + "package_maintainer": "Putta Khunchalee", + "package_maintainer_email": "putta@zcoin.io" + } +} diff --git a/configs/coins/zcoin.json b/configs/coins/zcoin.json deleted file mode 100644 index 37e9746a..00000000 --- a/configs/coins/zcoin.json +++ /dev/null @@ -1,125 +0,0 @@ -{ - "coin": { - "name": "Zcoin", - "shortcut": "XZC", - "label": "Zcoin", - "alias": "zcoin" - }, - "ports": { - "backend_rpc": 8050, - "backend_message_queue": 38350, - "blockbook_internal": 9050, - "blockbook_public": 9150 - }, - "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-zcoin", - "package_revision": "satoshilabs-1", - "system_user": "zcoin", - "version": "0.14.0.4", - "binary_url": "https://github.com/zcoinofficial/zcoin/releases/download/v0.14.0.4/zcoin-0.14.0.4-linux64.tar.gz", - "verification_type": "sha256", - "verification_source": "d060c76fe5fc0fe2527485035e984413881c4a845f65c4c9e71cc298b227a816", - "extract_command": "tar -C backend --strip 1 -xf", - "exclude_files": [ - "bin/tor", - "bin/tor-gencert", - "bin/torify", - "bin/tor-print-ed-signing-cert", - "bin/tor-resolve", - "bin/zcoin-qt", - "bin/zcoin-tx", - "etc/tor/torrc.sample", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/cmake/relic-config.cmake", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/chiabls/aggregationinfo.hpp", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/chiabls/bls.hpp", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/chiabls/chaincode.hpp", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/chiabls/extendedprivatekey.hpp", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/chiabls/extendedpublickey.hpp", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/chiabls/privatekey.hpp", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/chiabls/publickey.hpp", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/chiabls/signature.hpp", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/chiabls/test-utils.hpp", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/chiabls/util.hpp", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/low/relic_bn_low.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/low/relic_dv_low.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/low/relic_fb_low.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/low/relic_fp_low.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/low/relic_fpx_low.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_arch.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_bc.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_bench.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_bn.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_conf.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_core.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_cp.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_dv.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_eb.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_ec.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_ed.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_ep.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_epx.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_err.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_fb.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_fbx.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_fp.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_fpx.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_label.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_md.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_pc.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_pool.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_pp.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_rand.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_test.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_trace.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_types.h", - "home/ubuntu/build/zcoin/depends/x86_64-linux-gnu/include/relic_util.h", - "include/bitcoinconsensus.h", - "lib/libbitcoinconsensus.so", - "lib/libbitcoinconsensus.so.0", - "lib/libbitcoinconsensus.so.0.0.0", - "README.md", - "share/tor/geoip", - "share/tor/geoip6" - ], - "exec_command_template": "{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/bin/zcoind -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": { - "deprecatedrpc": "estimatefee" - } - }, - "blockbook": { - "package_name": "blockbook-zcoin", - "system_user": "blockbook-zcoin", - "internal_binding_template": ":{{.Ports.BlockbookInternal}}", - "public_binding_template": ":{{.Ports.BlockbookPublic}}", - "explorer_url": "", - "additional_params": "", - "block_chain": { - "mempool_workers": 8, - "mempool_sub_workers": 2, - "block_addresses_to_keep": 300, - "xpub_magic": 76067358, - "slip44": 136, - "additional_params": {} - } - }, - "meta": { - "package_maintainer": "Putta Khunchalee", - "package_maintainer_email": "putta@zcoin.io" - } -} diff --git a/docs/ports.md b/docs/ports.md index 13b25218..8929d7ba 100644 --- a/docs/ports.md +++ b/docs/ports.md @@ -22,7 +22,7 @@ | Liquid | 9047 | 9147 | 8047 | 38347 | | Fujicoin | 9048 | 9148 | 8048 | 38348 | | PIVX | 9049 | 9149 | 8049 | 38349 | -| Zcoin | 9050 | 9150 | 8050 | 38350 | +| Firo | 9050 | 9150 | 8050 | 38350 | | Koto | 9051 | 9151 | 8051 | 38351 | | Bellcoin | 9052 | 9152 | 8052 | 38352 | | NULS | 9053 | 9153 | 8053 | 38353 | diff --git a/tests/rpc/testdata/zcoin.json b/tests/rpc/testdata/firo.json similarity index 100% rename from tests/rpc/testdata/zcoin.json rename to tests/rpc/testdata/firo.json diff --git a/tests/sync/testdata/zcoin.json b/tests/sync/testdata/firo.json similarity index 100% rename from tests/sync/testdata/zcoin.json rename to tests/sync/testdata/firo.json diff --git a/tests/tests.json b/tests/tests.json index 49ae8212..1ddfddad 100644 --- a/tests/tests.json +++ b/tests/tests.json @@ -157,7 +157,7 @@ "EstimateSmartFee", "EstimateFee", "GetBestBlockHash", "GetBestBlockHeight", "GetBlockHeader"], "sync": ["ConnectBlocksParallel", "ConnectBlocks"] }, - "zcoin": { + "firo": { "rpc": ["GetBlock", "GetBlockHash", "GetTransaction", "GetTransactionForMempool", "MempoolSync", "EstimateFee", "GetBestBlockHash", "GetBestBlockHeight", "GetBlockHeader"], "sync": ["ConnectBlocksParallel", "ConnectBlocks", "HandleFork"]