telegram link : t.me/nullifiersystem
1. Summary & Core Promise
When users experience extended cellular network outages during a physical cash handover, the client app cannot reach Velo API servers to update trade state. Currently, if local queue items in mobile/frontend/src/lib/sync/queue.ts fail to sync, users have no mechanism to export signed transaction proofs locally to complete settlement manually.
This feature implements an Off-Chain P2P Emergency Settlement Recovery & Manual Proof Export Engine. It builds offline transaction queue serialization in mobile/frontend/src/lib/sync/queue.ts, cryptographically signed JSON/QR proof file exports, an offline proof validation route in apps/api/src/routes/cash.ts, and PostgreSQL row locking (SELECT FOR UPDATE).
2. Background & Architectural Risks
- Stuck Cash Settlements: Users paying cash in offline areas cannot complete escrow releases if server connections drop indefinitely.
- Proof Tampering: Allowing manual proof uploads without cryptographic signatures allows malicious users to forge offline release authorizations.
3. Database Layer Specifications
Migration SQL (034_add_offline_recovery_proofs.sql)
CREATE TABLE offline_recovery_proofs (
proof_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
trade_id VARCHAR(64) NOT NULL UNIQUE REFERENCES cash_requests(id),
signer_pubkey VARCHAR(56) NOT NULL,
signature VARCHAR(128) NOT NULL,
payload_json JSONB NOT NULL,
processed_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
4. Backend Route & Service Layer Specifications
Route: POST /api/v1/cash/emergency-recovery
- Signature Verification: Verifies payload cryptographic signature against buyer/seller Ed25519 public keys.
- Locking: DB transaction acquires
SELECT FOR UPDATE on cash_requests.
- Execution: Settles trade on-chain via
submitReleaseTx().
- Response: Returns
HTTP 200 OK with settlement confirmation.
5. Background Processors / Workers
(Client-Side Sync Queue Worker in mobile/frontend/src/lib/sync/queue.ts)
6. Frontend / UI Component Specifications
Component: mobile/frontend/src/components/OfflineRecoveryModal.tsx
- UI modal allowing users to export encrypted proof JSON files offline, display backup recovery QR codes, or import proof files when network connection restores.
7. Rigor & Test Plan
- Unit Tests (
mobile/frontend/src/lib/sync/__tests__/queue.test.ts): Test offline transaction serialization and signature generation.
- Recovery API Test (
cash.test.ts): Upload valid signed proof file; assert trade releases cleanly.
8. Relevant Files Inventory
New Files to Create
apps/api/src/db/migrations/034_add_offline_recovery_proofs.sql
mobile/frontend/src/components/OfflineRecoveryModal.tsx
mobile/frontend/src/lib/sync/__tests__/queue.test.ts
Existing Files to Modify
mobile/frontend/src/lib/sync/queue.ts
apps/api/src/routes/cash.ts
apps/api/src/lib/store.ts
mobile/frontend/src/pages/ClaimQR.tsx
9. Acceptance Criteria
10. Contributor Notes
- ⚠️ Security Warning: ALWAYS verify payload Ed25519 signatures before processing manual proof uploads.
telegram link : t.me/nullifiersystem
1. Summary & Core Promise
When users experience extended cellular network outages during a physical cash handover, the client app cannot reach Velo API servers to update trade state. Currently, if local queue items in
mobile/frontend/src/lib/sync/queue.tsfail to sync, users have no mechanism to export signed transaction proofs locally to complete settlement manually.This feature implements an Off-Chain P2P Emergency Settlement Recovery & Manual Proof Export Engine. It builds offline transaction queue serialization in
mobile/frontend/src/lib/sync/queue.ts, cryptographically signed JSON/QR proof file exports, an offline proof validation route inapps/api/src/routes/cash.ts, and PostgreSQL row locking (SELECT FOR UPDATE).2. Background & Architectural Risks
3. Database Layer Specifications
Migration SQL (
034_add_offline_recovery_proofs.sql)4. Backend Route & Service Layer Specifications
Route:
POST /api/v1/cash/emergency-recoverySELECT FOR UPDATEoncash_requests.submitReleaseTx().HTTP 200 OKwith settlement confirmation.5. Background Processors / Workers
(Client-Side Sync Queue Worker in
mobile/frontend/src/lib/sync/queue.ts)6. Frontend / UI Component Specifications
Component:
mobile/frontend/src/components/OfflineRecoveryModal.tsx7. Rigor & Test Plan
mobile/frontend/src/lib/sync/__tests__/queue.test.ts): Test offline transaction serialization and signature generation.cash.test.ts): Upload valid signed proof file; assert trade releases cleanly.8. Relevant Files Inventory
New Files to Create
apps/api/src/db/migrations/034_add_offline_recovery_proofs.sqlmobile/frontend/src/components/OfflineRecoveryModal.tsxmobile/frontend/src/lib/sync/__tests__/queue.test.tsExisting Files to Modify
mobile/frontend/src/lib/sync/queue.tsapps/api/src/routes/cash.tsapps/api/src/lib/store.tsmobile/frontend/src/pages/ClaimQR.tsx9. Acceptance Criteria
10. Contributor Notes