From f415a20c984816130dc085458d7911ea68c24170 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 6 Jul 2026 17:25:22 -0400 Subject: [PATCH] fix stuff --- .../tx/transactors/credentials/CredentialAccept.cpp | 8 +++++++- src/test/app/Sponsor_test.cpp | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/libxrpl/tx/transactors/credentials/CredentialAccept.cpp b/src/libxrpl/tx/transactors/credentials/CredentialAccept.cpp index 605deb8ff2..5188a9095e 100644 --- a/src/libxrpl/tx/transactors/credentials/CredentialAccept.cpp +++ b/src/libxrpl/tx/transactors/credentials/CredentialAccept.cpp @@ -115,13 +115,19 @@ CredentialAccept::doApply() } sleCred->setFieldU32(sfFlags, lsfAccepted); - view().update(sleCred); auto txSponsorSle = getTxReserveSponsor(ctx_.getApplyViewContext()); if (!txSponsorSle) return tefINTERNAL; // LCOV_EXCL_LINE + + // Release the original creation sponsor from the credential (it covered + // the issuer's reserve), then assign the accept tx's sponsor (if any) so + // the credential reflects whoever is now covering the subject's reserve. decreaseOwnerCountForObject(view(), sleIssuer, sleCred, 1, j_); + removeSponsorFromLedgerEntry(sleCred); + addSponsorToLedgerEntry(sleCred, *txSponsorSle); increaseOwnerCount(view(), sleSubject, *txSponsorSle, 1, j_); + view().update(sleCred); return tesSUCCESS; } diff --git a/src/test/app/Sponsor_test.cpp b/src/test/app/Sponsor_test.cpp index 7dfbd69976..2368559243 100644 --- a/src/test/app/Sponsor_test.cpp +++ b/src/test/app/Sponsor_test.cpp @@ -2882,15 +2882,15 @@ public: BEAST_EXPECT(ownerCount(env, bob) == 0); BEAST_EXPECT(sponsoredOwnerCount(env, bob) == 0); - // Bob accepts: ownership and sponsorship transfer to bob + // Bob accepts: issuer's sponsorship ends, bob becomes unsponsored owner env(credentials::accept(bob, alice, credType)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); BEAST_EXPECT(sponsoredOwnerCount(env, alice) == 0); - BEAST_EXPECT(sponsoringOwnerCount(env, sponsor) == 1); // still sponsoring, but now bob + BEAST_EXPECT(sponsoringOwnerCount(env, sponsor) == 0); // original sponsorship ended BEAST_EXPECT(ownerCount(env, bob) == 1); - BEAST_EXPECT(sponsoredOwnerCount(env, bob) == 1); + BEAST_EXPECT(sponsoredOwnerCount(env, bob) == 0); // bob owns it without a sponsor // CredentialDelete by subject env(credentials::deleteCred(bob, bob, alice, credType));