Check if index is within range

This commit is contained in:
Alfred Kamanda 2024-11-19 16:23:35 +03:00
parent 6159686a8e
commit eab6dbd74c
Signed by untrusted user: Alfred-mk
GPG Key ID: 7EA3D01708908703

View File

@ -77,6 +77,11 @@ func GetTransferData(ctx context.Context, db storage.PrefixDb, publicKey string,
dates := strings.Split(string(data["txdate"]), "\n") dates := strings.Split(string(data["txdate"]), "\n")
syms := strings.Split(string(data["txsym"]), "\n") syms := strings.Split(string(data["txsym"]), "\n")
// Check if index is within range
if index < 1 || index > len(senders) {
return "", fmt.Errorf("transaction not found: index %d out of range", index)
}
// Adjust for 0-based indexing // Adjust for 0-based indexing
i := index - 1 i := index - 1
transactionType := "received" transactionType := "received"