From 6dc3aedc25ac88c98d80e8aa01255bf3641137ac Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Fri, 30 Jun 2017 18:30:02 +0200 Subject: [PATCH] Fix up the tx parsing for chain ids in address --- types/tx.go | 6 +++--- types/tx_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/types/tx.go b/types/tx.go index a54d7caf0a..4d1455d7ab 100644 --- a/types/tx.go +++ b/types/tx.go @@ -123,12 +123,12 @@ func (txOut TxOutput) ChainAndAddress() ([]byte, []byte, abci.Result) { var chainPrefix []byte address := txOut.Address if len(address) > 20 { - spl := bytes.Split(address, []byte("/")) - if len(spl) < 2 { + spl := bytes.SplitN(address, []byte("/"), 2) + if len(spl) != 2 { return nil, nil, abci.ErrBaseInvalidOutput.AppendLog("Invalid address format") } chainPrefix = spl[0] - address = bytes.Join(spl[1:], nil) + address = spl[1] } if len(address) != 20 { diff --git a/types/tx_test.go b/types/tx_test.go index 35f359c1c9..73ccbf54da 100644 --- a/types/tx_test.go +++ b/types/tx_test.go @@ -133,7 +133,7 @@ func TestSendTxIBC(t *testing.T) { require.Nil(err) short, err := hex.DecodeString("1960CA7E170862837AA8F22F947194F41F610B") require.Nil(err) - long, err := hex.DecodeString("1960CA7E170862837AA8F22A947194F41F6186120B") + long, err := hex.DecodeString("1960CA7E170862837AA8F22F947194F41F6186120B") require.Nil(err) slash, err := hex.DecodeString("F40ECECEA86F29D0FDF2980EF72F1708687BD4BF") require.Nil(err)