diff --git a/cmd/commands/ibc.go b/cmd/commands/ibc.go index 4297bba42..8f1bdb4f5 100644 --- a/cmd/commands/ibc.go +++ b/cmd/commands/ibc.go @@ -2,6 +2,7 @@ package commands import ( "encoding/hex" + "encoding/json" "fmt" "io/ioutil" @@ -133,7 +134,12 @@ func ibcRegisterTxCmd(cmd *cobra.Command, args []string) error { }, } - fmt.Println("IBCTx:", string(wire.JSONBytes(ibcTx))) + out, err := json.Marshal(ibcTx) + if err != nil { + return err + } + + fmt.Printf("IBCTx: %s\n", string(out)) data := []byte(wire.BinaryBytes(struct { ibc.IBCTx `json:"unwrap"` @@ -172,7 +178,11 @@ func ibcUpdateTxCmd(cmd *cobra.Command, args []string) error { Commit: *commit, } - fmt.Println("IBCTx:", string(wire.JSONBytes(ibcTx))) + out, err := json.Marshal(ibcTx) + if err != nil { + return err + } + fmt.Printf("IBCTx: %s\n", string(out)) data := []byte(wire.BinaryBytes(struct { ibc.IBCTx `json:"unwrap"` @@ -211,7 +221,11 @@ func ibcPacketCreateTxCmd(cmd *cobra.Command, args []string) error { }, } - fmt.Println("IBCTx:", string(wire.JSONBytes(ibcTx))) + out, err := json.Marshal(ibcTx) + if err != nil { + return err + } + fmt.Printf("IBCTx: %s\n", string(out)) data := []byte(wire.BinaryBytes(struct { ibc.IBCTx `json:"unwrap"` @@ -253,7 +267,11 @@ func ibcPacketPostTxCmd(cmd *cobra.Command, args []string) error { Proof: proof, } - fmt.Println("IBCTx:", string(wire.JSONBytes(ibcTx))) + out, err := json.Marshal(ibcTx) + if err != nil { + return err + } + fmt.Printf("IBCTx: %s\n", string(out)) data := []byte(wire.BinaryBytes(struct { ibc.IBCTx `json:"unwrap"` diff --git a/cmd/commands/query.go b/cmd/commands/query.go index 330ba1514..e31d62549 100644 --- a/cmd/commands/query.go +++ b/cmd/commands/query.go @@ -2,6 +2,7 @@ package commands import ( "encoding/hex" + "encoding/json" "fmt" "strconv" @@ -9,6 +10,7 @@ import ( "github.com/spf13/cobra" "github.com/tendermint/go-wire" + "github.com/tendermint/go-wire/data" "github.com/tendermint/merkleeyes/iavl" "github.com/tendermint/tendermint/rpc/client" tmtypes "github.com/tendermint/tendermint/types" @@ -99,11 +101,16 @@ func queryCmd(cmd *cobra.Command, args []string) error { proof := resp.Proof height := resp.Height - fmt.Println(string(wire.JSONBytes(struct { - Value []byte `json:"value"` - Proof []byte `json:"proof"` - Height uint64 `json:"height"` - }{val, proof, height}))) + out, err := json.Marshal(struct { + Value data.Bytes `json:"value"` + Proof data.Bytes `json:"proof"` + Height uint64 `json:"height"` + }{val, proof, height}) + if err != nil { + return err + } + + fmt.Println(string(out)) return nil } @@ -126,7 +133,11 @@ func accountCmd(cmd *cobra.Command, args []string) error { if err != nil { return err } - fmt.Println(string(wire.JSONBytes(acc))) + out, err := json.Marshal(acc) + if err != nil { + return err + } + fmt.Println(string(out)) return nil } @@ -147,7 +158,7 @@ func blockCmd(cmd *cobra.Command, args []string) error { return err } - fmt.Println(string(wire.JSONBytes(struct { + out, err := json.Marshal(struct { Hex BlockHex `json:"hex"` JSON BlockJSON `json:"json"` }{ @@ -159,13 +170,18 @@ func blockCmd(cmd *cobra.Command, args []string) error { Header: header, Commit: commit, }, - }))) + }) + if err != nil { + return err + } + + fmt.Println(string(out)) return nil } type BlockHex struct { - Header []byte `json:"header"` - Commit []byte `json:"commit"` + Header data.Bytes `json:"header"` + Commit data.Bytes `json:"commit"` } type BlockJSON struct { diff --git a/cmd/commands/tx.go b/cmd/commands/tx.go index d13411bf0..70bc8e626 100644 --- a/cmd/commands/tx.go +++ b/cmd/commands/tx.go @@ -141,8 +141,9 @@ func sendTxCmd(cmd *cobra.Command, args []string) error { signBytes := tx.SignBytes(chainIDFlag) tx.Inputs[0].Signature = privKey.Sign(signBytes) + out := wire.BinaryBytes(tx) fmt.Println("Signed SendTx:") - fmt.Println(string(wire.JSONBytes(tx))) + fmt.Printf("%X\n", out) // broadcast the transaction to tendermint data, log, err := broadcastTx(tx) @@ -197,8 +198,9 @@ func AppTx(name string, data []byte) error { tx.Input.Signature = privKey.Sign(tx.SignBytes(chainIDFlag)) + out := wire.BinaryBytes(tx) fmt.Println("Signed AppTx:") - fmt.Println(string(wire.JSONBytes(tx))) + fmt.Printf("%X\n", out) data, log, err := broadcastTx(tx) if err != nil { diff --git a/cmd/counter/cmd.go b/cmd/counter/cmd.go index 451f42a48..e83430498 100644 --- a/cmd/counter/cmd.go +++ b/cmd/counter/cmd.go @@ -1,6 +1,7 @@ package main import ( + "encoding/json" "fmt" "github.com/spf13/cobra" @@ -45,7 +46,11 @@ func counterTxCmd(cmd *cobra.Command, args []string) error { Fee: countFee, } - fmt.Println("CounterTx:", string(wire.JSONBytes(counterTx))) + out, err := json.Marshal(counterTx) + if err != nil { + return err + } + fmt.Println("CounterTx:", string(out)) data := wire.BinaryBytes(counterTx) name := "counter" diff --git a/demo/clean.sh b/demo/clean.sh index e39f090ee..bffdefdb8 100644 --- a/demo/clean.sh +++ b/demo/clean.sh @@ -1,8 +1,8 @@ #! /bin/bash killall -9 basecoin tendermint -TMROOT=./data/chain1 tendermint unsafe_reset_all -TMROOT=./data/chain2 tendermint unsafe_reset_all +TMHOME=./data/chain1 tendermint unsafe_reset_all +TMHOME=./data/chain2 tendermint unsafe_reset_all rm ./*.log diff --git a/demo/start.sh b/demo/start.sh index 490806fd6..d42e5ae11 100644 --- a/demo/start.sh +++ b/demo/start.sh @@ -91,13 +91,13 @@ echo "" echo "... starting chains" echo "" # start the first node -TMROOT=$BCHOME1 tendermint node --p2p.skip_upnp --log_level=info &> $LOG_DIR/chain1_tendermint.log & +TMHOME=$BCHOME1 tendermint node --p2p.skip_upnp --log_level=info &> $LOG_DIR/chain1_tendermint.log & ifExit BCHOME=$BCHOME1 basecoin start --without-tendermint &> $LOG_DIR/chain1_basecoin.log & ifExit # start the second node -TMROOT=$BCHOME2 tendermint node --p2p.skip_upnp --log_level=info --p2p.laddr tcp://localhost:36656 --rpc_laddr tcp://localhost:36657 --proxy_app tcp://localhost:36658 &> $LOG_DIR/chain2_tendermint.log & +TMHOME=$BCHOME2 tendermint node --p2p.skip_upnp --log_level=info --p2p.laddr tcp://localhost:36656 --rpc.laddr tcp://localhost:36657 --proxy_app tcp://localhost:36658 &> $LOG_DIR/chain2_tendermint.log & ifExit BCHOME=$BCHOME2 basecoin start --address tcp://localhost:36658 --without-tendermint &> $LOG_DIR/chain2_basecoin.log & ifExit @@ -124,7 +124,7 @@ echo "... creating egress packet on chain1" echo "" # send coins from chain1 to an address on chain2 # TODO: dont hardcode the address -basecoin tx send --amount 10mycoin $CHAIN_FLAGS1 --to $CHAIN_ID2/053BA0F19616AFF975C8756A2CBFF04F408B4D47 +basecoin tx send --amount 10mycoin $CHAIN_FLAGS1 --to $CHAIN_ID2/053BA0F19616AFF975C8756A2CBFF04F408B4D47 ifExit # alternative way to create packets (for testing)