Skip to content
sattle-techPublic

About

Split expenses and settle up over Bitcoin Lightning. Only one person needs the app.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

443 Commits

Folders and files

Repository files navigation

Sattle

Split expenses with friends and settle up over Bitcoin Lightning or UPI. Nobody else needs to install anything.

Try it at sattle.tech. The Android build is attached to each GitHub release.

Watch the 1:43 demo video: one person with the app, a friend paying from a plain browser, and the group rebuilt from Nostr. It was recorded on a local server, so the payment in it is simulated.

A monorepo: an Expo (React Native) app for Android and web (iOS builds from the same code but hasn't been released), a Node API on SQLite, and the domain package both of them share. The app runs against either an in-memory mock or the real API; one env var switches between them.

Quick start

Requires Node 24+. The API uses the built-in node:sqlite and, for Nostr relays, the built-in WebSocket. On Node 22 that WebSocket reports an error again when a failing connection is closed, which sends nostr-tools into a loop that overflows the stack and takes the whole server down whenever a relay refuses a connection. CI runs on 24.

git clone https://github.com/sattle-tech/sattle.git
cd sattle
npm install
cp apps/mobile/.env.example apps/mobile/.env
cp apps/api/.env.example apps/api/.env

npm run dev        # API on :3000 + web app on :8081, wired together
npm run web        # web app alone, against the in-memory mock
npm run api        # API alone

npm run web is demo mode: it opens on seeded groups, and the tab bar adds a Guest link tab showing the pay page someone gets when they pay a debt from a group's link. Against the real API (npm run dev, or any build without EXPO_PUBLIC_USE_MOCK=true), the app first asks your name and which currencies you use, makes a device account, asks your UPI ID if you ticked rupees, and you start with no groups. Then comes a three-screen tour: splitting, that only one of you needs the app, and the ways to settle up. It is shown once per device; Skip leaves it. Demo mode has no account to make, so it opens on the tour. Then, on the groups list, an account with nowhere yet to be paid is asked where, once: the demo's Yash is, in a browser. Skip leaves that too.

Try these flows:

  • Goa trip → Pay (Om). Om has the app. The payment goes from created to in_flight to confirmed, and the balance changes only once the proof arrives.
  • Goa trip → Options (Aman). Aman never installed the app. The sheet names him and offers three fixes. If you paste an invoice, it gets rejected. If you paste aman@walletofsatoshi.com, it's accepted.
  • Add expense. A live preview shows each person's share, including where the leftover paisa goes.
npm test           # core ledger tests + API route tests (vitest)
npm run e2e        # the web app in a headless browser against the real API (Playwright)
npm run typecheck  # all workspaces
npm run db:reset -w @sattle/api   # wipe the API database; it reseeds on next start

Configuration

apps/mobile/.env:

Variable Default Meaning
EXPO_PUBLIC_USE_MOCK false true swaps in the in-memory mock with its demo data and fake wallet. .env.example sets it; npm run dev overrides it to false
EXPO_PUBLIC_MOCK_LATENCY 400 ms added to every mock call
EXPO_PUBLIC_MOCK_FAILURE_RATE 0 0–1 chance any mock call fails
EXPO_PUBLIC_MOCK_ALWAYS_FAIL false true makes every mock payment end in failed
EXPO_PUBLIC_API_URL http://localhost:3000 real backend base URL
EXPO_PUBLIC_APP_URL http://localhost:8081 base for the links the app shares
EXPO_PUBLIC_APP_VERSION app.json's version what the app says it is when it reports how it's used. The release builds set it: the version tagged, pr-<number>, or web-<commit>

apps/api/.env:

Variable Default Meaning
PORT 3000
DATABASE_PATH data/sattle.db SQLite file, relative to apps/api
SEED false true loads the demo fixtures into an empty database. Leave unset in production
DEMO_USER_ID u-yash requests without a bearer token act as this user. Dev only
CORS_ORIGIN http://localhost:8081 comma-separated, * when empty
PAYMENTS sim nwc gets real invoices from payees' connected wallets or their own Lightning addresses; anything else simulates. A production server warns at startup without nwc
ALLOW_SIMULATED_PAYMENTS true says a production server simulates on purpose, for a public demo, and silences that warning
LIGHTNING_NETWORK bc network address invoices must be on: bc mainnet, tbs signet, tb testnet, bcrt regtest
LEDGER_RELAYS empty comma-separated relays the group ledger is published to. Empty: entries are signed and kept, not sent. See The ledger on Nostr
RATE_FALLBACK_INR_PER_BTC unset fixed rate used only if no price source (CoinGecko, Blockchain.com, Coinbase) has ever answered. Unset, that payment fails instead
SIM_* timings, rate and forced failure for the simulated payment backend

Layout

packages/core/src/           @sattle/core: pure, no I/O, imported by both app and API
  types.ts                   Domain vocabulary. Member ≠ User. Debt is in the group's currency.
  currency.ts                The currencies a group can be kept in, and how an amount in each is typed and shown.
  formats.ts                 Number and date formats, made once each and kept: making one costs fifty times using one.
  ledger.ts                  Pure maths: splits, balances, and who pays whom, simplified or not.
  history.ts                 A group's history, read off its expenses, the changes to them, its settlements and its log.
  settlementOptions.ts       Resolves what's possible BEFORE the user taps, from the ways to pay the payer uses.
  quote.ts                   What a debt comes to in sats: a pinned rate for rupees, none for a group kept in bitcoin. 90s TTL.
  payLinks.ts                Guest-safe settlement view, NWC method lists.
  groupLinks.ts              The /g/<token> and /join/<token> paths, and finding the link's token in what someone pasted.
  expenseRules.ts            Who may change or remove an expense. The app and the server both ask it.
  groupRules.ts              Who may delete a group, and when someone may leave one. The app and the server both ask it.
  lightningAddress.ts        Parses what people paste. An address is not an invoice.
  upi.ts                     UPI: parsing an ID, the upi://pay link, and reading what a UPI app hands back.
  nostrLedger.ts             Reading a group's ledger back from Nostr events with its backup key. Imported as @sattle/core/nostrLedger, so only what reads it pulls in nostr-tools.
  analytics.ts               What the app reports of how it is used: the event and batch shapes, and the limits the server holds a batch to.
  fixtures.ts                Seed data covering all three member states.
  ledger.test.ts             Run before touching ledger.ts.

packages/e2e-web/            @sattle/e2e-web: the web app in a browser against the real API. See Browser tests.
  playwright.config.ts       Starts both servers, exports the app, runs headless Chromium as a phone.
  src/fixtures.ts            device, person and api: a browser in a given state, a signed-in account in one, the API spoken to directly.
  src/actions.ts             The screens, driven the way a person drives them.
  tests/                     One file per area: onboarding, groups, expenses, settling, links, pay links, UPI, the API itself.

apps/api/src/                @sattle/api: Hono + node:sqlite
  server.ts                  Boot, env, and the payment backend choice.
  app.ts                     Assembly: CORS, auth, errors, route modules.
  routes/                    One module per owner: groups, settlements, payLinks, groupLinks, joining, wallet, ledger, history, upi, analytics, sync.
  middleware.ts              Auth (with the public /s/, /g/, /join/ and /analytics/ prefixes), idempotency, and the request log.
  settlementRules.ts         Debt cap and in-progress checks every settle route shares.
  groupRules.ts              Who may change or remove what: expenses, members, groups, accounts.
  repo.ts                    Row ↔ domain mapping. Only domain types leave it.
  db.ts                      Migration runner and seeding.
  migrations/                NNN_name.sql, applied in order. Add files; never edit merged ones.
  payments.ts                Payment seam, and SimulatedPayments for dev and demos.
  payments/lightning.ts      Real payments: invoices on the payee's NWC wallet or Lightning address, confirmed by lookup, LUD-21 verify or proof.
  nwc.ts                     NIP-47 client: get_info, make_invoice, lookup_invoice.
  lnurl.ts                   LNURL-pay client: an invoice from a Lightning address, checked before it's used.
  bolt11.ts                  Reads an invoice's payment hash, amount, description hash and expiry.
  safeFetch.ts               Every request to a typed address: https only, no private IPs, no redirects, capped.
  proof.ts                   Checks a preimage against the payment hash.
  rates.ts                   Live BTC price from CoinGecko, Blockchain.com or Coinbase, cached 30s.
  backup.ts                  Database backups: before every deploy, or by hand.
  nostrLedger.ts             The ledger on Nostr: signing, encrypting and publishing entries. Reading them back is in core.
  scripts/ledgerVerify.ts    Rebuilds a group's balances from relays alone.
  app.test.ts                Route tests against an in-memory database.
  contract.test.ts           Auth boundary and migrations.

apps/mobile/                 @sattle/mobile: Expo
  App.tsx                    Routes /s/<token> to the guest page, /g/<token> to the group page, /join/<token> to joining and /restore to restoring; otherwise the app.
  modules/in-app-updates/    Local Expo module (Kotlin): Google Play in-app updates.
  modules/app-store-updates/ Local Expo module (Swift): what this iPhone install is, and its App Store page in a sheet.
  modules/upi-apps/          Local Expo module (Kotlin): the phone's UPI apps, and opening one on a link or plain.
  src/
    account/
      tokenStore.ts          Where the device keeps its account token. SecureStore on native, localStorage on web.
      signInKey.ts           The token as a sign-in key, to copy to another device and paste there.
    analytics/
      tracker.ts             What the app reports of how it is used, queued and sent in batches. No React Native, so it runs under vitest.
      analytics.ts           The app's tracker: where to post, who's signed in, which install, and the app going to the background and back.
      useScreenView.ts       The hook at the top of every screen, sheet and page: this is showing.
      deviceStore.ts         This install's id for that. SecureStore on native, localStorage on web.
    ledger/
      readBack.ts            Fetches a group's entries from relays and reads them with its backup key. Loaded only when someone restores.
    client/
      SattleClient.ts        The interface. The only seam.
      MockClient.ts          In-memory, with latency and failure injection.
      ApiClient.ts           HTTP client for apps/api. Reads give up after 15 s, writes after 20.
    data/
      AppData.ts             What the app knows: the last GET /sync, kept on the device, with the user's own changes laid over it. See Opening at once.
      changes.ts             Those changes: an expense added, changed or deleted here, shown before the server has it.
      views.ts               What the groups list and a group's screen show, worked out from that.
      useAppData.ts          The screens' hooks into it, each redrawing only when what it reads changes.
      reads.ts               The reads the sync doesn't carry (a group's history, its link, who to pay by UPI, a link's pages), each named once: what the screen that shows one and the screen that reads it ahead both go by.
      carriedRead.ts         One read carried across a page load on the web, in sessionStorage: the join page's list, from the group's page.
      savedStore.ts          Where the copy lives between launches: the server's answer in the cache folder on native, the changes still to send in the documents folder, which the phone never empties; localStorage on web.
    wallet/
      WalletProvider.ts      Wallet seam. Breez is native-only; web gets a stub.
    updates/
      updater.ts             When to ask about an update, and what the banner shows.
      nativeUpdates.ts       Native seam. Android talks to Play; iOS and web get null.
      appStore.ts            The same for an iPhone: a newer version on the App Store, and Update showing its page.
      nativeAppStore.ts      Native seam. iOS reports its install and shows the App Store page; Android and web get null.
    upi/
      ahead.ts               Whether Pay by UPI opens at once on what was read ahead, or waits for the server. The rule, under vitest.
      knownApps.ts           The phone's UPI apps, asked for before the sheet that lists them (warmUpiApps.ts fetches an iPhone's icons with them).
      launchUpi.ts           Native seam. Android lists the phone's UPI apps, opens one and hears back; iOS finds the ones it knows by URL scheme and opens one; the web gets null.
      upiApps.ts             Which apps are known to take a link from another app (CRED, and on Android Paytm); every other is paid in by hand. The UPI apps an iPhone looks for.
    prefs/
      currencyPrefs.ts       Which currencies someone uses, and what a new group starts in. The rules, under vitest.
      currencyStore.ts       Where the device keeps that. SecureStore on native, localStorage on web.
      useCurrencyPrefs.ts    The choice, live, and the ways to pay it leaves on show.
    react/
      SattleProvider.tsx     Context, hooks, and the mock/real swap.
      useSettleFlow.ts       One settle attempt, from open to terminal.
      useAppUpdate.ts        Checks on every foreground; the banner's hook.
    ui/
      theme.ts               Design tokens. Cool grey paper, navy ink, one blue accent, and each group's cover colour.
      primitives.tsx         Buttons, cards, Amount, loading/error/empty.
      backNavigation.ts      Android's back button and the browser's: the sheet or screen showing gets the press.
      WelcomeScreen.tsx      First launch against the real API: your name and currencies, and a device account. Or a sign-in key from another device.
      UpiStepScreen.tsx      Right after it, for rupees: your UPI ID, or Skip.
      FirstRunScreen.tsx     The frame those two share: one big question, centred, no title bar.
      RestoreScreen.tsx      The /restore page: a group rebuilt from its backup key, straight off the relays.
      GroupsListScreen.tsx   Entry screen. Net position across all groups.
      NewGroupScreen.tsx     A group's name on its own cover, and the people in it. Opens on the link to share.
      SimplifyDebts.tsx      The Simplify debts switch, under Manage.
      GroupDetailScreen.tsx  The group's cover, where you stand, who pays whom, the activity by day; Add people and Remind sheets.
      HistoryScreen.tsx      Everything added, changed, removed and settled, and the sheet one entry opens in.
      AddExpenseScreen.tsx   Amount first, a live split preview, and split equally, by amount, parts, percent or item.
      Coachmarks.tsx         A tip over the screen: the dim with a spotlight cut out, an arrow drawn to it, and Skip, Back and Next.
      coachmarkLayout.ts     Where the spotlight, the card and the arrow go. The geometry, under vitest.
      SettleUpSheet.tsx      Rails, the blocked screen, address entry, and paying by UPI.
      InvoicePanel.tsx       The invoice: Open your wallet, a QR code, copying it, and how long it has left.
      UpiPanel.tsx           What to pay over UPI: the ID, a QR code on the web, and the button that opens a UPI app.
      AccountPages.tsx       The pages under Account: UPI ID, Lightning wallet and address, currencies, sign-in key, Nostr, the trust disclosure, deleting.
      ActivityScreen.tsx     Every group's expenses, their edits and removals, and payments, newest first, with what each did for you.
      TabBar.tsx             Groups, Activity, Account: a floating capsule, Liquid Glass on iPhone, solid on Android and the web.
      FaqScreen.tsx          Behind that FAQ: how getting paid, confirming, UPI, the links and the account work, for the ways to pay the reader uses.
      GuestPayScreen.tsx     The /s/<token> page. No app, no signup. Lightning, UPI, or a choice of the two.
      JoinScreen.tsx         The /join/<token> page: which group it is, who you are, and asking to join.
      GroupGuestScreen.tsx   The /g/<token> page, where the shared link lands: the whole group, read-only, Lightning, UPI and Mark as paid on each debt, and Join.
      GroupSettingsScreen.tsx  Manage: rename the group, simplify its debts or not, its link, its Nostr backup (copy the key, read it back), leave it, delete it.
      AccountScreen.tsx      Who you're signed in as, and every setting as a row that opens its page: get paid, preferences, sign-in, about.
      OnboardingScreen.tsx   Once you're in: three screens on how it works, shown once.
      tourStore.ts           Whether this device has been shown them. SecureStore on native, localStorage on web.
      tips.ts                The one-time tips (the split guide), and which this device has seen.
      tipsStore.ts           Where the device keeps that. SecureStore on native, localStorage on web.
      GetPaidSheet.tsx       Asked once at launch, with nowhere yet to be paid: a Lightning address, a UPI ID, or Skip.
      getPaidStore.ts        Whether this device is done with that: asked, or found somewhere already. SecureStore on native, localStorage on web.
      CurrencyPicker.tsx     Which currencies someone uses and what a new group starts in, under Account.
      UpdateBanner.tsx       Update available, downloading, restart to install.
      DemoApp.tsx            Throwaway navigator so it all runs today.

