mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Introduce Credentials support (XLS-70d): (#5103)
Amendment:
- Credentials
New Transactions:
- CredentialCreate
- CredentialAccept
- CredentialDelete
Modified Transactions:
- DepositPreauth
- Payment
- EscrowFinish
- PaymentChannelClaim
- AccountDelete
New Object:
- Credential
Modified Object:
- DepositPreauth
API updates:
- ledger_entry
- account_objects
- ledger_data
- deposit_authorized
Read full spec: https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-0070d-credentials
This commit is contained in:
@@ -151,7 +151,10 @@ enum error_code_i {
|
||||
// Oracle
|
||||
rpcORACLE_MALFORMED = 95,
|
||||
|
||||
rpcLAST = rpcORACLE_MALFORMED // rpcLAST should always equal the last code.
|
||||
// deposit_authorized + credentials
|
||||
rpcBAD_CREDENTIALS = 96,
|
||||
|
||||
rpcLAST = rpcBAD_CREDENTIALS // rpcLAST should always equal the last code.
|
||||
};
|
||||
|
||||
/** Codes returned in the `warnings` array of certain RPC commands.
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace detail {
|
||||
// Feature.cpp. Because it's only used to reserve storage, and determine how
|
||||
// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than
|
||||
// the actual number of amendments. A LogicError on startup will verify this.
|
||||
static constexpr std::size_t numFeatures = 105;
|
||||
static constexpr std::size_t numFeatures = 106;
|
||||
|
||||
/** Amendments that this server supports and the default voting behavior.
|
||||
Whether they are enabled depends on the Rules defined in the validated
|
||||
|
||||
@@ -92,7 +92,10 @@ enum class HashPrefix : std::uint32_t {
|
||||
hookNonce = detail::make_hash_prefix('N', 'C', 'E'),
|
||||
|
||||
/* Hash of a Hook's actual code */
|
||||
hookDefinition = detail::make_hash_prefix('W', 'S', 'M')
|
||||
hookDefinition = detail::make_hash_prefix('W', 'S', 'M'),
|
||||
|
||||
/** Credentials signature */
|
||||
credential = detail::make_hash_prefix('C', 'R', 'D'),
|
||||
};
|
||||
|
||||
template <class Hasher>
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <xrpl/protocol/Serializer.h>
|
||||
#include <xrpl/protocol/UintTypes.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace ripple {
|
||||
@@ -214,6 +215,11 @@ check(uint256 const& key) noexcept
|
||||
Keylet
|
||||
depositPreauth(AccountID const& owner, AccountID const& preauthorized) noexcept;
|
||||
|
||||
Keylet
|
||||
depositPreauth(
|
||||
AccountID const& owner,
|
||||
std::set<std::pair<AccountID, Slice>> const& authCreds) noexcept;
|
||||
|
||||
inline Keylet
|
||||
depositPreauth(uint256 const& key) noexcept
|
||||
{
|
||||
@@ -321,6 +327,18 @@ did(AccountID const& account) noexcept;
|
||||
Keylet
|
||||
oracle(AccountID const& account, std::uint32_t const& documentID) noexcept;
|
||||
|
||||
Keylet
|
||||
credential(
|
||||
AccountID const& subject,
|
||||
AccountID const& issuer,
|
||||
Slice const& credType) noexcept;
|
||||
|
||||
inline Keylet
|
||||
credential(uint256 const& key) noexcept
|
||||
{
|
||||
return {ltCREDENTIAL, key};
|
||||
}
|
||||
|
||||
Keylet
|
||||
mptIssuance(std::uint32_t seq, AccountID const& issuer) noexcept;
|
||||
|
||||
|
||||
@@ -195,6 +195,9 @@ enum LedgerSpecificFlags {
|
||||
|
||||
// ltMPTOKEN
|
||||
lsfMPTAuthorized = 0x00000002,
|
||||
|
||||
// ltCREDENTIAL
|
||||
lsfAccepted = 0x00010000,
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -95,6 +95,15 @@ std::size_t constexpr maxDIDAttestationLength = 256;
|
||||
/** The maximum length of a domain */
|
||||
std::size_t constexpr maxDomainLength = 256;
|
||||
|
||||
/** The maximum length of a URI inside a Credential */
|
||||
std::size_t constexpr maxCredentialURILength = 256;
|
||||
|
||||
/** The maximum length of a CredentialType inside a Credential */
|
||||
std::size_t constexpr maxCredentialTypeLength = 64;
|
||||
|
||||
/** The maximum number of credentials can be passed in array */
|
||||
std::size_t constexpr maxCredentialsArraySize = 8;
|
||||
|
||||
/** The maximum length of MPTokenMetadata */
|
||||
std::size_t constexpr maxMPTokenMetadataLength = 1024;
|
||||
|
||||
|
||||
@@ -360,6 +360,7 @@ enum TECcodes : TERUnderlyingType {
|
||||
tecARRAY_EMPTY = 195,
|
||||
tecARRAY_TOO_LARGE = 196,
|
||||
tecLOCKED = 197,
|
||||
tecBAD_CREDENTIALS = 198,
|
||||
tecLAST_POSSIBLE_ENTRY = 255,
|
||||
};
|
||||
|
||||
|
||||
@@ -151,6 +151,12 @@ struct hash<ripple::Directory> : ripple::Directory::hasher
|
||||
explicit hash() = default;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash<ripple::uint256> : ripple::uint256::hasher
|
||||
{
|
||||
explicit hash() = default;
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
// If you add an amendment here, then do not forget to increment `numFeatures`
|
||||
// in include/xrpl/protocol/Feature.h.
|
||||
|
||||
XRPL_FEATURE(Credentials, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(AMMClawback, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (AMMv1_2, Supported::yes, VoteBehavior::DefaultNo)
|
||||
// InvariantsV1_1 will be changes to Supported::yes when all the
|
||||
// invariants expected to be included under it are complete.
|
||||
@@ -119,7 +121,7 @@ XRPL_FIX (1513, Supported::yes, VoteBehavior::DefaultYe
|
||||
XRPL_FEATURE(FlowCross, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FEATURE(Flow, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FEATURE(OwnerPaysFee, Supported::no, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(AMMClawback, Supported::yes, VoteBehavior::DefaultYes)
|
||||
|
||||
|
||||
// The following amendments are obsolete, but must remain supported
|
||||
// because they could potentially get enabled.
|
||||
|
||||
@@ -338,10 +338,11 @@ LEDGER_ENTRY(ltOFFER, 0x006f, Offer, ({
|
||||
*/
|
||||
LEDGER_ENTRY(ltDEPOSIT_PREAUTH, 0x0070, DepositPreauth, ({
|
||||
{sfAccount, soeREQUIRED},
|
||||
{sfAuthorize, soeREQUIRED},
|
||||
{sfAuthorize, soeOPTIONAL},
|
||||
{sfOwnerNode, soeREQUIRED},
|
||||
{sfPreviousTxnID, soeREQUIRED},
|
||||
{sfPreviousTxnLgrSeq, soeREQUIRED},
|
||||
{sfAuthorizeCredentials, soeOPTIONAL},
|
||||
}))
|
||||
|
||||
/** A claim id for a cross chain transaction.
|
||||
@@ -531,3 +532,18 @@ LEDGER_ENTRY(ltMPTOKEN, 0x007f, MPToken, ({
|
||||
{sfPreviousTxnID, soeREQUIRED},
|
||||
{sfPreviousTxnLgrSeq, soeREQUIRED},
|
||||
}))
|
||||
|
||||
/** A ledger object which tracks Credential
|
||||
\sa keylet::credential
|
||||
*/
|
||||
LEDGER_ENTRY(ltCREDENTIAL, 0x0081, Credential, ({
|
||||
{sfSubject, soeREQUIRED},
|
||||
{sfIssuer, soeREQUIRED},
|
||||
{sfCredentialType, soeREQUIRED},
|
||||
{sfExpiration, soeOPTIONAL},
|
||||
{sfURI, soeOPTIONAL},
|
||||
{sfIssuerNode, soeREQUIRED},
|
||||
{sfSubjectNode, soeREQUIRED},
|
||||
{sfPreviousTxnID, soeREQUIRED},
|
||||
{sfPreviousTxnLgrSeq, soeREQUIRED},
|
||||
}))
|
||||
|
||||
@@ -147,6 +147,8 @@ TYPED_SFIELD(sfAssetPrice, UINT64, 23)
|
||||
TYPED_SFIELD(sfMaximumAmount, UINT64, 24, SField::sMD_BaseTen|SField::sMD_Default)
|
||||
TYPED_SFIELD(sfOutstandingAmount, UINT64, 25, SField::sMD_BaseTen|SField::sMD_Default)
|
||||
TYPED_SFIELD(sfMPTAmount, UINT64, 26, SField::sMD_BaseTen|SField::sMD_Default)
|
||||
TYPED_SFIELD(sfIssuerNode, UINT64, 27)
|
||||
TYPED_SFIELD(sfSubjectNode, UINT64, 28)
|
||||
TYPED_SFIELD(sfTouchCount, UINT64, 97)
|
||||
TYPED_SFIELD(sfAccountIndex, UINT64, 98)
|
||||
TYPED_SFIELD(sfAccountCount, UINT64, 99)
|
||||
@@ -278,6 +280,7 @@ TYPED_SFIELD(sfData, VL, 28)
|
||||
TYPED_SFIELD(sfAssetClass, VL, 29)
|
||||
TYPED_SFIELD(sfProvider, VL, 30)
|
||||
TYPED_SFIELD(sfMPTokenMetadata, VL, 31)
|
||||
TYPED_SFIELD(sfCredentialType, VL, 32)
|
||||
TYPED_SFIELD(sfRemarkValue, VL, 98)
|
||||
TYPED_SFIELD(sfRemarkName, VL, 99)
|
||||
|
||||
@@ -302,6 +305,7 @@ TYPED_SFIELD(sfAttestationSignerAccount, ACCOUNT, 20)
|
||||
TYPED_SFIELD(sfAttestationRewardAccount, ACCOUNT, 21)
|
||||
TYPED_SFIELD(sfLockingChainDoor, ACCOUNT, 22)
|
||||
TYPED_SFIELD(sfIssuingChainDoor, ACCOUNT, 23)
|
||||
TYPED_SFIELD(sfSubject, ACCOUNT, 24)
|
||||
TYPED_SFIELD(sfInform, ACCOUNT, 99)
|
||||
|
||||
// vector of 256-bit
|
||||
@@ -310,6 +314,7 @@ TYPED_SFIELD(sfHashes, VECTOR256, 2)
|
||||
TYPED_SFIELD(sfAmendments, VECTOR256, 3)
|
||||
TYPED_SFIELD(sfNFTokenOffers, VECTOR256, 4)
|
||||
TYPED_SFIELD(sfHookNamespaces, VECTOR256, 5)
|
||||
TYPED_SFIELD(sfCredentialIDs, VECTOR256, 6)
|
||||
TYPED_SFIELD(sfURITokenIDs, VECTOR256, 99)
|
||||
|
||||
// path set
|
||||
@@ -362,6 +367,7 @@ UNTYPED_SFIELD(sfXChainCreateAccountProofSig, OBJECT, 29)
|
||||
UNTYPED_SFIELD(sfXChainClaimAttestationCollectionElement, OBJECT, 30)
|
||||
UNTYPED_SFIELD(sfXChainCreateAccountAttestationCollectionElement, OBJECT, 31)
|
||||
UNTYPED_SFIELD(sfPriceData, OBJECT, 32)
|
||||
UNTYPED_SFIELD(sfCredential, OBJECT, 33)
|
||||
UNTYPED_SFIELD(sfAmountEntry, OBJECT, 91)
|
||||
UNTYPED_SFIELD(sfMintURIToken, OBJECT, 92)
|
||||
UNTYPED_SFIELD(sfHookEmission, OBJECT, 93)
|
||||
@@ -396,6 +402,8 @@ UNTYPED_SFIELD(sfXChainCreateAccountAttestations, ARRAY, 22)
|
||||
// 23 unused
|
||||
UNTYPED_SFIELD(sfPriceDataSeries, ARRAY, 24)
|
||||
UNTYPED_SFIELD(sfAuthAccounts, ARRAY, 25)
|
||||
UNTYPED_SFIELD(sfAuthorizeCredentials, ARRAY, 26)
|
||||
UNTYPED_SFIELD(sfUnauthorizeCredentials, ARRAY, 27)
|
||||
UNTYPED_SFIELD(sfRemarks, ARRAY, 97)
|
||||
UNTYPED_SFIELD(sfGenesisMints, ARRAY, 96)
|
||||
UNTYPED_SFIELD(sfActiveValidators, ARRAY, 95)
|
||||
|
||||
@@ -37,6 +37,7 @@ TRANSACTION(ttPAYMENT, 0, Payment, ({
|
||||
{sfInvoiceID, soeOPTIONAL},
|
||||
{sfDestinationTag, soeOPTIONAL},
|
||||
{sfDeliverMin, soeOPTIONAL, soeMPTSupported},
|
||||
{sfCredentialIDs, soeOPTIONAL},
|
||||
}))
|
||||
|
||||
/** This transaction type creates an escrow object. */
|
||||
@@ -56,6 +57,7 @@ TRANSACTION(ttESCROW_FINISH, 2, EscrowFinish, ({
|
||||
{sfEscrowID, soeOPTIONAL}, // keylet as alternative to offerseq
|
||||
{sfFulfillment, soeOPTIONAL},
|
||||
{sfCondition, soeOPTIONAL},
|
||||
{sfCredentialIDs, soeOPTIONAL},
|
||||
}))
|
||||
|
||||
|
||||
@@ -143,6 +145,7 @@ TRANSACTION(ttPAYCHAN_CLAIM, 15, PaymentChannelClaim, ({
|
||||
{sfBalance, soeOPTIONAL},
|
||||
{sfSignature, soeOPTIONAL},
|
||||
{sfPublicKey, soeOPTIONAL},
|
||||
{sfCredentialIDs, soeOPTIONAL},
|
||||
}))
|
||||
|
||||
/** This transaction type creates a new check. */
|
||||
@@ -170,6 +173,8 @@ TRANSACTION(ttCHECK_CANCEL, 18, CheckCancel, ({
|
||||
TRANSACTION(ttDEPOSIT_PREAUTH, 19, DepositPreauth, ({
|
||||
{sfAuthorize, soeOPTIONAL},
|
||||
{sfUnauthorize, soeOPTIONAL},
|
||||
{sfAuthorizeCredentials, soeOPTIONAL},
|
||||
{sfUnauthorizeCredentials, soeOPTIONAL},
|
||||
}))
|
||||
|
||||
/** This transaction type modifies a trustline between two accounts. */
|
||||
@@ -183,6 +188,7 @@ TRANSACTION(ttTRUST_SET, 20, TrustSet, ({
|
||||
TRANSACTION(ttACCOUNT_DELETE, 21, AccountDelete, ({
|
||||
{sfDestination, soeREQUIRED},
|
||||
{sfDestinationTag, soeOPTIONAL},
|
||||
{sfCredentialIDs, soeOPTIONAL},
|
||||
}))
|
||||
|
||||
/** This transaction type installs a hook. */
|
||||
@@ -454,6 +460,27 @@ TRANSACTION(ttMPTOKEN_AUTHORIZE, 66, MPTokenAuthorize, ({
|
||||
{sfHolder, soeOPTIONAL},
|
||||
}))
|
||||
|
||||
/** This transaction type create an Credential instance */
|
||||
TRANSACTION(ttCREDENTIAL_CREATE, 67, CredentialCreate, ({
|
||||
{sfSubject, soeREQUIRED},
|
||||
{sfCredentialType, soeREQUIRED},
|
||||
{sfExpiration, soeOPTIONAL},
|
||||
{sfURI, soeOPTIONAL},
|
||||
}))
|
||||
|
||||
/** This transaction type accept an Credential object */
|
||||
TRANSACTION(ttCREDENTIAL_ACCEPT, 68, CredentialAccept, ({
|
||||
{sfIssuer, soeREQUIRED},
|
||||
{sfCredentialType, soeREQUIRED},
|
||||
}))
|
||||
|
||||
/** This transaction type delete an Credential object */
|
||||
TRANSACTION(ttCREDENTIAL_DELETE, 69, CredentialDelete, ({
|
||||
{sfSubject, soeOPTIONAL},
|
||||
{sfIssuer, soeOPTIONAL},
|
||||
{sfCredentialType, soeREQUIRED},
|
||||
}))
|
||||
|
||||
/* A note attaching transactor that allows the owner or issuer (on a object by object basis) to attach remarks */
|
||||
TRANSACTION(ttREMARKS_SET, 94, SetRemarks, ({
|
||||
{sfObjectID, soeREQUIRED},
|
||||
|
||||
@@ -66,6 +66,7 @@ JSS(Bridge); // ledger type.
|
||||
JSS(Check); // ledger type.
|
||||
JSS(ClearFlag); // field.
|
||||
JSS(CreateCode); // field.
|
||||
JSS(Credential); // ledger type.
|
||||
JSS(DID); // ledger type.
|
||||
JSS(DeliverMax); // out: alias to Amount
|
||||
JSS(DeliverMin); // in: TransactionSign
|
||||
@@ -101,6 +102,7 @@ JSS(isVLEncoded); // out: RPC server_definitions
|
||||
// matches definitions.json format
|
||||
JSS(ImportVLSequence);
|
||||
JSS(Invalid); //
|
||||
JSS(Issuer); // in: Credential transactions
|
||||
JSS(InvoiceID); // field
|
||||
JSS(LastLedgerSequence); // in: TransactionSign; field
|
||||
JSS(LastUpdateTime); // field.
|
||||
@@ -140,6 +142,7 @@ JSS(HookStateKey); // field.
|
||||
JSS(EmittedTxn); // ledger type.
|
||||
JSS(SignerList); // ledger type.
|
||||
JSS(SigningPubKey); // field.
|
||||
JSS(Subject); // in: Credential transactions
|
||||
JSS(TakerGets); // field.
|
||||
JSS(TakerPays); // field.
|
||||
JSS(Ticket); // ledger type.
|
||||
@@ -201,6 +204,7 @@ JSS(attestations); //
|
||||
JSS(attestation_reward_account); //
|
||||
JSS(auction_slot); // out: amm_info
|
||||
JSS(authorized); // out: AccountLines
|
||||
JSS(authorized_credentials); // in: ledger_entry DepositPreauth
|
||||
JSS(auth_accounts); // out: amm_info
|
||||
JSS(auth_change); // out: AccountInfo
|
||||
JSS(auth_change_queued); // out: AccountInfo
|
||||
@@ -269,6 +273,9 @@ JSS(converge_time_s); // out: NetworkOPs
|
||||
JSS(cookie); // out: NetworkOPs
|
||||
JSS(count); // in: AccountTx*, ValidatorList
|
||||
JSS(counters); // in/out: retrieve counters
|
||||
JSS(credential); // in: LedgerEntry Credential
|
||||
JSS(credentials); // in: deposit_authorized
|
||||
JSS(credential_type); // in: LedgerEntry DepositPreauth
|
||||
JSS(coins);
|
||||
JSS(children);
|
||||
JSS(ctid); // in/out: Tx RPC
|
||||
@@ -693,6 +700,7 @@ JSS(streams); // in: Subscribe, Unsubscribe
|
||||
JSS(strict); // in: AccountCurrencies, AccountInfo
|
||||
JSS(sub_index); // in: LedgerEntry
|
||||
JSS(subcommand); // in: PathFind
|
||||
JSS(subject); // in: LedgerEntry Credential
|
||||
JSS(success); // rpc
|
||||
JSS(supported); // out: AmendmentTableImpl
|
||||
JSS(sync_mode); // in: Submit
|
||||
|
||||
Reference in New Issue
Block a user