Skip to content

XLS 85d: Token Escrow #3027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ci-config/rippled.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ fixInvalidTxFlags
# 2.5.0 Amendments
PermissionDelegation
Batch
TokenEscrow

# This section can be used to simulate various FeeSettings scenarios for rippled node in standalone mode
[voting]
Expand Down
3 changes: 2 additions & 1 deletion packages/ripple-binary-codec/src/types/uint-64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ function useBase10(fieldName: string): boolean {
return (
fieldName === 'MaximumAmount' ||
fieldName === 'OutstandingAmount' ||
fieldName === 'MPTAmount'
fieldName === 'MPTAmount' ||
fieldName === 'LockedAmount'
)
}

Expand Down
3 changes: 3 additions & 0 deletions packages/xrpl/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xr
### Fixed
* Fix `AccountRoot` ledger object to correctly parse `FirstNFTokenSequence` field.

### Added
* Implement support for XLS-85d Token Escrow amendment.

## 4.3.0 (2025-6-09)

### Added
Expand Down
11 changes: 11 additions & 0 deletions packages/xrpl/src/models/ledger/AccountRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ export interface AccountRootFlagsInterface {
* This address can claw back issued IOUs. Once enabled, cannot be disabled.
*/
lsfAllowTrustLineClawback?: boolean

/**
* If the issuer's account does not have the lsfAllowTrustLineLocking flag set,
* then Escrow ledger-objects cannot be created with such IOUs.
*/
lsfAllowTrustLineLocking?: boolean
}

export enum AccountRootFlags {
Expand Down Expand Up @@ -210,4 +216,9 @@ export enum AccountRootFlags {
* This address can claw back issued IOUs. Once enabled, cannot be disabled.
*/
lsfAllowTrustLineClawback = 0x80000000,
/**
* If the issuer's account does not have the lsfAllowTrustLineLocking flag set,
* then Escrow ledger-objects cannot be created with such IOUs.
*/
lsfAllowTrustLineLocking = 0x40000000,
}
15 changes: 14 additions & 1 deletion packages/xrpl/src/models/ledger/Escrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export default interface Escrow extends BaseLedgerEntry, HasPreviousTxnID {
* successful.
*/
Destination: string
/** The amount of XRP, in drops, to be delivered by the held payment. */
/** The amount to be delivered by the held payment. Can represent XRP, an IOU token, or an MPT.
* Must always be a positive value. */
Amount: string
/**
* A PREIMAGE-SHA-256 crypto-condition, as hexadecimal. If present, the
Expand Down Expand Up @@ -61,4 +62,16 @@ export default interface Escrow extends BaseLedgerEntry, HasPreviousTxnID {
* this object, in case the directory consists of multiple pages.
*/
DestinationNode?: string

/**
* The transfer rate or fee at which the funds are escrowed, stored at creation
* and used during settlement. Applicable to both IOUs and MPTs.
*/
TransferRate?: number

/**
* (Optional) The ledger index of the issuer's directory node associated with
* the Escrow. Used when the issuer is neither the source nor destination account.
*/
IssuerNode?: number
}
3 changes: 3 additions & 0 deletions packages/xrpl/src/models/ledger/MPToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ export interface MPToken extends BaseLedgerEntry, HasPreviousTxnID {
MPTAmount?: MPTAmount
Flags: number
OwnerNode?: string

// (Optional) The total of all outstanding escrows for this issuance.
LockedAmount?: string
}
3 changes: 3 additions & 0 deletions packages/xrpl/src/models/ledger/MPTokenIssuance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ export interface MPTokenIssuance extends BaseLedgerEntry, HasPreviousTxnID {
TransferFee?: number
MPTokenMetadata?: string
OwnerNode?: string

// (Optional) The total of all outstanding escrows for this issuance.
LockedAmount?: string
}
2 changes: 2 additions & 0 deletions packages/xrpl/src/models/transactions/accountSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export enum AccountSetAsfFlags {
asfDisallowIncomingTrustline = 15,
/** Permanently gain the ability to claw back issued IOUs */
asfAllowTrustLineClawback = 16,
/** Issuers allow their IOUs to be used as escrow amounts */
asfAllowTrustLineLocking = 17,
}

/**
Expand Down
16 changes: 10 additions & 6 deletions packages/xrpl/src/models/transactions/escrowCreate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ValidationError } from '../../errors'
import { Amount, MPTAmount } from '../common'

import {
Account,
Expand All @@ -18,11 +19,12 @@ import {
export interface EscrowCreate extends BaseTransaction {
TransactionType: 'EscrowCreate'
/**
* Amount of XRP, in drops, to deduct from the sender's balance and escrow.
* Once escrowed, the XRP can either go to the Destination address (after the.
* FinishAfter time) or returned to the sender (after the CancelAfter time).
* The amount to deduct from the sender's balance and and set aside in escrow.
* Once escrowed, this amount can either go to the Destination address (after any Finish times/conditions)
* or returned to the sender (after any cancellation times/conditions). Can represent XRP, in drops,
* an IOU token, or an MPT. Must always be a positive value.
*/
Amount: string
Amount: Amount | MPTAmount
/** Address to receive escrowed XRP. */
Destination: Account
/**
Expand Down Expand Up @@ -62,8 +64,10 @@ export function validateEscrowCreate(tx: Record<string, unknown>): void {
throw new ValidationError('EscrowCreate: missing field Amount')
}

if (typeof tx.Amount !== 'string') {
throw new ValidationError('EscrowCreate: Amount must be a string')
if (typeof tx.Amount !== 'string' && typeof tx.Amount !== 'object') {
throw new ValidationError(
'EscrowCreate: Amount must be a string (XRP) or object (IOU or MPT)',
)
}

validateRequiredField(tx, 'Destination', isAccount)
Expand Down
Loading
Loading