DemoApp.tsx is a plain state machine, not expo-router. When routing is added, each case becomes a route file and the navigator is deleted. The screens only take props and callbacks, so none of them need to change.

Browser tests

npm run e2e runs the web app in a headless Chromium against the real API, from packages/e2e-web. The Playwright config starts both: the API on 127.0.0.1:3900 with an in-memory database, no seed, no demo user and the payment simulator, so nothing reaches the network; and the web app on 127.0.0.1:8900, exported once with those addresses baked in and served the way nginx serves it, so /s/<token> and /g/<token> load the app and /privacy the policy. Every test makes its own accounts and groups, so the files run in parallel against one server. To run beside another checkout's run, move both ports: E2E_API_PORT=3920 E2E_WEB_PORT=8920 npm run e2e.

The browser is a phone: Pixel 7's width, touch and user agent, in Chrome's own headless mode (not the headless shell), so what it renders is what Chrome renders. Headless always, in CI too; there is nothing in the app a window would change. To watch a test, npx playwright test --ui from the package; a failed run in CI uploads its report with a trace of each failure, which npx playwright show-report replays step by step.

Tests sit under tests/, one file per area, built on three fixtures (src/fixtures.ts): device() is a browser in a given starting state, a brand-new phone or one that has seen the tour and the tips or holds a token; person(name) is an account made through the API and open in its own browser on the groups list, with the API bound to its token for seeding and checking; api is the API spoken to directly, which tests/api.spec.ts uses to abuse every route. The screens are driven through src/actions.ts, which finds buttons by their label and inputs by their placeholder, since react-native-web draws a Pressable as a plain div.

A test that shows up a bug in the app keeps its correct expectation and is marked test.fail with the bug in its reason, so the run stays green and the bug stays on record until it's fixed.

Working on it

docs/BUILD_PLAN.md has the task dependency graph, who owns what, and the rules for working in parallel.

Using the core

import { SattleProvider, useClient, useAsync } from './src';

function GroupScreen({ groupId }: { groupId: string }) {
  const client = useClient();
  const { data: debts, loading, error, reload } = useAsync(
    () => client.getDebts(groupId),
    [groupId]
  );
  // ...
}

Settlement is async by design. createSettlement returns before the payment is finished, so you subscribe for updates:

const settlement = useSettlement(settlementId);
// status: created → awaiting_payment → in_flight → confirmed

Opening at once

