Guides › XRP

Locks and scheduled payments

Lock XRP until a date, pay someone later, or set up an allowance.

Simple

XRP tools → Savings lock, scheduled & timed payments lets you put XRP in a locked box on the XRP Ledger itself. You can choose:

  • Savings lock: put your own XRP away until a date. Nobody can spend it before then, not even you.
  • Claim by a deadline, or future gift: lock XRP for someone. With a deadline they must collect it in time, or it comes back to you. A future gift can be collected from a date you choose.
  • Scheduled payment or allowance: pay someone once on a future day, or regularly, like pocket money. You can cancel any payment until it has been paid.

Savings locks, deadlines and gifts can't be undone, so check the amount, date and person before you confirm. Each open lock sets aside 0.2 XRP of your deposit until it's settled, and Kalda lets you know when someone locks XRP for you.

Detailed

Escrow on the XRP Ledger

Escrow is built into the XRP Ledger. Creating one moves XRP out of your spendable balance into a ledger object that names a recipient and the rules for release. From then on the XRP is held by the network itself, not by any company. An escrow can have:

  • A finish time: before it, nobody can release the escrow. After it, anyone may submit the release, but the XRP can only ever go to the named recipient.
  • A cancel time (optional): after it, the escrow can no longer be released, and anyone may send the XRP back to its owner. Before it, not even the owner can take it back.
  • A crypto-condition (optional): a lock that opens only when a matching secret is shown. It lets a payment be prepared in advance yet released only if its sender chooses to.

Reserves and limits

Each open escrow holds one owner reserve (0.2 XRP today) on the sender's account until it's finished or cancelled, so an allowance of ten payments sets aside 2 XRP. The ledger judges every time by its own clock: the agreed close time of each validated ledger. Escrow of tokens is only possible when the token's issuer allows it, and RLUSD's issuer doesn't, so locks hold XRP.

A family or business wallet can lock XRP too. Like any spend from that wallet, the lock needs its co-signers' approval first.

In depth

Time locks

A time lock is a rule in the ledger's state machine: a transaction that releases the funds is valid only if the ledger's agreed time is past a given point. Every validator applies the same rule to the same agreed timestamp, so no single party, the sender included, can override it.

Hash locks and crypto-conditions

A cryptographic hash function such as SHA-256 maps any input to a fixed 256-bit fingerprint. It's easy to compute forwards, infeasible to reverse, and infeasible to make two inputs share a fingerprint. A hash lock publishes the fingerprint and opens for whoever presents an input (the preimage) that hashes to it:

condition = SHA-256(preimage)        opens ⇔ SHA-256(presented) = condition

The XRP Ledger follows the Crypto-Conditions standard written for the Interledger Protocol and supports its PREIMAGE-SHA-256 type. Presenting the preimage makes it public, so each hash lock opens only once.

Hashed time-locked contracts

Combining a hash lock with a time-out gives a hashed time-locked contract (HTLC): either the secret is revealed before the deadline and the funds move forward, or the deadline passes and they go back. HTLCs make a payment all-or-nothing without trusting a middleman, which is why they underpin payment channels, the Lightning Network and atomic swaps between different blockchains.

Reserves as a price for state

Every object in the ledger's current state must be kept by every validator. A refundable deposit per object puts a price on that storage, and returning the deposit when the object is removed rewards cleaning up.