@@ -20,6 +20,7 @@ import (
2020const (
2121 xrpCurrency = "XRP"
2222 XRPTimeToUTD = uint64 (946684800 )
23+ paymentType = "Payment"
2324)
2425
2526type Config struct {
@@ -242,8 +243,12 @@ func (c xrpClient) GetBlockResult(ctx context.Context, blockNum uint64,
242243 Response : string (respStruct .Result .Ledger .Transactions [i ]),
243244 }
244245
245- transactions [i ].PaymentReference = paymentReference (tx )
246- transactions [i ].IsNativePayment = isNativePayment (tx )
246+ // case-insensitive check for transaction type
247+ if strings .EqualFold (tx .TransactionType , paymentType ) {
248+ transactions [i ].PaymentReference = paymentReference (tx )
249+ transactions [i ].IsNativePayment = isNativePayment (tx )
250+ }
251+
247252 transactions [i ].SourceAddressesRoot , err = sourceAddressesRoot (tx )
248253 if err != nil {
249254 return nil , err
@@ -268,23 +273,18 @@ func paymentReference(tx xrpTransaction) string {
268273}
269274
270275func isNativePayment (tx xrpTransaction ) bool {
271- if tx .TransactionType == "Payment" {
272- var amountStr string
273- err := json .Unmarshal (tx .Amount , & amountStr )
276+ var amountStr string
277+ err := json .Unmarshal (tx .Amount , & amountStr )
278+ if err == nil {
279+ _ , err = strconv .Atoi (amountStr )
274280 if err == nil {
275- _ , err = strconv .Atoi (amountStr )
276- if err == nil {
277- return true
278- }
279- }
280- var amountStruct xrpAmount
281- err = json .Unmarshal (tx .Amount , & amountStruct )
282- if err == nil && amountStruct .Currency == xrpCurrency {
283281 return true
284282 }
285283 }
284+ var amountStruct xrpAmount
285+ err = json .Unmarshal (tx .Amount , & amountStruct )
286286
287- return false
287+ return err == nil && amountStruct . Currency == xrpCurrency
288288}
289289
290290func sourceAddressesRoot (tx xrpTransaction ) (string , error ) {
0 commit comments