diff --git a/src/github.com/stellar/horizon/db2/core/transaction.go b/src/github.com/stellar/horizon/db2/core/transaction.go index 69719085..5d0450eb 100644 --- a/src/github.com/stellar/horizon/db2/core/transaction.go +++ b/src/github.com/stellar/horizon/db2/core/transaction.go @@ -4,6 +4,8 @@ import ( "encoding/base64" "fmt" + "strings" + sq "github.com/Masterminds/squirrel" "github.com/guregu/null" "github.com/stellar/go/strkey" @@ -52,7 +54,9 @@ func (tx *Transaction) Memo() null.String { case xdr.MemoTypeMemoNone: value, valid = "", false case xdr.MemoTypeMemoText: - value, valid = utf8.Scrub(tx.Envelope.Tx.Memo.MustText()), true + scrubbed := utf8.Scrub(tx.Envelope.Tx.Memo.MustText()) + notnull := strings.Join(strings.Split(scrubbed, "\x00"), "") + value, valid = notnull, true case xdr.MemoTypeMemoId: value, valid = fmt.Sprintf("%d", tx.Envelope.Tx.Memo.MustId()), true case xdr.MemoTypeMemoHash: diff --git a/src/github.com/stellar/horizon/db2/core/transaction_test.go b/src/github.com/stellar/horizon/db2/core/transaction_test.go index cc7e6e09..01633f49 100644 --- a/src/github.com/stellar/horizon/db2/core/transaction_test.go +++ b/src/github.com/stellar/horizon/db2/core/transaction_test.go @@ -3,6 +3,7 @@ package core import ( "testing" + "github.com/stellar/go/xdr" "github.com/stellar/horizon/test" ) @@ -27,3 +28,14 @@ func TestTransactionsQueries(t *testing.T) { tt.Assert.Equal(int32(3), tx.LedgerSequence) } } + +func TestMemo(t *testing.T) { + tt := test.Start(t).Scenario("base") + defer tt.Finish() + + var tx Transaction + + xdr.SafeUnmarshalBase64("AAAAAMvoFDdcyQrJAcBmRdyEnW6047pvlk4MS/4r0n/1WH8VAAAAZAACnMAAAAACAAAAAAAAAAEAAAARADEuMC4xb3dlcnJpZGUgbWUAAAAAAAABAAAAAQAAAACJzogbLxrrmN7N5JVQceSxl8jkED26RGzbyyRIpwTh6wAAAAoAAAAWaSBzaG91bGQgYmUgb3dlcnJpZGRlbgAAAAAAAQAAABVpIHNob3VsZCBiZSBvd2VycmlkZW4AAAAAAAAAAAAAAacE4esAAABA0GuCIEmKyQ2DRqt5+BOIqjVlHisjY6rK1IcOtzjIKCDgSAoiv5yhYe09PohBH91TXvAQ/LZJj5hVMihfMjtgCw==", &tx.Envelope) + + tt.Assert.Equal("1.0.1owerride me", tx.Memo().String) +} diff --git a/src/github.com/stellar/horizon/ingest/session.go b/src/github.com/stellar/horizon/ingest/session.go index cc913a2d..5e15b764 100644 --- a/src/github.com/stellar/horizon/ingest/session.go +++ b/src/github.com/stellar/horizon/ingest/session.go @@ -465,12 +465,14 @@ func (is *Session) ingestTransaction() { if !is.Cursor.Transaction().IsSuccessful() { return } - - is.Ingestion.Transaction( + is.Err = is.Ingestion.Transaction( is.Cursor.TransactionID(), is.Cursor.Transaction(), is.Cursor.TransactionFee(), ) + if is.Err != nil { + return + } for is.Cursor.NextOp() { is.ingestOperation()