Repository navigation
[ANCHOR-1407]: Enhance underpayment handling and transaction recording logic - #2091
Merged
Merged
Conversation
…it to a transaction
…fy_onchain_funds_received
…ures and tighten the weak underpayment tests
…second underpayment test
amandagonsalves
approved these changes
Nov 12, 2026
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.
Description
DefaultPaymentListenerrejects a payment because its on-chain amount is belowamount_expected, it no longer drops it silently. It now:stellar_transactionsand saves it;transaction_status_changedevent (no new event type), so the business server sees the payment;amount_inand the other amounts untouched and does not call the Platform API, so the underpayment is still not credited.DataAccessException,TransactionException) or to publish (AnchorExceptionor an unchecked exception) throwsIOException, so the observer cursor is held and the payment is retried instead of dropped again.stellar_transactionsis not appended twice, but its event is sent again.PaymentHelper.addStellarTransactionnow merges by Stellar transaction hash instead of appending blindly, so crediting a recorded payment later throughnotify_onchain_funds_received(hash + real amount) leaves a single entry. It also stops failing on anulllist that was an immutableList.of.DefaultPaymentListenernow receivesEventServiceandSacToAssetMapper(wired inPaymentObserverBeans).Context
checkAssetAmountSufficientreturnedfalsewith no exception, so the observer cursor advanced for good. The funds sat in the distribution account while the transaction stayed inpending_sender/pending_user_transfer_startwith no record and no signal to the anchor.Testing
./gradlew test./gradlew :platform:spotlessCheck :platform:testat HEAD: 1453 tests, 0 failures.DefaultPaymentListenerTest,PaymentHelperTestandNotifyOnchainFundsReceivedHandlerTestcover: record + event for SEP-31 / SEP-24 / SEP-6 (both kinds), status and amounts unchanged, no Platform API call, save and publish failures holding the cursor, optimistic-lock conflict, redelivery, events disabled, muxed fallback, path payment, one stroop below, a second underpayment (recorded separately, not summed), and the later credit leaving one entry.extended-tests(e2e against a live stack).Documentation
N/A for stellar-docs in this PR. Business servers will now receive a
transaction_status_changedevent with an unchanged status when an underpayment is recorded; consider a docs note on that behavior and on crediting throughnotify_onchain_funds_received.Known limitations
KafkaSession.publishlogs and swallows every exception, so with Kafka a failed event delivery never reaches the listener: the savedstellar_transactionsentry is the guaranteed signal and the event is best effort. Changing that is out of scope and affects every event.notify_onchain_funds_received.