Skip to content

Commit c85ae1c

Browse files
committed
Merge branch 'main' into ryan/xrp-move-private
2 parents b9c76a8 + cbafa95 commit c85ae1c

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

internal/xrp/xrp.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
const (
2121
xrpCurrency = "XRP"
2222
XRPTimeToUTD = uint64(946684800)
23+
paymentType = "Payment"
2324
)
2425

2526
type 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

270275
func 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

290290
func sourceAddressesRoot(tx xrpTransaction) (string, error) {

0 commit comments

Comments
 (0)