feat: add PostgreSQL journals with fenced wallet ownership #18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/6-postgres-leases"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Applications can enable the
postgresfeature to store payment journals and CDK wallet state in PostgreSQL.decide_claim_in_transactionlets the application's resource reservation and Satsettle's capture decision commit or roll back together; the network claim happens after commit and remains recoverable.Each namespace has one renewable Engine lease, so several application instances can contend for ownership or serve independent namespaces. PostgreSQL's clock and immutable ownership epochs govern takeover. Wallets must come from the acquired store's fenced CDK database factory: lease checks and wallet mutations use the same PostgreSQL transaction. Cancelled work retains ordering and its database lock; stale owners cannot write after takeover, and renewals blocked past expiry cannot revive an owner. Ordinary supplied databases and managed SQLite wallets are rejected in leased mode.
The embedded backend remains the default. PostgreSQL uses an explicit versioned migration, application-configured connection pool, stable per-wallet schemas/seeds, bounded wallet SQL, and documented release/recovery procedures. This supports one active owner per namespace; it does not run concurrent CDK recovery against one wallet. Eight real PostgreSQL tests cover the reusable backend contracts, application rollback, expiry/takeover, delayed renewal, cancellation across pooled connections, rejecting unfenced wallets, and Cashu lost-response recovery under a new owner.
Validation: formatting, all-feature Clippy, default and all-feature unit/integration/doc suites, API docs, isolated PostgreSQL 17 tests, and
nix flake check path:. -L. The same all-feature and PostgreSQL tests also run against CDK 0.18.1 in an isolated compatibility checkout. A dedicated Nix shell, service helpers and CI job run the PostgreSQL checks. aarch64 was not checked.Closes #6.
Stacked on #17; this PR contains the PostgreSQL and lease commit only.
Review follow-up: the isolated PostgreSQL helper now drops database-service privileges when running inside a root CI container.
66374dc80b150194f0cb