The app opens on what it has, as Splitwise does, and catches up behind it. Nothing waits on the network to change screens, and a change the user makes shows the moment they make it.

  • One read for everything. GET /sync answers who the user is, each of their groups whole (members, expenses, settlements, their UPI claims, who is waiting to join), their requests to join and their UPI ID. Each part is what that part's own route answers, byte for byte (apps/api/src/sync.test.ts), so old app versions on the old routes and new ones see the same thing. The one part with no route of its own is each group's expense changes, the rows GET /groups/:id/history is built from, there so Activity can list edits and removals. ?group=<id> answers for those groups only, which is what a group's screen asks for. The answer's version is a hash of it: asked with If-None-Match, a sync where nothing changed is a 304 of a few bytes.

  • A copy on the device. AppData keeps the last answer, in a file on native and in localStorage on the web, and the first screen is drawn from it before anything is asked. It's one account's (named by a fingerprint of its token, never the token), and it goes when the token stops working or the account is deleted. Nothing that works as a key is kept: not the group link, the ledger's backup key or a pay link.

  • Read ahead. A few things a screen shows aren't in the sync: a group's history, its link, where to pay someone by UPI, what a link's pages show. The screen that shows one asks for it as it opens; the screen before it asks ahead (AppData.warm, useReadAhead), a moment after it is up, so the next one opens on an answer instead of a loading state. Each is named once in src/data/reads.ts, which is what both go by. Where a flow is known, it's read two screens ahead:

    • Paying. A group's screen reads who to pay by UPI for the debts the user has a Pay button on (three at most), and the phone's UPI apps with their icons; the sheet Pay opens asks again as it opens, unless that was in the last 10 s. Pay by UPI then opens on them at once, when who to pay was read in the last minute.
    • Joining. A group's link arriving in the app asks for the group's page and for who the link offers to join as alongside checking whether the user is already in the group, not one after the other. The group's page reads the join list ahead; in a browser, where Join is a real link and the app loads afresh, that one answer is carried over the page load in sessionStorage (carriedRead.ts). Once someone has joined, the group is read while Join is still busy, for 2.5 s at most, so it opens whole.
    • Around a group. Its link, for Add people, Remind and the QR code (read again whenever the group's log says the link changed); then the history, and what Manage shows of the link and the backup.
    • Elsewhere. The groups list reads how the user is set up to be paid, for the Account tab; an account just made has its groups read behind the UPI step and the tour; which payments the server makes is asked at launch.

    Three rules keep it from doing harm. It only reads: no invoice is asked for and no link is made ahead of the tap that asks for one. Screens are never drawn ahead, only their answers fetched, so nothing is reported as seen that wasn't. And what was read ahead is a head start, never the last word: the screen still asks as it opens, what the server says then replaces it, and a link turned off since shows as that. Pay by UPI is the exception: its step opens on who to pay as read in the last minute and asks nothing again, so a UPI ID changed in that minute can be the one shown (upi/ahead.ts). Saying it was paid still goes to the server, which refuses a debt that's gone or a payee with no UPI ID. Someone else's UPI ID, and anything that works as a key, is kept in memory only, and goes when the user leaves the group.

  • Kept current. The groups list and a group's screen sync every few seconds while they're up and the app is in front (useKeepCurrent): 4 s for the group (which asks for that group alone), 15 s for the list (which asks for all of them), or 4 s while a request to join is waiting. A sync is also made on coming back to the app and after every change. Failures back off to 30 s.

  • The user's own changes don't wait. Saving an expense, changing one or deleting one lays the change over the copy at once and sends it behind, with one idempotency key for every try. The group shows it as Saving… until the server has it. One the server refuses stays on the group as Not saved, with why, and counts in nobody's balance until it's sent again or deleted; one that couldn't get through is sent again by itself once a sync works. Changes are kept with the copy, so one made just before the app closed is still sent. Other writes (a settlement, a rename, letting someone in) still wait for the server, since it can refuse them for reasons the app can't see, but its answer shows at once rather than after a second read.

  • Never back, never twice. A change the server has answered stays laid over until a sync that started after the answer lands, since one that left earlier can't have it. While an added expense is still on its way it has no id from the server, so an answer that may already hold it isn't used; the add's own answer brings the sync that is.

  • An older server has no /sync: the app reads it the old way, one route at a time, and asks less often, until it has one.

Four decisions baked in

Members are not users. A Member is a row in a group with a status of ghost, joined, or nwc_linked. Ghosts have never installed anything. They can pay by scanning, but they can't receive until someone adds their Lightning address. Until then createSettlement throws member_cannot_receive. Retrofitting this is miserable, which is why it is in the type from line one.

Debt is in the group's currency, in whole units of its smallest part. amount is always minor units: paise in a group kept in rupees, cents in one kept in dollars, sats in one kept in bitcoin. A group has one currency from the day it is made, chosen from the ones its maker uses, and it never changes. A rupee debt becomes sats only inside a Quote, pinned at quote time with a 90-second TTL. A sats debt is paid as it stands: its quote names no rate, and the server never looks one up. A dollar debt is never paid in the app at all, so it never meets a rate either: it is marked settled (see Dollars).

The ledger moves on preimage, never on optimism. computeBalances only counts settlements in confirmed or manually_confirmed. The mock enforces the same rule, so you cannot accidentally build a screen that assumes otherwise.

Fees are added on top, never deducted. A ₹1,200 debt settles at exactly ₹1,200 plus the payer's fee. Quote.feeSat is separate from Quote.amountSat for this reason.

Building the screens

Turn the failure knobs on while you work. Most of the screens you'll get wrong are the ones you never see with happy-path fixtures:

new MockClient({ failureRate: 0.3 })              // error states
new MockClient({ alwaysFailSettlement: true })    // payment failure screen
new MockClient({ settleDelayMs: 12000 })          // the long wait
new MockClient({ latencyMs: 0 })                  // tests

The app has three tabs, Groups, Activity and Account, on a bar that floats a little above the bottom edge (TabBar.tsx). It is only on those three screens; a group, the expense form or a page under Account hides it, and back takes you out. On an iPhone with iOS 26 or later the bar is Apple's Liquid Glass (expo-glass-effect, a native module, so pod install after pulling it in); older iPhones get a translucent bar, and Android and the web a solid one. On a phone the highlight springs to the tab tapped, unless the phone asks for less motion. A screen under the bar is told its height as the bottom safe-area inset (AboveBottomBar), so its last row stays clear.

The ghost path

Aman never installed anything, so there is nowhere to send his money. The wrong fix is a catch around createSettlement — by then the user has already committed to an action that was never going to work, and the only honest thing left is an error.

resolveSettlementOptions() decides first. When the recipient cannot receive, it returns blocked with three remedies in place of rails:

  1. Add their Lightning address. The route most people miss. Any wallet gives Aman an address, and paying it needs nothing from him — no install, no signup, no device awake. setMemberPayoutAddress stores it and leaves his status as ghost, because he is payable, not joined.
  2. Invite them. Shares the group's link, where Aman taps Join group, picks his own row and takes it over; see Joining a group. Best long-term, slowest right now.
  3. Mark as settled. Cash, UPI, forgiven. Present on every screen, never removable.

Two rules the tests pin down: the blocked message names Aman rather than describing a system state, and manual survives into rails even when every other option is gone. A ledger app that cannot record "he paid me in cash" is punitive.

First launch and currencies

The first screen (WelcomeScreen.tsx) asks two things, and can't be skipped: a name, and which currencies they use, as chips for ₹ · INR, $ · USD and ₿ · BTC. Rupees start ticked; any of them can be on, never none. Continue as the name makes the account and keeps the choice. Someone who ticked rupees is asked their UPI ID next (UpiStepScreen.tsx), with Skip at the top right; saving or skipping also answers the groups list's question about getting paid, below, so it isn't asked twice. Signing in with a sign-in key or Nostr instead skips the UPI step, since that account's UPI ID, if any, is already on it, and keeps the ticked currencies only if they were changed: left as they started, the device hasn't said, and shows them all. Other ways to sign in offers all three ways back in, the Nostr ones too, whatever is ticked: someone reaching for them is getting back in, and hiding one would strand whoever has no other.

Once they're in comes a three-screen tour (OnboardingScreen.tsx): splitting, that only one person needs the app, and the ways to settle up, only those that go with the currencies they use. It asks nothing and is shown once: reaching the end or tapping Skip is what the device remembers (tourStore). A /join/ link that opened the app is kept and followed afterwards. The guest pages (/s/, /g/) are for people without the app and never show it.

Someone new who arrives by a group's /join/ link isn't asked about currencies: they start on the one the group is kept in, alone, and can change it under Account. The join page tells the app which that is (JoinView.currency).

Someone signed in with nowhere yet to be paid (no Lightning address, no UPI ID, no wallet connected under Account) is asked where, once, in a sheet over the groups list (GetPaidSheet.tsx). Each device looks at the first launch that opens on the groups list, which includes right after making an account, on the welcome screen or by joining from a link. An account already signed in whose app opens on a link goes where the link leads, and is looked at next launch. The sheet takes a Lightning address to be paid in bitcoin and a UPI ID to be paid in rupees, only the ones that go with the currencies they use, and saves them as Account does: whatever the server refuses stays in its field with the reason, and the rest is saved. Saving, Skip and closing the sheet are all answers. An account with somewhere to be paid already isn't asked. Either way the device remembers (getPaidStore) and doesn't look again, even if that somewhere is removed later. In a browser the back button closes the sheet only once the page has had a tap: Chrome passes over a history entry added before one (backNavigation.ts), so until then back leaves the page, and the sheet comes back at the next launch.

The first time a device adds an expense, a tip over the split card points at Split differently: new expenses are split equally between everyone, and leaving someone out is in that sheet. Show me opens it on a five-step tour (Coachmarks.tsx) of who paid, leaving someone out, the ways to split, Split by item and Done. Each step dims everything but the one thing it's about, which shows through a spotlight with an arrow drawn to it, and taps reach only that thing: on the step about leaving someone out, the tap on the person is real, and the card says what it did. Not now leaves the tour for the first time the sheet opens. Skip or Got it ends it for good on that device (tips.ts), and the i beside Done plays it again.

A device that has never chosen, like one signed in before the first screen asked, uses all three currencies, so nothing is hidden. A way to pay is offered when the person owed has set it up: UPI for a UPI ID, Lightning for a wallet or a Lightning address.

A group is kept in one currency, picked when it is made and never changed: rupees, dollars or bitcoin. A group kept in bitcoin is counted in sats everywhere: amounts are typed and shown as whole sats, and settling one needs no exchange rate.

Under Account, Currencies changes what the first screen, or the join link, chose. Turning one off does three things.

  • New groups aren't offered in it. Someone who uses one currency is never asked which. Someone who uses more than one picks per group, starting from the one they said new groups start in.
  • The app stops showing what goes with it. Rupees bring UPI and bitcoin brings Lightning; dollars bring neither. With bitcoin off there is no wallet connection, Lightning address, invoice or sats anywhere, and the trust screen leaves out the rows about them. The group link stays either way: a debt on its page can be paid whichever ways the person owed can be paid (see Paying by UPI). With rupees off there is no UPI. payWays() in @sattle/core is the whole rule, and resolveSettlementOptions takes its answer, so a payer left with no way to pay is told what to ask for in terms of the way they do use.
  • Without bitcoin, nothing of Nostr shows either (showsNostr in prefs/currencyPrefs.ts): no Nostr key under Account unless one is already linked, no backup card under Manage, and the FAQ and trust screen leave Nostr out. The group's backup still goes to the relays; only the app stops showing it.

Three things are never hidden, because hiding them would strand someone:

  • Lightning, in a group kept in bitcoin. Nothing else can settle it, so it shows there whatever was chosen. If people owe someone in such a group and they have bitcoin turned off, Set up getting paid turns it back on for them and says so.
  • UPI, in a group kept in rupees, for someone who uses neither rupees nor bitcoin (dollars alone, say). Without it they would have no way to pay there. Set up getting paid turns rupees on for them the same way (turnsOnToGetPaid).
  • Anything already set up. A connected wallet, a Lightning address or a UPI ID stays under Account until its owner removes it, even with that currency turned off. Other people can still pay them that way, so they have to be able to see it and take it away.

The last currency can't be turned off. The choice is kept on the device (prefs/currencyStore) and never sent to the server, which is why it changes what is shown and not what is allowed: the server still takes UPI for a rupee group and Lightning for any group but a dollar one, whoever asks.

Dollars

A group kept in dollars is only counted: Sattle moves no dollars, so nothing in it settles by itself. settledByMarking in @sattle/core names the currencies that work this way, dollars alone, and everything follows it. payWays shows neither Lightning nor UPI in such a group, whatever someone uses, and resolveSettlementOptions offers Mark as settled alone and blocks nobody, since there is nothing for the person owed to set up. On the group screen what the user owes has Settle, whose sheet says to pay however they like and has that one button; it records the debt as settled at once, with whoever marked it in the history. The server refuses a Lightning payment in a dollar group (POST /groups/:id/settlements, 400), and neither the group's link nor a pay link offers one (payableIn): the group's page has only Mark as paid, which the person owed confirms in the app. Nobody who uses dollars alone is asked for a UPI ID or a Lightning address, at first launch or after.

The API

apps/api implements every route ApiClient calls, and nets debts with the same @sattle/core ledger the app uses, so balances can never disagree. The server doesn't trust the client:

  • You only see groups you're a member of. Other groups return 404, not 403, so a guessed id reveals nothing.
  • A settlement can't exceed what is owed right now (simplified or not, as the group chose), and a second one can't start while one is in progress.
  • A ghost with no payout address gets 409 member_cannot_receive.
  • A repeated idempotency-key replays the first response instead of acting twice.

Payments go through PaymentBackend in payments.ts, and PAYMENTS picks one:

  • nwc (payments/lightning.ts): real payments. For each settlement it pins a quote at the live rate, or for a group kept in bitcoin takes the sats owed as they are, and gets an invoice that pays the payee directly:

    • from their own wallet over Nostr Wallet Connect, polling it (lookup_invoice) until it reports the invoice paid, or
    • for a member with no NWC wallet, from the Lightning address they set themselves (LNURL-pay, lnurl.ts). The invoice is checked first: exact amount, our network, the address's metadata. When the address has a verify link (LUD-21) it's polled, and only a preimage that matches the payment hash counts as paid. Without one, the invoice is closed when it expires, saying we couldn't tell. Either way the payer can confirm it with their proof of payment, the preimage their wallet hands back (POST /settlements/:id/proof, or /s/:token/proof from a pay link), even after we've called it expired: it's checked against the payment hash stored when the invoice was minted. Every request to an address goes through safeFetch.ts, which refuses private addresses, redirects and slow or oversized answers.

    The preimage is checked against the payment hash before it's stored. Open invoices are picked up again after a restart. The server never holds funds. npm run lnurl:smoke -w @sattle/api -- you@wallet.com checks a real address.

  • anything else: SimulatedPayments, which walks the same states as the mock with a fake preimage.

One gap with real payments on: a ghost's Lightning address can't be paid yet. A groupmate typed it, so a payment to it proves nothing about the ghost; joining clears it, and the member sets their own. The payment ends as failed with "Nothing moved" rather than be marked paid without proof.

Auth is a bearer token looked up in users.token. POST /accounts is the only way to get one: it takes a display name and returns a new user and a random token, and the app keeps the token on the device (src/account/tokenStore, SecureStore on native, localStorage on web). There's no email or password. Account → Sign-in key, Copy sign-in key gives the token as sattle-signin:<token>; pasting that under I have a sign-in key on the welcome screen of another phone or browser, or the same one after its data was cleared, checks it against GET /me and keeps it. Both devices are then signed in as the same user. Replace sign-in key (POST /me/token) issues a new token and ends the old one on every device that has it, which is what to do about a key that may have leaked or a lost phone that was signed in. A device whose answer was lost still holds the old key, so for ten minutes the old key can reach that route alone, and only to have the same request (same idempotency key) replayed; a new request with it gets 401.

Signing in with Nostr

An account can have a Nostr key linked to it (Account → Nostr), and then Sign in with Nostr on the welcome screen opens that account on a device with nothing on it: no old phone, no sign-in key. That is the way back into a group nobody else has joined, where there's nobody to let you in.

The app never sees the private key. It asks the person's own signer to sign a proof: a browser extension (NIP-07, window.nostr, web only) or a remote signer they point it at with a bunker:// link (NIP-46: nsec.app, Amber, their own bunker). The proof is an HTTP-auth event shaped as NIP-98 has it (kind 27235, the URL and method as tags) plus a challenge tag from POST /auth/nostr/challenge. The server (nostrAuth.ts) checks the signature, the kind, that it was made in the last five minutes, that it names the route it was sent to, and last that the challenge is one it handed out, unused and unexpired, which uses it up. A proof can't be replayed, and one made for linking can't sign in.

Talking to a remote signer takes random bytes, for the app's throwaway key and each message's nonce, and nostr-tools gets them from crypto.getRandomValues. Hermes, the phone apps' JavaScript engine, has no crypto, so src/randomValues.native.ts puts expo-crypto's, from the OS, there before anything else loads. Browsers have their own.

  • POST /auth/nostr/challenge: public, { challenge, expiresAt }, good once for five minutes.
  • POST /auth/nostr: public, { event } → { user, token }, the account's current sign-in key. 404 if no account has the key linked. No idempotency key: a replay on a public route would hand the token to whoever repeated it.
  • POST /me/nostr: { event } links the key that signed it, answering the User with its npub. 409 if another account has it. Linking another replaces it.
  • DELETE /me/nostr: unlinks it.

The remote-signer code and the restore code load with one import() (src/nostr/lazy.ts), so nostr-tools isn't on the app's startup path. With DEMO_USER_ID set, requests without a token act as that user. That's for local dev and must be unset anywhere real.

Joining a group

A group starts with one person who has the app; everyone else is a ghost, a name on the ledger. The group's link turns ghosts into members. It is the group's one link, /g/<token>: anyone already in the group taps Add people on the group's cover and sends it from WhatsApp, their messages or any other app, or shows it as a QR code. It opens the group's page, where anyone can see what's been split and pay what they owe (see The group link), and that page has Join on it. Join opens /join/<token>, with the same token: whoever taps it sees which group it is and the people in it, picks the one they are, and is in. Picking someone nobody has joined as takes over that row as it is: same name, same history, same balance. Picking someone who has joined makes this device that person too, alongside the devices they already have: that is how one person is in a group from a phone and a laptop, and how someone who lost the device they joined with gets back in. Someone who isn't on the list taps +, gives their name, and is added as a new member with nothing owed either way. Someone with no account gets one in the same tap, under the name they picked. Someone already in the group is one of those people on this device already, so for them Join opens the group.

A group can ask to look first: Manage → Joining → Approve who joins, off until someone in the group turns it on (approve_joins). Then picking a name asks to join instead of joining. Someone already in the group sees "Someone wants to join as Kabir" at the top of the group, with a four-digit code, and taps Let in or Not them. Until they're let in, the group sits on the asker's groups list as Asked to join, showing their code, and they can do no more than anyone else holding the link.

Joining is full membership. There are no roles, so the new member can read everything in the group and add expenses, members and settlements, and share or replace its link. They can leave, but nobody else can remove them. So the link is treated as a key:

  • It is 128 random bits, and only a member of the group can make one.
  • A group has at most one. Sharing again hands out the same link, so the one already in the chat keeps working.
  • It doesn't run out by itself. Anyone in the group can replace it or turn it off under Manage, which is how a link sent to the wrong chat is cancelled.
  • Holding it gives any name in the group, whether or not someone has joined as it. With approving on, it gives nothing by itself: asking makes a request (join_requests), only someone already in the group can let them in, and only then are they that person.
  • A name can be joined from more than one device. Each device is an account of its own (member_accounts holds every one after the first), and each is that member: it sees the group, pays what they owe, marks what they're owed settled, and changes what they paid. The member is paid through whichever of them has a wallet, a Lightning address or a UPI ID set up, the first to join first. In a group that approves joins, a request for someone who has joined says so, "Someone says they're Kabir, on another device", and on Kabir's own device "Someone says they're you, on another device"; anyone in the group can let them in. Several people can ask to be the same name, and each gets their own yes or no. The card says when two people are asking for one name, and the code is how to tell which is which: ask the person which code they see.
  • At most 20 requests wait on a group at once, so a leaked link can't bury the real one under requests from throwaway accounts. Turning some down makes room.
  • Adding yourself under the name of a ghost who is still waiting answers 409 conflict too, so nobody starts a second row beside the one that holds their balance. Joining straight in under the name of someone who has joined does as well, since nobody is there to see two people go by one name; asking under it is allowed, and whoever lets them in sees it.
  • An account can be only one member of a group.

The link proves nothing about who is on the other end, since it can be forwarded: whoever holds it can join as anyone in the group, someone who has joined included, and act as them. That is the price of one link for everyone and no passwords. A group whose link has gone further than people it knows turns on approving joins, and then a person checks instead. A link in the wrong hands is turned off, and its requests turned down; a device that got in is undone only by it leaving, so the card asks to let in only someone you know is them.

GET /join/:token is public, like the group page, and returns names and nothing else: the group, and each person in it, with an opaque ref in place of an id and whether someone has joined as them. A ref is a hash of the link and the member, so it is no use with another link. Joining is POST /join with the token and either the ref or, to be added as someone new, a displayName; it needs an account, answers with the member, and is refused (409 conflict) when the group approves joins. Asking is POST /join-requests with the same body; asking again replaces the last request. PUT /groups/:id with approveJoins turns approving on or off. GET /links/:token/group needs an account too: it answers with the group when the caller is already in it and null when they aren't, which is how the app knows to open the group. GET /me/join-requests and DELETE /join-requests/:id are the asker's; GET /groups/:id/join-requests, POST /join-requests/:id/approve and /decline are for anyone in the group. The link itself is made, replaced and turned off with GET, POST and DELETE /groups/:id/link.

The shared link, /g/<token>, opens in a browser, so paying needs no app. On a phone with the app installed it opens the app instead, which claims /g/ and /join/ links (intentFilters and ios.associatedDomains in app.json):

  • Someone already in the group lands in the group, on Settle up. That is the point of handing the link to the app: paying by UPI from there goes through the app, which hears what the UPI app says, where a browser hears nothing.
  • Anyone else, with an account or without, gets the same group page inside the app: what's been split, who owes whom, the buttons to pay. Having the app installed doesn't take away what holding the link shows. Join on it goes to the app's join screen.
  • A /join/ link opens the join screen, or the group for someone already in it, as before.

Everywhere else the link carries on in the browser, and in the installed app it can still be pasted under Join with a link on the groups list. What the app claims is fixed when it is built, so a copy from before /g/ was added still gets that link in the browser until it is updated. A pay link, /s/<token>, always opens in the browser.

Android hands the app the link only when the site vouches for it. apps/mobile/public/.well-known/assetlinks.json, which the web deploy publishes, has to list the SHA-256 of every certificate a real copy is signed with: the upload key, which signs the APK on a GitHub release, and Play's app signing key, which signs what Play installs (Play Console, App integrity, App signing). A copy signed with a key that isn't listed, a debug build for one, gets the link in the browser as before.

An iPhone asks the same of the site through apps/mobile/public/.well-known/apple-app-site-association, which names the app as its team and bundle ID (4G96L8W59F.tech.sattle.app) and the two paths. Apple's CDN fetches it when the app is installed and every few days after, so a change to it takes a while to reach phones. It must come back as application/json with no redirect. It has no extension, so the nginx site on the VM needs to say so:

location = /.well-known/apple-app-site-association { default_type application/json; }

A copy from Xcode with the app's team gets the links too; one signed by any other team doesn't. Expo's scene delegate passes the link to React Native whether it launched the app or reached it running, and App.tsx reads both.

Paying by UPI

A rupee debt can also be paid over UPI, outside Lightning. Someone adds their UPI ID under Account; whoever owes them in a group kept in INR then sees Pay by UPI in the settle sheet, unless they have turned rupees off and use bitcoin, which pays them there over Lightning (see First launch and currencies).

The payer is always asked, even with one way to pay, since Mark as settled is there beside it. Pay by UPI is offered only for someone who has added a UPI ID. It never opens a UPI app by itself: someone who takes UPI and has no wallet still gets Pay by UPI to tap. Neither is required of anyone: an account is only a name. Someone with neither can't be paid here yet, and whoever owes them is told so and can remind them, or mark it settled if they paid another way. An invoice still out for the debt, from the sheet before it was closed or from a pay link, is picked up when the payer taps Pay with Lightning, not made a second time, since the server makes one at a time.

What happens with UPI depends on the device, because only Android lets an app hear back from a UPI app:

  • Android. The sheet lists the UPI apps on the phone, with their own icons, through a small native module (modules/upi-apps, behind src/upi/launchUpi.android.ts). The one tapped is opened on the upi://pay link as an activity that returns a result, the payer pays, and the app hands back a status and a reference when it closes. On SUCCESS the debt is settled there and then (below). Anything else is left to the payer: try again, or say they paid. That is only for the apps known to take such a link: CRED and Paytm (TAKE_LINKS in src/upi/upiApps.ts). Most apps refuse one (NPCI's rule for person-to-person intents since April 2024), Google Pay, PhonePe and Amazon Pay among them, and a refused link is a failed payment. So every other app, one nobody has tried included, is never sent one: the UPI ID is copied, the app opens plain, the payer pastes it in, and when they come back the sheet asks whether it went through, as on an iPhone, without a reference box.
  • iPhone. iOS can't list the phone's apps, and a upi://pay link goes to whichever UPI app iOS picks, which nobody can change. So the sheet looks for the UPI apps it knows by their URL schemes (Google Pay, PhonePe, Paytm, CRED, BHIM, YONO SBI and Navi, in IPHONE_UPI_APPS in src/upi/upiApps.ts; each scheme also has to be under LSApplicationQueriesSchemes in app.json, or iOS always answers no) and lists the ones it finds. An iPhone can't read another app's icon, so each shows its App Store icon, from one request to Apple's public lookup that names every app on the list (initials if Apple doesn't answer within 3 seconds). On an iPhone only CRED was seen taking the link (November 2026), so only CRED is opened on it, on its own scheme with the same payee, amount and note; every other app gets the UPI ID copied and is opened plain, as on Android. A UPI app says nothing back, so when the payer returns the sheet asks whether it went through. With none of those apps on the phone, the sheet has one button that opens the plain upi://pay link.
  • Web. The same link as a QR code to scan from a phone, and the UPI ID to copy, then I’ve paid. No link is opened, not even on a phone's browser: a browser can't tell which UPI app would get it, and most refuse one to a person. So the payer copies the ID and pastes it into their UPI app, and coming back to the page after copying asks whether it went through.

Sattle never learns that the money moved. No bank or UPI app tells a third party that one person paid another. The payer's word is therefore a claim (upi_claims), not a settlement, and it moves no balance. The person owed sees "Kabir says they paid you ₹500 by UPI", with the reference when there is one, and either confirms it, which makes it a settlement (rail: upi, manually_confirmed), or says it didn't arrive, which the payer is then shown. Marking a debt settled by hand is different: anyone in the group can, the payer included, and the group's history names whoever did.

The exception: a UPI app that says it went through. On Android the UPI app hands back one line when it closes (parseUpiResponse reads it): a status, its transaction ID, the bank's approval reference, and the link's own reference when the link asked for one. When the status is SUCCESS, the payer's phone passes that on (POST /groups/:id/upi-payments) and the debt is settled on the spot: a settlement with rail: upi, already manually_confirmed, with those ids and the name of the app it was paid in (paidWith) kept on it (settlements.upi_receipt, migration 021). The person owed is asked nothing, and nothing undoes it. The payer's sheet says Settled and shows the ids, and so does the entry in the group's history. A claim that was waiting on the same debt goes.

This is a choice to trust each other's apps, and it has a cost worth knowing. The line carries no amount, no payee and no signature, and the server never talks to the UPI app: it is told "success" by the payer's phone and takes it as true, the same phone that could have been told to say it. The ids are what make it checkable afterwards, by anyone, against a bank or UPI statement. A browser hears nothing back from a UPI app, and neither does an iPhone.

Where no app says anything, the payer is asked. On an iPhone and in a browser all the app can know is that the payer left for a UPI app and has come back (useBackFromUpi: the app going to the background and returning, or the page being hidden and shown). At that moment the settle sheet asks Did the payment go through?, and I’ve paid opens the same question, on Android too when the UPI app stayed quiet:

  • Yes, it went through. That settles the debt on the spot through the same route, on the payer's word (upi.byPayer), with nothing for the person owed to confirm. The sheet has a box for the reference the UPI app shows for the payment (its UPI transaction ID, UTR or UPI Ref No). It can be left empty. When one is typed it is kept as upi.reference and shown in the history, and parseUpiReference asks only that it could be a reference: letters and digits with at least six digits, spaces and dashes dropped.
  • No, it didn’t go through. Back to paying, with nothing recorded.

So from the app a UPI payment no longer ends in a claim at all. Claims are what the shared pages make, below, including the group page's Mark as paid for money that went another way (see The group link).

The group's shared page asks the same question when someone comes back to it from a UPI app, and still asks if the browser reloaded the tab while they were away, which Android Chrome often does (upi/upiReturn.ts keeps it for the tab). There Yes, I’ve paid stays a claim that the person owed confirms. That page has no login, so letting it settle a debt outright would let anyone holding the link clear any debt in the group.

  • A debt has at most one claim; claiming again replaces it. While one is pending, the payer's Pay button waits, so they don't pay twice.
  • The claim can't be for more than is owed. If less than that is owed by the time the person owed answers, because an expense changed or simplifying sent the debt through someone else, confirming is refused. Such a claim is no longer shown or waited on, and doesn't stop the group turning simplifying on or off (liveClaims in settlementRules.ts). The next claim for the debt replaces it, and it counts again if the debt grows back to its amount.
  • A UPI ID often contains a phone number, so it isn't in the member list. GET /groups/:id/members only says who takes UPI; GET /groups/:id/members/:memberId/upi gives the ID, and only to someone who owes that person right now.
  • Account says so before such an ID is saved. When the one being typed has a mobile number in it (upiIdHasPhoneNumber), a warning says who would see the number, and that most UPI apps let you add an ID without one. It only warns: Save anyway saves it. An ID with no number in it gets no warning.
  • Only a member who has joined can be paid this way. A ghost has no account to put a UPI ID on and nobody to confirm.
  • It is offered under real and simulated payments alike, and someone who can only be paid by UPI isn't shown as blocked.
  • UPI apps, GPay in particular, sometimes refuse or cap a payment started from another app's link to a personal UPI ID. When that happens the payer can still pay the ID shown on screen by hand and tap I’ve paid.

PUT/DELETE /me/upi set and remove the ID. PUT /me/upi/group-links turns off, or back on, the group links offering it, and GET/PUT /me/upi/group-links/:groupId is the same choice for one group (below). POST /groups/:id/upi-claims makes a claim; POST /upi-claims/:id/confirm and /decline are the payee's; DELETE /upi-claims/:id is the payer taking it back.

A pay link offers UPI too. A pay link (/s/<token>) can be paid whichever way the person owed can be paid, and its page shows only those:

  • Lightning only. It opens straight on the invoice, as it always has.
  • Both. In a rupee group, when they also have a UPI ID that shared links may show (the same switch as for the group link, below), the page asks first: Pay by UPI or Pay with Lightning. No invoice is minted until Lightning is chosen (POST /s/:token/open with { "rail": "lightning" }). One nobody asked for would be a payment in progress, and would stand in the way of the UPI one.
  • UPI only. It opens on who to pay: the QR code, the ID, and on a phone a button that opens a UPI app.

GET /s/:token/upi gives the ID, only to a page that asks to pay. I’ve paid is POST /s/:token/upi-claims: a claim, marked as coming from a link, that the person owed confirms or turns down in the app like any other. Meanwhile the page waits and offers nothing, so nobody pays twice. When they confirm, the settlement is tied to the link (upi_claims.pay_link_token, migration 020), so the page shows Paid and the link can't be paid a second time. With an invoice out for the debt, UPI waits until it has lapsed.

Nobody sends a pay link by hand: the person owed shares the group link from Add people, and choosing a debt on its page is what hands one out (POST /g/:token/debts/:ref/pay-link, see The group link). A link nobody could pay is never made: for someone with nowhere to receive over Lightning the page answers 409 member_cannot_receive, and in the app a card on the group screen, above who pays whom, says what to add, in terms of the ways you use, with Set up getting paid going to Account.

The group link

A pay link covers one debt. The group link covers the group, and it is the only link a group has: someone in it taps Add people on the group's cover and posts /g/<token> in the chat everyone is already in. Whoever opens it, with no app and no account, sees every spend with each person's share and who owes whom, and taps Pay with Lightning on a debt to pay it. That opens the pay page for that one debt, which mints the invoice on the wallet of the person owed and offers Open your wallet and a QR code, exactly as a pay link does. Join group, at the top beside the group's name, is for the people who belong in it; see Joining a group.

A pay link deliberately shows nothing else about the group, and this shows all of it, so it is the group's own choice:

  • There is no link until someone in the group makes one, and there is only ever one. Making another replaces it, and the old one stops working.
  • Anyone in the group can replace it or turn it off, under Manage. It doesn't expire by itself.
  • It only reads. Nothing under /g/ changes the group. It can start a payment, which goes to the person owed like any other, or say one was made, which counts only once the person owed confirms it, and its holder can join, or ask to, as the group chooses.
  • GET /g/:token returns names and amounts and no ids. Each debt carries an opaque ref, a hash tied to that link, which is what the page sends back to pay it.

Pay with Lightning appears on a debt when the person owed can receive, by the same rule the app uses (canReceive). Pay by UPI appears in a rupee group when the person owed has a UPI ID. Shared links show it from the start, so Account says so before an ID is saved: a UPI ID often holds a phone number and the link has no login. When the ID has a mobile number in it (upiIdHasPhoneNumber), Account warns before saving it and beside the switch once it's saved. IDs with a number that were saved before the warning existed kept the setting they had when shared links went from opt-in to on (migration 016). Under Account, Turn off for shared links stops it for every group they're in. Under Manage, in a group, the same switch is for that group alone, and it wins: off for one group while it is on for the rest, or on for one while it is off, until they tap Use my Account setting here. Neither choice is tied to one ID, so a new UPI ID leaves them as they are, and the choice for a group goes when the person leaves it. The ID isn't in GET /g/:token; GET /g/:token/debts/:ref/upi gives it for the one debt someone chose to pay. The page then shows the QR code (and on a phone, a button that opens a UPI app) and I’ve paid, which is POST /g/:token/debts/:ref/upi-claims: a claim, as in the app, marked as coming from the link. The person owed confirms it or says it didn't arrive, and the page shows which. It won't replace a claim the payer made in the app.

Mark as paid is on every debt to someone who has joined, for money that went another way: cash, or UPI to their phone number. It doesn't matter what the person owed has set up, a UPI ID, a wallet, a Lightning address or nothing, or what the group's currency is. It asks Paid them another way?, and Yes, I’ve paid is POST /g/:token/debts/:ref/paid-another-way: a claim like the UPI one, marked as from the link and as another way (upi_claims.another_way, migration 026). The person owed sees "Someone on the group's link says Kabir paid you ₹500 another way" and confirms it, which settles the debt outside the app (rail: manual, note "Paid another way", in the history like Mark as settled), or says it didn't arrive, and the page shows which. A debt to a ghost doesn't offer it, since nobody could confirm it (409 conflict); the page says to settle with them directly. Like a UPI claim it waits for an invoice out on the debt to lapse, and it won't replace a claim already waiting. The debt's markable says it is offered, which tells the holder nothing /join/<token> doesn't: that the person owed has joined. Since every debt to someone who has joined can be marked, a forwarded link can leave a claim waiting on each of them, and while one waits, paying that debt and the switch for simplifying debts wait with it. The person owed saying it didn't arrive clears each one, and replacing the link stops more.

A debt to someone with nowhere to receive is listed with "can't be paid here yet", and in the app that person sees a card saying who can't pay them yet, with a way to set up getting paid. The page can't tell who is looking, so every debt has the buttons: paying someone else's is allowed, and the money goes to the person owed either way, and marking someone else's as paid only asks the person owed.

Opening the wallet is the phone's job, not ours. The button is a lightning: link: Android shows a chooser of the installed wallets, iOS opens one, and on a computer the QR code is scanned.

Changing and removing

One rule runs through all of it: nobody can undo what someone else is owed. groupRules.ts holds it, and the app only offers what the server would accept. Marking a debt settled is outside it: anyone in the group can, and the history names whoever did.

What Who When it's refused
Change or delete an expense The person who paid it, and whoever added it. What a ghost paid, anyone in the group. For anyone else: a groupmate could otherwise shrink what they owe. They're told who can.
Rename a group Anyone in it
Turn simplifying debts on or off Anyone in it While a payment is under way or a UPI payment hasn't been confirmed, since it can move the debt that payment is for.
Remove a member Anyone in the group, for a ghost that no expense, payment or pay link names For anyone in the ledger, and for someone who has joined: only they can leave.
Leave a group Yourself If you're the only one with an account (delete the group instead), while a payment to you is under way, or while you owe or are owed anything in it.
Delete a group Whoever made it. Once they have left, the only account still in it. For anyone else. And while anything is owed in it or a payment is under way, so deleting it can't erase a debt.
Disconnect a wallet Yourself While a payment to you is under way: that wallet is what confirms it.
Delete an account Yourself While a payment to you is under way.

Leaving takes the device that leaves out of the group. A member joined from another device too stays joined there, so that device may go with a debt still open. Otherwise the person is leaving, and has to be settled up first: nothing they owe and nothing owed to them (isSettledUp). The member's row then stays, as a ghost, with its name and history, so the others' ledger still adds up; the group's link hands it back.

A group keeps who made it (Group.createdByMemberId, migration 028), and deleting it is theirs alone, on any device they joined from (canDeleteGroup in @sattle/core). Everyone else leaves instead. It is the member, not the account, and it isn't handed back with the name: once whoever made the group has left it or deleted their account, nobody made it, and it can be deleted only by the last account still in it. For groups from before the migration, whoever still holds the group's first member made it.

Deleting an account leaves every group that way. A group only that account could open is deleted with it, since nobody could ever reach it again. The token, the wallet connection, the pay links that belong to it and its requests to join are removed; the names its members had in shared groups stay.

An edited or deleted expense can't be changed on Nostr, where entries are permanent, so the change is published as a further entry (see The ledger on Nostr). Deleting a group deletes its ledger key from the server; what was already published stays on the relays, readable only by someone who copied the backup key.

Simplifying debts

A group can simplify its debts, as Splitwise does (Group.simplifyDebts). It starts off: the app sends false when it makes a group, so debts first read the way they were spent. Anyone in it can turn it on or off with the Simplify debts switch under Manage (⋯ on the group's cover), the one place it's switched; the group screen says how many payments it would save. Everyone's balance is the same either way; what changes is who pays whom.

  • On: debts are combined into as few payments as there can be (simplifyDebts). If Aman owes Priya and Priya owes Om the same, Aman pays Om and Priya is done. Someone can end up paying a person they never split with.
  • Off: everyone pays back whoever paid for them (directDebts). Only what two people owe each other cancels out.

groupDebts in @sattle/core picks between the two, and everything that asks what is owed goes through it: the group screen, the server's checks on a payment, the group link, deleting a group, and a group read back from its Nostr backup, whose entries carry the setting. PUT /groups/:id with { simplifyDebts } changes it, and answers 409 conflict while a payment is under way or a UPI payment waits to be confirmed, since the debt that payment is for could move.

History

On a group's Settle up tab, the button at the bottom is History rather than Add expense. It lists everything that has happened to the group's money, newest first: each expense added, changed or removed, and each debt settled, with who did it and when (GET /groups/:id/history, members only). Tapping an entry opens it in full:

  • A payment: when it was paid or marked as paid, how, and its proof if it has one. A Lightning payment has the preimage, in full and copyable, and in a rupee group the sats sent and the rate. A debt marked as settled, or a UPI payment someone confirmed, has no proof, and the entry says so and names whose word it was settled on. A UPI payment settled because the payer's UPI app said it went through shows what that app handed back: its transaction ID and the approval reference, and the link's own reference when there was one.
  • An expense: who paid and each person's part. A change shows both sides of whatever it changed: the name, the amount, who paid, and each part.

An expense's entry has Edit expense, for whoever may change it (the payer or whoever added it; anyone, when the payer hasn't joined). It opens the form on the expense as it reads now, saying so on an older entry for one that has changed since, and saving, deleting or going back returns to History. Anyone else is told who can edit it; an expense removed since, or with an edit still saving, says that instead. Payments and changes to the group can't be edited.

Nothing is stored as a history. buildHistory in @sattle/core reads it off three things the server already keeps, and the mock builds it the same way: the expenses, the changes to them, and the settlements. Migration 019 added what those didn't say: who added an expense, who changed or removed one and how it read before, and who marked a debt as settled or confirmed a UPI payment. Each "who" is the member that person was in the group. Things from before 019 show without a name, and an expense edited before it shows as added the way it read after that first edit, since the earlier reading wasn't kept.

Two things are left out on purpose. A payment that failed or ran out isn't in the history, because it moved nothing. And saving an expense exactly as it stood isn't a change: the server notes nothing for it, in the history or on Nostr.

Changes to the group itself are in its history too, each as one line that says who made it: "Om turned on Simplify debts", "Riya renamed the group to “Goa 2026”". The server notes them in the group's log (group_log, migration 027) as they happen: Simplify debts or Approve who joins turned on or off, the group renamed, someone added by name, removed, joining from the link, let in or leaving, and the group's link made, replaced or turned off. Names are kept as they were then. Saying what something already is notes nothing. The log is GET /groups/:id/log, and each group's log in sync, where the Activity tab reads it: there every line says who did it, "You turned off Simplify debts" beside "Added by Om · Riya paid". Activity reads each group's expense changes from sync the same way, so an edit or a removal is a line of its own there too ("Edited by you · was ₹3,000", "Removed by Om"), above the line the expense was added on. Migration 029 indexes them by group, since every sync reads them. It isn't published to Nostr: it doesn't change what anyone owes. Nothing was kept before 027, so a group's log starts there.

Usage statistics

The server keeps a record of how the app is used, in one table, analytics_events, for a statistics page that doesn't exist yet. Nothing reads it; nothing in the app shows it. One row per thing that happened, with who was signed in when someone was, which install and session it was in, and when, by the device's clock and by the server's:

  • What the app reports of itself (apps/mobile/src/analytics, POST /analytics/events). Every screen, sheet and page says when it is showing, with what tells one showing from another: the group, the tab, the step of paying. Every control says when it was pressed, by what it said, or by its track name where the label holds someone's name. The app says when it opens, goes to the background and comes back, and when it hands off to another app: a wallet or a UPI app opened, a link put on the share sheet, something copied. An error put on screen is a row too. The route is public, since a guest on a pay page counts too; a bearer token sent with the batch names the account. In demo mode nothing is sent.
  • What the server saw (requestLog in middleware.ts), off unless REQUEST_LOG=true: every route is then a write to the disk the settlements are on, and its limits aren't settled yet. When on, one row per request answered that names an account or comes from the app (its device header), kind request: the method and the route it was for, like POST /groups/:id/expenses, with the route's params, the status and how long it took. A request turned away by auth is a row under its route too, when it came from the app, and a token sent to a public route still names the account. Every request from the app carries the install and session in x-sattle-device and x-sattle-session, so these rows join the app's. /health and the analytics route itself are left out.

The app queues events and posts them every few seconds, sooner when enough has piled up, and on going to the background. A long queue goes in several posts, each under 50 events and 48 KB, since nginx takes 64 KB at most. A post that fails goes again with the same ids, so the server keeps each event once, and the wait doubles after each failure up to five minutes. The app cuts down what the server would refuse: a name over 120 characters is shortened and props over 4 KB are left out. The server refuses a batch over ANALYTICS_LIMITS whole, and the app drops a refused batch instead of sending it forever.

A link's token never goes in the table. Request rows leave it out of the params, and out of the path of a request that matched no route, since holding one is all it takes to see a group or pay. Nor does an invoice or a UPI ID: opening a wallet or a UPI app records only which kind it was.

A session is one launch of the app, or one return to it after half an hour away. The install's id is made once and kept beside the account token, so what a guest did before making an account is theirs afterwards; it identifies nothing but that copy of the app. On iOS, where it's kept in the keychain like the token, deleting the app doesn't delete it: reinstalled on the same phone, the app carries on with the same id, until the phone is erased. The props column is JSON; a page wanting a value out of it can use SQLite's json_extract.

A request from neither, like a scanner trying paths, leaves no row, since the table shares a disk with every settlement. nginx limits only the analytics route per address, not the rest of the API, since a room of phones behind one address would share that limit: a phone with a group open sends eight requests every 4 seconds. So a client that pretends to be the app can write as many request rows as it likes, which is why the log is off by default. In production the API listens on 127.0.0.1 only, so everything comes through nginx and its X-Real-IP can be trusted (HOST overrides it). Request rows are kept for 30 days (REQUEST_LOG_DAYS), and the server drops older ones on start and daily, a few thousand at a time and by when it took them: a group left open refreshes every 4 seconds, about 900 requests an hour, and would otherwise outgrow everything else on the disk. What the app reports without an account goes after 30 days too (GUEST_EVENT_DAYS), since anyone can post it, unless that install has made an account since: what someone did before signing up is theirs afterwards. What it reports for an account, and what its install did before, is kept for a year (ACCOUNT_EVENT_DAYS): anyone can make an account, so the daily cap bounds how fast the table grows, and this how big. Deleting an account deletes its usage record, and what its install did before signing in unless another account has used that install since.

The route is public and the table shares a disk with every settlement, so besides nginx's limit per address the server keeps at most 50 MB of events a day in all (ANALYTICS_DAILY_BYTES), and at most 5 MB of that from any one address (ANALYTICS_ADDRESS_DAILY_BYTES, by nginx's X-Real-IP), so one client can't use up the day for everyone. An IPv6 address counts as its /64, since its owner can take a new one in there whenever they like. Only what is stored counts: a batch sent again after a lost answer costs nothing. Past either limit it answers 429, and the app keeps the batch and tries again later. The count is kept in memory, so a restart starts the day again. Analytics rows are stamped with the wall clock, not nowIso, which settlements rely on to only move forward.

