From 6e3a199f0921509f86da2a508e39e95a1158bf2b Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 30 Jan 2017 19:11:44 +0100 Subject: [PATCH] Fix sendtx to not panic on error --- .gitignore | 1 + cmd/basecoin/commands/start.go | 1 - cmd/basecoin/commands/tx.go | 5 +++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fbf50087e3..100b0cae2f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.swp vendor +merkleeyes.db diff --git a/cmd/basecoin/commands/start.go b/cmd/basecoin/commands/start.go index 90e701afd8..225619399f 100644 --- a/cmd/basecoin/commands/start.go +++ b/cmd/basecoin/commands/start.go @@ -41,7 +41,6 @@ var StartCmd = cli.Command{ InProcTMFlag, ChainIDFlag, IbcPluginFlag, - // CounterPluginFlag, }, } diff --git a/cmd/basecoin/commands/tx.go b/cmd/basecoin/commands/tx.go index 43d36c81d7..2e7d3028dc 100644 --- a/cmd/basecoin/commands/tx.go +++ b/cmd/basecoin/commands/tx.go @@ -183,6 +183,11 @@ func broadcastTx(c *cli.Context, tx types.Tx) ([]byte, error) { return nil, errors.New(cmn.Fmt("Error on broadcast tx: %v", err)) } res := (*tmResult).(*ctypes.ResultBroadcastTxCommit) + // if it fails check, we don't even get a delivertx back! + if !res.CheckTx.Code.IsOK() { + r := res.CheckTx + return nil, errors.New(cmn.Fmt("BroadcastTxCommit got non-zero exit code: %v. %X; %s", r.Code, r.Data, r.Log)) + } if !res.DeliverTx.Code.IsOK() { r := res.DeliverTx return nil, errors.New(cmn.Fmt("BroadcastTxCommit got non-zero exit code: %v. %X; %s", r.Code, r.Data, r.Log))