`closed: Set<String>`, `inFlightCapMsat: Long` — and returns a `Verdict` instead
of a bare `Ledger`:
- **Rule 2 at open.** Every offered HTLC in commitment 0 is checked the way
`checkRemoteCommitment` checks an added one (`:96-101`): its hash must have a
budget (open authorisations, `GroupLightningAuthorisations.budgets`), must not
be expired (`closed`), and its amount must fit what is left. `remaining`
starts from `budgets` itself, since nothing is in flight from earlier
commitments. The per-hash accumulation is the same loop; factor the
added-HTLC block out of `checkRemoteCommitment` so open and later commitments
share it verbatim, rather than copying it.
- **The cap at open.** All offered HTLCs are new at commitment 0, so the
`added.isNotEmpty()` guard (`:106`) is always true and the check is simply
`offered.sum > inFlightCapMsat` → refuse.
- **The floor still starts where the first commitment puts it.** The
`Verdict.Sign` ledger keeps `floorMsat = ours + offered − feeAllowance` as at
`:61` today, and `consumed` is empty: nothing can settle at commitment 0, so
no budget is spent by opening. What changes is only that offered HTLCs in the
baseline are now authorised ones.
| | decision | why |
|---|---|---|
| an *authorised* offered HTLC in commitment 0 signs | rule 2 already expresses "the group agreed"; refusing offered HTLCs at open outright would hardcode today's on-the-fly-only world into the policy | a group-funded or spliced-in channel (the splice-out follow-up in Phase 13 of the design doc) would carry one legitimately, and a policy that cannot express it will be worked around |
| the floor-starting behaviour is kept | a co-signer's first commitment is its only truth about the channel; any other starting floor (zero, capacity) refuses every real open | the review found no fault in the floor itself, only in what gets into it |
| the checks live in `CoSignerPolicy`, not in `checkRemote` | the policy is pure and unit-tested in `CoSignerPolicyTest.kt`; logic in the co-signer is reachable only through the four-device harness | the same shape as every other value rule |
**Tests, in `CoSignerPolicyTest.kt`:** one new test beside the existing eight:
- `the first commitment answers to the authorisations too` — `open` with an
offered HTLC and empty budgets refuses; with a budget for its hash it signs
and the floor starts at value − allowance; with the hash in `closed` it
refuses; with two offered HTLCs against one budget it applies the same
budget-left arithmetic as `one authorisation cannot be offered twice over`;
with offered HTLCs over `inFlightCapMsat` it refuses; and the honest shape —
an incoming-only on-the-fly commitment with empty budgets — signs.
### Phase 2 — the two call sites, and the four-device tests
**About a day.**
`GroupLightningCoSigner.kt`:
- **`checkRemote` (`:399-405`).** The early return goes. Budgets, the expired
set and the cap are fetched for the open case as they already are for the
| risk or question | why it matters | what to do |
|---|---|---|
| a legitimate first commitment with an offered HTLC never occurs today | on-the-fly funding is the only open flow, and its commitment 0 is incoming-only; the authorised-HTLC-at-open branch will be dead code until group-funded channels exist | keep it anyway (the decision table above), with the Phase 2 test as its only exercise; a splice-in flow that needs it must re-read this note |
| mixed-build groups | old-build co-signers still echo a poisoned open, so the fix is per-device, not per-group | say so on the wallet screen until every participant is upgraded; the failure mode is a stalled malicious open, never a signed one |
| the factored added-HTLC loop must not drift from `checkRemoteCommitment`'s | two copies of rule 2 would re-create this finding in miniature the next time one is edited | share one private function; the existing `CoSignerPolicyTest` suite plus the new open tests pin both paths |
| does `open` need the repeat-commitment branch? | `checkRemoteCommitment` allows re-signing the same txid at the same index (`:79-81`) for retransmission; at open there is no previous row, so a retransmitted commitment 0 arrives while `pinned` is still null on devices that never echoed it — already handled, since `open` is deterministic over the same spec | no special case; a device that already echoed commitment 0 has a ledger row and takes the `checkRemoteCommitment` repeat branch |
| interaction with the first-commitment trust in `signedOursMsat` | the wallet screen's "matches the last commitment you signed" reads the ledger this fix now guards more strictly | nothing to do; the figure can only improve |