4 min read

Board Ark (and ecash mints) with Payjoins

Board Ark (and ecash mints) with Payjoins

In Bark version 0.6.2 we added support for Payjoin boards, which means Bark-based wallet apps now, with a little work, can receive a Payjoin and board the proceeds onto Ark in the same transaction.

It’s been available a couple of weeks already, but we wanted to take a closer look at the feature, describe some of the interesting ways it can be used, and explain how it can be implemented.

Boarding direct from external wallets

Boarding is how on-chain bitcoin gets onto Ark. Until now, in Bark, it took two transactions: one from the user’s other wallet app to their Bark wallet app’s on-chain address, then a second one that Bark builds to board those coins.

With Payjoin boards, the first transaction does both jobs. Any wallet app that can send Payjoin v2 (BIP 77) can pay a Bark wallet app over Payjoin, Bark swaps in the board output and cosigns it, and the sender’s own transaction lands the bitcoin in the Ark balance. This saves the user fees and time.

Bark boards with Payjoin mark the first production deployment of “Transaction Cut-Through” bitcoin has ever seen. That 13-year-old idea, to let users combine multiple dependent transactions into one to save time and fees, awaited some standard way to coordinate. Async Payjoin codifies 2-party coordination, so it lets Bark users net-settle what would be two boarding transactions as one for free.

Dan Gould, Payjoin Dev Kit

An ecash on-ramp with no channel management

Illustration of a Cashu mint receiving an on-chain deposit that lands as a VTXO in an Ark

Cashu mints mostly interface with the bitcoin network over Lightning, so every mint must manage channels and liquidity on top of running the mint. A mint running with Bark as its Lightning backend instead holds its reserve as VTXOs while still receiving and paying out over Lightning, with no channels at all.

Payjoin boards do the same for the mint’s on-chain deposits. Without them, a user’s deposit lands as a UTXO in the mint’s on-chain wallet and the mint pays for a second transaction to board it into Ark. With them, the user’s deposit is the board: one transaction, paid by the user, drops the bitcoin straight into the mint’s Ark balance.

NUT-30 recently brought on-chain payments to Cashu, and using Bark as a backend means a mint can offer both on-chain and Lightning payments from a single balance without the operator having to manage channels or liquidity between the two. The draft NUT-31 adds Payjoin support, which composes nicely with Bark’s recent Payjoin support: what would otherwise require two transactions, depositing into the mint and boarding into Ark, can be combined into a single transaction.

thesimplekid, CDK

The new primitive: board_psbt

The new functionality is enabled by the addition of board_psbt in Bark 0.6.2, a method that lets Bark board from a transaction it did not build. Give it any PSBT paying the board funding address and it cosigns the board against it.

The board_psbt method replaces the now-deprecated board_tx, and the caveats for implementers are set out in the changelog.

Because Bark only needs a PSBT, a board can be composed into an application already built on PDK (Payjoin Dev Kit) and BDK (Bitcoin Dev Kit). PDK negotiates the Payjoin, BDK handles the sender’s wallet, and Bark cosigns the board. They exchange the same PSBT at each step, so none of the three libraries needs code written specifically for the other two.

How a Payjoin board works

In a regular board, the Bark wallet app builds and broadcasts the funding transaction itself, and the Ark server cosigns the exit transaction that spends from it. In a Payjoin board, the sender’s wallet app builds and broadcasts the funding transaction instead, and Bark only swaps in the board output and cosigns it before handing the transaction back:

  1. The receiving Bark wallet app opens a Payjoin v2 session and hands out a payment request with the Payjoin endpoint.
  2. The sender’s wallet app builds the original PSBT paying the receiver’s address and delivers it through the Payjoin directory.
  3. Bark replaces its receiving output with the board funding output and calls board_psbt, which cosigns the board with the Ark server against that exact transaction.
  4. Bark returns the proposal PSBT. The sender signs it and broadcasts it.
  5. After six confirmations, the board VTXO is active in the receiver’s Bark wallet app.

How a Cashu deposit works with Bark

Cashu’s quote protocol wraps the same flow, with the mint as the receiver:

  1. The user’s wallet app asks the mint for an on-chain deposit quote. The mint replies with a bitcoin address and a Payjoin offer.
  2. The wallet app builds the deposit transaction and delivers it to the mint over Payjoin v2.
  3. The mint’s Bark backend replaces its receiving output with the board funding output and calls board_psbt to cosign the board with the Ark server.
  4. The wallet app signs the proposal and broadcasts it.
  5. Once it confirms, the mint holds the deposit as a VTXO and issues the user their ecash.

The mint-side plumbing for the Payjoin offer is in CDK PR #2407.

Shipped in Bark, in draft for Cashu

The board_psbt method shipped in Bark 0.6.2, so any wallet app built on Bark can add Payjoin boards now. On the Cashu side, the Payjoin extension to NUT-30 is a draft spec in cashubtc/nuts#376, and the mint-side implementation is an open draft in CDK PR #2407.

Get started

If you want to add Payjoin boards to a Bark wallet app, start with the Bark docs and the board_psbt entry in the 0.6.2 changelog. Use PDK to run the Payjoin session.

If you run a Cashu mint, you do not need to wait for Payjoin boards to merge. The Bark payment processor for CDK is available to activate Lightning the easy way now.