Skip to content

Payments

Payments use credits on a ledger service. Amounts are integers.

Flow

  1. The caller asks the ledger to hold the price for the provider and route. The hold expires after 900 seconds.
  2. The request carries the ledger's signed confirmation.
  3. The provider verifies it, and that the hold was not used before, and runs the work.
  4. On success, the provider captures the hold with the digest of the result. On failure, it cancels the hold, and the caller is refunded.
  5. The reply carries the ledger's signed receipt. The caller verifies that it names this hold and this result.

If the provider disappears, the hold expires and is refunded.

Accounts

curl -X POST http://ledger:8080/v1/fund -H "Authorization: Bearer $LEDGER_TOKEN" -H "Content-Type: application/json" \
  -d '{"aid": "<identifier>", "amount": 1000, "ref": "invoice-7"}'
curl http://ledger:8080/v1/balance/<identifier> -H "Authorization: Bearer $LEDGER_TOKEN"

Funding with the same ref is applied once.

Audit

Every movement is a row in an append-only journal. GET /v1/audit compares issued credits with balances and holds and reports consistent.