Skip to content

fix(payment-requests): validate memo length against Stellar 28-byte limit (#49) - #67

Open
ghzhost wants to merge 1 commit into
StellarSend:mainfrom
ghzhost:fix/payment-request-memo-length-49
Open

fix(payment-requests): validate memo length against Stellar 28-byte limit (#49)#67
ghzhost wants to merge 1 commit into
StellarSend:mainfrom
ghzhost:fix/payment-request-memo-length-49

Conversation

@ghzhost

@ghzhost ghzhost commented Sep 2, 2026

Copy link
Copy Markdown

Summary

Closes #49

Enforces Stellar protocol's 28-byte maximum length constraint on payment_requests.memo both in application logic and in Postgres.

Changes

  1. Application Validation (PaymentRequestService::validate_create_request):
    • Added validation enforcing that memo.len() <= 28 (checked in bytes, not character count).
    • Rejects oversized memos with AppError::Validation before any DB insert.
  2. Database Constraint (migrations/012_add_payment_request_memo_check.sql):
    • Added CHECK (memo IS NULL OR octet_length(memo) <= 28) on payment_requests table for defense-in-depth.
  3. Unit Tests (src/services/payment_request.rs):
    • Tested ASCII memos (28 bytes accepted, 29 bytes rejected).
    • Tested multi-byte UTF-8 boundary (e.g. 7 4-byte emojis = 28 bytes accepted; 8 4-byte emojis = 32 bytes rejected despite only 8 characters).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

payment_requests.memo has no length validation against Stellar's 28-byte on-chain MEMO_TEXT limit

1 participant