0092 XLS-92d: XRPL Sub-accounts #283
Replies: 4 comments 7 replies
-
I may be misunderstanding your point here, but payment tags are 32-bits, which allows for over 4 billion options. But if you're talking about self-custody accounts, yeah, we wouldn't want 4 billion of those. Other thoughts:
|
Beta Was this translation helpful? Give feedback.
-
What about the ledger size aspect used in one incremental reserve? |
Beta Was this translation helpful? Give feedback.
-
This sounds great at the surface, how does the amendment encourage exchanges to use this? We also saw something similar in the past with x addresses but no one was incentivized to adopt the newer standard... |
Beta Was this translation helpful? Give feedback.
-
@sappenin Is there any progress on this? We're working on a project where we could leverage this feature on XRPL than creating one fat wallet and manage everything via tags. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
1. XRPL Sub-Accounts
1.1. Abstract
XRPL Sub-accounts enable a single XRPL account to track on-ledger balances representing tokens owned by a public-key/r-address. By enabling this type of sub-account balance tracking, the ledger can also optionally enable balance transfers
at the sub-account level using transactions signed by the private-key of any particular sub-account.
Today's XRPL ledger uses source and destination
tags to
help off-ledger entities track the balances of their customers whenever an on-ledger payment occurs. However,
these tagging mechanisms do not support hybrid-custody scenarios, where funds might sit on-ledger while being
available to both the custodian and the account holder at the same time (i.e., to enable end-user control, and to
provide 100% transparency to custodial customers that funds are not co-mingled with any other custodian assets).
Likewise, payment tags do not enable the XRP Ledger to support a very large number of self-custody accounts, because
today's account are somewhat large (from a space-on-ledger perspective) and somewhat expensive (from an account reserve
perspective). By enabling token custody and payments using very small -- with reduced functionality -- on-ledger
sub-accounts, this specification seeks to simultaneously reduce storage requirements for simple accounts while also
allowing for enhanced user-trust in institutional DeFi service providers.
1.2. Overview
XRPL Account owners use sub-accounts to track balances for entities that control their own private key
material.
1.2.1. Goals
1.2.2. Terminology
Sub-Account
: An on-ledger object that is associated with a parent account and tracks a balance for a single publickey.
Sub-Account Page
: A collection of sub-account balances tracked in an aggregate form to reduce space on-ledger.Account Owner
: An entity that controls a private key corresponding to an XRP Ledger account.Sub-Account Owner
: An entity that controls a private-key that has been associated with a particular XRPLAccount
to form a sub-account.1.2.3. Example Use-cases
The following are example usages of XRPL Sub-accounts:
control the agent's discrete portion of the overall omnibus balance. This saves account reserves by making each
sub-account balance less expensive to track, while still allowing independent payments into and out of each sub-account
using discrete private keys.
funds that are accessible to a centralized entity like an exchange, stablecoin issuer, or otherwise. It is envisioned
that this use-case would likely require some of the ideas presented
in XLS-83d: Passkey Signature Support.
independetly need full account capabilities.
(i.e., either key-holder can potentially execute funds transfers). Useful for transparency purposes by allowing
end-users to independently verify on-chain balances to ensure that a custodian is not co-mingling funds or
otherwise putting funds at risk.
1.2.4. Protocol Flow
1.2.4.1. Initial Setup
We assume that a centralized entity (e.g., ExchangeCo) has one or more Ed25519 private keys that
allow it to control its own accounts on the XRP Ledger.
1.2.4.1.1. ExchangeCo
balance of zero).
1.2.4.1.2. ExchangeCo Customer (End-User)
For purposes of this document, this passkey is known as the
authentication_key
, allowing the user to control a (non-ledger) account at ExchangeCo using a private key that is bound both to the ExchangeCo website and the device the
user used to register with ExchangeCo[1].
siging_key
) is created on the user's device. This passkey is used for signing XRPLtransactions, and is likewise registered with ExchangeCo. Note that ExchangeCo may allow multiple signing keys to be
created.
on-device, or off-device, for example in a Yubikey or Ledger Nano).
siging_key
, ExchangeCo will derivean XRPL address using the sub-account's public key.
CreateSubAccount
transaction to the XRPL, whichwill register the end-user's signing-key as controlling a sub-account in ExchangeCo's omnibus account on the XRPL.
actually having an on-ledger account.
1.2.4.2. Payment Flow Examples
1.2.4.2.1. Example: End-user Moves Value Out of a Sub-account
In this example, an end-user with a phone wants to move 10 XRP out of their sub-account held with ExchangeCo.
The user assembles an XRPL payment
transaction.
Account
is the 20-byte address of ExchangeCo.SubAccount
(a new field proposed to be added to apayment
) is the 20-byte address of the sub-account.SigningPubKey
is the public key corresponding toSubAccount
.Destination
field works per-usual, and indicates where a payment should be sent.The SubAccount user signs the transaction using the pre-registered sub-account
signing_key
stored on theirphone/device, and publishes the signed transaction to the XRPL.
The payment transactor detectes that a
SubAccount
has been specified in the payment, so it searches for the correctSubAccountCollection
page using an algorithm similar to that defined in XLS-20.tfCustodial
flag is set buttfNonCustodial
is unset, then the transaciton is valid only if signed bythe
Account
private key. In this case, the transaction fails because it was signed by theSubAccount
, but paymentsmay only be executed by the custodian (i.e., the
Account
).tfCustodial
flag is unset, buttfNonCustodial
is set, then the transaciton is valid only if signed bythe
SubAccount
private key. In this case, the transaction is valid and succeeds if the balance is sufficient.tfCustodial
andtfNonCustodial
flags are set, then the transaction is valid if signed by eitherthe
Account
orSubAccount
private key. In this case, the transaction is valid and succeeds if the balanceis sufficient.
(Note that one flag or both must be set in order for a SubAccountCollection to be created).
1.2.4.2.2. Example: ExchangeCo Moves Value Out of a Sub-account
In this example, ExchangeCo wants to move 10 XRP out of a sub-account under their control (e.g., in response to an
exchange order to sell XRP).
transaction.
Account
is the 20-byte address of ExchangeCo.SubAccount
(a new field proposed to be added to apayment
) is the 20-byte address of the sub-account.SigningPubKey
is the public key corresponding toAccount
.Destination
field works per-usual, and indicates where a payment should be sent.SubAccount
has been specified in the payment, so it searches for the correctSubAccountCollection
page using an algorithm similar to that defined in XLS-20.tfCustodial
flag is set buttfNonCustodial
is unset, then the transaciton is valid only if signed bythe
Account
private key. In this case, the transaction is valid and succeeds if the balance is sufficient.tfCustodial
flag is unset, buttfNonCustodial
is set, then the transaciton is valid only if signed bythe
SubAccount
private key. In this case, the transaction fails because it was signed by theAccount
, but paymentsmay only be executed by the
SubAccount
.tfCustodial
andtfNonCustodial
flags are set, then the transaction is valid if signed by eitherthe
Account
orSubAccount
private key. In this case, the transaction is valid and succeeds if the balanceis sufficient.
1.2.4.2.3. Example: Move Value Into a Sub-account
In this example, a regular account signer wants to send 10 XRP into a sub-account held with ExchangeCo.
assembled with the following:
Account
andSigningPubKey
(assuming single-sig) work per-usual for the sender of funds.Destination
field works per-usual, and is the 20-byte address of ExchangeCo.SubAccountDestination
specifies the address of the sub-account.The
SubAccountDestination
is a new field that, if persent, is used to locate the sub-account to credit funds to.1.3. On-Ledger Data Structures
We propose two new objects and one new ledger structure:
SubAccountCollection
is a is a new object that describes an overall collection of balances tracked by anaccount.
SubAccount
is a new object that describes a balance owned by a public-key.SubAccountPage
is a ledger structure that contains a set ofSubAccount
objects contained inside aSubAccountCollection
.1.3.1. The
SubAccountCollection
objectThe
SubAccountCollection
object represents a collection of sub-accounts and their associated data.SubAccountCollections are created using the
SubAccountCollectionCreate
transaction and can be destroyed using theSubAccountCollectionDelete
transaction, if certain conditions are met.1.3.1.1.
SubAccountCollection
IdentifierThe identifier of a SubAccountCollection is defined as a
SubAccountCollectionID
, and is the result of SHA512-Halfof the following values, concatenated in order:
1.3.1.2. Fields
SubAccountCollection
objects are stored in the ledger and tracked inan Owner Directory owned by the collection creator. These collections
have the following required and optional fields:
LedgerEntryType
number
UINT16
Flags
number
UINT32
Account
string
ACCOUNTID
Issuance
object
STIssue
TransferFee
number
UINT16
PreviousTxnID
string
HASH256
PreviousTxnLgrSeq
number
UINT32
OwnerNode
number
UINT64
1.3.1.3.1.
LedgerEntryType
The value
0x009E
, mapped to the stringSubAccountCollection
, indicates that this object describes aSubAccountCollection.
1.3.1.3.2.
Flags
Flags for a
SubAccountCollection
.1.3.1.3.2.1. SubAccountCollection Flags
tfCustodial
0x0001
tfNonCustodial
0x0020
Note that shared-custody (also known as hybrid-custody) can be enabled by setting both flags.
1.3.1.3.3.
Account
The Account that owns this collection.
1.3.1.3.4.
Issuance
An
STIssue
that uniquely identifies the token type for balances tracked by this collection. For Issued Currencies, this will contain the currency code and issuer address (approx 40 bytes). For MPTs, this will contain anMPTokenIssuanceID
(approximately 24 bytes). Note that in any single account, there must be a distinctSubAccountCollection
for each token type.1.3.1.3.5.
TransferFee
This value specifies the fee, in tenths of a basis point, charged by
the omnibus account owner for transfers out of sales of the omnibus account (if such transfers are allowed at all).
Valid values for this field are between 0 and 50,000 inclusive. A value of 1 is equivalent to 1/10 of a basis point or
0.001%, allowing transfer rates between 0% and 50%. A TransferFee of 50,000 corresponds to 50%. The default value for
this field is 0. Any decimals in the transfer fee will be rounded down, hence the fee can be rounded down to zero if the
payment is small.
1.3.1.3.6.
PreviousTxnID
The identifying hash of the transaction that most recently modified this object.
1.3.1.3.7.
PreviousTxnLgrSeq
The index of the ledger that contains the transaction that most recently modified this object.
1.3.1.3.8.
OwnerNode
Identifies the page in the owner's directory where this item is referenced.
1.3.1.4. Examples
This section contains example
SubAccount
objects.1.3.1.4.1. Example
SubAccountCollection
JSON1.3.2. The
SubAccount
Ledger ObjectThis structure defines a single sub-account.
1.3.2.1. Fields
SubAccount
objects have the following required and optional fields:SubAccount
string
ACCOUNTID
Balance
number
UINT64
Sequence
number
UINT32
1.3.2.2.1.
SubAccount
The address of the sub-account.
1.3.2.2.2.
Balance
An
STAmount
representing the amount of token (XRP/MPT/IOU) that this sub-account currently holds.1.3.2.3. Examples
This section contains example
SubAccount
objects.1.3.2.3.1. Example
SubAccount
JSON1.3.3. The
SubAccountPage
objectTODO: See
XLS-20d
1.4. Transactions
This proposal introduces several new transactions to allow for the creation and deletion of SubAccounts.
All transactions introduced by this proposal incorporate
the common transaction fields that are shared by all transactions.
Common fields are not documented in this proposal unless this proposal introduces new possible values for such fields.
1.4.1. The
SubAccountCreate
TransactionTODO (only allowed by the owner of the SubAccount)
1.4.2. The
SubAccountDelete
TransactionTODO (only allowed if the account is empty)
1.4.1. The
SubAccountCollectionCreate
TransactionTODO
1.4.2. The
SubAccountCollectionDelete
TransactionTODO (only allowed if there are no sub-accounts)
1.4.3. Changes to
Payment
TransactionThis specification proposes adding a
SubAccount
field to the Payment transaction. This field mirrors theAccount
field, as follows:
SubAccount
string
ACCOUNTID
2. Footnotes
Passkeys here, and consult this
discussion here as well for some
of the nuances.
3. Appendices
3.1. Appendix: Non-normative Examples
This appendix contains non-normative descriptions of various example use-cases.
3.1.1. Example: TBD
TBD
3.2. Appendix: FAQs
This appendix answers frequently asked questions (FAQs) relating to this specification.
3.2.1. Why not use LiteAccounts?
This proposal requires fewer bytes on-ledger for each sub-account (sub-accounts require ~32 bytes compared to ~87 bytes
for Lite Accounts). In addition, Lite Accounts cost 1 owner reserve per account. SubAccounts, on the other hand, should cost approx 1/32 of the base reserve.
3.2.2. What are the benefits of hybrid-custody sub-accounts?
Hybrid custody sub-accounts allow both a custodian (e.g., an exchange) and an account holder to simultaneously control
funds; i.e., either key-holder can potentially execute funds transfers.
This is useful for transparency purposes and also allows end-users to independently verify on-chain balance to ensure that
a custodian is not co-mingling funds or otherwise putting funds at risk. In this way, if an account holder ever wants to
move funds out of an exchange's omnibus account, that end-user always has full control over their own funds. At the same
time, the centralized entity can also move funds out of the shared account and into a transactional account to ensure
proper funding of any transactions initiated by the account holder.
3.2.3. Doesn't existing multisig already enable hybrid-custody?
Yes, it does (hybrid-custody is equivalent to a 1-of-2 multisig). However, today's XRPL full-accounts are expensive, both from a ledger-space perspective and historically also from a reserves perspective. Until recently, every new account on the XRPL cost 10 XRP. While the base reserve is now only 1 XRP, sub-accounts cost 1/32nd of the owner reserve (currently 0.2 XRP) meaning each new sub-account balance should cost approximately 0.00625 XRP.
3.2.4 Does a Sub-account have less capability/functionality than a regular account?
Yes, much less. That's the tradeoff this document is proposing: a less-functional account primitive that only tracks a balance and allows for value movement, in exchange for much lower fees and fewer required on-ledger resources.
Beta Was this translation helpful? Give feedback.
All reactions