diff --git a/alert/alert.go b/alert/alert.go index d761da2a9..5f4b9b54e 100644 --- a/alert/alert.go +++ b/alert/alert.go @@ -15,16 +15,16 @@ var alertCountSince int = 0 func Alert(message string) { log.Error(" ALERT \n" + message) now := time.Now().Unix() - if now-lastAlertUnix > int64(config.App().GetInt("Alert.MinInterval")) { - message = fmt.Sprintf("%v:%v", config.App().GetString("Network"), message) + if now-lastAlertUnix > int64(config.App().GetInt("alert_min_interval")) { + message = fmt.Sprintf("%v:%v", config.App().GetString("network"), message) if alertCountSince > 0 { message = fmt.Sprintf("%v (+%v more since)", message, alertCountSince) alertCountSince = 0 } - if len(config.App().GetString("Alert.TwilioSid")) > 0 { + if len(config.App().GetString("alert_twilio_sid")) > 0 { go sendTwilio(message) } - if len(config.App().GetString("Alert.EmailRecipients")) > 0 { + if len(config.App().GetString("alert_email_recipients")) > 0 { go sendEmail(message) } } else { @@ -41,8 +41,8 @@ func sendTwilio(message string) { if len(message) > 50 { message = message[:50] } - twilio := gotwilio.NewTwilioClient(config.App().GetString("Alert.TwilioSid"), config.App().GetString("Alert.TwilioToken")) - res, exp, err := twilio.SendSMS(config.App().GetString("Alert.TwilioFrom"), config.App().GetString("Alert.TwilioTo"), message, "", "") + twilio := gotwilio.NewTwilioClient(config.App().GetString("alert_twilio_sid"), config.App().GetString("alert_twilio_token")) + res, exp, err := twilio.SendSMS(config.App().GetString("alert_twilio_from"), config.App().GetString("alert_twilio_to"), message, "", "") if exp != nil || err != nil { log.Error("sendTwilio error", "res", res, "exp", exp, "error", err) } @@ -58,7 +58,7 @@ func sendEmail(message string) { if len(subject) > 80 { subject = subject[:80] } - err := SendEmail(subject, message, config.App().GetStringSlice("Alert.EmailRecipients")) + err := SendEmail(subject, message, config.App().GetStringSlice("alert_email_recipients")) if err != nil { log.Error("sendEmail error", "error", err, "message", message) } diff --git a/alert/email.go b/alert/email.go index d484f6f26..97ada14ce 100644 --- a/alert/email.go +++ b/alert/email.go @@ -19,7 +19,7 @@ import ( // Convenience function func SendEmail(subject, body string, tos []string) error { email := Compose(subject, body) - email.From = config.App().GetString("SMTP.User") + email.From = config.App().GetString("smtp_user") email.ContentType = "text/html; charset=utf-8" email.AddRecipients(tos...) err := email.Send() @@ -86,12 +86,12 @@ func (e *Email) Send() error { auth := smtp.PlainAuth( "", - config.App().GetString("SMTP.User"), - config.App().GetString("SMTP.Password"), - config.App().GetString("SMTP.Host"), + config.App().GetString("smtp_user"), + config.App().GetString("smtp_password"), + config.App().GetString("smtp_host"), ) - conn, err := smtp.Dial(fmt.Sprintf("%v:%v", config.App().GetString("SMTP.Host"), config.App().GetString("SMTP.Port"))) + conn, err := smtp.Dial(fmt.Sprintf("%v:%v", config.App().GetString("smtp_host"), config.App().GetString("smtp_port"))) if err != nil { return err } diff --git a/cmd/tendermint/gen_validator.go b/cmd/tendermint/gen_validator.go index 1d3af701e..63d76ed21 100644 --- a/cmd/tendermint/gen_validator.go +++ b/cmd/tendermint/gen_validator.go @@ -18,7 +18,7 @@ Paste the following JSON into your %v file %v `, - config.App().GetString("PrivValidatorFile"), + config.App().GetString("priv_validator_file"), string(privValidatorJSONBytes), ) } diff --git a/cmd/tendermint/reset_priv_validator.go b/cmd/tendermint/reset_priv_validator.go index 82301b0b8..4eeb60d66 100644 --- a/cmd/tendermint/reset_priv_validator.go +++ b/cmd/tendermint/reset_priv_validator.go @@ -12,7 +12,7 @@ import ( func reset_priv_validator() { // Get PrivValidator var privValidator *sm.PrivValidator - privValidatorFile := config.App().GetString("PrivValidatorFile") + privValidatorFile := config.App().GetString("priv_validator_file") if _, err := os.Stat(privValidatorFile); err == nil { privValidator = sm.LoadPrivValidator(privValidatorFile) privValidator.LastHeight = 0 diff --git a/config/config.go b/config/config.go index 7ae4e3117..f41f4d2fb 100644 --- a/config/config.go +++ b/config/config.go @@ -35,33 +35,14 @@ func SetApp(a *confer.Config) { var defaultConfig = `# This is a TOML config file. # For more information, see https://github.com/toml-lang/toml -Moniker = "anonymous" -Network = "tendermint_testnet4.2" -ListenAddr = "0.0.0.0:46656" -# First node to connect to. Command-line overridable. -SeedNode = "" -# Pool of seeds. Best to use these, and specify one on command line -# if needed to override -SeedNodes = ["navytoad.chaintest.net:46656", "whiteferret.chaintest.net:46656", "magentagriffin.chaintest.net:46656", "greensalamander.chaintest.net:46656", "blackshadow.chaintest.net:46656", "purpleanteater.chaintest.net:46656", "pinkpenguin.chaintest.net:46656", "polkapig.chaintest.net:46656", "128.199.230.153:8080"] - - -[DB] -# The only other available backend is "memdb" -Backend = "leveldb" -# Dir = "~/.tendermint/data" - -[Log.Stdout] -Level = "debug" - -[RPC.HTTP] -# For the RPC API HTTP server. Port required. -ListenAddr = "0.0.0.0:46657" - -[Alert] -# TODO: Document options - -[SMTP] -# TODO: Document options +network = "tendermint_testnet_5" +moniker = "anonymous" +node_laddr = "0.0.0.0:46656" +seeds = "goldenalchemist.chaintest.net:46656" +fast_sync = true +db_backend = "leveldb" +log_level = "debug" +rpc_laddr = "0.0.0.0:46657" ` var DefaultGenesis = `{ @@ -141,19 +122,18 @@ var DefaultGenesis = `{ // NOTE: If you change this, maybe also change defaultConfig func initDefaults(rootDir string) { - app.SetDefault("Moniker", "anonymous") - app.SetDefault("Network", "tendermint_testnet0") - app.SetDefault("ListenAddr", "0.0.0.0:46656") - app.SetDefault("DB.Backend", "leveldb") - app.SetDefault("DB.Dir", rootDir+"/data") - app.SetDefault("Log.Stdout.Level", "info") - app.SetDefault("RPC.HTTP.ListenAddr", "0.0.0.0:46657") - - app.SetDefault("GenesisFile", rootDir+"/genesis.json") - app.SetDefault("AddrBookFile", rootDir+"/addrbook.json") - app.SetDefault("PrivValidatorfile", rootDir+"/priv_validator.json") - - app.SetDefault("FastSync", false) + app.SetDefault("network", "tendermint_testnet0") + app.SetDefault("genesis_file", rootDir+"/genesis.json") + app.SetDefault("moniker", "anonymous") + app.SetDefault("node_laddr", "0.0.0.0:46656") + app.SetDefault("seeds", "goldenalchemist.chaintest.net:46656") + app.SetDefault("fast_sync", true) + app.SetDefault("addrbook_file", rootDir+"/addrbook.json") + app.SetDefault("priv_validator_file", rootDir+"/priv_validator.json") + app.SetDefault("db_backend", "leveldb") + app.SetDefault("db_dir", rootDir+"/data") + app.SetDefault("log_level", "info") + app.SetDefault("rpc_laddr", "0.0.0.0:46657") } func Init(rootDir string) { @@ -209,11 +189,12 @@ func ParseFlags(args []string) { // Declare flags flags.BoolVar(&printHelp, "help", false, "Print this help message.") - flags.String("listen_addr", app.GetString("ListenAddr"), "Listen address. (0.0.0.0:0 means any interface, any port)") - flags.String("seed_node", app.GetString("SeedNode"), "Address of seed nodes") - flags.String("rpc_http_listen_addr", app.GetString("RPC.HTTP.ListenAddr"), "RPC listen address. Port required") - flags.Bool("fast_sync", app.GetBool("FastSync"), "Fast blockchain syncing") - flags.String("log_stdout_level", app.GetString("Log.Stdout.Level"), "Stdout log level") + flags.String("moniker", app.GetString("moniker"), "Node Name") + flags.String("node_laddr", app.GetString("node_laddr"), "Node listen address. (0.0.0.0:0 means any interface, any port)") + flags.String("seeds", app.GetString("seeds"), "Comma delimited seed nodes") + flags.Bool("fast_sync", app.GetBool("fast_sync"), "Fast blockchain syncing") + flags.String("rpc_laddr", app.GetString("rpc_laddr"), "RPC listen address. Port required") + flags.String("log_level", app.GetString("log_level"), "Log level") flags.Parse(args) if printHelp { flags.PrintDefaults() @@ -221,11 +202,12 @@ func ParseFlags(args []string) { } // Merge parsed flag values onto app. - app.BindPFlag("ListenAddr", flags.Lookup("listen_addr")) - app.BindPFlag("SeedNode", flags.Lookup("seed_node")) - app.BindPFlag("FastSync", flags.Lookup("fast_sync")) - app.BindPFlag("RPC.HTTP.ListenAddr", flags.Lookup("rpc_http_listen_addr")) - app.BindPFlag("Log.Stdout.Level", flags.Lookup("log_stdout_level")) + app.BindPFlag("moniker", flags.Lookup("moniker")) + app.BindPFlag("node_laddr", flags.Lookup("node_laddr")) + app.BindPFlag("seeds", flags.Lookup("seeds")) + app.BindPFlag("fast_sync", flags.Lookup("fast_sync")) + app.BindPFlag("rpc_laddr", flags.Lookup("rpc_laddr")) + app.BindPFlag("log_level", flags.Lookup("log_level")) // Confused? //app.Debug() diff --git a/consensus/state.go b/consensus/state.go index 4994be76e..100bb8321 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -657,7 +657,7 @@ func (cs *ConsensusState) RunActionPropose(height uint, round uint) { txs := cs.mempoolReactor.Mempool.GetProposalTxs() block = &types.Block{ Header: &types.Header{ - Network: config.App().GetString("Network"), + Network: config.App().GetString("network"), Height: cs.Height, Time: time.Now(), Fees: 0, // TODO fees diff --git a/consensus/types/proposal.go b/consensus/types/proposal.go index 9296abbe4..483575d31 100644 --- a/consensus/types/proposal.go +++ b/consensus/types/proposal.go @@ -41,7 +41,7 @@ func (p *Proposal) String() string { func (p *Proposal) WriteSignBytes(w io.Writer, n *int64, err *error) { // We hex encode the network name so we don't deal with escaping issues. - binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("Network"))), w, n, err) + binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("network"))), w, n, err) binary.WriteTo([]byte(`,"proposal":{"block_parts":`), w, n, err) p.BlockParts.WriteSignBytes(w, n, err) binary.WriteTo([]byte(Fmt(`,"height":%v,"pol_parts":`, p.Height)), w, n, err) diff --git a/consensus/types/proposal_test.go b/consensus/types/proposal_test.go index 4b10eb483..a20583b4a 100644 --- a/consensus/types/proposal_test.go +++ b/consensus/types/proposal_test.go @@ -20,7 +20,7 @@ func TestProposalSignable(t *testing.T) { signBytes := account.SignBytes(proposal) signStr := string(signBytes) expected := Fmt(`{"network":"%X","proposal":{"block_parts":{"hash":"626C6F636B7061727473","total":111},"height":12345,"pol_parts":{"hash":"706F6C7061727473","total":222},"round":23456}}`, - config.App().GetString("Network")) + config.App().GetString("network")) if signStr != expected { t.Errorf("Got unexpected sign string for SendTx. Expected:\n%v\nGot:\n%v", expected, signStr) } diff --git a/db/db.go b/db/db.go index 3300727f5..af775f8b9 100644 --- a/db/db.go +++ b/db/db.go @@ -32,19 +32,19 @@ func GetDB(name string) DB { if db != nil { return db.(DB) } - switch config.App().GetString("DB.Backend") { + switch config.App().GetString("db_backend") { case DBBackendMemDB: db := NewMemDB() dbs.Set(name, db) return db case DBBackendLevelDB: - db, err := NewLevelDB(path.Join(config.App().GetString("DB.Dir"), name+".db")) + db, err := NewLevelDB(path.Join(config.App().GetString("db_dir"), name+".db")) if err != nil { panic(err) } dbs.Set(name, db) return db default: - panic(Fmt("Unknown DB backend: %v", config.App().GetString("DB.Backend"))) + panic(Fmt("Unknown DB backend: %v", config.App().GetString("db_backend"))) } } diff --git a/logger/log.go b/logger/log.go index 24c060d50..2b1ce8c72 100644 --- a/logger/log.go +++ b/logger/log.go @@ -20,14 +20,14 @@ func Reset() { // stdout handler stdoutHandler := log15.LvlFilterHandler( - getLevel(config.App().GetString("Log.Stdout.Level")), + getLevel(config.App().GetString("log_level")), log15.StreamHandler(os.Stdout, log15.TerminalFormat()), ) handlers = append(handlers, stdoutHandler) /* // Maybe also write to a file. - if _logFileDir := config.App().GetString("Log.File.Dir"); _logFileDir != "" { + if _logFileDir := config.App().GetString("log_file_dir"); _logFileDir != "" { // Create log dir if it doesn't exist err := os.MkdirAll(_logFileDir, 0700) if err != nil { @@ -36,7 +36,7 @@ func Reset() { } // File handler handlers = append(handlers, log15.LvlFilterHandler( - getLevel(config.App().GetString("Log.File.Level")), + getLevel(config.App().GetString("log_file_level")), log15.Must.FileHandler(_logFileDir+"/tendermint.log", log15.LogfmtFormat()), )) } diff --git a/node/node.go b/node/node.go index 9f533e518..9e05d74f7 100644 --- a/node/node.go +++ b/node/node.go @@ -7,6 +7,7 @@ import ( "net/http" "os" "strconv" + "strings" "time" bc "github.com/tendermint/tendermint/blockchain" @@ -53,13 +54,13 @@ func NewNode() *Node { stateDB := dbm.GetDB("state") state := sm.LoadState(stateDB) if state == nil { - state = sm.MakeGenesisStateFromFile(stateDB, config.App().GetString("GenesisFile")) + state = sm.MakeGenesisStateFromFile(stateDB, config.App().GetString("genesis_file")) state.Save() } // Get PrivValidator var privValidator *sm.PrivValidator - privValidatorFile := config.App().GetString("PrivValidatorFile") + privValidatorFile := config.App().GetString("priv_validator_file") if _, err := os.Stat(privValidatorFile); err == nil { privValidator = sm.LoadPrivValidator(privValidatorFile) log.Info("Loaded PrivValidator", @@ -75,11 +76,11 @@ func NewNode() *Node { eventSwitch.Start() // Get PEXReactor - book := p2p.NewAddrBook(config.App().GetString("AddrBookFile")) + book := p2p.NewAddrBook(config.App().GetString("addrbook_file")) pexReactor := p2p.NewPEXReactor(book) // Get BlockchainReactor - bcReactor := bc.NewBlockchainReactor(state, blockStore, config.App().GetBool("FastSync")) + bcReactor := bc.NewBlockchainReactor(state, blockStore, config.App().GetBool("fast_sync")) // Get MempoolReactor mempool := mempl.NewMempool(state.Copy()) @@ -93,7 +94,7 @@ func NewNode() *Node { } // so the consensus reactor won't do anything until we're synced - if config.App().GetBool("FastSync") { + if config.App().GetBool("fast_sync") { consensusReactor.SetSyncing(true) } @@ -155,16 +156,8 @@ func (n *Node) AddListener(l p2p.Listener) { // NOTE: Blocking func (n *Node) DialSeed() { - // if the single seed node is available, use only it - prioritySeed := config.App().GetString("SeedNode") - if prioritySeed != "" { - addr := p2p.NewNetAddressString(prioritySeed) - n.dialSeed(addr) - return - } - // permute the list, dial them in random order. - seeds := config.App().GetStringSlice("SeedNodes") + seeds := strings.Split(config.App().GetString("seeds"), ",") perm := rand.Perm(len(seeds)) for i := 0; i < len(perm); i++ { go func(i int) { @@ -195,7 +188,7 @@ func (n *Node) StartRPC() { core.SetMempoolReactor(n.mempoolReactor) core.SetSwitch(n.sw) - listenAddr := config.App().GetString("RPC.HTTP.ListenAddr") + listenAddr := config.App().GetString("rpc_laddr") mux := http.NewServeMux() rpc.RegisterEventsHandler(mux, n.evsw) rpc.RegisterRPCFuncs(mux, core.Routes) @@ -220,8 +213,8 @@ func (n *Node) EventSwitch() *events.EventSwitch { func makeNodeInfo(sw *p2p.Switch) *types.NodeInfo { nodeInfo := &types.NodeInfo{ - Moniker: config.App().GetString("Moniker"), - Network: config.App().GetString("Network"), + Network: config.App().GetString("network"), + Moniker: config.App().GetString("moniker"), Version: "0.2.0", // Everything is in Big Endian. } if !sw.IsListening() { @@ -230,11 +223,11 @@ func makeNodeInfo(sw *p2p.Switch) *types.NodeInfo { p2pListener := sw.Listeners()[0] p2pHost := p2pListener.ExternalAddress().IP.String() p2pPort := p2pListener.ExternalAddress().Port - rpcListenAddr := config.App().GetString("RPC.HTTP.ListenAddr") + rpcListenAddr := config.App().GetString("rpc_laddr") _, rpcPortStr, _ := net.SplitHostPort(rpcListenAddr) rpcPort, err := strconv.Atoi(rpcPortStr) if err != nil { - panic(Fmt("Expected numeric RPC.HTTP.ListenAddr port but got %v", rpcPortStr)) + panic(Fmt("Expected numeric RPC.ListenAddr port but got %v", rpcPortStr)) } // We assume that the rpcListener has the same ExternalAddress. @@ -250,17 +243,17 @@ func makeNodeInfo(sw *p2p.Switch) *types.NodeInfo { func RunNode() { // Create & start node n := NewNode() - l := p2p.NewDefaultListener("tcp", config.App().GetString("ListenAddr"), false) + l := p2p.NewDefaultListener("tcp", config.App().GetString("node_laddr"), false) n.AddListener(l) n.Start() // If seedNode is provided by config, dial out. - if config.App().GetString("SeedNode") != "" || len(config.App().GetStringSlice("SeedNodes")) != 0 { + if len(config.App().GetStringSlice("seeds")) != 0 { n.DialSeed() } // Run the RPC server. - if config.App().GetString("RPC.HTTP.ListenAddr") != "" { + if config.App().GetString("rpc_laddr") != "" { n.StartRPC() } diff --git a/rpc/core/net.go b/rpc/core/net.go index 7f852f34e..fc77bc24f 100644 --- a/rpc/core/net.go +++ b/rpc/core/net.go @@ -12,7 +12,7 @@ import ( func Status() (*ctypes.ResponseStatus, error) { db := dbm.NewMemDB() - genesisState := sm.MakeGenesisStateFromFile(db, config.App().GetString("GenesisFile")) + genesisState := sm.MakeGenesisStateFromFile(db, config.App().GetString("genesis_file")) genesisHash := genesisState.Hash() latestHeight := blockStore.Height() var ( @@ -26,15 +26,15 @@ func Status() (*ctypes.ResponseStatus, error) { latestBlockTime = latestBlockMeta.Header.Time.UnixNano() } - return &ctypes.ResponseStatus{genesisHash, config.App().GetString("Network"), latestBlockHash, latestHeight, latestBlockTime}, nil + return &ctypes.ResponseStatus{genesisHash, config.App().GetString("network"), latestBlockHash, latestHeight, latestBlockTime}, nil } //----------------------------------------------------------------------------- func NetInfo() (*ctypes.ResponseNetInfo, error) { listening := p2pSwitch.IsListening() - moniker := config.App().GetString("Moniker") - network := config.App().GetString("Network") + moniker := config.App().GetString("moniker") + network := config.App().GetString("network") listeners := []string{} for _, listener := range p2pSwitch.Listeners() { listeners = append(listeners, listener.String()) diff --git a/rpc/test/helpers_test.go b/rpc/test/helpers_test.go index 45945239d..e6bd4cd32 100644 --- a/rpc/test/helpers_test.go +++ b/rpc/test/helpers_test.go @@ -61,7 +61,7 @@ func decodeHex(hexStr string) []byte { func newNode(ready chan struct{}) { // Create & start node node = nm.NewNode() - l := p2p.NewDefaultListener("tcp", config.App().GetString("ListenAddr"), false) + l := p2p.NewDefaultListener("tcp", config.App().GetString("node_laddr"), false) node.AddListener(l) node.Start() @@ -79,12 +79,12 @@ func init() { rootDir := ".tendermint" config.Init(rootDir) app := config.App() - app.Set("SeedNode", "") - app.Set("DB.Backend", "memdb") - app.Set("RPC.HTTP.ListenAddr", rpcAddr) - app.Set("GenesisFile", rootDir+"/genesis.json") - app.Set("PrivValidatorFile", rootDir+"/priv_validator.json") - app.Set("Log.Stdout.Level", "debug") + app.Set("genesis_file", rootDir+"/genesis.json") + app.Set("seeds", "") + app.Set("priv_validator_file", rootDir+"/priv_validator.json") + app.Set("db_backend", "memdb") + app.Set("rpc_laddr", rpcAddr) + app.Set("log_level", "debug") config.SetApp(app) logger.Reset() diff --git a/rpc/test/tests_test.go b/rpc/test/tests_test.go index b2381eff0..3694ee506 100644 --- a/rpc/test/tests_test.go +++ b/rpc/test/tests_test.go @@ -16,9 +16,9 @@ func testStatus(t *testing.T, typ string) { if err != nil { t.Fatal(err) } - if resp.Network != config.App().GetString("Network") { + if resp.Network != config.App().GetString("network") { t.Fatal(fmt.Errorf("Network mismatch: got %s expected %s", - resp.Network, config.App().Get("Network"))) + resp.Network, config.App().Get("network"))) } } diff --git a/state/priv_validator.go b/state/priv_validator.go index ef2c0dd6d..03e72b6b7 100644 --- a/state/priv_validator.go +++ b/state/priv_validator.go @@ -68,7 +68,7 @@ func GenPrivValidator() *PrivValidator { LastHeight: 0, LastRound: 0, LastStep: stepNone, - filename: config.App().GetString("PrivValidatorFile"), + filename: config.App().GetString("priv_validator_file"), } } diff --git a/state/state_test.go b/state/state_test.go index c2d766e31..7db1d43a0 100644 --- a/state/state_test.go +++ b/state/state_test.go @@ -65,7 +65,7 @@ func TestCopyState(t *testing.T) { func makeBlock(t *testing.T, state *State, commits []types.Commit, txs []types.Tx) *types.Block { block := &types.Block{ Header: &types.Header{ - Network: config.App().GetString("Network"), + Network: config.App().GetString("network"), Height: state.LastBlockHeight + 1, Time: state.LastBlockTime.Add(time.Minute), Fees: 0, diff --git a/types/block.go b/types/block.go index bb0decc4a..824ba8933 100644 --- a/types/block.go +++ b/types/block.go @@ -24,7 +24,7 @@ type Block struct { // Basic validation that doesn't involve state data. func (b *Block) ValidateBasic(lastBlockHeight uint, lastBlockHash []byte, lastBlockParts PartSetHeader, lastBlockTime time.Time) error { - if b.Network != config.App().GetString("Network") { + if b.Network != config.App().GetString("network") { return errors.New("Wrong Block.Header.Network") } if b.Height != lastBlockHeight+1 { diff --git a/types/tx.go b/types/tx.go index 046418b62..a18f2283e 100644 --- a/types/tx.go +++ b/types/tx.go @@ -132,7 +132,7 @@ type SendTx struct { func (tx *SendTx) WriteSignBytes(w io.Writer, n *int64, err *error) { // We hex encode the network name so we don't deal with escaping issues. - binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("Network"))), w, n, err) + binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("network"))), w, n, err) binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"inputs":[`, TxTypeSend)), w, n, err) for i, in := range tx.Inputs { in.WriteSignBytes(w, n, err) @@ -166,7 +166,7 @@ type CallTx struct { func (tx *CallTx) WriteSignBytes(w io.Writer, n *int64, err *error) { // We hex encode the network name so we don't deal with escaping issues. - binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("Network"))), w, n, err) + binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("network"))), w, n, err) binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"address":"%X","data":"%X"`, TxTypeCall, tx.Address, tx.Data)), w, n, err) binary.WriteTo([]byte(Fmt(`,"fee":%v,"gas_limit":%v,"input":`, tx.Fee, tx.GasLimit)), w, n, err) tx.Input.WriteSignBytes(w, n, err) @@ -187,7 +187,7 @@ type BondTx struct { func (tx *BondTx) WriteSignBytes(w io.Writer, n *int64, err *error) { // We hex encode the network name so we don't deal with escaping issues. - binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("Network"))), w, n, err) + binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("network"))), w, n, err) binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"inputs":[`, TxTypeBond)), w, n, err) for i, in := range tx.Inputs { in.WriteSignBytes(w, n, err) @@ -221,7 +221,7 @@ type UnbondTx struct { func (tx *UnbondTx) WriteSignBytes(w io.Writer, n *int64, err *error) { // We hex encode the network name so we don't deal with escaping issues. - binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("Network"))), w, n, err) + binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("network"))), w, n, err) binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"address":"%X","height":%v}]}`, TxTypeUnbond, tx.Address, tx.Height)), w, n, err) } @@ -239,7 +239,7 @@ type RebondTx struct { func (tx *RebondTx) WriteSignBytes(w io.Writer, n *int64, err *error) { // We hex encode the network name so we don't deal with escaping issues. - binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("Network"))), w, n, err) + binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("network"))), w, n, err) binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"address":"%X","height":%v}]}`, TxTypeRebond, tx.Address, tx.Height)), w, n, err) } diff --git a/types/tx_test.go b/types/tx_test.go index f85dc087d..8c769aa00 100644 --- a/types/tx_test.go +++ b/types/tx_test.go @@ -36,7 +36,7 @@ func TestSendTxSignable(t *testing.T) { signBytes := account.SignBytes(sendTx) signStr := string(signBytes) expected := Fmt(`{"network":"%X","tx":[1,{"inputs":[{"address":"696E70757431","amount":12345,"sequence":67890},{"address":"696E70757432","amount":111,"sequence":222}],"outputs":[{"address":"6F757470757431","amount":333},{"address":"6F757470757432","amount":444}]}]}`, - config.App().GetString("Network")) + config.App().GetString("network")) if signStr != expected { t.Errorf("Got unexpected sign string for SendTx. Expected:\n%v\nGot:\n%v", expected, signStr) } @@ -57,7 +57,7 @@ func TestCallTxSignable(t *testing.T) { signBytes := account.SignBytes(callTx) signStr := string(signBytes) expected := Fmt(`{"network":"%X","tx":[2,{"address":"636F6E747261637431","data":"6461746131","fee":222,"gas_limit":111,"input":{"address":"696E70757431","amount":12345,"sequence":67890}}]}`, - config.App().GetString("Network")) + config.App().GetString("network")) if signStr != expected { t.Errorf("Got unexpected sign string for CallTx. Expected:\n%v\nGot:\n%v", expected, signStr) } @@ -93,7 +93,7 @@ func TestBondTxSignable(t *testing.T) { signBytes := account.SignBytes(bondTx) signStr := string(signBytes) expected := Fmt(`{"network":"%X","tx":[17,{"inputs":[{"address":"696E70757431","amount":12345,"sequence":67890},{"address":"696E70757432","amount":111,"sequence":222}],"pub_key":[1,"3B6A27BCCEB6A42D62A3A8D02A6F0D73653215771DE243A63AC048A18B59DA29"],"unbond_to":[{"address":"6F757470757431","amount":333},{"address":"6F757470757432","amount":444}]}]}`, - config.App().GetString("Network")) + config.App().GetString("network")) if signStr != expected { t.Errorf("Got unexpected sign string for BondTx") } @@ -107,7 +107,7 @@ func TestUnbondTxSignable(t *testing.T) { signBytes := account.SignBytes(unbondTx) signStr := string(signBytes) expected := Fmt(`{"network":"%X","tx":[18,{"address":"6164647265737331","height":111}]}`, - config.App().GetString("Network")) + config.App().GetString("network")) if signStr != expected { t.Errorf("Got unexpected sign string for UnbondTx") } @@ -121,7 +121,7 @@ func TestRebondTxSignable(t *testing.T) { signBytes := account.SignBytes(rebondTx) signStr := string(signBytes) expected := Fmt(`{"network":"%X","tx":[19,{"address":"6164647265737331","height":111}]}`, - config.App().GetString("Network")) + config.App().GetString("network")) if signStr != expected { t.Errorf("Got unexpected sign string for RebondTx") } diff --git a/types/vote.go b/types/vote.go index b4bd7a2f3..ae3175a45 100644 --- a/types/vote.go +++ b/types/vote.go @@ -48,7 +48,7 @@ const ( func (vote *Vote) WriteSignBytes(w io.Writer, n *int64, err *error) { // We hex encode the network name so we don't deal with escaping issues. - binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("Network"))), w, n, err) + binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.App().GetString("network"))), w, n, err) binary.WriteTo([]byte(Fmt(`,"vote":{"block_hash":"%X","block_parts":%v`, vote.BlockHash, vote.BlockParts)), w, n, err) binary.WriteTo([]byte(Fmt(`,"height":%v,"round":%v,"type":%v}}`, vote.Height, vote.Round, vote.Type)), w, n, err) }