Deploying

Both halves run on one Oracle VM behind nginx:

  • API at https://api.sattle.tech: the sattle systemd unit on port 3100, from apps/api/deploy/sattle.service. Its nginx site is /etc/nginx/sites-available/battle on the VM, not in git (apps/*/deploy/nginx.conf is ignored, for a local copy). It also answers as battle.axiosiiitl.dev, its address before the move, which the installs from then have baked in.
  • Web app at https://sattle.tech: static files from expo export --platform web, served from /var/www/sattle-web/current, and also as sattle.axiosiiitl.dev for the links shared before the move. Its nginx site is /etc/nginx/sites-available/sattle on the VM, not in git. Every path falls back to index.html, so pay links (/s/<token>) open the guest page.

.github/workflows/deploy.yml deploys both, in two parallel jobs. Merging to main doesn't run it. Publishing a release does, and so does running it by hand from the Actions tab, which ships a server fix without a new app. It deploys the commit the run started on, and only from main: on any other branch both jobs are skipped.

  • api SSHes in, fast-forwards to that commit, runs npm ci for the API, restarts the unit and waits for /health, printing the unit's log if either step fails. If a later deploy already went past the commit, the fast-forward leaves it where it is.
  • web builds the web app in Actions against the API above, uploads it to releases/<sha> on the VM and repoints the current symlink, unless the live build already includes the commit. The five newest builds stay there; to roll back, point current at an older one.

