@@ -17,8 +17,11 @@ import (
1717 "github.com/pkg/errors"
1818)
1919
20- const XRPCurrency = "XRP"
21- const XRPTimeToUTD = uint64 (946684800 )
20+ const (
21+ XRPCurrency = "XRP"
22+ XRPTimeToUTD = uint64 (946684800 )
23+ paymentType = "Payment"
24+ )
2225
2326type Config struct {
2427 Url string `toml:"url"`
@@ -250,8 +253,12 @@ func (c XRPClient) GetBlockResult(ctx context.Context, blockNum uint64,
250253 Response : string (respStruct .Result .Ledger .Transactions [i ]),
251254 }
252255
253- transactions [i ].PaymentReference = paymentReference (tx )
254- transactions [i ].IsNativePayment = isNativePayment (tx )
256+ // case-insensitive check for transaction type
257+ if strings .EqualFold (tx .TransactionType , paymentType ) {
258+ transactions [i ].PaymentReference = paymentReference (tx )
259+ transactions [i ].IsNativePayment = isNativePayment (tx )
260+ }
261+
255262 transactions [i ].SourceAddressesRoot , err = sourceAddressesRoot (tx )
256263 if err != nil {
257264 return nil , err
@@ -276,23 +283,18 @@ func paymentReference(tx XRPTransaction) string {
276283}
277284
278285func isNativePayment (tx XRPTransaction ) bool {
279- if tx .TransactionType == "Payment" {
280- var amountStr string
281- err := json .Unmarshal (tx .Amount , & amountStr )
286+ var amountStr string
287+ err := json .Unmarshal (tx .Amount , & amountStr )
288+ if err == nil {
289+ _ , err = strconv .Atoi (amountStr )
282290 if err == nil {
283- _ , err = strconv .Atoi (amountStr )
284- if err == nil {
285- return true
286- }
287- }
288- var amountStruct XRPAmount
289- err = json .Unmarshal (tx .Amount , & amountStruct )
290- if err == nil && amountStruct .Currency == XRPCurrency {
291291 return true
292292 }
293293 }
294+ var amountStruct XRPAmount
295+ err = json .Unmarshal (tx .Amount , & amountStruct )
294296
295- return false
297+ return err == nil && amountStruct . Currency == XRPCurrency
296298}
297299
298300func sourceAddressesRoot (tx XRPTransaction ) (string , error ) {
0 commit comments