DocsSpend and withdraw

DocsGuides19 of 33 · 2 min read

Spend and withdraw

Pay a received payment onward, or withdraw private balance to a public wallet.

Everything in your private balance is spent the same way, whether it came from a deposit or from a payment to you. There are two things to do with it: pay another whitelisted recipient, or withdraw to a public wallet.

You need to be unlocked. Both cost the two flat fees, taken from the balance.

#Pay onward

Paying onward is an ordinary payment. Your device chooses which notes to spend, and a note that reached you at a stealth address is spent with its one-time key, which only you can compute.

In the app, a row under Received on Receive has a Pay onward button that opens the Pay form.

On chain, the onward payment names the owner address of each note it spends and creates a note at a new stealth address. A reader can see that the payment at your stealth address was spent. The reader does not learn who held it or who was paid next.

#Withdraw

A withdrawal sends SOL out of the Ring to a wallet you name. The destination and the amount are public. The relayer submits it and pays the network fee.

App

On /app, under Move funds, choose Withdraw. Enter the destination wallet and the amount in SOL, and press Withdraw. Your device proves and the relayer sends. No wallet approval is asked.

A row under Received on Receive has a Withdraw button that leads to the same form.

SDK

ts
const result = await liora.withdraw(
  { destination: wallet.address, assetId: "1", amountLamports: "100000000" },
  (state) => render(state),
);

It reports pending, sent and then confirmed or failed.

CLI

bash
liora withdraw 42iGKxoSijMn7Gk6SXgNYZnofBoCWpyzhF6fvzfhnzz9 100000000 --keypair payer.json
state  confirmed
kind  withdraw
signature  326mDxiJNRHYL2wgCPAPe9mQ3KFsn4Mc47qVBcfYGgfvBd7vSHaoWPMJE2DSQY26GKc9c7NRexQ7kDTXzs6fKViA

#What a withdrawal shows

PublicHidden
The destination walletWho paid the notes being spent
The amount paid outThe amounts of those notes
The owner address of each note spentWhat remains in your balance
The two fees

A withdrawal therefore connects the notes it spends to the wallet it pays. Withdrawing a received payment shows that the payment at that stealth address was paid out to that wallet. Paying onward keeps the value inside the Ring.

The proof binds the destination and the amount, so the relayer cannot change either.

What you do not withdraw stays in the Ring as change, at the owner address of the first note spent.

#If it fails

What you seeWhyNext
INSUFFICIENT_BALANCEThe spendable notes do not cover the amount and both feesWithdraw less
VALIDATION_ERRORThe destination is not a Solana address, or the amount is zeroCorrect it
INPUT_SPENTA note in this transfer was spent by another transfer of yours, or one that spends it is still pendingWait for the pending one, scan, then withdraw again
CONFIRMATION_FAILEDThe transaction was sent and failedThe notes are unspent. Withdraw again