It needs the ORACLE_VM_HOST, ORACLE_VM_USER and ORACLE_VM_SSH_KEY repository secrets. EXPO_PUBLIC_API_URL and EXPO_PUBLIC_APP_URL are the two addresses the web and Android builds bake in, each https://<host> with no path, read from repository variables, or from secrets of the same name. Variables suit them better: the addresses are public, a secret is masked wherever it appears in a log, and a pull request from a fork gets no secrets at all. No workflow names a host; every build checks for both first and stops without them.

The server's config lives in ~/sattle/apps/api/.env on the VM, not in git. For a live server, leave SEED and DEMO_USER_ID unset, so the database starts empty and every request needs a device account's token. Set PAYMENTS=nwc so settling up moves real money. The server refuses to start when NODE_ENV=production, which the systemd unit sets, if SEED or DEMO_USER_ID is set, and names the one to remove. Without PAYMENTS=nwc it starts but logs a warning, since settling up would move balances and no money. A public demo server that should simulate payments sets ALLOW_SIMULATED_PAYMENTS=true to say so. Set CORS_ORIGIN=https://sattle.tech,https://sattle.axiosiiitl.dev so only the web app, at either of its addresses, can call the API from a browser. The deploy jobs don't install the systemd units or the nginx sites. After changing the unit, sudo cp apps/api/deploy/sattle.service /etc/systemd/system/ && sudo systemctl daemon-reload && sudo systemctl restart sattle on the VM; after changing a site, copy it into /etc/nginx/sites-available/ and sudo nginx -t && sudo systemctl reload nginx. The unit sandboxes the server so the only place it can write is apps/api/data/. If .env moves DATABASE_PATH, update ReadWritePaths to match. Both TLS certificates come from certbot and renew themselves; each covers the new name and the old one, and the command that made it is noted at the top of its site file on the VM. Cloudflare fronts sattle.tech and api.sattle.tech with its SSL/TLS mode on Full (strict), so it checks the origin's certificate too.

