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.
mix_logic’s script reward account (withdraw_zero.rs:96). mix_logic is a withdraw-zero validator: that withdrawal is what runs it, once a transaction.:16-17), and refuses anything else as WithdrawalsNotInRewards, which koios.ts:701 words today.mix_logic’s. Register a stake pool that names its reward address as the pool’s reward account, then retire it: POOLREAP refunds the pool’s 500 ₳ deposit into the account, which is registered, as withdraw-zero needs. A pool paying its rewards there does it too, and so does a governance action’s deposit coming back.| 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 |
✅ |
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).
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:
Rewards hands a balance over only once a transaction is built (balance to read it, taken once built), so a build that fails takes nothing. A chain that fails part-way keeps what its earlier mixes took, so the public account’s chain, which tries again with one more UTxO (chain_from_account_at), starts each try from a copy. Rewards::of drops a balance of 0.&mut Rewards as its last argument: mix, mix_giveme, the three withdraws, chain, chain_from, chain_across, again, again_at, collateral_tail and collateral_mix. The tests pass &mut Rewards::none(), and the two way-back probes (way_back, usable) do too.withdraw_paid: the balance counts toward the register’s minimum, so the account makes up only what the boxes and the balance still fall short of. Its change is as before unless the box can’t pay its way back, which is when withdraw_paid is used: then the balance covers the top-up.Mix, Withdraw and ChainTx carry taken. The WebAssembly results add no field: returned and a withdraw’s lovelace count the balance, and the worker can read what its own transactions withdraw from the bytes it holds (txWithdrawals, as withdrawingOf does).rewards, { <mix_logic hash>: <lovelace, a decimal string> } (RewardsIn), on ChainRequest, CollateralMixRequest, AccountChainRequest, the three withdraws’ and api::SessionReturnRequest. A hash that isn’t 28 bytes, or an amount a u64 doesn’t hold, is refused in words.lovejoinMixLogic: { network, poolRef } in, the classic pool without a poolRef, { hash, stake } out. wasm/README.md names it and every request’s rewards.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:
LovejoinService.rewardsIn, in lovejoin-rewards.ts’s rules. A session’s chain keeps its reads on its ChainCall (rewardsOf), so each pool is read once a build, its stale rebuilds and four’s fall to three included; acrossOf adds its legs’ pools to the same reads.unread: never taken at Send for a balance that moved. A figure that’s no whole number, or past all the ADA there is, is 0 too.heldSent, goingOut’s either), and a chain being sent, its unsent first mix included: its reservation now keeps takes, what it withdraws by account, and holdOnly keeps a held step’s. A chain kept for Send doesn’t count: Send’s read catches two that took one balance. The rule is account.ts’s: on its way and read at least as much, 0; read less, that one landed, and what’s read is new.rewardsMoved, of the accounts a kept chain’s transactions withdraw from (balances, readsFor), in publicStart, backSubmit and claimSubmit, a StaleReviewError in lj.rewardsMovedReview’s words. A runner’s return is built and sent at once, and isn’t asked.RewardsChangedError, staking’s words still. A chain it stops says lj.warn.rewardsMoved (pumpPublicNow, sessions.ts pump). withdrawOne builds again once, in its submit’s catch, with giveme.my asked again; refused again, it’s a KoiosError in those words, its due time back.paidScripts (cip30.rs: a pool registration’s reward account, a proposal’s return, a treasury withdrawal’s payee, where each is a script’s), and DappService refuses one among LovejoinService.mixLogicHashes (the classic pool and every pool discovery keeps, retired pools and copies included, asking nobody; #367’s took a copy only once handed over or found holding the wallet’s boxes, which told a site where those were: 1.8.1’s release review, guard#1, v-guard#1), in dapp.lovejoinRewards’s words, before the user is asked.lj.rewardsMovedReview, lj.warn.rewardsMoved (accuracy-critical, back-translated without the English in view, in verified-critical-es/ja.json) and dapp.lovejoinRewards, in en, es and ja.seedelf-platform/CLAUDE.md’s Things that bite.mix_logic’s withdraw handler names its account _account and never reads the withdrawals (Lovejoin’s contracts/validators/mix_logic.ak:46, at cb5a5a3, the classic pool’s mainnet commit, and at 8131b1d, the token-pool templates).mix_box asks only that mix_logic’s credential withdraws (mix_box.ak:62, pairs.has_key; its header: “The amount is unconstrained”).mix_logic, anyone’s Lovejoin mix or withdraw, takes all of it: nothing else can withdraw a script’s account. So once one has taken it, it’s 0 until the next epoch starts.seedelf_core::eval), the network’s check of a chain’s first mix (Koios’s Ogmios, lovejoin.ts crossCheck), and giveme.my’s, which is “not full phase-1 ledger validation or a balance check” (check_valid_tx in its source). Only the submit sees a wrong amount, and it refuses it at no cost.Rewards beside the protocol: each pool’s balance by its mix_logic hash. It hands a pool’s balance to the first transaction there that asks for it, and 0 after: the first takes it all. Empty, every builder builds today’s transaction, and the existing tests pass with it added.WithdrawZero (withdraw_zero.rs:56) gains the lovelace it withdraws, where (account, 0) is at :96. The name stays: withdraw-zero is the pattern’s, and the amount is 0 nearly always.mix_with (lovejoin/mod.rs:899), WithdrawZero::new at :968 and the patch at :1033 take it. The change is the payer’s ADA plus it, less the fee, in two places:
:975-981;Mix::change at :1108-1111, computed apart, which the next mix and a session’s return build on as an unsent input.ctx, :931-939), so nothing else moves. The amount’s few bytes are priced as the fee settles (:1081-1093).checked_add, and refused in words past a u64 (seedelf-platform/CLAUDE.md’s rule).withdraw and withdraw_private have no other output, and for withdraw_paid it’s the private side rather than the account, as the owner’s “going to their Seedelf” has it.
into_register (:1391-1406) adds it for all three, and the patch at :1484 writes it. withdraw_paid’s change to the account stays as it is (:1434-1444, :1588-1597).CantPayBack and PrivateTooSmall (:1574-1587) read into_register, so they count it.owner_context, :1171). They’re made after it’s staged, as now.fan_out (:2380) passes it to each mix (:2407), so only its first in a pool takes any;chain_across’s legs (:2149, Leg at :2137) are a pool each;again_at (:2225), collateral_tail (:2259) and collateral_mix (:2298, its mix_giveme at :2316) ask too.Rewards for the whole chain matters: a mix session into the 5 ₳ pool mixes its collateral there too, and that tail’s mix must withdraw 0 once the chain’s first mix has taken it.way_back (box_value.rs:281) and comes_back (pool.rs:618), which build a withdraw to judge a pool. They stay at 0, so a pool’s verdict never moves with a windfall.| 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 |
rewards, { <mix_logic hash>: <lovelace> }, #[serde(default)]: none is 0 everywhere, today’s transactions (lovejoin.rs).
ChainRequest (:1295), one map for the chain’s pool, each leg’s (LegRequest, :1030) and the collateral’s 5 ₳ pool;api::SessionReturnRequest (lib.rs:922), for a direct return’s tail (direct_tail, :1420);CollateralMixRequest (:420), AccountChainRequest (:2025), and the three withdraws’ (:2503, :2585, :2701).mix_logic hash and stake address from protocol_of (:110), the classic pool’s included, as a launch’s result already does (mix_logic_stake, lib.rs:2564). It’s pure, so the worker keeps it per pool.ChainResult::returned (:1402), which is what a public chain leaves in the account, and a withdraw’s lovelace.accountInfo for each pool’s mix_logic stake address and takes rewards_available (no row: 0). It’s asked before unstale (:4156), so a stale pool’s rebuilds and four-wide’s fallback to three reuse it, in:
fanOut (:3524), with the collateral pool’s where collateralAsked (:790) asks for one, and acrossOf (:3639), each leg’s;tailChain (:4031), publicBuild (:4311), publicAgainBuild (:4467), and each branch of withdrawOne (:6883);buildSessionReturn, :4560) whose collateral goes into the 5 ₳ pool.withdrawingOf, incoming.ts:176, used at account.ts:184-193). The worker holds those bytes: a chain being sent, a withdraw kept as sent.The owner, 2026-11-06: “the wallet at least does not allow a user to set that stake key for anything.”
mix_logic’s publish handler accepts only RegisterCredential: at the classic pool’s cb5a5a3 and at v2’s 29573c5, mix_logic.ak (“Delegation, redelegation, and governance certs are rejected by the same default”). So its credential can’t be delegated, and no staking rewards ever arrive. What does arrive is named by someone’s transaction, with no witness of mix_logic’s:
mix_logic reward account in any of the three, in its own words, as it refuses a session’s stake key (dapp.sessionStakeKey, dapp.ts).
Cert::credential, Proposal::credential and recipients are key hashes only). It gains the script hashes those three name.mix_logic hashes, the classic pool’s (lovejoinMixLogic) and every found pool’s (PoolView.mixLogicHash, kept under seedelf.lovejoinPools.<network>). One among the script hashes is refused, before the user is asked.mix_logic’s. That address puts nothing in the account (its stake can’t be delegated), so it’s left alone unless the owner wants it refused too.account_info, as the account’s own rewards are read. On mainnet the data layer first, then Koios for a part that’s down or with the Koios-only switch on (data-layer.ts:297, the root CLAUDE.md); on preprod, Koios.
stake_bytes, ids.rs:36, header 0xf1). Its rewards_available counts every kind, a refunded pool deposit included, less the withdrawals (account.rs:143, :254). Nothing changes there.:413).koiosAlone.account_info per pool a build mixes in or withdraws from, never per mix.
dataCost: one user’s live SQL) and keeps no answer; on Koios’s public tier it’s one request. Beside a chain’s 4k + 2 (architecture.md’s What each costs), it’s one or two more.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.
BUILT_TTL_MS, lovejoin.ts :148, sessions.ts :228).pumpChain (:437) sends it in order, at most CHAIN_WINDOW (:294; CHAIN_WINDOW_FOUR for four-box mixes, :300) in the mempool at once.chainRetryMs, :236) stops it: pumpPublicNow’s catch (:4825), sessions.ts’s pump (:5019). Its unfinished boxes lose their due times (lovejoin.ts chainEnded, :5082) and wait, not mixed yet, for Mix my boxes again. A session’s rest comes back directly (chainSoFar, sessions.ts :1264).Proposed, the simplest that’s correct:
RewardsChangedError, a KoiosError as SpentInputError is (:625), where stakingRefusal (:700) finds it, in staking’s words as now.
t(), and named .warn. where a warning shows it (tests/i18n-worker-reasons.test.ts).data-layer.ts:393), so koios.ts is the one place.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).
StaleReviewError): “Review it again”, before anything is sent.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.Not proposed: building the rest of a cut chain again (call 2).
pumpPublicNow’s id, :4719; ChainGone; sessions.ts’s pendingHere and a session’s chain.last; chainEnded). So a rest built again is a new chain resuming the old, as a collateral’s mix built again is (tailChain, resumes, chainSoFar’s from).again_at fans out from the wallet’s boxes alone.a_mix_of_pool_boxes_passes_mix_logic, :228, and a_mix_under_givemes_collateral_passes_mix_logic, :430):
mix_logic’s reward account. Its change output and Mix::change both hold the payer’s ADA plus it, less the fee, and inputs plus the withdrawal equal outputs plus the fee;mix_with measures the finished transaction against the bundled scripts (:1096), and withdraw_with each round, so building at all is the scripts passing with an amount that isn’t 0;withdraw_paid’s change not; and a chain across two pools, whose first mix in each withdraws that pool’s balance and every later one 0, its last change carrying both;Rewards builds what it builds today; a balance that passes a u64 with the change is refused in words;a_mainnet_mix_and_withdraw_pay_the_ledgers_minimum, :299, checks today), and a token pool’s (lovejoin_pools_test.rs);a_patch_adds_the_withdrawal_and_its_redeemer, :85).wasm/tests/lovejoin_test.rs): a session’s chain’s first mix takes its pool’s balance and its collateral’s tail the 5 ₳ pool’s, the return sweeping both into the private balance and returned counting them; a tail in the chain’s own pool takes nothing once the chain took it; a public chain’s first mix takes it, and the second withdraws 0; a box comes back with it in its register; none, or 0, is none, and a hash or an amount that isn’t one is refused in words. lovejoin_across_test.rs passes none (1.8.1’s release review, mutants#10, money#2).WithdrawalsNotInRewardsCERTS is a RewardsChangedError, still in staking’s words (:364);account_info once for each pool’s mix_logic and sends the figures, and one the wallet’s own chain on its way takes counts as 0. The fakes answer account_info by stake address (fakes.ts:248), and an address they don’t know is 0, so every test today builds as it does;rejectSubmit, :233) is built again with the new figure and sent; refused twice, its due time goes back;pumpPublicNow (lovejoin-reward-balance.test.ts), not chain-resend.test.ts’s pumpChain as planned (mutants#10).Set::V2 with a take, every chain transaction’s balance, the classic scripts’ withdraw_paid and withdraw_private, and mainnet’s mix_giveme (core#1, money#1); a withdraw refused after it read the balance taking nothing, and Mix again’s take leaving the caller’s Rewards (mutants#1, #2);rewards: chain_across_pools and its tail, again_from_account_at, withdraw_paid_in, withdraw_private_in, collateral_mix and session_return’s direct tail (mutants#3, money#2); and a proposal’s deposit return in paidScripts on its own (mutants#4);lovejoin-rewards.ts’s rules (a sent transaction counted as on its way, the most a chain being sent takes, a reading above the take, a move in one of two pools), and the read’s own (mutants#5–#8, worker#4);lovejoin left out of sw.ts’s wiring (guard#3, mutants#9);ConwayIncompleteWithdrawals and ConwayWithdrawalsMissingAccounts, which koios.ts missed: every test above hands it the older WithdrawalsNotInRewardsCERTS (readers#4).mix_logic account, and retire it at the next epoch: its 500 tADA deposit lands there as that epoch starts;account_info for every wallet that uses the pool, from the IP address that sends the transaction, and at its review, even one never sent (1.8.1’s release review, guard#7), as the pool read before it already tells the server. It’s still a new request, so privacy.md’s Lovejoin What Koios learns gains it, and the privacy policy a dated entry under Changes, in the same PR (the plans README).account_info among its diagram’s reads, a chain’s first mix in each pool taking the balance, and What each costs.seedelf-platform/CLAUDE.md’s Things that bite: withdraw_zero.rs withdraws the account’s balance, 0 nearly always.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.
account_info of the pool’s account at the build, one more at Send, then the chain: deposit baca0b1ad8bf3c9a9d12d71df18a9d38b0df6074e663ed8bf6a5cb6199d9b818 to its last mix 76993d4772703f670cbdae22bb05fb76951eb5d2fae2e20c20a68b6bf3b5c040 (block 5382052), each mix withdrawing 0.18ff63d8…#0): one account_info, then giveme.my and the submit: c70ade9e345e7a4cc7640884254ccbfa0830d2fb5118d8e03a3ee40669750afd (block 5382055), withdrawing 0, 4.704978 ₳ into the register.b786e87e5d6e9bad6c1ee0739c94dd8484bf695d9004dd7e3296cf25f69b17f9, then the runner’s chain with one account_info for its pool and its collateral’s, the same 5 ₳ pool: deposit c0f2429186b3b465d6964246eb872da938292d8b5dc218fc84934a7fa4270a8a, mixes f240623e…, 51adb8da…, 4f16def1…, 210eee60…, the collateral’s deposit 8255a59a… and mix 6f100296… (giveme.my’s), and the return 0c02eacb5b69b9612a7f8c33f1e523819c30ef89503a0abf8a273d99d81b52db (blocks 5382064–5382069), every mix withdrawing 0.#367 (web-wallet/lovejoin-reward-balance, into main):
ad429751): Rewards, the &mut Rewards every Lovejoin builder takes, WithdrawZero’s amount, and where a balance goes: a mix’s change, a withdraw’s register. The tests, mainnet’s and the token pools’ among them.179bba3d): every request’s rewards, a chain and its collateral’s tail on one, and lovejoinMixLogic.7a8c9eeb): Step 3’s read, on-the-way rule, Send’s read and the typed refusal; Step 5’s paidScripts and the signer’s refusal; the words in three languages; privacy.md, the privacy policy’s dated entry, architecture.md and seedelf-platform/CLAUDE.md.67300f18), then this record, the plan moved here, and the backlog’s three lines for what’s left open.