From 5acb2416dc133d06facd3b61bb44219e5f2a7625 Mon Sep 17 00:00:00 2001 From: Peter Oliha Date: Tue, 26 Sep 2017 11:38:18 +0100 Subject: [PATCH 1/4] load transaction id --- .../gateway/db/drivers/mysql/bindata.go | 25 ++++++++++++++++- .../mysql/migrations_gateway/02_init.sql | 5 ++++ .../gateway/db/drivers/postgres/bindata.go | 25 ++++++++++++++++- .../postgres/migrations_gateway/02_init.sql | 5 ++++ .../gateway/db/entities/received_payment.go | 13 +++++---- .../gateway/horizon/payment_response.go | 2 ++ .../gateway/listener/payment_listener.go | 28 ++++++++++--------- 7 files changed, 82 insertions(+), 21 deletions(-) create mode 100644 src/github.com/stellar/gateway/db/drivers/mysql/migrations_gateway/02_init.sql create mode 100644 src/github.com/stellar/gateway/db/drivers/postgres/migrations_gateway/02_init.sql diff --git a/src/github.com/stellar/gateway/db/drivers/mysql/bindata.go b/src/github.com/stellar/gateway/db/drivers/mysql/bindata.go index 0e40922..a71af9b 100644 --- a/src/github.com/stellar/gateway/db/drivers/mysql/bindata.go +++ b/src/github.com/stellar/gateway/db/drivers/mysql/bindata.go @@ -1,6 +1,7 @@ // Code generated by go-bindata. // sources: // migrations_gateway/01_init.sql +// migrations_gateway/02_init.sql // migrations_gateway/02_payment_id.sql // migrations_compliance/01_init.sql // DO NOT EDIT! @@ -90,6 +91,26 @@ func migrations_gateway01_initSql() (*asset, error) { return a, nil } +var _migrations_gateway02_initSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd2\xd5\x55\xd0\xce\xcd\x4c\x2f\x4a\x2c\x49\x55\x08\x2d\xe0\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x08\x4a\x4d\x4e\xcd\x2c\x4b\x4d\x09\x48\xac\xcc\x4d\xcd\x2b\x49\x50\x70\x74\x71\x51\x48\x28\x29\x4a\xcc\x2b\x4e\x4c\x2e\xc9\xcc\xcf\x8b\xcf\x4c\x49\x50\x08\x73\x0c\x72\xf6\x70\x0c\xd2\x30\x33\xd1\x54\x70\x71\x75\x73\x0c\xf5\x09\x51\x50\xf7\xd3\x77\x54\xb7\xe6\xe2\x42\x36\xdd\x25\xbf\x3c\x8f\x80\xf9\x2e\x41\xfe\x01\x18\x16\x58\x73\x01\x02\x00\x00\xff\xff\xa5\x9e\xfe\x52\xa4\x00\x00\x00") + +func migrations_gateway02_initSqlBytes() ([]byte, error) { + return bindataRead( + _migrations_gateway02_initSql, + "migrations_gateway/02_init.sql", + ) +} + +func migrations_gateway02_initSql() (*asset, error) { + bytes, err := migrations_gateway02_initSqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "migrations_gateway/02_init.sql", size: 164, mode: os.FileMode(420), modTime: time.Unix(1516147187, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var _migrations_gateway02_payment_idSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd2\xd5\x55\xd0\xce\xcd\x4c\x2f\x4a\x2c\x49\x55\x08\x2d\xe0\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x08\x4e\xcd\x2b\x09\x29\x4a\xcc\x2b\x4e\x4c\x2e\xc9\xcc\xcf\x4b\x50\x70\x74\x71\x51\x48\x28\x48\xac\xcc\x4d\xcd\x2b\x89\xcf\x4c\x49\x50\x08\x73\x0c\x72\xf6\x70\x0c\xd2\x30\x32\x35\xd5\x54\xf0\x0b\xf5\xf1\x51\x70\x71\x75\x73\x0c\xf5\x09\x81\x70\x1c\xdd\x40\xa6\x25\x64\xa6\x24\xe8\x80\xf5\x86\xfa\x79\x06\x86\xba\x2a\x68\x20\x9b\xa1\xa9\x60\xcd\xc5\x85\xec\x0a\x97\xfc\xf2\x3c\x02\xee\x70\x09\xf2\x0f\x40\x71\x88\x35\x17\x20\x00\x00\xff\xff\x8e\xff\xcd\xef\xc8\x00\x00\x00") func migrations_gateway02_payment_idSqlBytes() ([]byte, error) { @@ -105,7 +126,7 @@ func migrations_gateway02_payment_idSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "migrations_gateway/02_payment_id.sql", size: 200, mode: os.FileMode(420), modTime: time.Unix(1515503927, 0)} + info := bindataFileInfo{name: "migrations_gateway/02_payment_id.sql", size: 200, mode: os.FileMode(420), modTime: time.Unix(1516147186, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -183,6 +204,7 @@ func AssetNames() []string { // _bindata is a table, holding each asset generator, mapped to its name. var _bindata = map[string]func() (*asset, error){ "migrations_gateway/01_init.sql": migrations_gateway01_initSql, + "migrations_gateway/02_init.sql": migrations_gateway02_initSql, "migrations_gateway/02_payment_id.sql": migrations_gateway02_payment_idSql, "migrations_compliance/01_init.sql": migrations_compliance01_initSql, } @@ -232,6 +254,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ }}, "migrations_gateway": &bintree{nil, map[string]*bintree{ "01_init.sql": &bintree{migrations_gateway01_initSql, map[string]*bintree{}}, + "02_init.sql": &bintree{migrations_gateway02_initSql, map[string]*bintree{}}, "02_payment_id.sql": &bintree{migrations_gateway02_payment_idSql, map[string]*bintree{}}, }}, }} diff --git a/src/github.com/stellar/gateway/db/drivers/mysql/migrations_gateway/02_init.sql b/src/github.com/stellar/gateway/db/drivers/mysql/migrations_gateway/02_init.sql new file mode 100644 index 0000000..0773108 --- /dev/null +++ b/src/github.com/stellar/gateway/db/drivers/mysql/migrations_gateway/02_init.sql @@ -0,0 +1,5 @@ +-- +migrate Up +ALTER TABLE `ReceivedPayment` ADD `transaction_id` VARCHAR(64) DEFAULT 'N/A'; + +-- +migrate Down +ALTER TABLE `ReceivedPayment` DROP `transaction_id`; diff --git a/src/github.com/stellar/gateway/db/drivers/postgres/bindata.go b/src/github.com/stellar/gateway/db/drivers/postgres/bindata.go index 7a1d92a..ad4b2be 100644 --- a/src/github.com/stellar/gateway/db/drivers/postgres/bindata.go +++ b/src/github.com/stellar/gateway/db/drivers/postgres/bindata.go @@ -1,6 +1,7 @@ // Code generated by go-bindata. // sources: // migrations_gateway/01_init.sql +// migrations_gateway/02_init.sql // migrations_gateway/02_payment_id.sql // migrations_compliance/01_init.sql // DO NOT EDIT! @@ -90,6 +91,26 @@ func migrations_gateway01_initSql() (*asset, error) { return a, nil } +var _migrations_gateway02_initSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd2\xd5\x55\xd0\xce\xcd\x4c\x2f\x4a\x2c\x49\x55\x08\x2d\xe0\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x08\x4a\x4d\x4e\xcd\x2c\x4b\x4d\x09\x48\xac\xcc\x4d\xcd\x2b\x49\x50\x70\x74\x71\x51\x48\x28\x29\x4a\xcc\x2b\x4e\x4c\x2e\xc9\xcc\xcf\x8b\xcf\x4c\x49\x50\x08\x73\x0c\x72\xf6\x70\x0c\xd2\x30\x33\xd1\x54\x70\x71\x75\x73\x0c\xf5\x09\x51\x50\xf7\xd3\x77\x54\xb7\xe6\xe2\x42\x36\xdd\x25\xbf\x3c\x8f\x80\xf9\x2e\x41\xfe\x01\x18\x16\x58\x73\x01\x02\x00\x00\xff\xff\xa5\x9e\xfe\x52\xa4\x00\x00\x00") + +func migrations_gateway02_initSqlBytes() ([]byte, error) { + return bindataRead( + _migrations_gateway02_initSql, + "migrations_gateway/02_init.sql", + ) +} + +func migrations_gateway02_initSql() (*asset, error) { + bytes, err := migrations_gateway02_initSqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "migrations_gateway/02_init.sql", size: 164, mode: os.FileMode(420), modTime: time.Unix(1516147187, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var _migrations_gateway02_payment_idSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x84\xce\x31\x0b\xc2\x30\x10\x05\xe0\x3d\xbf\xe2\xc6\x16\xe9\x22\x74\xea\x74\x36\x11\x0b\x21\xd5\xf4\xe2\x5a\x82\x06\xc9\xd0\x6b\xad\x29\xe2\xbf\x17\x5c\xec\xa4\xe3\xe3\xc1\xf7\x5e\x51\xc0\x66\x88\xb7\xd9\xa7\x00\x6e\x12\xa8\x49\x59\x20\xdc\x69\x05\x5d\xe0\x44\xb3\xe7\x87\xbf\xa4\x38\x32\xa0\x94\x30\xf9\xd7\x10\x38\xf5\xf1\x0a\x67\xb4\xf5\x01\x6d\xb6\x2d\xcb\x1c\x8c\xd3\x1a\xa4\xda\xa3\xd3\xf4\x09\xd5\x5f\xaa\x6e\x4d\x47\x16\x1b\x43\x2b\xb5\x5f\x38\xde\x97\x00\xce\x34\x27\xa7\x20\xfb\x36\x79\x25\xc4\xfa\xac\x1c\x9f\xfc\x73\x43\xda\xf6\xb8\x92\x2b\xf1\x0e\x00\x00\xff\xff\xd0\xf6\xe1\x10\xeb\x00\x00\x00") func migrations_gateway02_payment_idSqlBytes() ([]byte, error) { @@ -105,7 +126,7 @@ func migrations_gateway02_payment_idSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "migrations_gateway/02_payment_id.sql", size: 235, mode: os.FileMode(420), modTime: time.Unix(1515597678, 0)} + info := bindataFileInfo{name: "migrations_gateway/02_payment_id.sql", size: 235, mode: os.FileMode(420), modTime: time.Unix(1516147186, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -183,6 +204,7 @@ func AssetNames() []string { // _bindata is a table, holding each asset generator, mapped to its name. var _bindata = map[string]func() (*asset, error){ "migrations_gateway/01_init.sql": migrations_gateway01_initSql, + "migrations_gateway/02_init.sql": migrations_gateway02_initSql, "migrations_gateway/02_payment_id.sql": migrations_gateway02_payment_idSql, "migrations_compliance/01_init.sql": migrations_compliance01_initSql, } @@ -232,6 +254,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ }}, "migrations_gateway": &bintree{nil, map[string]*bintree{ "01_init.sql": &bintree{migrations_gateway01_initSql, map[string]*bintree{}}, + "02_init.sql": &bintree{migrations_gateway02_initSql, map[string]*bintree{}}, "02_payment_id.sql": &bintree{migrations_gateway02_payment_idSql, map[string]*bintree{}}, }}, }} diff --git a/src/github.com/stellar/gateway/db/drivers/postgres/migrations_gateway/02_init.sql b/src/github.com/stellar/gateway/db/drivers/postgres/migrations_gateway/02_init.sql new file mode 100644 index 0000000..0773108 --- /dev/null +++ b/src/github.com/stellar/gateway/db/drivers/postgres/migrations_gateway/02_init.sql @@ -0,0 +1,5 @@ +-- +migrate Up +ALTER TABLE `ReceivedPayment` ADD `transaction_id` VARCHAR(64) DEFAULT 'N/A'; + +-- +migrate Down +ALTER TABLE `ReceivedPayment` DROP `transaction_id`; diff --git a/src/github.com/stellar/gateway/db/entities/received_payment.go b/src/github.com/stellar/gateway/db/entities/received_payment.go index 7e23e5d..98d3aa6 100644 --- a/src/github.com/stellar/gateway/db/entities/received_payment.go +++ b/src/github.com/stellar/gateway/db/entities/received_payment.go @@ -6,12 +6,13 @@ import ( // ReceivedPayment represents payment received by the gateway server type ReceivedPayment struct { - exists bool - ID *int64 `db:"id" json:"id"` - OperationID string `db:"operation_id" json:"operation_id"` - ProcessedAt time.Time `db:"processed_at" json:"processed_at"` - PagingToken string `db:"paging_token" json:"paging_token"` - Status string `db:"status" json:"status"` + exists bool + ID *int64 `db:"id" json:"id"` + OperationID string `db:"operation_id" json:"operation_id"` + ProcessedAt time.Time `db:"processed_at" json:"processed_at"` + PagingToken string `db:"paging_token" json:"paging_token"` + Status string `db:"status" json:"status"` + TransactionID string `db:"transaction_id" json:"transaction_id"` } // GetID returns ID of the entity diff --git a/src/github.com/stellar/gateway/horizon/payment_response.go b/src/github.com/stellar/gateway/horizon/payment_response.go index aaface0..74f683a 100644 --- a/src/github.com/stellar/gateway/horizon/payment_response.go +++ b/src/github.com/stellar/gateway/horizon/payment_response.go @@ -25,4 +25,6 @@ type PaymentResponse struct { Type string `json:"memo_type"` Value string `json:"memo"` } `json:"memo"` + + TransactionID string `json:"transaction_hash"` } diff --git a/src/github.com/stellar/gateway/listener/payment_listener.go b/src/github.com/stellar/gateway/listener/payment_listener.go index e26d129..390531c 100644 --- a/src/github.com/stellar/gateway/listener/payment_listener.go +++ b/src/github.com/stellar/gateway/listener/payment_listener.go @@ -179,10 +179,11 @@ func (pl *PaymentListener) onPayment(payment horizon.PaymentResponse) (err error } dbPayment := &entities.ReceivedPayment{ - OperationID: payment.ID, - ProcessedAt: pl.now(), - PagingToken: payment.PagingToken, - Status: "Processing...", + OperationID: payment.ID, + TransactionID: payment.TransactionID, + ProcessedAt: pl.now(), + PagingToken: payment.PagingToken, + Status: "Processing...", } err = pl.entityManager.Persist(dbPayment) @@ -288,15 +289,16 @@ func (pl *PaymentListener) process(payment horizon.PaymentResponse) error { resp, err := pl.postForm( pl.config.Callbacks.Receive, url.Values{ - "id": {payment.ID}, - "from": {payment.From}, - "route": {route}, - "amount": {payment.Amount}, - "asset_code": {payment.AssetCode}, - "asset_issuer": {payment.AssetIssuer}, - "memo_type": {payment.Memo.Type}, - "memo": {payment.Memo.Value}, - "data": {receiveResponse.Data}, + "id": {payment.ID}, + "from": {payment.From}, + "route": {route}, + "amount": {payment.Amount}, + "asset_code": {payment.AssetCode}, + "asset_issuer": {payment.AssetIssuer}, + "memo_type": {payment.Memo.Type}, + "memo": {payment.Memo.Value}, + "data": {receiveResponse.Data}, + "transaction_id": {payment.TransactionID}, }, ) if err != nil { From 4405bdf2ae0de76c8df50d0640d2776b7d651536 Mon Sep 17 00:00:00 2001 From: Peter Oliha Date: Thu, 28 Sep 2017 07:14:00 +0100 Subject: [PATCH 2/4] added tests and migration --- .../gateway/db/drivers/mysql/bindata.go | 34 ++++---- .../{02_init.sql => 02_transaction_id.sql} | 0 .../gateway/db/drivers/postgres/bindata.go | 34 ++++---- .../{02_init.sql => 02_transaction_id.sql} | 0 .../gateway/listener/payment_listener_test.go | 87 +++++++++++++++++++ 5 files changed, 121 insertions(+), 34 deletions(-) rename src/github.com/stellar/gateway/db/drivers/mysql/migrations_gateway/{02_init.sql => 02_transaction_id.sql} (100%) rename src/github.com/stellar/gateway/db/drivers/postgres/migrations_gateway/{02_init.sql => 02_transaction_id.sql} (100%) diff --git a/src/github.com/stellar/gateway/db/drivers/mysql/bindata.go b/src/github.com/stellar/gateway/db/drivers/mysql/bindata.go index a71af9b..f4babd8 100644 --- a/src/github.com/stellar/gateway/db/drivers/mysql/bindata.go +++ b/src/github.com/stellar/gateway/db/drivers/mysql/bindata.go @@ -1,8 +1,8 @@ // Code generated by go-bindata. // sources: // migrations_gateway/01_init.sql -// migrations_gateway/02_init.sql // migrations_gateway/02_payment_id.sql +// migrations_gateway/02_transaction_id.sql // migrations_compliance/01_init.sql // DO NOT EDIT! @@ -91,42 +91,42 @@ func migrations_gateway01_initSql() (*asset, error) { return a, nil } -var _migrations_gateway02_initSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd2\xd5\x55\xd0\xce\xcd\x4c\x2f\x4a\x2c\x49\x55\x08\x2d\xe0\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x08\x4a\x4d\x4e\xcd\x2c\x4b\x4d\x09\x48\xac\xcc\x4d\xcd\x2b\x49\x50\x70\x74\x71\x51\x48\x28\x29\x4a\xcc\x2b\x4e\x4c\x2e\xc9\xcc\xcf\x8b\xcf\x4c\x49\x50\x08\x73\x0c\x72\xf6\x70\x0c\xd2\x30\x33\xd1\x54\x70\x71\x75\x73\x0c\xf5\x09\x51\x50\xf7\xd3\x77\x54\xb7\xe6\xe2\x42\x36\xdd\x25\xbf\x3c\x8f\x80\xf9\x2e\x41\xfe\x01\x18\x16\x58\x73\x01\x02\x00\x00\xff\xff\xa5\x9e\xfe\x52\xa4\x00\x00\x00") +var _migrations_gateway02_payment_idSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd2\xd5\x55\xd0\xce\xcd\x4c\x2f\x4a\x2c\x49\x55\x08\x2d\xe0\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x08\x4e\xcd\x2b\x09\x29\x4a\xcc\x2b\x4e\x4c\x2e\xc9\xcc\xcf\x4b\x50\x70\x74\x71\x51\x48\x28\x48\xac\xcc\x4d\xcd\x2b\x89\xcf\x4c\x49\x50\x08\x73\x0c\x72\xf6\x70\x0c\xd2\x30\x32\x35\xd5\x54\xf0\x0b\xf5\xf1\x51\x70\x71\x75\x73\x0c\xf5\x09\x81\x70\x1c\xdd\x40\xa6\x25\x64\xa6\x24\xe8\x80\xf5\x86\xfa\x79\x06\x86\xba\x2a\x68\x20\x9b\xa1\xa9\x60\xcd\xc5\x85\xec\x0a\x97\xfc\xf2\x3c\x02\xee\x70\x09\xf2\x0f\x40\x71\x88\x35\x17\x20\x00\x00\xff\xff\x8e\xff\xcd\xef\xc8\x00\x00\x00") -func migrations_gateway02_initSqlBytes() ([]byte, error) { +func migrations_gateway02_payment_idSqlBytes() ([]byte, error) { return bindataRead( - _migrations_gateway02_initSql, - "migrations_gateway/02_init.sql", + _migrations_gateway02_payment_idSql, + "migrations_gateway/02_payment_id.sql", ) } -func migrations_gateway02_initSql() (*asset, error) { - bytes, err := migrations_gateway02_initSqlBytes() +func migrations_gateway02_payment_idSql() (*asset, error) { + bytes, err := migrations_gateway02_payment_idSqlBytes() if err != nil { return nil, err } - info := bindataFileInfo{name: "migrations_gateway/02_init.sql", size: 164, mode: os.FileMode(420), modTime: time.Unix(1516147187, 0)} + info := bindataFileInfo{name: "migrations_gateway/02_payment_id.sql", size: 200, mode: os.FileMode(420), modTime: time.Unix(1516147186, 0)} a := &asset{bytes: bytes, info: info} return a, nil } -var _migrations_gateway02_payment_idSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd2\xd5\x55\xd0\xce\xcd\x4c\x2f\x4a\x2c\x49\x55\x08\x2d\xe0\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x08\x4e\xcd\x2b\x09\x29\x4a\xcc\x2b\x4e\x4c\x2e\xc9\xcc\xcf\x4b\x50\x70\x74\x71\x51\x48\x28\x48\xac\xcc\x4d\xcd\x2b\x89\xcf\x4c\x49\x50\x08\x73\x0c\x72\xf6\x70\x0c\xd2\x30\x32\x35\xd5\x54\xf0\x0b\xf5\xf1\x51\x70\x71\x75\x73\x0c\xf5\x09\x81\x70\x1c\xdd\x40\xa6\x25\x64\xa6\x24\xe8\x80\xf5\x86\xfa\x79\x06\x86\xba\x2a\x68\x20\x9b\xa1\xa9\x60\xcd\xc5\x85\xec\x0a\x97\xfc\xf2\x3c\x02\xee\x70\x09\xf2\x0f\x40\x71\x88\x35\x17\x20\x00\x00\xff\xff\x8e\xff\xcd\xef\xc8\x00\x00\x00") +var _migrations_gateway02_transaction_idSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd2\xd5\x55\xd0\xce\xcd\x4c\x2f\x4a\x2c\x49\x55\x08\x2d\xe0\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x08\x4a\x4d\x4e\xcd\x2c\x4b\x4d\x09\x48\xac\xcc\x4d\xcd\x2b\x49\x50\x70\x74\x71\x51\x48\x28\x29\x4a\xcc\x2b\x4e\x4c\x2e\xc9\xcc\xcf\x8b\xcf\x4c\x49\x50\x08\x73\x0c\x72\xf6\x70\x0c\xd2\x30\x33\xd1\x54\x70\x71\x75\x73\x0c\xf5\x09\x51\x50\xf7\xd3\x77\x54\xb7\xe6\xe2\x42\x36\xdd\x25\xbf\x3c\x8f\x80\xf9\x2e\x41\xfe\x01\x18\x16\x58\x73\x01\x02\x00\x00\xff\xff\xa5\x9e\xfe\x52\xa4\x00\x00\x00") -func migrations_gateway02_payment_idSqlBytes() ([]byte, error) { +func migrations_gateway02_transaction_idSqlBytes() ([]byte, error) { return bindataRead( - _migrations_gateway02_payment_idSql, - "migrations_gateway/02_payment_id.sql", + _migrations_gateway02_transaction_idSql, + "migrations_gateway/02_transaction_id.sql", ) } -func migrations_gateway02_payment_idSql() (*asset, error) { - bytes, err := migrations_gateway02_payment_idSqlBytes() +func migrations_gateway02_transaction_idSql() (*asset, error) { + bytes, err := migrations_gateway02_transaction_idSqlBytes() if err != nil { return nil, err } - info := bindataFileInfo{name: "migrations_gateway/02_payment_id.sql", size: 200, mode: os.FileMode(420), modTime: time.Unix(1516147186, 0)} + info := bindataFileInfo{name: "migrations_gateway/02_transaction_id.sql", size: 164, mode: os.FileMode(420), modTime: time.Unix(1516147358, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -204,8 +204,8 @@ func AssetNames() []string { // _bindata is a table, holding each asset generator, mapped to its name. var _bindata = map[string]func() (*asset, error){ "migrations_gateway/01_init.sql": migrations_gateway01_initSql, - "migrations_gateway/02_init.sql": migrations_gateway02_initSql, "migrations_gateway/02_payment_id.sql": migrations_gateway02_payment_idSql, + "migrations_gateway/02_transaction_id.sql": migrations_gateway02_transaction_idSql, "migrations_compliance/01_init.sql": migrations_compliance01_initSql, } @@ -254,8 +254,8 @@ var _bintree = &bintree{nil, map[string]*bintree{ }}, "migrations_gateway": &bintree{nil, map[string]*bintree{ "01_init.sql": &bintree{migrations_gateway01_initSql, map[string]*bintree{}}, - "02_init.sql": &bintree{migrations_gateway02_initSql, map[string]*bintree{}}, "02_payment_id.sql": &bintree{migrations_gateway02_payment_idSql, map[string]*bintree{}}, + "02_transaction_id.sql": &bintree{migrations_gateway02_transaction_idSql, map[string]*bintree{}}, }}, }} diff --git a/src/github.com/stellar/gateway/db/drivers/mysql/migrations_gateway/02_init.sql b/src/github.com/stellar/gateway/db/drivers/mysql/migrations_gateway/02_transaction_id.sql similarity index 100% rename from src/github.com/stellar/gateway/db/drivers/mysql/migrations_gateway/02_init.sql rename to src/github.com/stellar/gateway/db/drivers/mysql/migrations_gateway/02_transaction_id.sql diff --git a/src/github.com/stellar/gateway/db/drivers/postgres/bindata.go b/src/github.com/stellar/gateway/db/drivers/postgres/bindata.go index ad4b2be..11488a9 100644 --- a/src/github.com/stellar/gateway/db/drivers/postgres/bindata.go +++ b/src/github.com/stellar/gateway/db/drivers/postgres/bindata.go @@ -1,8 +1,8 @@ // Code generated by go-bindata. // sources: // migrations_gateway/01_init.sql -// migrations_gateway/02_init.sql // migrations_gateway/02_payment_id.sql +// migrations_gateway/02_transaction_id.sql // migrations_compliance/01_init.sql // DO NOT EDIT! @@ -91,42 +91,42 @@ func migrations_gateway01_initSql() (*asset, error) { return a, nil } -var _migrations_gateway02_initSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd2\xd5\x55\xd0\xce\xcd\x4c\x2f\x4a\x2c\x49\x55\x08\x2d\xe0\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x08\x4a\x4d\x4e\xcd\x2c\x4b\x4d\x09\x48\xac\xcc\x4d\xcd\x2b\x49\x50\x70\x74\x71\x51\x48\x28\x29\x4a\xcc\x2b\x4e\x4c\x2e\xc9\xcc\xcf\x8b\xcf\x4c\x49\x50\x08\x73\x0c\x72\xf6\x70\x0c\xd2\x30\x33\xd1\x54\x70\x71\x75\x73\x0c\xf5\x09\x51\x50\xf7\xd3\x77\x54\xb7\xe6\xe2\x42\x36\xdd\x25\xbf\x3c\x8f\x80\xf9\x2e\x41\xfe\x01\x18\x16\x58\x73\x01\x02\x00\x00\xff\xff\xa5\x9e\xfe\x52\xa4\x00\x00\x00") +var _migrations_gateway02_payment_idSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x84\xce\x31\x0b\xc2\x30\x10\x05\xe0\x3d\xbf\xe2\xc6\x16\xe9\x22\x74\xea\x74\x36\x11\x0b\x21\xd5\xf4\xe2\x5a\x82\x06\xc9\xd0\x6b\xad\x29\xe2\xbf\x17\x5c\xec\xa4\xe3\xe3\xc1\xf7\x5e\x51\xc0\x66\x88\xb7\xd9\xa7\x00\x6e\x12\xa8\x49\x59\x20\xdc\x69\x05\x5d\xe0\x44\xb3\xe7\x87\xbf\xa4\x38\x32\xa0\x94\x30\xf9\xd7\x10\x38\xf5\xf1\x0a\x67\xb4\xf5\x01\x6d\xb6\x2d\xcb\x1c\x8c\xd3\x1a\xa4\xda\xa3\xd3\xf4\x09\xd5\x5f\xaa\x6e\x4d\x47\x16\x1b\x43\x2b\xb5\x5f\x38\xde\x97\x00\xce\x34\x27\xa7\x20\xfb\x36\x79\x25\xc4\xfa\xac\x1c\x9f\xfc\x73\x43\xda\xf6\xb8\x92\x2b\xf1\x0e\x00\x00\xff\xff\xd0\xf6\xe1\x10\xeb\x00\x00\x00") -func migrations_gateway02_initSqlBytes() ([]byte, error) { +func migrations_gateway02_payment_idSqlBytes() ([]byte, error) { return bindataRead( - _migrations_gateway02_initSql, - "migrations_gateway/02_init.sql", + _migrations_gateway02_payment_idSql, + "migrations_gateway/02_payment_id.sql", ) } -func migrations_gateway02_initSql() (*asset, error) { - bytes, err := migrations_gateway02_initSqlBytes() +func migrations_gateway02_payment_idSql() (*asset, error) { + bytes, err := migrations_gateway02_payment_idSqlBytes() if err != nil { return nil, err } - info := bindataFileInfo{name: "migrations_gateway/02_init.sql", size: 164, mode: os.FileMode(420), modTime: time.Unix(1516147187, 0)} + info := bindataFileInfo{name: "migrations_gateway/02_payment_id.sql", size: 235, mode: os.FileMode(420), modTime: time.Unix(1516147186, 0)} a := &asset{bytes: bytes, info: info} return a, nil } -var _migrations_gateway02_payment_idSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x84\xce\x31\x0b\xc2\x30\x10\x05\xe0\x3d\xbf\xe2\xc6\x16\xe9\x22\x74\xea\x74\x36\x11\x0b\x21\xd5\xf4\xe2\x5a\x82\x06\xc9\xd0\x6b\xad\x29\xe2\xbf\x17\x5c\xec\xa4\xe3\xe3\xc1\xf7\x5e\x51\xc0\x66\x88\xb7\xd9\xa7\x00\x6e\x12\xa8\x49\x59\x20\xdc\x69\x05\x5d\xe0\x44\xb3\xe7\x87\xbf\xa4\x38\x32\xa0\x94\x30\xf9\xd7\x10\x38\xf5\xf1\x0a\x67\xb4\xf5\x01\x6d\xb6\x2d\xcb\x1c\x8c\xd3\x1a\xa4\xda\xa3\xd3\xf4\x09\xd5\x5f\xaa\x6e\x4d\x47\x16\x1b\x43\x2b\xb5\x5f\x38\xde\x97\x00\xce\x34\x27\xa7\x20\xfb\x36\x79\x25\xc4\xfa\xac\x1c\x9f\xfc\x73\x43\xda\xf6\xb8\x92\x2b\xf1\x0e\x00\x00\xff\xff\xd0\xf6\xe1\x10\xeb\x00\x00\x00") +var _migrations_gateway02_transaction_idSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd2\xd5\x55\xd0\xce\xcd\x4c\x2f\x4a\x2c\x49\x55\x08\x2d\xe0\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x08\x4a\x4d\x4e\xcd\x2c\x4b\x4d\x09\x48\xac\xcc\x4d\xcd\x2b\x49\x50\x70\x74\x71\x51\x48\x28\x29\x4a\xcc\x2b\x4e\x4c\x2e\xc9\xcc\xcf\x8b\xcf\x4c\x49\x50\x08\x73\x0c\x72\xf6\x70\x0c\xd2\x30\x33\xd1\x54\x70\x71\x75\x73\x0c\xf5\x09\x51\x50\xf7\xd3\x77\x54\xb7\xe6\xe2\x42\x36\xdd\x25\xbf\x3c\x8f\x80\xf9\x2e\x41\xfe\x01\x18\x16\x58\x73\x01\x02\x00\x00\xff\xff\xa5\x9e\xfe\x52\xa4\x00\x00\x00") -func migrations_gateway02_payment_idSqlBytes() ([]byte, error) { +func migrations_gateway02_transaction_idSqlBytes() ([]byte, error) { return bindataRead( - _migrations_gateway02_payment_idSql, - "migrations_gateway/02_payment_id.sql", + _migrations_gateway02_transaction_idSql, + "migrations_gateway/02_transaction_id.sql", ) } -func migrations_gateway02_payment_idSql() (*asset, error) { - bytes, err := migrations_gateway02_payment_idSqlBytes() +func migrations_gateway02_transaction_idSql() (*asset, error) { + bytes, err := migrations_gateway02_transaction_idSqlBytes() if err != nil { return nil, err } - info := bindataFileInfo{name: "migrations_gateway/02_payment_id.sql", size: 235, mode: os.FileMode(420), modTime: time.Unix(1516147186, 0)} + info := bindataFileInfo{name: "migrations_gateway/02_transaction_id.sql", size: 164, mode: os.FileMode(420), modTime: time.Unix(1516147358, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -204,8 +204,8 @@ func AssetNames() []string { // _bindata is a table, holding each asset generator, mapped to its name. var _bindata = map[string]func() (*asset, error){ "migrations_gateway/01_init.sql": migrations_gateway01_initSql, - "migrations_gateway/02_init.sql": migrations_gateway02_initSql, "migrations_gateway/02_payment_id.sql": migrations_gateway02_payment_idSql, + "migrations_gateway/02_transaction_id.sql": migrations_gateway02_transaction_idSql, "migrations_compliance/01_init.sql": migrations_compliance01_initSql, } @@ -254,8 +254,8 @@ var _bintree = &bintree{nil, map[string]*bintree{ }}, "migrations_gateway": &bintree{nil, map[string]*bintree{ "01_init.sql": &bintree{migrations_gateway01_initSql, map[string]*bintree{}}, - "02_init.sql": &bintree{migrations_gateway02_initSql, map[string]*bintree{}}, "02_payment_id.sql": &bintree{migrations_gateway02_payment_idSql, map[string]*bintree{}}, + "02_transaction_id.sql": &bintree{migrations_gateway02_transaction_idSql, map[string]*bintree{}}, }}, }} diff --git a/src/github.com/stellar/gateway/db/drivers/postgres/migrations_gateway/02_init.sql b/src/github.com/stellar/gateway/db/drivers/postgres/migrations_gateway/02_transaction_id.sql similarity index 100% rename from src/github.com/stellar/gateway/db/drivers/postgres/migrations_gateway/02_init.sql rename to src/github.com/stellar/gateway/db/drivers/postgres/migrations_gateway/02_transaction_id.sql diff --git a/src/github.com/stellar/gateway/listener/payment_listener_test.go b/src/github.com/stellar/gateway/listener/payment_listener_test.go index 6af1294..334883a 100644 --- a/src/github.com/stellar/gateway/listener/payment_listener_test.go +++ b/src/github.com/stellar/gateway/listener/payment_listener_test.go @@ -34,6 +34,7 @@ func ensurePaymentStatus(t *testing.T, operation horizon.PaymentResponse, status assert.Equal(t, mocks.PredefinedTime, payment.ProcessedAt) assert.Equal(t, operation.PagingToken, payment.PagingToken) assert.Equal(t, status, payment.Status) + assert.Equal(t, operation.TransactionID, payment.TransactionID) } } @@ -506,6 +507,92 @@ func TestPaymentListener(t *testing.T) { mockEntityManager.AssertExpectations(t) }) }) + + Convey("When transaction id is not returned (current horizon release)", func() { + operation.Type = "payment" + operation.To = "GATKP6ZQM5CSLECPMTAC5226PE367QALCPM6AFHTSULPPZMT62OOPMQB" + operation.AssetCode = "USD" + operation.AssetIssuer = "GD4I7AFSLZGTDL34TQLWJOM2NHLIIOEKD5RHHZUW54HERBLSIRKUOXRR" + operation.Memo.Type = "text" + operation.Memo.Value = "testing" + + mockRepository.On("GetReceivedPaymentByOperationID", int64(1)).Return(nil, nil).Once() + mockHorizon.On("LoadMemo", &operation).Return(nil).Once() + + mockEntityManager.On("Persist", mock.AnythingOfType("*entities.ReceivedPayment")). + Run(ensurePaymentStatus(t, operation, "Processing...")).Return(nil).Once() + + mockEntityManager.On("Persist", mock.AnythingOfType("*entities.ReceivedPayment")). + Run(ensurePaymentStatus(t, operation, "Error response from receive callback")).Return(nil).Once() + + mockHTTPClient.On( + "Do", + mock.MatchedBy(func(req *http.Request) bool { + return req.URL.String() == "http://receive_callback" + }), + ).Return( + net.BuildHTTPResponse(503, "ok"), + nil, + ).Once() + + Convey("it should save the status", func() { + err := paymentListener.onPayment(operation) + assert.NoError(t, err) + mockHorizon.AssertExpectations(t) + mockEntityManager.AssertExpectations(t) + mockRepository.AssertExpectations(t) + }) + }) + + Convey("When transaction id is not returned by horizon", func() { + operation.Type = "payment" + operation.From = "GBL27BKG2JSDU6KQ5YJKCDWTVIU24VTG4PLB63SF4K2DBZS5XZMWRPVU" + operation.To = "GATKP6ZQM5CSLECPMTAC5226PE367QALCPM6AFHTSULPPZMT62OOPMQB" + operation.Amount = "100" + operation.AssetCode = "USD" + operation.AssetIssuer = "GD4I7AFSLZGTDL34TQLWJOM2NHLIIOEKD5RHHZUW54HERBLSIRKUOXRR" + operation.Memo.Type = "text" + operation.Memo.Value = "testing" + operation.TransactionID = "18ce6c3320d35e683cb653a3e812ce43e8f5c24ab0d0e87668d5591c679c9755" + + mockRepository.On("GetReceivedPaymentByOperationID", int64(1)).Return(nil, nil).Once() + mockHorizon.On("LoadMemo", &operation).Return(nil).Once() + + mockEntityManager.On("Persist", mock.AnythingOfType("*entities.ReceivedPayment")). + Run(ensurePaymentStatus(t, operation, "Processing...")).Return(nil).Once() + + mockEntityManager.On("Persist", mock.AnythingOfType("*entities.ReceivedPayment")). + Run(ensurePaymentStatus(t, operation, "Success")).Return(nil).Once() + + mockHTTPClient.On( + "Do", + mock.MatchedBy(func(req *http.Request) bool { + return req.URL.String() == "http://receive_callback" + }), + ).Return( + net.BuildHTTPResponse(200, "ok"), + nil, + ).Run(func(args mock.Arguments) { + req := args.Get(0).(*http.Request) + + assert.Equal(t, operation.From, req.PostFormValue("from")) + assert.Equal(t, operation.Amount, req.PostFormValue("amount")) + assert.Equal(t, operation.AssetCode, req.PostFormValue("asset_code")) + assert.Equal(t, operation.AssetIssuer, req.PostFormValue("asset_issuer")) + assert.Equal(t, operation.Memo.Type, req.PostFormValue("memo_type")) + assert.Equal(t, operation.Memo.Value, req.PostFormValue("memo")) + assert.Equal(t, operation.TransactionID, req.PostFormValue("transaction_id")) + }).Once() + + Convey("it should save the status", func() { + err := paymentListener.onPayment(operation) + assert.Nil(t, err) + mockHorizon.AssertExpectations(t) + mockEntityManager.AssertExpectations(t) + mockRepository.AssertExpectations(t) + }) + }) + }) } From 062732bc58d1b0ef7bce0bee0a59e8ea850482a0 Mon Sep 17 00:00:00 2001 From: Bartek Nowotarski Date: Wed, 17 Jan 2018 00:06:25 +0000 Subject: [PATCH 3/4] Update migrations --- .../gateway/db/drivers/mysql/bindata.go | 20 +++++++++---------- ...ansaction_id.sql => 03_transaction_id.sql} | 0 .../gateway/db/drivers/postgres/bindata.go | 20 +++++++++---------- .../migrations_gateway/02_transaction_id.sql | 5 ----- .../migrations_gateway/03_transaction_id.sql | 5 +++++ 5 files changed, 25 insertions(+), 25 deletions(-) rename src/github.com/stellar/gateway/db/drivers/mysql/migrations_gateway/{02_transaction_id.sql => 03_transaction_id.sql} (100%) delete mode 100644 src/github.com/stellar/gateway/db/drivers/postgres/migrations_gateway/02_transaction_id.sql create mode 100644 src/github.com/stellar/gateway/db/drivers/postgres/migrations_gateway/03_transaction_id.sql diff --git a/src/github.com/stellar/gateway/db/drivers/mysql/bindata.go b/src/github.com/stellar/gateway/db/drivers/mysql/bindata.go index f4babd8..fe283b7 100644 --- a/src/github.com/stellar/gateway/db/drivers/mysql/bindata.go +++ b/src/github.com/stellar/gateway/db/drivers/mysql/bindata.go @@ -2,7 +2,7 @@ // sources: // migrations_gateway/01_init.sql // migrations_gateway/02_payment_id.sql -// migrations_gateway/02_transaction_id.sql +// migrations_gateway/03_transaction_id.sql // migrations_compliance/01_init.sql // DO NOT EDIT! @@ -111,22 +111,22 @@ func migrations_gateway02_payment_idSql() (*asset, error) { return a, nil } -var _migrations_gateway02_transaction_idSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd2\xd5\x55\xd0\xce\xcd\x4c\x2f\x4a\x2c\x49\x55\x08\x2d\xe0\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x08\x4a\x4d\x4e\xcd\x2c\x4b\x4d\x09\x48\xac\xcc\x4d\xcd\x2b\x49\x50\x70\x74\x71\x51\x48\x28\x29\x4a\xcc\x2b\x4e\x4c\x2e\xc9\xcc\xcf\x8b\xcf\x4c\x49\x50\x08\x73\x0c\x72\xf6\x70\x0c\xd2\x30\x33\xd1\x54\x70\x71\x75\x73\x0c\xf5\x09\x51\x50\xf7\xd3\x77\x54\xb7\xe6\xe2\x42\x36\xdd\x25\xbf\x3c\x8f\x80\xf9\x2e\x41\xfe\x01\x18\x16\x58\x73\x01\x02\x00\x00\xff\xff\xa5\x9e\xfe\x52\xa4\x00\x00\x00") +var _migrations_gateway03_transaction_idSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd2\xd5\x55\xd0\xce\xcd\x4c\x2f\x4a\x2c\x49\x55\x08\x2d\xe0\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x08\x4a\x4d\x4e\xcd\x2c\x4b\x4d\x09\x48\xac\xcc\x4d\xcd\x2b\x49\x50\x70\x74\x71\x51\x48\x28\x29\x4a\xcc\x2b\x4e\x4c\x2e\xc9\xcc\xcf\x8b\xcf\x4c\x49\x50\x08\x73\x0c\x72\xf6\x70\x0c\xd2\x30\x33\xd1\x54\x70\x71\x75\x73\x0c\xf5\x09\x51\x50\xf7\xd3\x77\x54\xb7\xe6\xe2\x42\x36\xdd\x25\xbf\x3c\x8f\x80\xf9\x2e\x41\xfe\x01\x18\x16\x58\x73\x01\x02\x00\x00\xff\xff\xa5\x9e\xfe\x52\xa4\x00\x00\x00") -func migrations_gateway02_transaction_idSqlBytes() ([]byte, error) { +func migrations_gateway03_transaction_idSqlBytes() ([]byte, error) { return bindataRead( - _migrations_gateway02_transaction_idSql, - "migrations_gateway/02_transaction_id.sql", + _migrations_gateway03_transaction_idSql, + "migrations_gateway/03_transaction_id.sql", ) } -func migrations_gateway02_transaction_idSql() (*asset, error) { - bytes, err := migrations_gateway02_transaction_idSqlBytes() +func migrations_gateway03_transaction_idSql() (*asset, error) { + bytes, err := migrations_gateway03_transaction_idSqlBytes() if err != nil { return nil, err } - info := bindataFileInfo{name: "migrations_gateway/02_transaction_id.sql", size: 164, mode: os.FileMode(420), modTime: time.Unix(1516147358, 0)} + info := bindataFileInfo{name: "migrations_gateway/03_transaction_id.sql", size: 164, mode: os.FileMode(420), modTime: time.Unix(1516147358, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -205,7 +205,7 @@ func AssetNames() []string { var _bindata = map[string]func() (*asset, error){ "migrations_gateway/01_init.sql": migrations_gateway01_initSql, "migrations_gateway/02_payment_id.sql": migrations_gateway02_payment_idSql, - "migrations_gateway/02_transaction_id.sql": migrations_gateway02_transaction_idSql, + "migrations_gateway/03_transaction_id.sql": migrations_gateway03_transaction_idSql, "migrations_compliance/01_init.sql": migrations_compliance01_initSql, } @@ -255,7 +255,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "migrations_gateway": &bintree{nil, map[string]*bintree{ "01_init.sql": &bintree{migrations_gateway01_initSql, map[string]*bintree{}}, "02_payment_id.sql": &bintree{migrations_gateway02_payment_idSql, map[string]*bintree{}}, - "02_transaction_id.sql": &bintree{migrations_gateway02_transaction_idSql, map[string]*bintree{}}, + "03_transaction_id.sql": &bintree{migrations_gateway03_transaction_idSql, map[string]*bintree{}}, }}, }} diff --git a/src/github.com/stellar/gateway/db/drivers/mysql/migrations_gateway/02_transaction_id.sql b/src/github.com/stellar/gateway/db/drivers/mysql/migrations_gateway/03_transaction_id.sql similarity index 100% rename from src/github.com/stellar/gateway/db/drivers/mysql/migrations_gateway/02_transaction_id.sql rename to src/github.com/stellar/gateway/db/drivers/mysql/migrations_gateway/03_transaction_id.sql diff --git a/src/github.com/stellar/gateway/db/drivers/postgres/bindata.go b/src/github.com/stellar/gateway/db/drivers/postgres/bindata.go index 11488a9..1804fd0 100644 --- a/src/github.com/stellar/gateway/db/drivers/postgres/bindata.go +++ b/src/github.com/stellar/gateway/db/drivers/postgres/bindata.go @@ -2,7 +2,7 @@ // sources: // migrations_gateway/01_init.sql // migrations_gateway/02_payment_id.sql -// migrations_gateway/02_transaction_id.sql +// migrations_gateway/03_transaction_id.sql // migrations_compliance/01_init.sql // DO NOT EDIT! @@ -111,22 +111,22 @@ func migrations_gateway02_payment_idSql() (*asset, error) { return a, nil } -var _migrations_gateway02_transaction_idSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd2\xd5\x55\xd0\xce\xcd\x4c\x2f\x4a\x2c\x49\x55\x08\x2d\xe0\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x08\x4a\x4d\x4e\xcd\x2c\x4b\x4d\x09\x48\xac\xcc\x4d\xcd\x2b\x49\x50\x70\x74\x71\x51\x48\x28\x29\x4a\xcc\x2b\x4e\x4c\x2e\xc9\xcc\xcf\x8b\xcf\x4c\x49\x50\x08\x73\x0c\x72\xf6\x70\x0c\xd2\x30\x33\xd1\x54\x70\x71\x75\x73\x0c\xf5\x09\x51\x50\xf7\xd3\x77\x54\xb7\xe6\xe2\x42\x36\xdd\x25\xbf\x3c\x8f\x80\xf9\x2e\x41\xfe\x01\x18\x16\x58\x73\x01\x02\x00\x00\xff\xff\xa5\x9e\xfe\x52\xa4\x00\x00\x00") +var _migrations_gateway03_transaction_idSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd2\xd5\x55\xd0\xce\xcd\x4c\x2f\x4a\x2c\x49\x55\x08\x2d\xe0\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x08\x4a\x4d\x4e\xcd\x2c\x4b\x4d\x09\x48\xac\xcc\x4d\xcd\x2b\x51\x70\x74\x71\x51\x28\x29\x4a\xcc\x2b\x4e\x4c\x2e\xc9\xcc\xcf\x8b\xcf\x4c\x51\x08\x73\x0c\x72\xf6\x70\x0c\xd2\x30\x33\xd1\x54\x70\x71\x75\x73\x0c\xf5\x09\x51\x50\xf7\xd3\x77\x54\xb7\xe6\xe2\x42\x36\xd9\x25\xbf\x3c\x0f\xaf\xd9\x2e\x41\xfe\x01\x68\x86\x5b\x73\x01\x02\x00\x00\xff\xff\x95\xd0\x87\x98\x9c\x00\x00\x00") -func migrations_gateway02_transaction_idSqlBytes() ([]byte, error) { +func migrations_gateway03_transaction_idSqlBytes() ([]byte, error) { return bindataRead( - _migrations_gateway02_transaction_idSql, - "migrations_gateway/02_transaction_id.sql", + _migrations_gateway03_transaction_idSql, + "migrations_gateway/03_transaction_id.sql", ) } -func migrations_gateway02_transaction_idSql() (*asset, error) { - bytes, err := migrations_gateway02_transaction_idSqlBytes() +func migrations_gateway03_transaction_idSql() (*asset, error) { + bytes, err := migrations_gateway03_transaction_idSqlBytes() if err != nil { return nil, err } - info := bindataFileInfo{name: "migrations_gateway/02_transaction_id.sql", size: 164, mode: os.FileMode(420), modTime: time.Unix(1516147358, 0)} + info := bindataFileInfo{name: "migrations_gateway/03_transaction_id.sql", size: 156, mode: os.FileMode(420), modTime: time.Unix(1516147543, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -205,7 +205,7 @@ func AssetNames() []string { var _bindata = map[string]func() (*asset, error){ "migrations_gateway/01_init.sql": migrations_gateway01_initSql, "migrations_gateway/02_payment_id.sql": migrations_gateway02_payment_idSql, - "migrations_gateway/02_transaction_id.sql": migrations_gateway02_transaction_idSql, + "migrations_gateway/03_transaction_id.sql": migrations_gateway03_transaction_idSql, "migrations_compliance/01_init.sql": migrations_compliance01_initSql, } @@ -255,7 +255,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "migrations_gateway": &bintree{nil, map[string]*bintree{ "01_init.sql": &bintree{migrations_gateway01_initSql, map[string]*bintree{}}, "02_payment_id.sql": &bintree{migrations_gateway02_payment_idSql, map[string]*bintree{}}, - "02_transaction_id.sql": &bintree{migrations_gateway02_transaction_idSql, map[string]*bintree{}}, + "03_transaction_id.sql": &bintree{migrations_gateway03_transaction_idSql, map[string]*bintree{}}, }}, }} diff --git a/src/github.com/stellar/gateway/db/drivers/postgres/migrations_gateway/02_transaction_id.sql b/src/github.com/stellar/gateway/db/drivers/postgres/migrations_gateway/02_transaction_id.sql deleted file mode 100644 index 0773108..0000000 --- a/src/github.com/stellar/gateway/db/drivers/postgres/migrations_gateway/02_transaction_id.sql +++ /dev/null @@ -1,5 +0,0 @@ --- +migrate Up -ALTER TABLE `ReceivedPayment` ADD `transaction_id` VARCHAR(64) DEFAULT 'N/A'; - --- +migrate Down -ALTER TABLE `ReceivedPayment` DROP `transaction_id`; diff --git a/src/github.com/stellar/gateway/db/drivers/postgres/migrations_gateway/03_transaction_id.sql b/src/github.com/stellar/gateway/db/drivers/postgres/migrations_gateway/03_transaction_id.sql new file mode 100644 index 0000000..d2dba34 --- /dev/null +++ b/src/github.com/stellar/gateway/db/drivers/postgres/migrations_gateway/03_transaction_id.sql @@ -0,0 +1,5 @@ +-- +migrate Up +ALTER TABLE ReceivedPayment ADD transaction_id VARCHAR(64) DEFAULT 'N/A'; + +-- +migrate Down +ALTER TABLE ReceivedPayment DROP transaction_id; From 7f4c9f40bcb230a2a6946ea7a658d1595e2b8a1f Mon Sep 17 00:00:00 2001 From: Peter Oliha Date: Wed, 17 Jan 2018 15:28:24 +0100 Subject: [PATCH 4/4] updated bridge server readme --- readme_bridge.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme_bridge.md b/readme_bridge.md index 0c87db8..c3a998c 100644 --- a/readme_bridge.md +++ b/readme_bridge.md @@ -411,6 +411,7 @@ name | description `memo_type` | Type of the memo attached to the transaction. This field will be empty when no memo was attached. `memo` | Value of the memo attached. This field will be empty when no memo was attached. `data` | Value of the [AuthData](https://www.stellar.org/developers/learn/integration-guides/compliance-protocol.html). This field will be empty when compliance server is not connected. +`transaction_id` | The transaction hash of the operation (ex. `c7597583ad4f7caef15ad19b0f84017466b69790ee91bcacbbf98b51c93b17bf`) #### Response