diff --git a/composeApp/src/commonMain/composeResources/values/strings.xml b/composeApp/src/commonMain/composeResources/values/strings.xml
index 422243c2..b1e47688 100644
--- a/composeApp/src/commonMain/composeResources/values/strings.xml
+++ b/composeApp/src/commonMain/composeResources/values/strings.xml
@@ -645,6 +645,8 @@
Send from the group's wallet
Address
Amount in sats
+ sats
+ %1$s sats confirmed and free to spend
Send everything
Fee rate in sats per byte
Ask the group to send
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 839919be..7ea771b3 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,6 +1,13 @@
package com.machankura.bennu.compose.ui.composable
import bennu.composeapp.generated.resources.while_the_wallet_is_new_at_most_s_sats
+import androidx.compose.foundation.selection.toggleable
+import androidx.compose.material3.minimumInteractiveComponentSize
+import androidx.compose.ui.semantics.Role
+import androidx.compose.ui.text.input.ImeAction
+import bennu.composeapp.generated.resources.sats
+import bennu.composeapp.generated.resources.s_sats_confirmed_and_free_to_spend
+import com.machankura.bennu.compose.wallet.GroupWalletRollout
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@@ -160,6 +167,10 @@ fun GroupSendScreen(
.padding(MaterialTheme.spacing.screenMargin),
verticalArrangement = Arrangement.spacedBy(MaterialTheme.spacing.itemGap)
) {
+ val preview = groupSendViewModel.preview()
+ // A problem with the amount is said on the amount field, beside what caused it.
+ val amountProblem = preview?.takeIf { groupSendViewModel.isAboutTheAmount(it) }
+
OutlinedTextField(
modifier = Modifier.fillMaxWidth(),
state = groupSendViewModel.addressField,
@@ -167,26 +178,45 @@ fun GroupSendScreen(
label = { Text(stringResource(Res.string.address)) },
)
+ // The row is the target, so the label toggles too: one 48dp control with one name.
Row(
- modifier = Modifier.fillMaxWidth(),
+ modifier = Modifier.fillMaxWidth()
+ .toggleable(
+ value = groupSendViewModel.sendEverything.value,
+ role = Role.Switch,
+ onValueChange = { groupSendViewModel.sendEverything.value = it },
+ )
+ .minimumInteractiveComponentSize(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
Text(stringResource(Res.string.send_everything))
- Switch(
- checked = groupSendViewModel.sendEverything.value,
- onCheckedChange = { groupSendViewModel.sendEverything.value = it },
- )
+ Switch(checked = groupSendViewModel.sendEverything.value, onCheckedChange = null)
}
+ // Hidden rather than cleared, so turning send-everything off again finds the amount typed.
if (!groupSendViewModel.sendEverything.value) {
+ val spendable = groupSendViewModel.spendable()
+ val cap = GroupWalletRollout.capFor(chain)
OutlinedTextField(
modifier = Modifier.fillMaxWidth(),
state = groupSendViewModel.amountField,
outputTransformation = GroupedSats,
lineLimits = TextFieldLineLimits.SingleLine,
- keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
+ keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number, imeAction = ImeAction.Next),
label = { Text(stringResource(Res.string.amount_in_sats)) },
+ suffix = { Text(stringResource(Res.string.sats)) },
+ isError = amountProblem != null,
+ supportingText = if (amountProblem == null && spendable == null && cap == null) null else {
+ {
+ if (amountProblem != null) {
+ Text(problemWith(amountProblem, chain))
+ } else Column {
+ spendable?.let { Text(stringResource(Res.string.s_sats_confirmed_and_free_to_spend, it.grouped())) }
+ cap?.let { Text(stringResource(Res.string.while_the_wallet_is_new_at_most_s_sats, it.grouped())) }
+ }
+ }
+ },
)
}
@@ -199,10 +229,9 @@ fun GroupSendScreen(
)
// Still finding change is still finding coins: neither is anything to correct.
- val preview = groupSendViewModel.preview()
if (state.walletState == null || preview == GroupSpendBuilder.Result.FindingChange) {
LoadingDataIndicator(fillScreen = false, text = stringResource(Res.string.finding_the_group_s_coins))
- } else {
+ } else if (amountProblem == null) {
preview?.let { SendPreview(it, chain) }
}
@@ -267,22 +296,26 @@ private fun SendPreview(result: GroupSpendBuilder.Result, chain: Chain) {
}
else -> Text(
- text = when (result) {
- GroupSpendBuilder.Result.NotAnAddress ->
- 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)
- GroupSpendBuilder.Result.TooManyOpen -> stringResource(Res.string.too_many_spends_are_open_with_change)
- is GroupSpendBuilder.Result.OverCap -> stringResource(Res.string.while_the_wallet_is_new_at_most_s_sats, result.cap.grouped())
- is GroupSpendBuilder.Result.InvalidAmount -> when (result.input) {
- SatsInput.NotWhole -> stringResource(Res.string.sats_are_whole_numbers)
- SatsInput.TooLarge -> stringResource(Res.string.that_is_more_sats_than_there_will_ever_be)
- else -> stringResource(Res.string.that_isn_t_an_amount_in_sats)
- }
- else -> stringResource(Res.string.that_is_too_little_to_send)
- },
+ text = problemWith(result, chain),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.error,
)
}
}
+
+/** Why [result] cannot be proposed, in words. */
+@Composable
+private fun problemWith(result: GroupSpendBuilder.Result, chain: Chain): String = when (result) {
+ GroupSpendBuilder.Result.NotAnAddress ->
+ 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)
+ GroupSpendBuilder.Result.TooManyOpen -> stringResource(Res.string.too_many_spends_are_open_with_change)
+ is GroupSpendBuilder.Result.OverCap -> stringResource(Res.string.while_the_wallet_is_new_at_most_s_sats, result.cap.grouped())
+ is GroupSpendBuilder.Result.InvalidAmount -> when (result.input) {
+ SatsInput.NotWhole -> stringResource(Res.string.sats_are_whole_numbers)
+ SatsInput.TooLarge -> stringResource(Res.string.that_is_more_sats_than_there_will_ever_be)
+ else -> stringResource(Res.string.that_isn_t_an_amount_in_sats)
+ }
+ else -> stringResource(Res.string.that_is_too_little_to_send)
+}
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 9f1a4acc..9825401d 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
@@ -22,6 +22,7 @@ import com.machankura.bennu.compose.wallet.GroupOnchainWallets
import com.machankura.bennu.compose.wallet.GroupSpendBuilder
import com.vitorpamplona.quartz.nip01Core.core.HexKey
import fr.acinq.bitcoin.Chain
+import fr.acinq.bitcoin.Satoshi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
@@ -99,6 +100,26 @@ class GroupSendViewModel(
/** What the amount field says, read the one way everything that reads it does. */
fun amount(): SatsInput = parseSats(amountField.text)
+ /** The confirmed coins no open spend holds, summed, or null before Electrum has answered. */
+ fun spendable(): Satoshi? {
+ val state = groupSendUIState as? GroupSendUIState.Ready ?: return null
+ return state.walletState?.let { GroupSpendBuilder.spendableBalance(it, state.reserved) }
+ }
+
+ /**
+ * Whether [result] is about the amount typed, and so belongs on the amount
+ * field rather than under the form. Never while sending everything: there
+ * is no amount field then, and a send-all too small or over the cap is the
+ * form's problem as a whole.
+ */
+ fun isAboutTheAmount(result: GroupSpendBuilder.Result?): Boolean =
+ !sendEverything.value && (
+ result is GroupSpendBuilder.Result.InvalidAmount ||
+ result is GroupSpendBuilder.Result.OverCap ||
+ result == GroupSpendBuilder.Result.NotEnough ||
+ result == GroupSpendBuilder.Result.BelowDust
+ )
+
/**
* The spend the form describes right now, or null while it is incomplete --
* no wallet state yet, no feerate, no amount. An amount that is not one is
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 b27368cc..8024178f 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
@@ -150,9 +150,17 @@ object GroupSpendBuilder {
)
}
- private fun spendable(state: GroupWalletState, reserved: Set): List =
+ /** The coins a new spend may use: confirmed, and held by no open spend. */
+ fun spendable(state: GroupWalletState, reserved: Set): List =
state.utxos.filter { it.isConfirmed && it.utxo.outPoint !in reserved }
+ /**
+ * What [spendable] adds up to: the most a form can offer, before the fee.
+ * Less than the wallet's confirmed balance by whatever open spends hold.
+ */
+ fun spendableBalance(state: GroupWalletState, reserved: Set): Satoshi =
+ spendable(state, reserved).map { it.amount }.sum()
+
private fun scriptOf(state: GroupWalletState, address: String): ByteVector? =
Bitcoin.addressToPublicKeyScript(state.account.chain.chainHash, address.trim()).right
?.let { ByteVector(Script.write(it)) }
diff --git a/composeApp/src/jvmTest/kotlin/com/machankura/bennu/compose/ui/composable/GroupSendScreenJvmTest.kt b/composeApp/src/jvmTest/kotlin/com/machankura/bennu/compose/ui/composable/GroupSendScreenJvmTest.kt
new file mode 100644
index 00000000..197071e3
--- /dev/null
+++ b/composeApp/src/jvmTest/kotlin/com/machankura/bennu/compose/ui/composable/GroupSendScreenJvmTest.kt
@@ -0,0 +1,173 @@
+package com.machankura.bennu.compose.ui.composable
+
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.semantics.SemanticsProperties
+import androidx.compose.ui.test.ComposeUiTest
+import androidx.compose.ui.test.ExperimentalTestApi
+import androidx.compose.ui.test.SemanticsMatcher
+import androidx.compose.ui.test.assert
+import androidx.compose.ui.test.assertIsDisplayed
+import androidx.compose.ui.test.assertIsEnabled
+import androidx.compose.ui.test.assertIsNotEnabled
+import androidx.compose.ui.test.onNodeWithText
+import androidx.compose.ui.test.performClick
+import androidx.compose.ui.test.performTextInput
+import androidx.compose.ui.test.runDesktopComposeUiTest
+import com.machankura.bennu.compose.database.model.ChatRoom
+import com.machankura.bennu.compose.database.model.GroupSignedEvent
+import com.machankura.bennu.compose.database.model.intermdiate.LocalChatRoom
+import com.machankura.bennu.compose.managers.GroupWalletDerivation
+import com.machankura.bennu.compose.nostr.wallet.GroupWallet
+import com.machankura.bennu.compose.nostr.wallet.GroupWalletStatementEvent
+import com.machankura.bennu.compose.repository.ChatRepository
+import com.machankura.bennu.compose.repository.FrostSigningRepository
+import com.machankura.bennu.compose.ui.composable.widgets.ProvideSnackbarHost
+import com.machankura.bennu.compose.ui.theme.BennuTheme
+import com.machankura.bennu.compose.ui.view.state.GroupSendUIState
+import com.machankura.bennu.compose.wallet.GroupWalletState
+import fr.acinq.bitcoin.ByteVector
+import fr.acinq.bitcoin.ByteVector32
+import fr.acinq.bitcoin.Chain
+import fr.acinq.bitcoin.OutPoint
+import fr.acinq.bitcoin.PrivateKey
+import fr.acinq.bitcoin.Satoshi
+import fr.acinq.bitcoin.Transaction
+import fr.acinq.bitcoin.TxId
+import fr.acinq.bitcoin.TxIn
+import fr.acinq.bitcoin.TxOut
+import fr.acinq.lightning.blockchain.electrum.WalletState
+import fr.acinq.secp256k1.Hex
+import kotlin.test.Test
+import kotlin.time.Instant
+
+/**
+ * The send form, typed into: an amount is read back as the preview will say
+ * it, a problem with the amount is said on the amount field, and
+ * send-everything puts the field away without forgetting what was in it.
+ */
+@OptIn(ExperimentalTestApi::class)
+class GroupSendScreenJvmTest {
+ private val chatRoomId = "d4c3b2a1".repeat(8)
+ private val regtestAddress = "bcrt1qw508d6qejxtdg4y5r3zarvary0c5xw7kygt080"
+ private val mainnetAddress = "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"
+
+ private val isError = SemanticsMatcher.keyIsDefined(SemanticsProperties.Error)
+
+ @Test
+ fun `an amount is read back grouped, and the spend it builds can be proposed`() = render(Chain.Regtest) {
+ fill(regtestAddress, amount = "40000")
+
+ onNodeWithText("40,000").assertIsDisplayed()
+ onNodeWithText("Sends 40,000 sats", substring = true).assertIsDisplayed()
+ onNodeWithText("come back to the group as change", substring = true).assertIsDisplayed()
+ onNodeWithText("Ask the group to send").assertIsEnabled()
+ }
+
+ @Test
+ fun `how much can be spent is said under the amount`() = render(Chain.Regtest) {
+ onNodeWithText("100,000 sats confirmed and free to spend").assertIsDisplayed()
+ onNodeWithText("While the wallet is new", substring = true).assertDoesNotExist()
+ }
+
+ @Test
+ fun `a decimal is refused on the amount field, and nothing can be proposed`() = render(Chain.Regtest) {
+ fill(regtestAddress, amount = "0.5")
+
+ onNodeWithText("Sats are whole numbers", substring = true).assertIsDisplayed()
+ onNodeWithText("Amount in sats").assert(isError)
+ onNodeWithText("Sends", substring = true).assertDoesNotExist()
+ onNodeWithText("Ask the group to send").assertIsNotEnabled()
+ }
+
+ @Test
+ fun `send everything puts the amount away, and turning it off finds it again`() = render(Chain.Regtest) {
+ fill(regtestAddress, amount = "40000")
+
+ onNodeWithText("Send everything").performClick()
+ onNodeWithText("Amount in sats").assertDoesNotExist()
+ onNodeWithText("come back to the group as change", substring = true).assertDoesNotExist()
+
+ onNodeWithText("Send everything").performClick()
+ onNodeWithText("40,000").assertIsDisplayed()
+ onNodeWithText("Sends 40,000 sats", substring = true).assertIsDisplayed()
+ }
+
+ @Test
+ fun `on mainnet the cap is said before it is hit, and on the field when it is`() = render(Chain.Mainnet) {
+ val cap = "While the wallet is new, a spend on mainnet can send at most 100,000 sats."
+ onNodeWithText(cap).assertIsDisplayed()
+
+ fill(mainnetAddress, amount = "150000")
+
+ onNodeWithText(cap).assertIsDisplayed()
+ onNodeWithText("Amount in sats").assert(isError)
+ onNodeWithText("Ask the group to send").assertIsNotEnabled()
+ }
+
+ private fun ComposeUiTest.fill(address: String, amount: String) {
+ onNodeWithText("Address").performTextInput(address)
+ onNodeWithText("Fee rate in sats per byte").performTextInput("4")
+ onNodeWithText("Amount in sats").performTextInput(amount)
+ }
+
+ private fun ready(chain: Chain): GroupSendUIState.Ready {
+ val account = GroupWalletDerivation.account(
+ PrivateKey(ByteVector32(Hex.decode("1c0ffee".padStart(64, '0')))).publicKey().toString(), chain,
+ )
+ val wallet = GroupWallet(
+ GroupSignedEvent(
+ id = "e".repeat(64), chatRoomId = chatRoomId, publicKey = chatRoomId, kind = GroupWalletStatementEvent.KIND,
+ tags = GroupWalletStatementEvent.template(account).tags, content = account.xpub, signature = "f".repeat(128),
+ createdAt = Instant.fromEpochSeconds(1_700_000_000),
+ ),
+ account,
+ )
+ val receive = GroupWalletDerivation.derive(account, GroupWalletDerivation.RECEIVE, 0)
+ val change = GroupWalletDerivation.derive(account, GroupWalletDerivation.CHANGE, 0)
+ val funding = Transaction(
+ 2, listOf(TxIn(OutPoint(TxId(ByteVector32(ByteArray(32) { 1 })), 0), ByteVector.empty, 0xffffffffL)),
+ listOf(TxOut(Satoshi(if (chain.isMainnet()) 300_000 else 100_000), receive.pubkeyScript)), 0,
+ )
+ val meta = WalletState.AddressMeta.Derived(0)
+ val walletState = GroupWalletState(
+ account,
+ WalletState(mapOf(receive.address(chain) to WalletState.AddressState(meta, true, listOf(WalletState.Utxo(funding.txid, 0, 100, funding, meta))))),
+ WalletState(mapOf(change.address(chain) to WalletState.AddressState(WalletState.AddressMeta.Derived(0), false, emptyList()))),
+ tipHeight = 110,
+ )
+ val room = LocalChatRoom(
+ chatRoom = ChatRoom(
+ id = chatRoomId, userPublicKey = "a".repeat(64), subject = "Treasury", description = null,
+ initialGiftWrapPayloadId = "p", mlsGroupState = "state",
+ )
+ )
+ return GroupSendUIState.Ready(room, wallet, walletState, reserved = emptySet())
+ }
+
+ private fun render(chain: Chain, assertions: ComposeUiTest.() -> Unit) =
+ runDesktopComposeUiTest(width = 400, height = 1200) {
+ setContent {
+ BennuTheme {
+ ProvideSnackbarHost {
+ Box(modifier = Modifier.fillMaxSize()) {
+ GroupSendScreen(
+ activeUserPublicKey = "a".repeat(64),
+ chatRoomId = chatRoomId,
+ chain = chain,
+ initialGroupSendUIState = ready(chain),
+ chatRepository = ChatRepository.NO_OP_CHAT_REPOSITORY,
+ frostSigningRepository = FrostSigningRepository.NO_OP_FROST_SIGNING_REPOSITORY,
+ wallets = null,
+ onNavigateToRouteAndPopUpInclusive = {},
+ onNavigateBack = {},
+ )
+ }
+ }
+ }
+ }
+
+ assertions()
+ }
+}
diff --git a/docs/group-send-an-amount.md b/docs/group-send-an-amount.md
index d26f9157..44aa6697 100644
--- a/docs/group-send-an-amount.md
+++ b/docs/group-send-an-amount.md
@@ -9,7 +9,7 @@ Read [group-chain-wallet.md](./group-chain-wallet.md) first, Phases 8 and 10 in
particular. This plan is that note's third rollout gate, and it starts from the
code as it stands at `96055da5`.
-**Phases 1-3 built; 4-7 not.** Written against `GroupSendScreen`, `GroupSendViewModel`,
+**Phases 1-4 built; 5-7 not.** Written against `GroupSendScreen`, `GroupSendViewModel`,
`GroupSpendBuilder`, `GroupSpend` and `GroupWalletRollout` as they are at that
commit.
@@ -259,64 +259,62 @@ releases its change index.
## Phase 4: the form
-**Two days.** Everything the screen draws, under the CLAUDE.md rules.
+**Two days. Built.** Everything the screen draws, under the CLAUDE.md rules.
-Order, top to bottom:
+Top to bottom:
1. **Address.** Unchanged.
-2. **Send everything.** The row, not only the switch, toggles it:
- `Modifier.toggleable(role = Role.Switch)` on the `Row`, the `Switch` taking
- `onCheckedChange = null`, and `minimumInteractiveComponentSize()`. That is one
- 48dp target with one name, rather than a small switch beside a label that
- does nothing when tapped.
+2. **Send everything.** The whole row is the control:
+ `Modifier.toggleable(role = Role.Switch)` and
+ `minimumInteractiveComponentSize()` on the `Row`, with the `Switch` taking
+ `onCheckedChange = null`. That makes one 48dp target with one name, instead
+ of a small switch beside a label that does nothing when tapped.
3. **Amount in sats**, shown when the switch is off:
- - `keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number,
- imeAction = ImeAction.Next)`, with Phase 1's transformations;
- - `suffix = { Text(stringResource(Res.string.sats)) }`, so the unit is part of
- the field and not only its label;
- - `supportingText` holds **how much can be spent**: *"120,000 sats confirmed
- and free to spend"*. That is the sum of what `GroupSpendBuilder.spendable`
- returns. The function is private today; make it public, so the screen
- and the builder count the same coins. It is less than the wallet screen's
- balance by whatever open spends hold, and the line says *free to spend*
- because of that difference. On mainnet, while the cap holds, a second line
- says *"At most 100,000 sats in one spend while the wallet is new."*
- - `isError` and `supportingText` show **amount errors at the field**:
- `NotWhole`, `TooLarge`, `NotEnough`, `BelowDust`, `OverCap`. Address and
- fee problems stay in the preview below, so each error appears next to the
- field it is about.
+ - the number keyboard with `ImeAction.Next`, and Phase 1's `GroupedSats`;
+ - `suffix` *sats*, so the unit is part of the field and not only its label;
+ - `supportingText` says how much can be spent: *"100,000 sats confirmed and
+ free to spend"*. That is `GroupSpendBuilder.spendableBalance`, built on
+ `spendable`, which is now public so the screen and the builder count the
+ same coins. On mainnet a second line gives the cap, using the existing
+ `while_the_wallet_is_new_at_most_s_sats` rather than a reworded copy, so
+ the warning before the cap is hit and the error when it is hit are the
+ same sentence;
+ - amount problems go to the field, as `isError` plus the supporting text:
+ `InvalidAmount`, `NotEnough`, `BelowDust` and `OverCap`. The decision is
+ `GroupSendViewModel.isAboutTheAmount`, which is always false while sending
+ everything, because then there is no field to put them on. While the field
+ shows a problem, the preview below shows nothing, so the problem is said
+ once.
4. **Fee rate.** Unchanged.
-5. **Preview.** As today, plus one line when `absorbed > 0`: *"%1$s sats left
- over are too few to come back as change, and go to the fee."* The other
- addition is `TooManyOpen`.
+5. **Preview.** Built, or the reason it cannot be: address, nothing to spend,
+ `TooManyOpen`. The *go to the fee* line and `TooManyOpen` landed in Phase 3.
+ The wording of every reason is now one function, `problemWith`, shared by
+ the field and the preview.
6. **Nothing leaves until a quorum signs** and the button. Unchanged.
-When the switch is turned on and off again, the amount typed is kept. The field
-is hidden, not cleared, and `amountField` already outlives the composition.
+Turning *Send everything* on hides the amount field without clearing it, so
+turning it off again finds the amount typed.
-**Strings**, sentence case, format arguments, in `strings.xml`:
-`sats`, `s_sats_confirmed_and_free_to_spend`,
-`at_most_s_sats_in_one_spend_while_the_wallet_is_new`,
-`sats_are_whole_numbers`, `that_is_more_sats_than_there_are`,
-`s_sats_left_over_go_to_the_fee`, `too_many_spends_are_open_with_change`.
-(`for_now_a_spend_sends_everything` was removed in Phase 2.) The existing `while_the_wallet_is_new_at_most_s_sats` may be reworded and reused
-rather than duplicated.
+**Strings:** `sats` and `s_sats_confirmed_and_free_to_spend` are new here. The
+rest came in earlier phases. `sats_are_whole_numbers`,
+`that_is_more_sats_than_there_will_ever_be` and `that_isn_t_an_amount_in_sats`
+came in Phase 1, and `s_sats_left_over_go_to_the_fee` and
+`too_many_spends_are_open_with_change` in Phase 3.
-**Budgets that must not move:** 0 spacing `.dp` literals, 0 hardcoded colours,
-0 unguarded `.clickable`, 0 untriaged `contentDescription = null`. The amount
-field adds no icon.
+**Budgets:** the audit's budgets are all met. The amount field adds no icon,
+and the switch row is a `toggleable` with a minimum size, not a `.clickable`.
-**Test**, `jvmTest/…/ui/composable/GroupSendScreenJvmTest.kt`, in the style of
-`ProposeGroupEventScreenJvmTest`, with a `Ready` state on regtest:
-
-- typing `40000` shows `40,000` in the field and *Sends 40,000 sats* in the
- preview, and the button is enabled;
-- typing `0.5` shows the whole-numbers error on the field, and the button is
- disabled;
-- tapping the *Send everything* row hides the field, and tapping it again
- brings the field back with `40,000`;
-- on mainnet, the field is shown with the cap line under it, and `150000`
- shows the cap error on the field.
+**Test**, `jvmTest/…/ui/composable/GroupSendScreenJvmTest.kt`, five cases, on
+regtest unless stated:
+- typing `40000` shows `40,000`, *Sends 40,000 sats*, and change, and the
+ button is enabled;
+- the amount is shown as free to spend, and off mainnet there is no cap line;
+- `0.5` puts the whole-numbers error on the field, which is in its error
+ state, with no preview and a disabled button;
+- the *Send everything* row hides the field and the change, and tapping it
+ again brings back `40,000` and its preview;
+- on mainnet, the cap line shows before typing, and `150000` puts the field
+ in its error state with the button disabled.
---