Files
rippled/src/libxrpl/protocol/InnerObjectFormats.cpp
yinyiqian1 2db2791805 Add PermissionDelegation feature (#5354)
This change implements the account permission delegation described in XLS-75d, see https://github.com/XRPLF/XRPL-Standards/pull/257.

* Introduces transaction-level and granular permissions that can be delegated to other accounts.
* Adds `DelegateSet` transaction to grant specified permissions to another account.
* Adds `ltDelegate` ledger object to maintain the permission list for delegating/delegated account pair.
* Adds an optional `Delegate` field in common fields, allowing a delegated account to send transactions on behalf of the delegating account within the granted permission scope. The `Account` field remains the delegating account; the `Delegate` field specifies the delegated account. The transaction is signed by the delegated account.
2025-05-08 06:14:02 -04:00

181 lines
5.6 KiB
C++

//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include <xrpl/protocol/InnerObjectFormats.h>
#include <xrpl/protocol/SField.h>
#include <xrpl/protocol/SOTemplate.h>
namespace ripple {
InnerObjectFormats::InnerObjectFormats()
{
// inner objects with the default fields have to be
// constructed with STObject::makeInnerObject()
add(sfSignerEntry.jsonName,
sfSignerEntry.getCode(),
{
{sfAccount, soeREQUIRED},
{sfSignerWeight, soeREQUIRED},
{sfWalletLocator, soeOPTIONAL},
});
add(sfSigner.jsonName,
sfSigner.getCode(),
{
{sfAccount, soeREQUIRED},
{sfSigningPubKey, soeREQUIRED},
{sfTxnSignature, soeREQUIRED},
});
add(sfMajority.jsonName,
sfMajority.getCode(),
{
{sfAmendment, soeREQUIRED},
{sfCloseTime, soeREQUIRED},
});
add(sfDisabledValidator.jsonName,
sfDisabledValidator.getCode(),
{
{sfPublicKey, soeREQUIRED},
{sfFirstLedgerSequence, soeREQUIRED},
});
add(sfNFToken.jsonName,
sfNFToken.getCode(),
{
{sfNFTokenID, soeREQUIRED},
{sfURI, soeOPTIONAL},
});
add(sfVoteEntry.jsonName,
sfVoteEntry.getCode(),
{
{sfAccount, soeREQUIRED},
{sfTradingFee, soeDEFAULT},
{sfVoteWeight, soeREQUIRED},
});
add(sfAuctionSlot.jsonName,
sfAuctionSlot.getCode(),
{{sfAccount, soeREQUIRED},
{sfExpiration, soeREQUIRED},
{sfDiscountedFee, soeDEFAULT},
{sfPrice, soeREQUIRED},
{sfAuthAccounts, soeOPTIONAL}});
add(sfXChainClaimAttestationCollectionElement.jsonName,
sfXChainClaimAttestationCollectionElement.getCode(),
{
{sfAttestationSignerAccount, soeREQUIRED},
{sfPublicKey, soeREQUIRED},
{sfSignature, soeREQUIRED},
{sfAmount, soeREQUIRED},
{sfAccount, soeREQUIRED},
{sfAttestationRewardAccount, soeREQUIRED},
{sfWasLockingChainSend, soeREQUIRED},
{sfXChainClaimID, soeREQUIRED},
{sfDestination, soeOPTIONAL},
});
add(sfXChainCreateAccountAttestationCollectionElement.jsonName,
sfXChainCreateAccountAttestationCollectionElement.getCode(),
{
{sfAttestationSignerAccount, soeREQUIRED},
{sfPublicKey, soeREQUIRED},
{sfSignature, soeREQUIRED},
{sfAmount, soeREQUIRED},
{sfAccount, soeREQUIRED},
{sfAttestationRewardAccount, soeREQUIRED},
{sfWasLockingChainSend, soeREQUIRED},
{sfXChainAccountCreateCount, soeREQUIRED},
{sfDestination, soeREQUIRED},
{sfSignatureReward, soeREQUIRED},
});
add(sfXChainClaimProofSig.jsonName,
sfXChainClaimProofSig.getCode(),
{
{sfAttestationSignerAccount, soeREQUIRED},
{sfPublicKey, soeREQUIRED},
{sfAmount, soeREQUIRED},
{sfAttestationRewardAccount, soeREQUIRED},
{sfWasLockingChainSend, soeREQUIRED},
{sfDestination, soeOPTIONAL},
});
add(sfXChainCreateAccountProofSig.jsonName,
sfXChainCreateAccountProofSig.getCode(),
{
{sfAttestationSignerAccount, soeREQUIRED},
{sfPublicKey, soeREQUIRED},
{sfAmount, soeREQUIRED},
{sfSignatureReward, soeREQUIRED},
{sfAttestationRewardAccount, soeREQUIRED},
{sfWasLockingChainSend, soeREQUIRED},
{sfDestination, soeREQUIRED},
});
add(sfAuthAccount.jsonName,
sfAuthAccount.getCode(),
{
{sfAccount, soeREQUIRED},
});
add(sfPriceData.jsonName,
sfPriceData.getCode(),
{
{sfBaseAsset, soeREQUIRED},
{sfQuoteAsset, soeREQUIRED},
{sfAssetPrice, soeOPTIONAL},
{sfScale, soeDEFAULT},
});
add(sfCredential.jsonName,
sfCredential.getCode(),
{
{sfIssuer, soeREQUIRED},
{sfCredentialType, soeREQUIRED},
});
add(sfPermission.jsonName.c_str(),
sfPermission.getCode(),
{{sfPermissionValue, soeREQUIRED}});
}
InnerObjectFormats const&
InnerObjectFormats::getInstance()
{
static InnerObjectFormats instance;
return instance;
}
SOTemplate const*
InnerObjectFormats::findSOTemplateBySField(SField const& sField) const
{
auto itemPtr = findByType(sField.getCode());
if (itemPtr)
return &(itemPtr->getSOTemplate());
return nullptr;
}
} // namespace ripple