Backups

The whole database is one SQLite file, apps/api/data/sattle.db. npm run db:backup -w @sattle/api copies it into apps/api/data/backups/ with VACUUM INTO, which gives a consistent copy while the server keeps running and writing. Copies are named sattle-<time>-<kind>[-<note>].db, and each kind keeps its newest few: 14 daily, 20 deploy, 10 manual. A server with no database yet has nothing to copy, and that isn't an error.

Daily copies come from a systemd timer, apps/api/deploy/sattle-backup.{service,timer}, installed once on the VM:

sudo cp apps/api/deploy/sattle-backup.{service,timer} /etc/systemd/system/
sudo systemctl daemon-reload && sudo systemctl enable --now sattle-backup.timer
systemctl list-timers sattle-backup.timer    # next run

Every deploy takes a deploy copy, named for the commit going out, just before it restarts the server, because that's when migrations run and they can't be undone. If the copy fails, the deploy stops there and the running server is left alone. To keep one past the last 20 deploys, take it by hand: npm run db:backup -w @sattle/api -- manual before-<what>.

To restore one, stop the server, put the copy in place and drop the old WAL files:

sudo systemctl stop sattle
cd ~/sattle/apps/api
cp data/backups/<file>.db data/sattle.db && rm -f data/sattle.db-wal data/sattle.db-shm
sudo systemctl start sattle

The copies sit on the same disk as the database, so they cover a bad migration or a mistaken delete, not losing the VM. For that, copy data/backups/ somewhere else too.

Publishing a release

Merging to main ships nothing. A release is one run of the publish workflow (.github/workflows/publish.yml), started from the Actions tab or:

gh workflow run publish.yml -f bump_type=patch -f track=internal -f update_priority=0

It takes the three inputs of the Android release and runs four jobs, each once the one before has succeeded:

  1. ci: typecheck and tests.
  2. android: the Android release, up to the Play upload.
  3. wait: until 30 minutes after the Android build started, to give Play's review a head start.
  4. server: the deploy of the API and web app, from the commit the app was built from, even if main has moved on since.

The wait lines the two up only roughly. Play reviews internal in minutes and can take hours over production, and installed copies update when their owners let them. So a server change still has to work with the previous app.

The ios job runs beside wait, once the Android release has tagged the version: it uploads the same commit, as the same version, to App Store Connect. The server doesn't wait for it, since App Review takes a day or more and starts only when someone sends the build for review. See Releasing the iOS app.

To ship one half alone, run its workflow on its own: deploy.yml for a server fix, android-release.yml for an app-only release.

Releasing the Android app

The Android half of a publish is the Create Android Release (APK & AAB) workflow (.github/workflows/android-release.yml). Run on its own, from the Actions tab or like this, it releases the app without deploying the server:

gh workflow run android-release.yml -f bump_type=patch -f track=internal -f update_priority=0
Input Values What it sets
bump_type patch (default), minor, major, none How the version moves from the newest vX.Y.Z tag. none rebuilds that version without moving its tag.
track internal (default), alpha, beta, production The Play track the build is published to.
update_priority 0 (default) to 5 How hard installed copies are pushed to update. See Update priority.

The run then does the whole release:

  1. Works out the version from the newest vX.Y.Z tag. Releases are tags only: main takes changes only through pull requests, so nothing is committed back, and apps/mobile/package.json is just the starting point before the first tag. Runs from any branch but main are refused.
  2. Generates android/ with expo prebuild and builds a signed APK and AAB. The version name is the bumped version. The version code is the minutes since 1970, so it goes up whichever workflow runs the build, where a run number would start again from 1 in each one. Play takes no code below one it already has, so the codes can't go back to small numbers.
  3. Tags the commit it built as vX.Y.Z and pushes only the tag, which the main ruleset doesn't cover. This comes after the build, so a failed build leaves no tag behind.
  4. Creates the GitHub release vX.Y.Z, with both files attached and the commits since the last tag as its notes.
  5. Uploads the AAB to the chosen Play track, rolled out to everyone on it.

just android-release builds the same signed APK and AAB on your own machine, into dist-android/, without bumping, tagging or uploading anything; scripts/android-release.sh lists its inputs.

Release builds go through R8, which drops the Java and Kotlin code nothing reaches and renames the rest, and drops unused resources too (expo-build-properties in app.json). Play asks for this: below 25% obfuscated, an app can lose visibility on Play. The AAB carries R8's mapping file, so Play reads crash reports with the real names without any upload of ours. Native code that finds a class by its name needs a keep rule, under extraProguardRules in the same plugin; none does today. A debug build skips R8, so after adding a native module, run a release APK on a phone. That can't check modules/in-app-updates: Play answers only a copy it installed, and when the module fails the app carries on with no update prompts, so a break there would go unnoticed. Check it from Play instead, as Android updates says: install one release from internal, publish a second there, and see that the first offers it. Do this before promoting the first release built with R8 to production, and again after changing the module or its Play library. Play also flags deprecated edge-to-edge calls such as Window.setStatusBarColor. Those left after R8 are in React Native's own window setup and expo-navigation-bar, which Android 14 and older need to draw behind the system bars and Android 15 ignores, and in a Material date picker that no screen opens (@expo/log-box brings Material in, and Material's own layouts keep the class). There is nothing in the app to change.

Every pull request gets a release build too, from the android-build workflow, so a change that breaks the release shows up before anything is tagged. It needs no secrets, only the two EXPO_PUBLIC_* addresses: the APK is signed with the debug key and kept on the run for 7 days as sattle-pr-<number>.apk. That APK installs on a phone, but not over a copy from Play.

Send a release to internal first and install it from Play on a phone. Once it's checked, promote it to production in the Play Console, which ships the same file. An urgent fix is the exception: run the release straight to production with the priority set, because the priority is fixed at upload.

What it needs from the repository:

Name For
Secrets KEYSTORE_BASE64, KEYSTORE_PASSWORD, KEY_ALIAS, KEY_PASSWORD Signing. The run stops at the start without all four, rather than ship a build signed with the debug key.
Secret PLAY_STORE_CREDENTIALS The Play upload: a service account's JSON key. Without it the run ends at the GitHub release.
Variables EXPO_PUBLIC_API_URL, EXPO_PUBLIC_APP_URL The API and the web app the build talks to and links to, each https://<host>. Every build checks for them first and stops without them. Variables, not secrets: the addresses are public, a secret is masked in every log line, and a fork's pull request gets no secrets.
Variable EXPO_PUBLIC_USE_MOCK Leave unset. The run refuses to send a mock build to production.

Releasing the iOS app

The iOS half of a publish is the Create iOS Release (App Store Connect) workflow (.github/workflows/ios-release.yml). It builds the commit the Android release tagged, as that version, with the Android version code as its build number, and uploads it to App Store Connect, where it shows up in TestFlight. Nothing reaches the App Store until someone picks the build in App Store Connect and sends it for review. Run on its own, gh workflow run ios-release.yml uploads main as the newest tag's version, as the Android release's none does. App Store Connect takes that only while the version hasn't been released; after that, publish a new one.

just ios-release does the same from a Mac: it regenerates ios/ with expo prebuild --clean, archives a Release build into dist-ios/, and uploads it, signed and sent through the Apple account Xcode is signed in to. The archive stays there, so Xcode's Organizer can upload it by hand if the upload fails. UPLOAD=0 exports the .ipa there instead. scripts/ios-release.sh lists its inputs. It deletes and regenerates apps/mobile/ios and builds with a DerivedData folder of its own, so build nothing else from that folder while it runs, in Xcode or with just ios: two builds there at once pull files out from under each other. Both compile Expo's modules from source (EXPO_USE_PRECOMPILED_MODULES=0, which the justfile sets for every iOS build): the precompiled ones were built with Swift 6.3 and don't load under Xcode 27's Swift 6.4.

The app's team is ios.appleTeamId in app.json, and its bundle ID is tech.sattle.app, under a domain we own. Android stays com.chanakya.sattle, since a published Play app can't change its package; App Store Connect fixes the bundle ID the same way once the app is made there. The runner has no Xcode account, so it signs by hand: the certificate and profile go into a keychain made for the run and deleted after it, and plugins/withIosReleaseSigning points the app target's Release signing at three build settings that the script sets only when it is given PROVISIONING_PROFILE. CocoaPods' targets never see them, since a library handed a provisioning profile fails the build. The runner builds with Xcode 26.6 (XCODE in the workflow); App Store Connect has taken only builds made with Xcode 26 or later since 28 April 2026.

What it needs from the repository. Until all six secrets are set, a publish leaves iOS out with a notice:

Name For
Secrets IOS_DIST_CERT_P12_BASE64, IOS_DIST_CERT_PASSWORD An Apple Distribution certificate with its private key, exported from Keychain Access as a .p12, then base64 -i cert.p12 | pbcopy.
Secret IOS_PROFILE_BASE64 An App Store provisioning profile for tech.sattle.app, base64 the same way. Make it after the App ID has Associated Domains turned on, which Xcode does on the first signed build from a Mac, or the build fails on the entitlement.
Secrets ASC_KEY_ID, ASC_ISSUER_ID, ASC_KEY_P8 An App Store Connect API key with the App Manager role (Users and Access, Integrations), for the upload. ASC_KEY_P8 is the text of the .p8 file.
Variables EXPO_PUBLIC_API_URL, EXPO_PUBLIC_APP_URL The same two as the Android release.

Android updates

A copy installed from Google Play updates itself in place. On launch and on every return to the foreground the app asks Play whether a newer version is out. If one is, Play asks once, downloads it while the app stays open, and a line above the tab bar offers Restart when it's ready. A "no" is remembered for that version, and after that the same line offers Update without interrupting.

Update priority

Every Play release carries an in-app update priority, a number from 0 to 5 that installed copies read when they find the release. It is the update_priority input of a publish or an Android release, and the app sorts it into two bands:

Priority What an installed copy does Use it for
0 to 3 The flow above: Play asks once, downloads in the background, and the app offers Restart. Ordinary releases. 0 is the default, and the app treats all four the same.
4 or 5 Play takes over the screen, installs and restarts the app. Backing out leaves Update above the tab bar, and the next launch takes over again. A release nobody should stay behind on: a security or payment fix, or a server change that older builds can't work with. The app treats both the same.

Three things about it come from Play, not from this app:

  • It is set at upload and can't be changed afterwards. A release that got the wrong priority needs another build.
  • It can only be set through the Play API, which is what the workflow uses. A release uploaded by hand in the Play Console gets 0.
  • It carries over skipped versions, on any track. Someone updating across several versions gets the highest priority among them, even from a build that only went to internal. So a priority 5 build on internal makes the next production release urgent for everyone on an older version.

The line between the bands is URGENT_PRIORITY in src/updates/updater.ts.

src/updates/updater.ts holds the rules and runs under vitest against a fake Play. The native half is a local Expo module in apps/mobile/modules/in-app-updates, which autolinking picks up on expo prebuild, so there is nothing to add to app.json.

Play only answers for a copy it installed. A debug build or the APK from a GitHub release gets no prompts, so the real flow can only be tried from a Play track: install one release from the internal track, publish a second, and open the app.

iPhone updates

iOS has no way for an app to download its own update, and iPhones install App Store updates by themselves by default, usually overnight while charging. The app covers the time until then, and the people who have turned that off. On launch and on returning to the foreground, at most once an hour, it asks Apple's public lookup (itunes.apple.com/lookup) for the newest version of its bundle ID on the App Store, in the storefront of the phone's region, or India's when that storefront doesn't sell Sattle (the version is the same in all of them). While that is newer than the one running, and the phone's iOS can run it, the line above the tab bar offers Update. That opens Sattle's App Store page in a sheet inside the app, where one tap updates it, and iOS closes the app to install it. If the sheet can't load the page, the App Store app opens on it instead.

Nothing opens by itself, and there is no update priority: every release gets the same line, and update_priority only reaches Play. A version is offered once Apple has released it, and the lookup can take a while to catch up. During a phased release the line offers it to everyone, since updating by hand skips the phasing.

src/updates/appStore.ts holds the rules and runs under vitest against a fake App Store. The native half is a local Expo module in apps/mobile/modules/app-store-updates, which autolinking picks up on expo prebuild like the Android one.

Only a copy from the App Store asks. TestFlight, an Xcode build and the simulator have a sandbox receipt and never look, so the real flow can only be tried from the App Store: with one version live, install it, release the next, and open the app.

Wiring the wallet

Write BreezWallet implements WalletProvider against breez-sdk-liquid, then return it from buildWallet() in the provider instead of UnavailableWallet. MockWallet, with its made-up balance, is only for demo mode on native. Web keeps UnavailableWallet, because the SDK ships Rust bindings and will not run in a browser.

Screens should branch on wallet.isAvailable, never on Platform.OS — that way a native user who hasn't finished wallet setup hits the same path as a web guest, which is the behaviour you want.

The ledger on Nostr

The server keeps the ledger in SQLite, so if the server goes away, so would a group's history. To stop that, every expense, every change to one, and every confirmed settlement is also published to Nostr relays as one event (nostrLedger.ts):

  • Signed by the server's Nostr key (made on first start, kept in the database), so a relay can't forge or alter an entry.
  • Encrypted with NIP-44 under a random key per group. Relays and anyone else see ciphertext. Only members are given the key.
  • Chained. Each entry carries a sequence number and the id of the entry before it, so a missing or reordered entry shows up when the ledger is read back.
  • Append-only. A published entry can't be altered. An expense that is edited gets a second entry with how it reads now, and one that is deleted gets an entry saying so; whoever reads the ledger back takes the last word on each.

Entries go through an outbox table, ledger_entries. Every few seconds the server signs an entry for anything new, then publishes whatever hasn't gone out. A relay outage or a restart only delays publishing. With LEDGER_RELAYS empty, entries are still signed and kept, and they go out once relays are set, history included.

In the app, the Backed up on Nostr card under Manage shows how much has been published and copies the group's backup key, sattle-ledger://<server pubkey>?key=…&relay=…. With that key and no Sattle server at all, there are two ways to read the group back. Both fetch the group's entries from the relays, check every signature and the chain, decrypt them, and show the balances and who pays whom.

  • In the app: /restore on the web, Restore a group from its backup key on the welcome screen, or Read it back on the backup card. It needs no account and makes no request to the API: the browser asks the relays for the server's entries under the group's tag, and decrypts them itself (src/ledger/readBack.ts, which reads with @sattle/core/nostrLedger). The key is pasted on the page and never goes in the address. The web app is served from the same VM as the API, so if the VM is gone, use the Android app, a local npm run web, or the script below.

  • In a terminal:

    npm run ledger:verify -w @sattle/api

    asks for the key and prints the result.

The key decrypts the group's whole history, and the entries sit on public relays for good, so treat it like a password. The script reads it from a prompt that doesn't echo, never from the command line: npm prints the command line, and the shell keeps it in history. For scripts, pipe it in or set SATTLE_LEDGER_BACKUP.

What it doesn't fix: the server signs every entry, so the record proves what the server said, not what each member agreed to. Members signing their own entries needs Nostr identities, which come next. Relays can't read an entry, but they can see the server's pubkey, a per-group tag, and when each entry was made.

Not in here yet

  • Getting your place back in a group that approves joins, where you were the only one who had joined, without the old device, the sign-in key, or a Nostr key linked beforehand. Nobody else is there to let the new device in.
  • Taking a device off a member. Whoever joins as someone stays them until that device leaves, and the person can't remove it from their other device.
  • Amber's own sign-in intents (NIP-55) on Android. Amber works today through its bunker:// link. Remote signing hasn't been tried in the installed app, only on the web.
  • Removing someone who has joined. They can leave, but nobody else can take them out.
  • BreezWallet, an in-app wallet. Until then the app has none: you receive through your own wallet over NWC or at your Lightning address, and pay from any wallet. Demo mode on native shows MockWallet.
  • Native routing. On web, /s/<token>, /g/<token> and /join/<token> open the right screen; the installed app handles /g/<token> and /join/<token>, on Android and iPhone. A pay link, /s/<token>, opens in the browser on every phone.
  • Paying a ghost's Lightning address with real payments on (see The API).
  • Live status over SSE in the signed-in app. The server streams it, but a browser can't attach a sign-in token to an SSE connection, so the app polls; short-lived stream tickets would fix that.
  • Knowing that a UPI payment happened. The person owed confirms it; a payment gateway that could confirm it for us would mean holding people's money.
  • Members signing their own ledger entries with the Nostr key they sign in with, and on-chain rails.

The types already have room for all of these. None of them are implemented.

License

MIT.

About

Split expenses and settle up over Bitcoin Lightning. Only one person needs the app.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages