- Overpay attack:
- Attempt payment larger than remaining due.
- Verified only remaining amount is applied and recorded.
- Zero/negative payment values:
- Verified both reject with
InvalidAmount.
- Verified both reject with
- Double-pay / replay attempt:
- Nonce uniqueness is enforced per
(invoice_id, payer, nonce)in settlement storage.
- Nonce uniqueness is enforced per
- Paying a closed invoice:
- Verified payment rejection for
Paidinvoices. - Verified payment rejection for
Cancelledinvoices.
- Verified payment rejection for
total_paid <= total_due(invoice.total_paid <= invoice.amount) always.total_paidis monotonic (never decreases).- Applied payment amount is strictly positive.
- Settlement records are append-only by
(invoice_id, payment_index). - Fully settled invoices transition to
Paidand cannot accept further payments.
- Only the invoice business address can be the payer for settlement recording.
- Payer authorization is required before payment state updates.
- Payment accumulation uses checked arithmetic.
- Remaining due and progress calculations use checked operations and reject invalid states.