Skip to content

refactor: extract quickpay repository #1166

Description

@ovitrif

Goal

Extract a QuickPayRepo (or similarly named repository) for QuickPay policy + daily spend ledger concerns that are currently spread across AppViewModel, QuickPayViewModel, and CacheStore, so call sites only delegate instead of re-implementing conversion/cap math.

Why this was deferred from #1159

#1159 is a security-facing QuickPay daily spend limit patch. The daily-cap work added enough shared logic that a repository extraction is justified, but applying that refactor in the same PR would:

  • Expand review surface beyond the security fix
  • Mix behavioral change with structural move
  • Slow shipping the patch

Rationale: Keep #1159 limited to the security fix; do this extraction after it is merged.

Scope

In scope

  • Daily-cap resolution (settings threshold × multiplier, USD conversion)
  • Spent-today / reserve / release ledger APIs (currently on CacheStore, orchestrated from VMs)
  • Eligibility: “can this amount use QuickPay?” used by AppViewModel gating and consistent with pay-time checks
  • ViewModels delegate to the repo; keep UI state and navigation in VMs
  • Android journeys for daily-cap behavior (see below)

Out of scope

  • Moving payInvoice / node event watching out of LightningRepo
  • Reworking QuickPay settings UI
  • Changing product rules for the daily limit (behavior should stay equivalent to post-fix: add quickpay daily spend limit #1159)

Journeys

Add journeys/quickpay/ (README + XML), patterned after journeys/amount-limits/.

Setup: funded spending balance via bitkit-docker / LSP; QuickPay enabled.

Cover:

  1. Under per-tx + daily cap → QuickPay path (no Confirm / payment PIN)
  2. Over / exhausted daily cap → Confirm path

Acceptance criteria

  • Implementation work starts on master after fix: add quickpay daily spend limit #1159 is merged
  • Shared QuickPay policy + spend ledger live behind a repository API returning Result / simple types as appropriate
  • AppViewModel and QuickPayViewModel no longer duplicate daily-cap / USD conversion math
  • Existing unit coverage for spend reserve/release and QuickPay gating is updated/moved with the extraction
  • Unit tests are added for the new repository covering its logic
  • journeys/quickpay/ documents setup and covers under-cap QuickPay + over-cap Confirm
  • just compile, targeted unit tests, and just lint pass

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions