fix: Store Delegate object in delegating and authorized account directories for proper deletion (#6681)

This commit is contained in:
Zhiyuan Wang
2026-04-29 14:17:01 -04:00
committed by Bart
parent ed3aa6ecf5
commit 4da46d31ac
8 changed files with 298 additions and 38 deletions

View File

@@ -466,6 +466,7 @@ LEDGER_ENTRY(ltDELEGATE, 0x0083, Delegate, delegate, ({
{sfAuthorize, soeREQUIRED},
{sfPermissions, soeREQUIRED},
{sfOwnerNode, soeREQUIRED},
{sfDestinationNode, soeOPTIONAL},
{sfPreviousTxnID, soeREQUIRED},
{sfPreviousTxnLgrSeq, soeREQUIRED},
}))

View File

@@ -90,6 +90,30 @@ public:
return this->sle_->at(sfOwnerNode);
}
/**
* @brief Get sfDestinationNode (soeOPTIONAL)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT64::type::value_type>
getDestinationNode() const
{
if (hasDestinationNode())
return this->sle_->at(sfDestinationNode);
return std::nullopt;
}
/**
* @brief Check if sfDestinationNode is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasDestinationNode() const
{
return this->sle_->isFieldPresent(sfDestinationNode);
}
/**
* @brief Get sfPreviousTxnID (soeREQUIRED)
* @return The field value.
@@ -203,6 +227,17 @@ public:
return *this;
}
/**
* @brief Set sfDestinationNode (soeOPTIONAL)
* @return Reference to this builder for method chaining.
*/
DelegateBuilder&
setDestinationNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
{
object_[sfDestinationNode] = value;
return *this;
}
/**
* @brief Set sfPreviousTxnID (soeREQUIRED)
* @return Reference to this builder for method chaining.

View File

@@ -38,11 +38,7 @@ public:
// Interface used by AccountDelete
static TER
deleteDelegate(
ApplyView& view,
std::shared_ptr<SLE> const& sle,
AccountID const& account,
beast::Journal j);
deleteDelegate(ApplyView& view, std::shared_ptr<SLE> const& sle, beast::Journal j);
};
} // namespace xrpl