fix(payment-requests): validate memo length against Stellar 28-byte limit (#49) - #81
Open
Simultech369 wants to merge 1 commit into
Open
Simultech369 wants to merge 1 commit into
Simultech369 wants to merge 1 commit into
Conversation
…imit (StellarSend#49) Stellar's on-chain MEMO_TEXT field is hard-capped at 28 bytes by the protocol (stellar_xdr::curr::Memo::Text). - Enforce byte-length validation in PaymentRequestService::create via MAX_MEMO_TEXT_BYTES and validate_memo - Add migration 012_payment_requests_memo_length_check.sql with CHECK (memo IS NULL OR octet_length(memo) <= 28) - Add unit tests covering 28-byte ASCII limit, 29-byte rejection, 30-byte multi-byte UTF-8 rejection, 28-byte multi-byte acceptance, and None/empty cases Closes StellarSend#49
Author
|
Hi @abayomicornelius — PR #81 is fully tested and ready for review. It resolves #49 by enforcing Stellar's 28-byte UTF-8 Mergeable and ready for review whenever convenient!
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #49 by enforcing Stellar's on-chain 28-byte
MEMO_TEXTlimit (stellar_xdr::curr::Memo::Text/StringM<28>) onpayment_requests.memoat both the application service layer and database layer.Changes
src/services/payment_request.rs):pub const MAX_MEMO_TEXT_BYTES: usize = 28;.PaymentRequestService::validate_memo(memo: Option<&str>) -> AppResult<()>.PaymentRequestService::createbefore preparing or executing the database query.memo.as_bytes().len(), guarding against multi-byte character overflow where character count <= 28 but byte length > 28.migrations/012_payment_requests_memo_length_check.sql):octet_lengthfor byte-exact enforcement in PostgreSQL while preserving nullability for optional memos.src/services/payment_request.rs):memo_at_exact_28_ascii_bytes_is_accepted(28 bytes accepted).memo_exceeding_28_ascii_bytes_is_rejected(29 bytes rejected withAppError::Validation).memo_multi_byte_utf8_exceeding_28_bytes_is_rejected(10 3-byte unicode symbols = 30 bytes, 10 chars, rejected withAppError::Validation).memo_multi_byte_utf8_within_28_bytes_is_accepted(9 3-byte unicode symbols + 1 ASCII byte = 28 bytes total, accepted).memo_none_and_empty_is_accepted(Noneand""accepted).Closes #49
Payout Address (Stellar USDC):
GCK7WCZCOFNYXTH74KADMAIREIJKHIAX4ISJSGXZ4IF2MIRGAFLT4BTHEVM (Base USDC):
0xEa3A353Fb3fc88DB8F0FA1E6Ea541FEdc9F5F0E7