58. Payouts to authors
Status: partly implemented. Both the
#authority3-leg author-royalty settlement ledger (Worker + Validator + Module Author, royalty capped at<= 25%/2500 bps, repeat-safe idempotency, rolling UTC daily caps,101/101mutants killed,#13961) in `pay/executor-settlement.coax` / `psionic/lib/peer/pay.coax` (driving live Breez Spark payouts in `apps/openagents-cli/pylon-settle.coax`, see chapter 70) and the#authoritycapability economy payout runner (#14060) in `pay/price-policy.coax`, `pay/receipt-policy.coax`, `pay/payout-policy.coax`, `openagents/registry/registry.coax`, and `openagents/registry/install.coax` are implemented and exercised end-to-end by `openagents/examples/capability-economy-e2e.coax` (paid + held == earnedconservation, dust-free sat conversion, retry backoff, rolling UTC caps, and Lightning/Spark settlement proof). Remaining: scheduled production daemon wiring over live host wallets for third-party plugins.
Premise
Receipts say who is owed. This chapter pays them: a payout runner sends each author their share over Lightning, on a schedule, and publishes what it sent.
Draft
Episode 289 shows dots moving across the screen and names them: Lightning micropayments, where you get paid for all paid usage of plugins that you create. This is promise P11.
A payout runner reads the meter's totals. For each author it computes what is owed since the last payout and takes out what was already sent. If the amount is above a minimum, it pays the author's own Lightning Address or offer. An author can use an address they already have or claim name@openagents.com. Either way the money lands in the author's own wallet (chapter 32). The runner records each payout as a signed record that cites the receipts it covers.
The runner has to be boring. A payout has an ID, and running the same payout twice sends nothing the second time. A payment that fails is retried later and is never dropped. An author with no way to be paid keeps a balance until they add one. The sum of payouts and balances always equals the sum of author shares in the receipts, and anyone can check that.
We have run payouts before and learned from each attempt. [Episode 93](../../docs/transcripts/093.md) pays four builders by a daily process that was partly manual. Episode 98 moves to minute-by-minute balances. Episode 223 reports payouts as the bottleneck once many people were owed. The lesson is to automate it fully and keep each step checkable.
The share itself is now proven for Executor Network modules (#13961): `pay/executor-settlement.coax` enforces a 3-leg settlement (Worker + Validator + Module Author) with a hard <= 25% (2500 bps) royalty cap, duplicate-leg refusal, and rolling UTC daily caps, paying authors directly over Breez Spark / Lightning via `apps/openagents-cli/pylon-settle.coax`. For general third-party plugins with nested dependencies (#14060), the split policy stays a signed record in pay/payout-policy.coax.
What we build
Shipped today for Executor Network modules:
- 3-leg author-royalty admission,
<= 25%cap enforcement, and idempotent payouts in `pay/executor-settlement.coax` and `psionic/lib/peer/pay.coax` (#13961).
Remaining for general plugin payouts (#14060):
- A general payout runner as a Coax binary (
pay/payout-policy.coax): totals in, Lightning payments out, a signed record of each. - Repeat-safe scheduled payouts, retries, and held balances for authors with no address yet.
- A public check that payouts plus balances equal the author shares in the receipts.
It builds on what exists today:
- `pay/executor-settlement.coax` (3-leg author-royalty settlement,
101/101mutants killed,#13961) - `psionic/lib/peer/pay.coax` and `apps/openagents-cli/pylon-settle.coax`
- `coax/lib/lightning/offers.coax`
- `coax/lib/lightning/pay.coax`
- `coax/lib/lightning/invoice.coax`
- `coax/lib/bitcoin/treasury.coax`
- `coax/lib/nostr/nip57.coax`
On the protocol (chapter 65):
| Record | Schema | Carriage | Today |
|---|---|---|---|
| What an author is owed and was paid | openagents.ledger.v1 Earnings, Statement (spec 26.6) | HTTP; a signed payout record on Nostr | Spec sketch; no .proto file |
| Where to pay an author | openagents.payment.v1 LightningAddress (spec 26.5) | HTTP: LNURL | Built in forward mode (Lightning Addresses, #13208). LNURL is an external format |
The chapter's check
- Source:
pay/payout-policy.coax, run on the meter totals from chapter 57's case, with a fake Lightning payer that replays recorded answers and the controlled clock. Author A has an address, author B is owed less than the minimum, and author C has no address. - Trace: one signed payout record for A that cites the receipts it covers, a held balance for B and C, and
p-1: already sent, nothing paidwhen the same payout runs again. The fake payer fails A's first try; afterclockmoves past the retry time, the payout is sent once. - Refusal: a payout that would make payouts plus balances differ from the author shares in the receipts is refused before anything is sent:
refused: payouts and balances do not equal author shares. - Independent check: each invoice the fake payee issues is read by the independent BOLT 11 reader, `coax/tests/lightning/bolt11.py`, and the sum of payouts and balances is worked out by hand from the receipts.
Shipped paths: `pay/payout-policy.coax` (#14060) and `pay/executor-settlement.coax` (#13961), in the Payments context (`pay/`) beside the tips in `pay/makerpay-policy.coax`.
Planned paths: pay/payout-runner.coax.
Sources
- Episodes:
- Episode 289, *OpenAgents*: 2:00, Lightning micropayments to authors
- Episode 93, *The Sats Must Flow*
- Episode 96, *Payments & Payouts*
- Episode 98, *Agent Revenue Sharing*: revenue sharing
- Episode 99, *Lightning Addresses*
- Episode 223, *Pay the People*
- Episode 235, *Agents Earn Bitcoin Tips*: agents earn tips
- Old code at
coder-v1.0.0, crates:pay-ledger,pay-host,wallet,spark-wallet,receipts - NIPs: NIP-X402, NIP-XP, NIP-KEYS
- Promises covered (audit): P11
Open questions for the owner
- What is the author's share of each paid call? This is the audit's decision 3.
- What is the payout schedule and the minimum: for example, daily above a set number of sats?
- When a plugin depends on another paid plugin, how is the price split between the two authors?
- A tip goes straight from the payer to the maker's own wallet (owner decision D6 in docs/auth, built in #13210). A paid call with a split can't always do that. Who holds the money between such a call and the payout, and under what custody?