From a63f1ba53ec572c86917c4d5dd5b40ca9dc4c486 Mon Sep 17 00:00:00 2001 From: Richard Holland Date: Mon, 14 Mar 2022 11:17:07 +0000 Subject: [PATCH] block delete account if hooks and hook state are installed on account --- src/ripple/app/tx/impl/DeleteAccount.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ripple/app/tx/impl/DeleteAccount.cpp b/src/ripple/app/tx/impl/DeleteAccount.cpp index 16d7eb205..23f5a0b2c 100644 --- a/src/ripple/app/tx/impl/DeleteAccount.cpp +++ b/src/ripple/app/tx/impl/DeleteAccount.cpp @@ -187,6 +187,12 @@ DeleteAccount::preclaim(PreclaimContext const& ctx) if ((*sleAccount)[sfSequence] + seqDelta > ctx.view.seq()) return tecTOO_SOON; + // do not allow the account to be removed if there are hooks installed or one or more hook states + // when these fields are completely empty the field is made absent so this test is sufficient + // these fields cannot be populated unless hooks is enabled so the rules do not need to be checked + if (sleAccount->isFieldPresent(sfHookNamespaces) || sleAccount->isFieldPresent(sfHooks)) + return tecHAS_OBLIGATIONS; + // Verify that the account does not own any objects that would prevent // the account from being deleted. Keylet const ownerDirKeylet{keylet::ownerDir(account)}; @@ -247,6 +253,12 @@ DeleteAccount::doApply() if (!src || !dst) return tefBAD_LEDGER; + + // do not allow the account to be removed if there are hooks installed or one or more hook states + // when these fields are completely empty the field is made absent so this test is sufficient + // these fields cannot be populated unless hooks is enabled so the rules do not need to be checked + if (src->isFieldPresent(sfHookNamespaces) || src->isFieldPresent(sfHooks)) + return tecHAS_OBLIGATIONS; // Delete all of the entries in the account directory. Keylet const ownerDirKeylet{keylet::ownerDir(account_)};