check lock in ConfidentialSend (#5933)

This commit is contained in:
yinyiqian1
2025-10-23 12:58:38 -04:00
committed by GitHub
parent 35e4fad557
commit e4a8ba51f9
2 changed files with 54 additions and 0 deletions

View File

@@ -819,6 +819,46 @@ class ConfidentialTransfer_test : public beast::unit_test::suite
Buffer(ripple::ecGamalEncryptedTotalLength),
.err = tecOBJECT_NOT_FOUND});
}
// issuance is locked globally
{
mptAlice.set({.account = alice, .flags = tfMPTLock});
mptAlice.send(
{.account = bob,
.dest = carol,
.amt = 10,
.proof = "123",
.err = tecLOCKED});
}
// sender is locked
{
mptAlice.set(
{.account = alice, .flags = tfMPTUnlock}); // unlock issuance
mptAlice.set({.account = alice, .holder = bob, .flags = tfMPTLock});
mptAlice.send(
{.account = bob,
.dest = carol,
.amt = 10,
.proof = "123",
.err = tecLOCKED});
}
// destination is locked
{
mptAlice.set(
{.account = alice,
.holder = bob,
.flags = tfMPTUnlock}); // unlock bob
mptAlice.set(
{.account = alice, .holder = carol, .flags = tfMPTLock});
mptAlice.send(
{.account = bob,
.dest = carol,
.amt = 10,
.proof = "123",
.err = tecLOCKED});
}
}
void

View File

@@ -79,6 +79,10 @@ ConfidentialSend::preclaim(PreclaimContext const& ctx)
if (!sleIssuance)
return tecOBJECT_NOT_FOUND;
// Check if the issuance allows transfer
if (!sleIssuance->isFlag(lsfMPTCanTransfer))
return tecLOCKED;
// Check if issuance allows confidential transfer
if (sleIssuance->isFlag(lsfMPTNoConfidentialTransfer))
return tecNO_PERMISSION;
@@ -111,6 +115,16 @@ ConfidentialSend::preclaim(PreclaimContext const& ctx)
!sleDestinationMPToken->isFieldPresent(sfIssuerEncryptedBalance))
return tecNO_PERMISSION;
// Check lock
MPTIssue const mptIssue(mptIssuanceID);
if (auto const ter = checkFrozen(ctx.view, account, mptIssue);
ter != tesSUCCESS)
return ter;
if (auto const ter = checkFrozen(ctx.view, destination, mptIssue);
ter != tesSUCCESS)
return ter;
// todo: check zkproof. equality proof and range proof, combined or separate
// TBD. TER const terProof = verifyConfidentialSendProof(
// ctx.tx[sfZKProof],