mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-21 22:30:57 +00:00
Enforce no negative balance at the end of transaction
This commit is contained in:
@@ -176,6 +176,16 @@ VaultClawback::doApply()
|
||||
if (auto ter = accountSend(view(), vaultAccount, account_, assets, j_))
|
||||
return ter;
|
||||
|
||||
// Sanity check
|
||||
if (accountHolds(
|
||||
view(),
|
||||
vaultAccount,
|
||||
assets.asset(),
|
||||
FreezeHandling::fhIGNORE_FREEZE,
|
||||
AuthHandling::ahIGNORE_AUTH,
|
||||
j_) < beast::zero)
|
||||
return tefINTERNAL;
|
||||
|
||||
return tesSUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -177,6 +177,16 @@ VaultDeposit::doApply()
|
||||
view(), account_, vaultAccount, assets, j_, WaiveTransferFee::Yes))
|
||||
return ter;
|
||||
|
||||
// Sanity check
|
||||
if (accountHolds(
|
||||
view(),
|
||||
account_,
|
||||
assets.asset(),
|
||||
FreezeHandling::fhIGNORE_FREEZE,
|
||||
AuthHandling::ahIGNORE_AUTH,
|
||||
j_) < beast::zero)
|
||||
return tefINTERNAL;
|
||||
|
||||
// Transfer shares from vault to depositor.
|
||||
if (auto ter = accountSend(
|
||||
view(), vaultAccount, account_, shares, j_, WaiveTransferFee::Yes))
|
||||
|
||||
@@ -181,6 +181,16 @@ VaultWithdraw::doApply()
|
||||
view(), vaultAccount, dstAcct, assets, j_, WaiveTransferFee::Yes))
|
||||
return ter;
|
||||
|
||||
// Sanity check
|
||||
if (accountHolds(
|
||||
view(),
|
||||
vaultAccount,
|
||||
assets.asset(),
|
||||
FreezeHandling::fhIGNORE_FREEZE,
|
||||
AuthHandling::ahIGNORE_AUTH,
|
||||
j_) < beast::zero)
|
||||
return tefINTERNAL;
|
||||
|
||||
return tesSUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user