0034 XLS-34d: Token-Enabled Escrows and Payment Channels #88
Replies: 4 comments
-
While we're making improvements to payment channels, consider XRPLF/rippled#3322 |
Beta Was this translation helpful? Give feedback.
-
Proposed implementation: XRPLF/rippled#4396 |
Beta Was this translation helpful? Give feedback.
-
Hello group: per the new XLS Contributing process, it is my opinion that we have reach a "well-refined standard." As such, I propose that we move this discussion to a file (via #112) and work on final changes using additional PRs, for better change-tracking. Please comment here if you would like to object to moving this spec/discussion forward in the process into a DRAFT spec. (Note that per the Contributing guidelines, moving a spec into the DRAFT state does not mean any kind of endorsement, nor does it mean that this specification will become adopted. It is solely meant as a mechanism to enable better change tracking using PRs.) |
Beta Was this translation helpful? Give feedback.
-
Closing this discussion in order to focus future comments on #112. |
Beta Was this translation helpful? Give feedback.
-
Merged to XLS-34d: Token-Enabled Escrows and Payment Channels
An earlier version of the spec follows:
Token-Enabled Escrows and Payment Channels
The proposed amendment to the XRPL protocol,
PaychanAndEscrowForTokens
, would introduce changes to the ledger objects, transactions, and rpc methods to enableEscrows
andPayChannels
to use Trustline balances.1. Problem Statement
The XRPL supports several types of on-ledger negotiable Instruments, namely:
Escows
,PayChannels
andChecks
. While each of these instruments is implemented as a first-class on-ledger object, only theCheck
object supports the use of Trustline balances.PayChannels
andEscrows
support only the native asset XRP. This limitation is a barrier to wider-spread use of these Instruments for reasons including:2. Constraints
The amendment has the following constraints:
Escrows
to use Trustline balances.PayChannels
to use Trustline balances.3. Implementation
An Instrument can only be created over a Trustline balance if both parties (source and destination):
The destination may not have a Trustline yet. This is not a bar to creating the Instrument provided that a hypothetical Trustline created at the same time the Instrument is created, from the destination account to the Issuer, for the relevant currency, would meet the above requirements.
Settlement of an Instrument (e.g.
EscrowFinish
,PaymentChannelClaim
) carries the same semantics as crossing an offer: If no Trustline exists on the destination side, then a Trustline with zero limit is created and the tokens (balance) are placed into that line. However creation of a Trustline requires the transaction to be signed by the receiving account (because it creates an on-ledger object and increases the Owner Count and thus the XRP reserve locked by the destination account.)3.1. New Field:
LockedBalance
.If all or some of the Trustline balance is locked by a
PayChannel
or anEscrow
then this amount is accounted for in theLockedBalance
field. The Trustline Balance less the Locked Balance is the user's spendable balance for that asset. This may be zero if the whole balance is locked.The rules for the LockedBalance field are as follows:
RippleState
object and no longer takes up space on the ledger.Balance
field.For each Instrument (e.g.
Escrow
,PayChan
) a user holds that locks up some tokens from a Trustline:3.2. New Field:
LockCount
.The LockCount field on a RippleState ledger object indicates the total number of locks held against the balance of the Trustline. This is always exactly the number of Instruments (e.g.
Escrows
,PayChannels
) locking a non-zero amount of the Trustline balance. Adding an additional instrument increments the LockCount. Removing an instrument decrements the LockCount.The LockCount field exists to account for any floating point dust that is left after the final instrument locking a trustline balance is released. If the LockCount reaches zero but the LockBalance is non-zero (typically extrtemely small) then the LockBalance is assumed to be zero, and is thus deleted.
3.3. New Field:
TransferRate
.The TransferRate field on a
PayChannel
orEscrow
ledger object indicates the currentTransferRate
at which the funds are locked.The TransferRate is set at the time of instrument creation and is updated on subsequent funding/settlement events.
The TransferRate always favours the instrument holder. If the TransferRate is better than the current transfer rate for the asset, then settlement will occur at the better rate, and visa versa. If the current transfer rate is higher than the TransferRate then the preceding still applies but in the case of a PayChan no further PaymentChannelFund transactions are allowed.
3.4. The impact on Trustlines.
It is possible an Issuer causes an Instrument that uses some of their issued tokens to become frozen. They can do this by simply freezing their side of their Trustline with either of the parties to the Instrument. This prevents the Instrument from being resolved or cancelled until the freeze is lifted.
Escrows
andPayChannels
in this or any state are a bar to account deletion. Trustlines with LockedBalance (from any source) are also a bar to account deletion.It is posssible for an Issuer to create a
PayChannel
orEscrow
using their own token. The settlement of the Instrument follows the same guidlines as above.4. Final Documentation & SDK Changes
The proposed changes would include modifications to the following ledger objects;
RippleState
PayChannel
Escrow
The propossed changes would include modifications to the following transactions;
PaymentChannelCreate
PaymentChannelFund
PaymentChannelClaim
EscrowCreate
The propossed changes would include modifications to the following rpc methods;
account_lines
account_channels
account_objects
channel_authorize
channel_verify
4.1. Ledger Object Changes
4.1.1.
RippleState
Ledger ObjectThe following fields would be added to the
RippleState
Ledger Object;LockCount
LockedBalance
4.1.2.
PayChannel
Ledger ObjectThe following fields would be modified on the
PayChannel
Ledger Object;Amount
Balance
TransferRate
4.1.3.
Escrow
Ledger ObjectThe following fields would be modified on the
Escrow
Ledger Object;Amount
TransferRate
4.2. Transaction Changes
4.2.1.
PaymentChannelCreate
transactionThe following fields would be modified on the
PaymentChannelCreate
transaction;Amount
4.2.2.
PaymentChannelFund
transactionThe following fields would be modified on the
PaymentChannelFund
transaction;Amount
4.2.3.
PaymentChannelClaim
transactionThe following fields would be modified on the
PaymentChannelClaim
transaction;Balance
Amount
4.2.4.
EscrowCreate
transactionThe following fields would be modified on the
EscrowCreate
transaction;Amount
4.3. RPC Method Changes
4.3.1.
account_lines
methodEach
RippleState
Object has the following field added to theaccount_lines
method:LockedBalance
LockCount
4.3.2.
account_channels
methodEach
PayChannel
Object has the following fields updated on theaccount_channels
method:Amount
Balance
TransferRate
4.3.3.
account_objects
methodEach
Escrow
Object has the following fields updated on theaccount_objects
method:Amount
TransferRate
4.3.4.
channel_authorize
methodThe request includes the following updated fields for the
channel_authorize
method:Amount
4.3.5.
channel_verify
methodThe request includes the following updated fields for the
channel_verify
method:Amount
Beta Was this translation helpful? Give feedback.
All reactions