From c164acd3d6876aeb2a68e2cd31829366ff2ac322 Mon Sep 17 00:00:00 2001 From: Richard Holland Date: Mon, 30 Jan 2023 13:22:06 +0000 Subject: [PATCH] add URIToken deleter for account delete, change blank uri to tfBurn flag for burning --- src/ripple/app/tx/impl/DeleteAccount.cpp | 34 ++++++++++++++++++++++++ src/ripple/app/tx/impl/URIToken.cpp | 22 +++++++-------- src/ripple/protocol/TxFlags.h | 3 +++ 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/ripple/app/tx/impl/DeleteAccount.cpp b/src/ripple/app/tx/impl/DeleteAccount.cpp index 56c4d0c89..156a07bd0 100644 --- a/src/ripple/app/tx/impl/DeleteAccount.cpp +++ b/src/ripple/app/tx/impl/DeleteAccount.cpp @@ -142,6 +142,38 @@ removeNFTokenOfferFromLedger( return tesSUCCESS; } +/** Remove a generic object that only lives in the owner's directory */ +TER +removeGeneric( + Application& app, + ApplyView& view, + AccountID const& account, + uint256 const& delIndex, + std::shared_ptr const& sleDel, + beast::Journal) +{ + if (!sleDel) + return tesSUCCESS; + + auto const owner = (*offer)[sfOwner]; + + if (!view.dirRemove( + keylet::ownerDir(account), + (*sleDel)[sfOwnerNode], + sleDel->key(), + false)) + return false; + + adjustOwnerCount( + view, + view.peek(keylet::account(account)), + -1, + beast::Journal{beast::Journal::getNullSink()}); + + view.erase(sleDel); + return true; +} + // Return nullptr if the LedgerEntryType represents an obligation that can't // be deleted. Otherwise return the pointer to the function that can delete // the non-obligation @@ -160,6 +192,8 @@ nonObligationDeleter(LedgerEntryType t) return removeDepositPreauthFromLedger; case ltNFTOKEN_OFFER: return removeNFTokenOfferFromLedger; + case ltURI_TOKEN: + return removeGeneric; default: return nullptr; } diff --git a/src/ripple/app/tx/impl/URIToken.cpp b/src/ripple/app/tx/impl/URIToken.cpp index 26bbdb874..8568b165e 100644 --- a/src/ripple/app/tx/impl/URIToken.cpp +++ b/src/ripple/app/tx/impl/URIToken.cpp @@ -43,24 +43,24 @@ inline URIOperation inferOperation(STTx const& tx) uint32_t const flags = tx.getFlags(); bool const hasDigest = tx.isFieldPresent(sfDigest); bool const hasURI = tx.isFieldPresent(sfURI); - bool const blankURI = hasURI && tx.getFieldVL(sfURI).empty(); + bool const hasBurnFlag = flags == tfBurn; bool const hasID = tx.isFieldPresent(sfURITokenID); bool const hasAmt = tx.isFieldPresent(sfAmount); bool const hasDst = tx.isFieldPresent(sfDestination); bool const hasSellFlag = flags == tfSell; - bool const hasBurnFlag = flags == tfBurnable; + bool const hasBurnableFlag = flags == tfBurnable; bool const blankFlags = flags == 0; uint16_t combination = - (hasDigest ? 0b100000000U : 0) + - (hasURI ? 0b010000000U : 0) + - (blankURI ? 0b001000000U : 0) + - (hasID ? 0b000100000U : 0) + - (hasAmt ? 0b000010000U : 0) + - (hasDst ? 0b000001000U : 0) + - (hasSellFlag ? 0b000000100U : 0) + - (hasBurnFlag ? 0b000000010U : 0) + - (blankFlags ? 0b000000001U : 0); + (hasDigest ? 0b100000000U : 0) + + (hasURI ? 0b010000000U : 0) + + (hasBurnFlag ? 0b001000000U : 0) + + (hasID ? 0b000100000U : 0) + + (hasAmt ? 0b000010000U : 0) + + (hasDst ? 0b000001000U : 0) + + (hasSellFlag ? 0b000000100U : 0) + + (hasBurnableFlag ? 0b000000010U : 0) + + (blankFlags ? 0b000000001U : 0); switch (combination) { diff --git a/src/ripple/protocol/TxFlags.h b/src/ripple/protocol/TxFlags.h index 5b2322fa0..930a5be15 100644 --- a/src/ripple/protocol/TxFlags.h +++ b/src/ripple/protocol/TxFlags.h @@ -129,6 +129,9 @@ constexpr std::uint32_t const tfStrongTSH = 0x00008000; constexpr std::uint32_t const tfNFTokenMintOldMask = ~(tfUniversal | tfBurnable | tfOnlyXRP | tfTrustLine | tfTransferable | tfStrongTSH); +// URIToken flags: +constexpr std::uint32_t const tfBurn = 0x00000002; + // Prior to fixRemoveNFTokenAutoTrustLine, transfer of an NFToken between // accounts allowed a TrustLine to be added to the issuer of that token // without explicit permission from that issuer. This was enabled by