mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Compare commits
1 Commits
vlntb/RIPD
...
a123456/di
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31b48e3b08 |
@@ -655,7 +655,7 @@ createPseudoAccount(
|
||||
uint256 const& pseudoOwnerKey,
|
||||
SField const& ownerField);
|
||||
|
||||
// Returns true iff sleAcct is a pseudo-account or specific
|
||||
// Returns true if sleAcct is a pseudo-account or specific
|
||||
// pseudo-accounts in pseudoFieldFilter.
|
||||
//
|
||||
// Returns false if sleAcct is
|
||||
|
||||
@@ -1024,6 +1024,12 @@ class LoanBroker_test : public beast::unit_test::suite
|
||||
destination(dest),
|
||||
ter(tecFROZEN),
|
||||
THISLINE);
|
||||
|
||||
// preclaim: tecPSEUDO_ACCOUNT
|
||||
env(coverWithdraw(alice, brokerKeylet.key, asset(10)),
|
||||
destination(vaultInfo.pseudoAccount),
|
||||
ter(tecPSEUDO_ACCOUNT),
|
||||
THISLINE);
|
||||
}
|
||||
|
||||
if (brokerTest == CoverClawback)
|
||||
|
||||
@@ -5243,46 +5243,6 @@ class Vault_test : public beast::unit_test::suite
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
testFrozenWithdrawToIssuer()
|
||||
{
|
||||
using namespace test::jtx;
|
||||
|
||||
testcase("frozen IOU can be withdrawn to issuer");
|
||||
|
||||
Env env{*this, testable_amendments() | featureSingleAssetVault};
|
||||
Account issuer{"issuer"};
|
||||
Account owner{"owner"};
|
||||
Account depositor{"depositor"};
|
||||
env.fund(XRP(1000), issuer, owner, depositor);
|
||||
env.close();
|
||||
|
||||
PrettyAsset asset = issuer["IOU"];
|
||||
env.trust(asset(1000), owner);
|
||||
env.trust(asset(1000), depositor);
|
||||
env(pay(issuer, owner, asset(100)));
|
||||
env(pay(issuer, depositor, asset(200)));
|
||||
env.close();
|
||||
|
||||
Vault vault{env};
|
||||
auto [tx, keylet] = vault.create({.owner = owner, .asset = asset});
|
||||
env(tx);
|
||||
env.close();
|
||||
|
||||
env(vault.deposit(
|
||||
{.depositor = depositor, .id = keylet.key, .amount = asset(50)}));
|
||||
env.close();
|
||||
|
||||
env(fset(issuer, asfGlobalFreeze));
|
||||
env.close();
|
||||
|
||||
auto withdraw = vault.withdraw(
|
||||
{.depositor = depositor, .id = keylet.key, .amount = asset(10)});
|
||||
withdraw[sfDestination] = issuer.human();
|
||||
env(withdraw, ter{tesSUCCESS});
|
||||
env.close();
|
||||
}
|
||||
|
||||
public:
|
||||
void
|
||||
run() override
|
||||
@@ -5301,7 +5261,6 @@ public:
|
||||
testScaleIOU();
|
||||
testRPC();
|
||||
testDelegate();
|
||||
testFrozenWithdrawToIssuer();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -48,6 +48,11 @@ LoanBrokerCoverWithdraw::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
auto const dstAcct = tx[~sfDestination].value_or(account);
|
||||
|
||||
if (isPseudoAccount(ctx.view, dstAcct))
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "Trying to withdraw into a pseudo-account.";
|
||||
return tecPSEUDO_ACCOUNT;
|
||||
}
|
||||
auto const sleBroker = ctx.view.read(keylet::loanbroker(brokerID));
|
||||
if (!sleBroker)
|
||||
{
|
||||
|
||||
@@ -80,23 +80,13 @@ VaultWithdraw::preclaim(PreclaimContext const& ctx)
|
||||
return ter;
|
||||
|
||||
// Cannot withdraw from a Vault an Asset frozen for the destination account
|
||||
if (!vaultAsset.holds<Issue>() ||
|
||||
(dstAcct != vaultAsset.getIssuer() &&
|
||||
account != vaultAsset.getIssuer()))
|
||||
{
|
||||
if (auto const ret = checkFrozen(ctx.view, dstAcct, vaultAsset))
|
||||
return ret;
|
||||
}
|
||||
if (auto const ret = checkFrozen(ctx.view, dstAcct, vaultAsset))
|
||||
return ret;
|
||||
|
||||
// Cannot return shares to the vault, if the underlying asset was frozen for
|
||||
// the submitter
|
||||
if (!vaultAsset.holds<Issue>() ||
|
||||
(dstAcct != vaultAsset.getIssuer() &&
|
||||
account != vaultAsset.getIssuer()))
|
||||
{
|
||||
if (auto const ret = checkFrozen(ctx.view, account, vaultShare))
|
||||
return ret;
|
||||
}
|
||||
if (auto const ret = checkFrozen(ctx.view, account, vaultShare))
|
||||
return ret;
|
||||
|
||||
return tesSUCCESS;
|
||||
}
|
||||
@@ -125,7 +115,6 @@ VaultWithdraw::doApply()
|
||||
|
||||
auto const amount = ctx_.tx[sfAmount];
|
||||
Asset const vaultAsset = vault->at(sfAsset);
|
||||
auto const dstAcct = ctx_.tx[~sfDestination].value_or(account_);
|
||||
MPTIssue const share{mptIssuanceID};
|
||||
STAmount sharesRedeemed = {share};
|
||||
STAmount assetsWithdrawn;
|
||||
@@ -176,21 +165,11 @@ VaultWithdraw::doApply()
|
||||
return tecPATH_DRY;
|
||||
}
|
||||
|
||||
// When withdrawing IOU to the issuer, ignore freeze since spec allows
|
||||
// returning frozen IOU assets to their issuer. MPTs don't have this
|
||||
// exemption - MPT locks function like "deep freeze" with no issuer
|
||||
// exception.
|
||||
FreezeHandling const freezeHandling = (vaultAsset.holds<Issue>() &&
|
||||
(dstAcct == vaultAsset.getIssuer() ||
|
||||
account_ == vaultAsset.getIssuer()))
|
||||
? FreezeHandling::fhIGNORE_FREEZE
|
||||
: FreezeHandling::fhZERO_IF_FROZEN;
|
||||
|
||||
if (accountHolds(
|
||||
view(),
|
||||
account_,
|
||||
share,
|
||||
freezeHandling,
|
||||
FreezeHandling::fhZERO_IF_FROZEN,
|
||||
AuthHandling::ahIGNORE_AUTH,
|
||||
j_) < sharesRedeemed)
|
||||
{
|
||||
@@ -258,6 +237,8 @@ VaultWithdraw::doApply()
|
||||
// else quietly ignore, account balance is not zero
|
||||
}
|
||||
|
||||
auto const dstAcct = ctx_.tx[~sfDestination].value_or(account_);
|
||||
|
||||
return doWithdraw(
|
||||
view(),
|
||||
ctx_.tx,
|
||||
|
||||
Reference in New Issue
Block a user