Skip to content

fix: Check credential for LoanBrokerCoverWithdraw and VaultWithdraw - #7107

Merged
bthomee merged 27 commits into
XRPLF:developfrom
shawnxie999:fix-sav-cred
Aug 20, 2026
Merged

fix: Check credential for LoanBrokerCoverWithdraw and VaultWithdraw#7107
bthomee merged 27 commits into
XRPLF:developfrom
shawnxie999:fix-sav-cred

Conversation

@shawnxie999

@shawnxie999 shawnxie999 commented May 11, 2026

Copy link
Copy Markdown
Contributor

High Level Overview of Change

Context of Change

VaultWithdraw and LoanBrokerCoverWithdraw did not accept sfCredentialIDs, so withdrawals to a destination with lsfDepositAuth and credential-only preauth failed with tecNO_PERMISSION even when the sender held valid credentials.

Fix

Add sfCredentialIDs to both transaction formats and wire up credential validation, following the pattern used by Payment. Gated by fixCleanup3_4_0 (with featureCredentials for the field).

Spec update: XRPLF/XRPL-Standards#538

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • Peer protocol change (must be backward compatible or bump the peer protocol version)

@shawnxie999
shawnxie999 marked this pull request as ready for review May 11, 2026 14:50
@shawnxie999 shawnxie999 changed the title Fix sav cred fix: Check credential for LoanBrokerCoverWithdraw and VaultWithdraw May 11, 2026
@shawnxie999
shawnxie999 marked this pull request as draft May 11, 2026 14:57
@shawnxie999
shawnxie999 marked this pull request as ready for review May 11, 2026 14:57
@codecov

codecov Bot commented May 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

Copy link
Copy Markdown

This PR has conflicts, please resolve them in order for the PR to be reviewed.

@Tapanito
Tapanito self-requested a review May 15, 2026 15:22
@github-actions

Copy link
Copy Markdown

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

@github-actions

Copy link
Copy Markdown

This PR has conflicts, please resolve them in order for the PR to be reviewed.

@github-actions

Copy link
Copy Markdown

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

@ximinez ximinez added this to the 3.3.0 milestone May 20, 2026
@shawnxie999
shawnxie999 requested a review from Tapanito August 10, 2026 16:52

@Tapanito Tapanito left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@a1q123456 a1q123456 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@shawnxie999 shawnxie999 added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label Aug 17, 2026
@bthomee
bthomee requested a lite review from Copilot August 17, 2026 20:58
@bthomee bthomee removed the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label Aug 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes credential-based deposit authorization for VaultWithdraw and LoanBrokerCoverWithdraw so that withdrawals to destinations with lsfDepositAuth can succeed when the sender presents valid sfCredentialIDs. It extends both transaction formats to accept sfCredentialIDs and wires credential validation into preflight/preclaim and the withdraw authorization path.

Changes:

  • Add optional sfCredentialIDs to VaultWithdraw and LoanBrokerCoverWithdraw transaction templates and generated protocol_autogen wrappers/builders.
  • Validate sfCredentialIDs in preflight (credentials::checkFields) and validate referenced credentials in preclaim (credentials::valid), gated by featureCredentials + fixCleanup3_4_0.
  • Extend canWithdraw to support credential-based deposit preauth (and add app-level tests covering success/failure/expiration cases).

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/tests/libxrpl/protocol_autogen/transactions/VaultWithdrawTests.cpp Adds round-trip and nullopt coverage for sfCredentialIDs in the generated wrapper/builder.
src/tests/libxrpl/protocol_autogen/transactions/LoanBrokerCoverWithdrawTests.cpp Adds round-trip and nullopt coverage for sfCredentialIDs in the generated wrapper/builder.
src/test/app/Vault_test.cpp Adds integration coverage for vault withdraw to lsfDepositAuth destination using credentials, including expiration behavior.
src/test/app/lending/LoanBroker_test.cpp Adds integration coverage for broker cover withdraw to lsfDepositAuth destination using credentials, including expiration behavior.
src/libxrpl/tx/transactors/vault/VaultWithdraw.cpp Adds credential feature gating + preflight/preclaim validation; passes credential IDs into canWithdraw where needed.
src/libxrpl/tx/transactors/lending/LoanBrokerCoverWithdraw.cpp Adds credential feature gating + preflight/preclaim validation for cover withdraw.
src/libxrpl/ledger/View.cpp Extends canWithdraw to check credential-based deposit preauth when account-based preauth is absent.
include/xrpl/tx/transactors/vault/VaultWithdraw.h Declares checkExtraFeatures for gating credential field usage.
include/xrpl/protocol/detail/transactions.macro Adds sfCredentialIDs as an optional field for the two transaction types.
include/xrpl/protocol_autogen/transactions/VaultWithdraw.h Adds generated get/has/setCredentialIDs to wrapper/builder.
include/xrpl/protocol_autogen/transactions/LoanBrokerCoverWithdraw.h Adds generated get/has/setCredentialIDs to wrapper/builder.
include/xrpl/ledger/View.h Updates canWithdraw API to accept optional credential IDs (with default), and updates related documentation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread include/xrpl/ledger/View.h
Comment thread include/xrpl/ledger/View.h

@a1q123456 a1q123456 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment is updated, reapproving

@github-actions

Copy link
Copy Markdown

This PR has conflicts, please resolve them in order for the PR to be reviewed.

@github-actions

Copy link
Copy Markdown

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

@shawnxie999 shawnxie999 added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label Aug 19, 2026
@bthomee
bthomee enabled auto-merge August 19, 2026 16:04
@bthomee
bthomee added this pull request to the merge queue Aug 20, 2026
Merged via the queue into XRPLF:develop with commit e3ba569 Aug 20, 2026
94 of 96 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants