Seedelf-Wallet

Chunk 43 · Lovejoin’s reward balance

Branch web-wallet/lovejoin-reward-balance, from main.

Status: ✅ done, for 1.8.1. Archived with its PR (What its PR did, at the end). Planned 2026-11-04; the owner picked it for 1.8.1 on 2026-11-06. Steps 1, 2, 3 and 5 are built (Built so far, below). The edge case’s live run is declined (the owner, 2026-11-06, below). A small chunk: the wallet’s Lovejoin transactions withdraw whatever sits in mix_logic’s reward account, where today they always withdraw 0.

Step Status
1 · Core: the amount, and where it goes ✅
2 · WebAssembly: the requests carry it ✅
3 · The worker: the read, Send’s read, the refusal ✅
4 · Tests, and a live run on preprod ✅ every suite; the edge case’s live run declined
5 · The guard: the wallet never pays into mix_logic’s account ✅

What the owner decided (2026-11-04)

And on 2026-11-06, picking it for 1.8.1: “We want this case to be rare and if it happens default to lucky winner such that everything just continues on as normal.” Also: “make sure that the wallet at least does not allow a user to set that stake key for anything” (Step 5).

Built so far

Steps 1 and 2, 2026-11-06, on this branch. Core’s suite and the WebAssembly crate’s pass, with clippy clean. Where the build departs from the plan below:

Steps 3 and 5, 2026-11-06. The extension’s Vitest suite passes with the new tests (lovejoin-reward-balance.test.ts, and in koios.test.ts, dapp.test.ts, wasm’s cip30_test.rs); the 1.5.0 replay’s trace now has one account_info before each box’s way back. Where the build departs from the plan:

Why the wallet can take it

Step 1 · Core

Where it ends up

Transaction Built for The balance goes to Then
mix a session’s chain: a return, a mix from the private balance, Mix my boxes again the change, at the session’s one-time account each mix pays from the one before’s change; the session’s return sweeps the last into the private balance (with_return, wasm lovejoin.rs:1753)
mix a mix from the public account, and Mix again from it the change, at the public account it stays there: a public chain has no return
mix_giveme a session’s collateral, mixed once: its chain’s tail, that mix built again, a direct return’s tail the change, at the session’s account the sweep after it brings it into the private balance (lovejoin.rs:1801, :479, :398)
withdraw a box’s way back, under giveme.my’s collateral the fresh Seedelf register the private balance
withdraw_paid Bring one back, the public account paying the register the private balance; the account’s change as before
withdraw_private Bring one back, a private UTxO paying the register the private balance

Step 2 · WebAssembly

Step 3 · The worker

Step 5 · The guard

The owner, 2026-11-06: “the wallet at least does not allow a user to set that stake key for anything.”

Where the balance comes from

When the balance moves between build and send

How a chain goes today. It’s built whole and signed before any of it is sent, so every amount is fixed at the build.

Proposed, the simplest that’s correct:

  1. The refusal gets a type. koios.ts throws a RewardsChangedError, a KoiosError as SpentInputError is (:625), where stakingRefusal (:700) finds it, in staking’s words as now.
    • Lovejoin’s flows tell it by its type, never its text, and say their own words: a key of its own, read through a function, never a module-level t(), and named .warn. where a warning shows it (tests/i18n-worker-reasons.test.ts).
    • The data layer hands the node’s refusal on as it came (data-layer.ts:393), so koios.ts is the one place.
  2. Send reads again. A chain kept for Send reads each of its pools’ balances where it starts: lovejoin.ts’s publicStart (:4609, beside its lj.mixTooOld check at :4616), and a reviewed return’s, backSubmit (sessions.ts :3124) and Bring everything back’s claimSubmit (:3188).
    • One that moved is a stale review (StaleReviewError): “Review it again”, before anything is sent.
    • A runner’s chain is built and sent at once, and skips this.
  3. A withdraw is built again once. withdrawOne takes a refusal as never sent and gives its box’s due time back (:7028-7043). On this one it reads again and builds once more at once, with giveme.my’s witness asked again where it’s giveme.my’s. Refused again, it goes as now.
  4. A chain refused while it’s sent stops, as any refusal stops it, in its own words, and what it left takes the ways a chain cut short already has. That needs the balance to move in the minutes a chain is sent: an epoch starting, or another wallet’s Lovejoin transaction in the seconds after Send’s read.

Not proposed: building the rest of a cut chain again (call 2).

Step 4 · Tests

Privacy

Out of scope

The owner’s calls

  1. ❓ A line on a review that takes a balance. A return’s review and a public mix’s show what comes back with it counted, which can be far more than went in.
    • Recommended: one short line, only when there is one, naming it as what was left in the pool’s reward account for anyone to take. Nothing elsewhere: Activity shows the amount, and Transaction details the withdrawal, as for any.
  2. ❓ Building the rest of a cut chain again (Not proposed, above).
    • Recommended: not now. It needs the balance to move in the minutes a chain is sent, the chain then stops as a lock would stop it, and nothing is lost.

When it lands

The live run on preprod (2026-11-06)

The everyday path, with nothing in the pool’s account: the edge case’s run is declined (Step 4). Wallet A on this branch’s build, v2’s 5 ₳ pool 47bece42 (its mix_logic account stake_test17paf6kalpq7dxdfkxk3crsxdg4gr0ufx23zl0a4w4t0m3vq8my4fa), A’s 60 held boxes left alone. Hosts contacted: preprod.koios.rest and www.giveme.my alone.

What its PR did

#367 (web-wallet/lovejoin-reward-balance, into main):