Complete specification for rewriting Swarmops v5 as using.cash v6: - Proposal: scope buckets (Working Rewrite / First Beyond Working / Maybe), non-goals (governance, geography, memberships permanently cut) - Design: 18 architectural decisions including preserved patterns (Basic/Logic, stored procs, credential split), new patterns (repository classes, chain abstraction, rate providers), and operational concerns (Galera awareness, continuation transactions, VAT booking, OOD denormalization) - Specs: 17 capability specifications with SHALL/MUST requirements and WHEN/THEN scenarios, covering accounting core, AP/AR, crypto treasury, exchange rates, organizations, users/auth, documents, comms, dashboard, end-of-month, backend worker, event bus, data migration, API layer, frontend app, and CI/packaging - Tasks: 145 implementation tasks grouped by subsystem, ordered by dependency (migration gates API/frontend work) Two rounds of adversarial review incorporated. Made-with: Cursor
3.6 KiB
ADDED Requirements
Requirement: Chain abstraction layer
The system SHALL define an IBlockchainProvider interface abstracting chain-specific operations: address generation, UTXO/balance queries, transaction building, and transaction broadcast. Each supported cryptocurrency chain implements this interface. Bucket 1 ships with Bitcoin Cash (BCH) only.
Scenario: Generate deposit address
- WHEN the system needs a new deposit address for an organization
- THEN it calls the chain provider's address generation method and stores the address with its derivation metadata
Scenario: Query UTXOs
- WHEN the system checks the balance of a hot wallet address
- THEN it calls the chain provider's UTXO query method and receives a list of unspent outputs with amounts in satoshis
Requirement: Hot wallet management
The system SHALL maintain hot wallet addresses per organization, tracking each address and its unspent transaction outputs (UTXOs). The hot wallet balance is the sum of all UTXOs across all addresses for an organization.
Scenario: Track new UTXO
- WHEN a blockchain transaction sends funds to a tracked hot wallet address
- THEN the UTXO is recorded with its transaction hash, output index, and amount in satoshis
Scenario: Spend UTXO
- WHEN a payout or transfer consumes a UTXO
- THEN the UTXO is marked as spent with the consuming transaction hash
Scenario: View hot wallet balance
- WHEN a user views the crypto treasury page
- THEN the system displays the total hot wallet balance in both native crypto units and the organization's fiat equivalent (via exchange rates)
Requirement: Blockchain transaction ingestion
The system SHALL periodically query blockchain data sources to detect incoming transactions to hot wallet addresses. Detected deposits create financial transactions in the ledger (debit crypto asset account, credit income or receivable account as appropriate).
Scenario: Detect incoming deposit
- WHEN the backend worker detects a new confirmed transaction to a hot wallet address
- THEN a ledger transaction is created recording the deposit and the UTXO is tracked
Scenario: Skip closed-period transactions
- WHEN a blockchain transaction's timestamp falls within a closed fiscal period
- THEN the system SHALL skip ingestion for that transaction, on the assumption that it was already ingested and recorded before the period was closed
Scenario: Late-discovered historical deposit
- WHEN a deposit to a hot wallet address is discovered for the first time but its blockchain timestamp falls within a closed fiscal period
- THEN the system SHALL log a warning with the transaction details for manual review rather than silently skipping it; a manual recovery path (posting to the current open period with a reference to the original chain timestamp) is required
Requirement: Crypto payouts
The system SHALL support paying out approved expenses and invoices in cryptocurrency. A crypto payout builds a transaction from available UTXOs, broadcasts it via the chain provider, and records the outbound transaction in the ledger.
Scenario: Execute crypto payout
- WHEN an authorized user initiates a crypto payout for approved items
- THEN the system selects UTXOs sufficient to cover the amount plus fees, builds and broadcasts a transaction, and records it in the ledger
Scenario: Insufficient funds
- WHEN the hot wallet does not have sufficient UTXOs to cover a payout
- THEN the system SHALL reject the payout with a clear error indicating the shortfall