diff --git a/docs/README.md b/docs/README.md index afb95ef2..17dc037b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -58,10 +58,11 @@ The subgroup-wallet-policy note is a phased plan that has been built. It reads as the guardians note's *whose choice it is* reversed: read that section, then this note's Phase 0, whose five decisions shape every phase after it, and its table of where the build chose differently before the code. -The guardian-delay note is a phased plan that has not been built. It changes +The guardian-delay note is a phased plan that has been built. It changes the guardians note's *Why 12, and why for everybody* and reuses the wallet-policy note's plumbing one field further: read both, then its table of -what is already per leaf, then its Phase 0. +what is already per leaf, then its Phase 0, and its table of where the build +chose differently before the code. The Material Design note is a phased plan that has not been built, and is the only one about what the app looks like rather than what it does; read the jvm-target note first if you want to know why its adaptive-layout phase exists. diff --git a/docs/group-wallet-guardians.md b/docs/group-wallet-guardians.md index 074c1126..32a10ad5 100644 --- a/docs/group-wallet-guardians.md +++ b/docs/group-wallet-guardians.md @@ -39,8 +39,10 @@ cap as every other spend, `GroupWalletRollout.MAINNET_CAP`. The headline: **the parent puts a guardian key for the child into the child's birth certificate, beside the keys its own ancestors gave it, each derived one public step further for this child. Each becomes a leaf -` OP_CHECKSIGVERIFY 12 OP_CHECKSEQUENCEVERIFY` in every address of the child's -wallet.** Every ancestor can take a coin once it has 12 confirmations. The +` OP_CHECKSIGVERIFY OP_CHECKSEQUENCEVERIFY` in every address of the child's +wallet.** Every ancestor can take a coin once it has `d` confirmations, where `d` +is the delay that ancestor chose when it made the group below it — 12 unless it +chose otherwise, see [guardian-delay.md](./guardian-delay.md). The ancestor's quorum signs for its leaf with the FROST session it already runs, under plain tweaks of its own threshold key. @@ -131,16 +133,25 @@ anything the group did: a coin with 12 confirmations is the guardian's to take, and one that arrived or was moved within the last two hours is not. `12` is the single opcode `OP_12`, so the script is 36 bytes. -**Why 12, and why for everybody.** It is `GuardianDerivation.ANCESTOR_DELAY`, one -constant, the same at every distance. What it buys: +**Why a delay, and who sets it.** This section was *Why 12, and why for +everybody*: 12 was one constant, the same at every distance. Since +[guardian-delay.md](./guardian-delay.md), each parent chooses its own leaf's delay +when it makes a guarded subgroup, from `GuardianDerivation.MIN_DELAY` (6, about an +hour) to `MAX_DELAY` (65,535, BIP68's block-based ceiling, about 15 months), with +12 as `DEFAULT_DELAY`. Every inherited key keeps the delay its own ancestor chose, +so each group's terms follow its key down the tree. What 12 buys, and what a floor +of 6 keeps: -- **Not autonomy.** Two hours is not long enough for a child to notice a coin - coming within reach and move it. In practice this is an override, and it is - meant as one: ancestors have control now, not as a last resort. +- **Not autonomy, at 12.** Two hours is not long enough for a child to notice a + coin coming within reach and move it. In practice this is an override, and it + is meant as one: ancestors have control now, not as a last resort. A long delay + changes that: the clock is per coin and moving a coin restarts it, so a child + that moves its coins before a month-long lock runs out keeps them out of reach. + A long delay is a backstop for a group that falls silent, not an override. - **The child's own spends always go first.** A guardian cannot race the child for a payment that has only just arrived, nor take change from a spend the child made an hour ago. -- **It is a relative lock**, so every guardian input carries `nSequence = 12` in +- **It is a relative lock**, so every guardian input carries `nSequence = d` in a version-2 transaction. That is far below `GroupSpend.MAX_SEQUENCE`, so a guardian spend still signals replaceability and *Bump the fee* still works. @@ -455,4 +466,4 @@ there is none on mainnet to write it with (`OP_CHECKTEMPLATEVERIFY`, | passing inherited keys down unchanged | a grandchild's leaves would equal its parent's wallet's at the same index, and a guardian spend from one would link the two | | the whole certificate chain in the statement | nobody needs it to be safe — the parent's quorum vouches for the inherited keys and already holds more power than they give — and nesting signed events inside signed events escapes JSON once per level | | the tree in PSBT fields | bitcoin-kmp does not parse them; every signer rebuilds them anyway | -| delays escalating with distance | asked for and replaced: every ancestor at 12 blocks, for now | +| delays escalating with distance | asked for and replaced: every ancestor at 12 blocks, for now. Since [guardian-delay.md](./guardian-delay.md) each ancestor's delay is its own choice instead | diff --git a/docs/guardian-delay.md b/docs/guardian-delay.md index 7f92edd8..db66f71e 100644 --- a/docs/guardian-delay.md +++ b/docs/guardian-delay.md @@ -23,7 +23,25 @@ the guardian tag from the first and the wallet-policy plumbing from the second, and it changes one section of the first: [*Why 12, and why for everybody*](./group-wallet-guardians.md#the-leaf). -**Not built.** Written against the code as it stood at `60cb3fa7`, schema v29. +**Built**, phases 1-8, one commit each, in the order the plan asked for — +Phase 7 before Phase 5 — written against the code as it stood at `60cb3fa7`, +schema v29; the build is schema v30. `GuardianDerivation.DELAY_RANGE`, +`grant(..., delay)`, `BlockDuration` and `delayText` are the entry points. The +phases below are kept as written, line references included, which have since +moved; where the build chose differently the table says so. + +| what the plan said | what it turned out to be | +|---|---| +| Phase 2: one jvmTest | two. The script edges are in `GuardianSpendRoundTest` (commonTest), beside the 12-block test they generalise; the builder and the check are in `GuardianSigningJvmTest`, where the funded-state fixture is | +| Phase 3: `BlockDuration` in `wallet/` | in `text/`, beside `Sats.kt`, with `groupedBlocks()`. `delayText` and `approximateDuration` are in `ui/composable/widgets/DelayText.kt`. `BlockDuration.describe` says the same in fixed English for `ProposedEvent`, which is not a composable | +| Phase 4: a migration test | none, as for the policy's v29: the nullable auto-migrations have none, and every jvmTest's in-memory database runs at v30 | +| Phase 5: `setGuardianDelay` stores what was typed | two calls: `setGuardianDelay(blocks)` for a preset and `setGuardianDelayInput(text)` for the field, which drops anything but digits and stops at seven, enough to say *at most 65,535* about a number past it. The presets are `SelectSubgroupAdminsViewModel.DELAY_PRESETS`, as `FilterChip`s in a `FlowRow`. A retry comes back on its preset when it was one, and in the field when it was not | +| Phase 5: tests of `confirm` | not written, as for the policy: `confirm` needs an `Identity` with a private key and settled key packages | +| Phase 6: the summary's own-leaf line | a separate element, *this group after 144 blocks, about 1 day*, after the existing reach line | +| Phase 7: the guarded section's title says the shortest delay | not built. Each guardian is listed nearest first with its own delay, named by the room this device holds for it — `GroupWalletUIState.guardianNames` — and otherwise *a group above this one* | +| Phase 7: `withinReach` reads `wallet.account.guardians[position].delay` | `GuardianManager.GuardedWallet.delay`, the same thing named once | + +Still to do by hand: the three-emulator run in Phase 8. --- diff --git a/docs/subgroup-wallet-policy.md b/docs/subgroup-wallet-policy.md index 3c6b6d95..0a722414 100644 --- a/docs/subgroup-wallet-policy.md +++ b/docs/subgroup-wallet-policy.md @@ -265,6 +265,10 @@ A *Wallet* section under the threshold stepper, two radio rows in one | guarded | Guarded wallet | This group and the `N` above it can spend its coins once they are 12 blocks old | | unguarded | Unguarded wallet | Only the subgroup can spend from its wallet. Groups above it cannot reach it or anything beneath it | +Since [guardian-delay.md](./guardian-delay.md), the guarded row no longer quotes +12: under it the coordinator chooses the delay on this group's own leaf, from 6 to +65,535 blocks, and each group above keeps the delay it chose. + `N` is the count of the parent's own guardians (`SubgroupManager.guardiansOf`), so the line names the reach the parent is actually granting rather than "the groups above". The second sentence of the unguarded line is D2's cost; drop it if