diff --git a/composeApp/src/commonMain/composeResources/values/strings.xml b/composeApp/src/commonMain/composeResources/values/strings.xml
index d9037e04..727f9cca 100644
--- a/composeApp/src/commonMain/composeResources/values/strings.xml
+++ b/composeApp/src/commonMain/composeResources/values/strings.xml
@@ -848,4 +848,6 @@
Bump the fee
Sent again
Couldn't bump the fee: there isn't enough left over to pay it.
+ For now, a spend sends everything the group has confirmed to one address, less the fee.
+ While the wallet is new, a spend on mainnet can send at most %1$s sats.
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/ChatRoomDetailScreen.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/ChatRoomDetailScreen.kt
index 15a19383..b7bc0cb5 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/ChatRoomDetailScreen.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/ChatRoomDetailScreen.kt
@@ -1,5 +1,6 @@
package com.machankura.bennu.compose.ui.composable
+import com.machankura.bennu.compose.wallet.GroupWalletRollout
import com.machankura.bennu.compose.ui.composable.navigation.routes.GroupWalletRoute
import com.machankura.bennu.compose.nostr.wallet.GroupWalletStatementEvent
import bennu.composeapp.generated.resources.open_on_s
@@ -528,7 +529,7 @@ fun ChatRoomDetailScreen(
// leaves the group. Shown to every member, open or
// not -- the screen behind it is where a member who
// can sign asks the group to open one.
- item {
+ if (GroupWalletRollout.ENABLED) item {
SignedWorkRow(
icon = Icons.Default.AccountBalanceWallet,
headline = stringResource(Res.string.group_wallet),
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/GroupSendScreen.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/GroupSendScreen.kt
index e198fd46..c2e25fed 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/GroupSendScreen.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/composable/GroupSendScreen.kt
@@ -1,5 +1,8 @@
package com.machankura.bennu.compose.ui.composable
+import com.machankura.bennu.compose.wallet.GroupWalletRollout
+import bennu.composeapp.generated.resources.for_now_a_spend_sends_everything
+import bennu.composeapp.generated.resources.while_the_wallet_is_new_at_most_s_sats
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@@ -159,19 +162,29 @@ fun GroupSendScreen(
label = { Text(stringResource(Res.string.address)) },
)
- Row(
- modifier = Modifier.fillMaxWidth(),
- verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.SpaceBetween,
- ) {
- Text(stringResource(Res.string.send_everything))
- Switch(
- checked = groupSendViewModel.sendEverything.value,
- onCheckedChange = { groupSendViewModel.sendEverything.value = it },
+ // Send-all only while the wallet is new: no switch, no amount,
+ // and a sentence saying everything confirmed is what goes.
+ if (GroupWalletRollout.SEND_AN_AMOUNT) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.SpaceBetween,
+ ) {
+ Text(stringResource(Res.string.send_everything))
+ Switch(
+ checked = groupSendViewModel.sendEverything.value,
+ onCheckedChange = { groupSendViewModel.sendEverything.value = it },
+ )
+ }
+ } else {
+ Text(
+ text = stringResource(Res.string.for_now_a_spend_sends_everything),
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
- if (!groupSendViewModel.sendEverything.value) {
+ if (GroupWalletRollout.SEND_AN_AMOUNT && !groupSendViewModel.sendEverything.value) {
OutlinedTextField(
modifier = Modifier.fillMaxWidth(),
state = groupSendViewModel.amountField,
@@ -255,6 +268,7 @@ private fun SendPreview(result: GroupSpendBuilder.Result, chain: Chain) {
stringResource(Res.string.that_isn_t_an_address_on_s, GroupWalletStatementEvent.chainName(chain))
GroupSpendBuilder.Result.NothingToSpend -> stringResource(Res.string.the_group_has_nothing_confirmed_to_spend)
GroupSpendBuilder.Result.NotEnough -> stringResource(Res.string.the_group_doesn_t_have_that_much_confirmed)
+ is GroupSpendBuilder.Result.OverCap -> stringResource(Res.string.while_the_wallet_is_new_at_most_s_sats, result.cap.grouped())
else -> stringResource(Res.string.that_is_too_little_to_send)
},
style = MaterialTheme.typography.bodyMedium,
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/view/model/GroupSendViewModel.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/view/model/GroupSendViewModel.kt
index 4c3fcc8a..63348625 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/view/model/GroupSendViewModel.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/ui/view/model/GroupSendViewModel.kt
@@ -1,5 +1,6 @@
package com.machankura.bennu.compose.ui.view.model
+import com.machankura.bennu.compose.wallet.GroupWalletRollout
import androidx.compose.foundation.text.input.TextFieldState
import androidx.compose.foundation.text.input.setTextAndPlaceCursorAtEnd
import androidx.compose.runtime.MutableState
@@ -103,12 +104,13 @@ class GroupSendViewModel(
val feerate = feerateField.text.toString().trim().toLongOrNull()?.takeIf { it > 0 } ?: return null
val address = addressField.text.toString().trim().takeIf { it.isNotEmpty() } ?: return null
- return if (sendEverything.value) {
+ val built = if (sendEverything.value || !GroupWalletRollout.SEND_AN_AMOUNT) {
GroupSpendBuilder.sendAll(walletState, address, feerate, state.reserved)
} else {
val amount = amountField.text.toString().filter { it.isDigit() }.toLongOrNull() ?: return null
GroupSpendBuilder.send(walletState, address, Satoshi(amount), feerate, state.reserved)
}
+ return GroupSpendBuilder.capped(built, GroupWalletRollout.capFor(chain))
}
fun propose(onSuccess: (sessionId: String) -> Unit, onFailure: () -> Unit) {
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/wallet/GroupSpendBuilder.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/wallet/GroupSpendBuilder.kt
index 6f2bfb1e..d320df96 100644
--- a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/wallet/GroupSpendBuilder.kt
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/wallet/GroupSpendBuilder.kt
@@ -34,8 +34,18 @@ object GroupSpendBuilder {
data object BelowDust : Result
/** A bump has to pay more than the spend it replaces. */
data object NotHigher : Result
+ /** More than [GroupWalletRollout.capFor] lets one spend send. */
+ data class OverCap(val cap: Satoshi) : Result
}
+ /**
+ * [result] held to [cap]: the composer's gate while the wallet is new. A
+ * built spend sending more than the cap is refused here, before a quorum is
+ * asked; nothing at acceptance refuses one another build proposes.
+ */
+ fun capped(result: Result, cap: Satoshi?): Result =
+ if (cap != null && result is Result.Built && result.amount > cap) Result.OverCap(cap) else result
+
/** Every confirmed, unreserved coin, to [address], less the fee. */
fun sendAll(state: GroupWalletState, address: String, feeratePerVbyte: Long, reserved: Set): Result {
val script = scriptOf(state, address) ?: return Result.NotAnAddress
diff --git a/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/wallet/GroupWalletRollout.kt b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/wallet/GroupWalletRollout.kt
new file mode 100644
index 00000000..352ac80a
--- /dev/null
+++ b/composeApp/src/commonMain/kotlin/com/machankura/bennu/compose/wallet/GroupWalletRollout.kt
@@ -0,0 +1,37 @@
+package com.machankura.bennu.compose.wallet
+
+import fr.acinq.bitcoin.Chain
+import fr.acinq.bitcoin.Satoshi
+
+/**
+ * The gates the group wallet ships behind -- `docs/group-chain-wallet.md`, Phase
+ * 10 -- in one place, each with the condition that lifts it.
+ *
+ * Entry points only. A device with a gate closed still accepts, shows and signs
+ * a spend another member proposes, through every check `GroupSpend` makes: a
+ * gate decides what this device offers, never what a quorum may decide.
+ */
+object GroupWalletRollout {
+ /**
+ * Whether the group's screen offers a wallet at all. Lifted when Phases 1-9
+ * were in and the JVM suite passed, which they are and it did.
+ */
+ const val ENABLED: Boolean = true
+
+ /**
+ * Whether a member can send a chosen amount, with change, or only everything
+ * to one address. Send-all only until send-an-amount has had a release with
+ * nobody reporting a mislabelled change output.
+ */
+ const val SEND_AN_AMOUNT: Boolean = false
+
+ /**
+ * The most one spend proposed from this device may send on mainnet. Lifts
+ * when a release has run real spends end to end with no session that failed
+ * to aggregate and no transaction that failed to confirm. Test networks have
+ * no cap: nothing on them is worth one.
+ */
+ val MAINNET_CAP: Satoshi = Satoshi(100_000)
+
+ fun capFor(chain: Chain): Satoshi? = MAINNET_CAP.takeIf { chain.isMainnet() }
+}
diff --git a/composeApp/src/commonTest/kotlin/com/machankura/bennu/compose/wallet/GroupSpendBuilderTest.kt b/composeApp/src/commonTest/kotlin/com/machankura/bennu/compose/wallet/GroupSpendBuilderTest.kt
index 6c360793..6431d0f7 100644
--- a/composeApp/src/commonTest/kotlin/com/machankura/bennu/compose/wallet/GroupSpendBuilderTest.kt
+++ b/composeApp/src/commonTest/kotlin/com/machankura/bennu/compose/wallet/GroupSpendBuilderTest.kt
@@ -136,4 +136,15 @@ class GroupSpendBuilderTest {
assertIs(GroupSpendBuilder.bump(first, feerate))
}
+
+ @Test
+ fun `the mainnet cap refuses a spend over it, and test networks have none`() {
+ val built = GroupSpendBuilder.sendAll(state(coin(0, 300_000)), destination, feerate, emptySet())
+
+ assertIs(GroupSpendBuilder.capped(built, GroupWalletRollout.capFor(Chain.Mainnet)))
+ assertIs(GroupSpendBuilder.capped(built, GroupWalletRollout.capFor(Chain.Regtest)))
+ assertIs(
+ GroupSpendBuilder.capped(GroupSpendBuilder.sendAll(state(coin(0, 50_000)), destination, feerate, emptySet()), GroupWalletRollout.capFor(Chain.Mainnet))
+ )
+ }
}
diff --git a/composeApp/src/jvmTest/kotlin/com/machankura/bennu/compose/ui/view/model/GroupSendViewModelJvmTest.kt b/composeApp/src/jvmTest/kotlin/com/machankura/bennu/compose/ui/view/model/GroupSendViewModelJvmTest.kt
index d4c6b86e..355597ee 100644
--- a/composeApp/src/jvmTest/kotlin/com/machankura/bennu/compose/ui/view/model/GroupSendViewModelJvmTest.kt
+++ b/composeApp/src/jvmTest/kotlin/com/machankura/bennu/compose/ui/view/model/GroupSendViewModelJvmTest.kt
@@ -14,6 +14,7 @@ import com.machankura.bennu.compose.ui.view.state.GroupSendUIState
import com.machankura.bennu.compose.wallet.GroupSpend
import com.machankura.bennu.compose.wallet.GroupSpendBuilder
import com.machankura.bennu.compose.wallet.GroupWalletState
+import com.machankura.bennu.compose.wallet.GroupWalletRollout
import com.vitorpamplona.quartz.nip01Core.core.HexKey
import fr.acinq.bitcoin.ByteVector
import fr.acinq.bitcoin.ByteVector32
@@ -121,8 +122,14 @@ class GroupSendViewModelJvmTest {
model.feerateField.setTextAndPlaceCursorAtEnd("4")
model.amountField.setTextAndPlaceCursorAtEnd("40,000")
val built = assertIs(model.preview())
- assertEquals(Satoshi(40_000), built.amount)
- assertNotNull(built.change)
+ if (GroupWalletRollout.SEND_AN_AMOUNT) {
+ assertEquals(Satoshi(40_000), built.amount)
+ assertNotNull(built.change)
+ } else {
+ // Gated to send-all: the amount typed is not what is sent.
+ assertEquals(Satoshi(100_000), built.amount + built.fee)
+ assertNull(built.change)
+ }
model.propose(onSuccess = {}, onFailure = {})
runBlocking { withTimeout(5_000) { while (signing.proposed == null) delay(10) } }
diff --git a/docs/README.md b/docs/README.md
index b9838ee7..295442de 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -63,10 +63,11 @@ smallest of the plans: it changes the entrance to the direct-message flow and
nothing past it, so read it with `StartDirectMessageToNpubOrNip05Dialog` and
`ChatRoomMessagingViewModel.initiateNewChat` open, its four decisions before its
four phases, and its table of where the build chose differently first.
-The group chain wallet note is a phased plan that has not been built. It assumes
+The group chain wallet note is a phased plan that has been built. It assumes
both shared-key notes and the batch-signing note, and reads as the derivation
note's one rule with money behind it; read its derivation section before any
-phase, since every phase after the first is built on that path.
+phase, since every phase after the first is built on that path, and its table of
+where the build chose differently before any of the code.
The Marmot v2 note is a phased plan that has been built, and is the largest of
them: it assumes the membership and derivation notes, takes the quartz 1.15.2 bump
as its Phase 0, and is ordered so that the phases that reach other clients come
diff --git a/docs/group-chain-wallet.md b/docs/group-chain-wallet.md
index b9e056d4..c06203c9 100644
--- a/docs/group-chain-wallet.md
+++ b/docs/group-chain-wallet.md
@@ -14,8 +14,11 @@ wallet makes more expensive to break, and
with `k` inputs is a batch of `k` and that note's nonce rule is the one this
plan is built around too.
-**Being built**, one commit per phase. Written against the code as it stood at
-`b75d4b42`, with the `lightning-kmp-app` submodule at `e0d2b82`. Every path into
+**Built**, phases 1-10, one commit per phase (two each for 8 and 9). Written
+against the code as it stood at `b75d4b42`, with the `lightning-kmp-app` submodule
+at `e0d2b82`. `GroupWalletDerivation`, `FrostSigningManager.proposeSpend` and
+`GroupTransactionWatcher` are the entry points, and `GroupWalletRollout` holds the
+gates Phase 10 ships behind. Every path into
the library below is into that submodule, which a fresh worktree does not have
checked out — run `git submodule update --init --recursive` first. The phases are
kept as written; where the build chose differently the table below says so.
@@ -47,6 +50,8 @@ kept as written; where the build chose differently the table below says so.
| a conflicting spend is noticed when a reserved coin is spent by a different transaction | when one of the group's spends *confirms*: only the group can spend its coins, so the only other transaction that can take one is another of its own spends, and the confirmation is the moment the question is settled. Settled by the confirmed spend's own row, so every device decides the same way |
| a fee bump is proposed at a feerate the member chooses | at twice the spend's feerate, from a *Bump the fee* button on the spend's row — comfortably over BIP125's increment, and one decision rather than a form |
| `GroupTransaction` rows are kept by the screen that shows them | `GroupTransactionWatcher`, one per identity beside the wallets, started with the identity's node whether or not anybody opens the wallet. It found a real bug before it shipped: following each spend from the list a pass began with wrote a settled row back from its stale copy |
+| a feature flag, off, until Phases 1-9 are in | `GroupWalletRollout.ENABLED`, on: its own lift condition — Phases 1-9 in, the JVM suite passing — was met when it landed. The other two gates hold: `SEND_AN_AMOUNT` is false, so the form sends everything, and `MAINNET_CAP` is 100,000 sats per spend proposed from this device |
+| the gates are on the composer | and on nothing else, on purpose: a device with a gate closed still accepts, shows and signs what another member proposes, through every check `GroupSpend` makes. A gate decides what this device offers, never what a quorum may decide |
The headline: **the best path is BIP86's own unhardened tail, `//`,
hung under an account key the group's threshold key is tweaked to, with the