mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
check lock in ConfidentialSend (#5933)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user