SHARENOTEProof of energy
Specs/Paid work

Payout Receipts

A signed receipt of who gets what and which notes counted, so anyone can audit an offer's payout.

Summary

When an issuer splits an offer's reward, it publishes a signed receipt: who gets how much, and exactly which notes it counted. Anyone holding the offer can check that the amounts follow from the stated weights.

With the notes from the offer's relays, anyone can check the weights. Anyone holding a note the receipt leaves out can name it as an omission. A false receipt is proven by the issuer's own signature.

issuersworkersauditors

Kinds and tags

KindNameHow
1727Receiptsigned by the offer's issuer, published to every relay the offer names
14Destination request (NIP-17)gift-wrapped DM asking for a BOLT11 invoice
TagMeaning
ethe offer id; exactly one
rewardequal to the offer's reward; exactly one
payidentity, amount, weight, min H; one per identity
nalgorithm:H of one counted note; one per note
closedcutoff, only for an offer without closes

The receipt

A kind:1727 event with empty content, signed by the offer's issuer.

  • pay: [identity, amount, weight, min H], one per identity with at least one counted note, even if its amount is 0. weight sums the SNP-01 weights floor(2^384 / T); min H is the tie-breaker.
  • n: <algorithm>:<H>, H in 64 lowercase hex. A note is named by its key, never by event id.
  • No two pay tags share an identity or a min H.

The cutoff is when the issuer stopped counting: the offer's closes, else closed, else the receipt's created_at. A receipt exists only for a valid offer with a reward and at least one counted note. Readers find it with {"kinds":[1727], "authors":[<issuer>], "#e":[<offer id>]}.

What the issuer must do

A receipt is malformed, and ignored, if it is not signed by the issuer, has non-empty content, points to an offer without a reward, has closed while the offer has closes, or has a tag missing, repeated or ill-formed.

The issuer must make a well-formed receipt true:

  • reward equals the offer's;
  • amounts follow the SNP-01 split and add up to exactly the reward;
  • one n per counted note, each answering the offer;
  • weights and min H match those notes;
  • every counted note is published to the offer's relays.

Once it publishes a receipt, the cutoff is fixed. Two receipts for one offer with different reward, pay, n or cutoff are an equivocation.

Auditing

FindingNeeds notesMeans
amounts do not follow from the receipt's weightsnoprovably false
reward differs from the offer'snoprovably false
a key listed twicenoprovably false
two receipts differ in reward, pay, n or cutoffnoequivocation, naming both
a listed note does not answer the offeryesprovably false
weights or tie-breakers differ from the notesyes, allprovably false
a listed note found nowhereyesunverified
an answering note on the relays before the cutoff is not listedyesomission
an answering note not known on the relays before the cutoffyeslate; nothing against the issuer

An auditor holding several receipts audits each against the latest cutoff.

Omission or late

No auditor can know when the issuer first saw a note. So an unlisted note is an omission only if the auditor knows it was on one of the offer's relays before the cutoff: a worker from the relay's OK when it published, anyone from having fetched it there.

Otherwise the note is late. It may have reached the issuer too late to count, and that is no claim against the issuer.

An omission is not proof of fraud: the issuer may say the note never reached it. But whoever holds the note can name it. An issuer gains nothing by republishing with an earlier cutoff: no omission turns late, and the pair proves equivocation.

Asking for a destination

An issuer pays each identity at its SNP-03 Pay announcement. If an identity has no destination for a method the issuer uses, and the unit is sat or msat, the issuer may ask once per receipt by a NIP-17 kind:14 DM tagged p (identity), e (receipt id) and amount.

The identity answers with a kind:14 DM tagged ["e", <request rumor id>] whose content is a BOLT11 invoice. The issuer pays it only if it is for exactly that amount, on the right network, and no invoice was paid for that request before. Until paid, the amount stays owed.

Each n tag is about 80 bytes. Relays often cap events near 64 KB, so a receipt holds several hundred notes; an issuer expecting more sets a larger z.

Worked example

An offer asks for sha256d notes of at least 8z00 and rewards 1000 sat. Alice publishes 8z00 and 9z00 (weight 768), Bob 10z00 (1024), Carol 9z00 (512). Total 2304.

ReceiptAudit
counts all four notes; pays Alice 333, Bob 445, Carol 222consistent
counts only Alice's and Bob's; pays 429 and 571consistent; Carol's 9z00 named as omitted
counts all four; pays Alice 383, Bob 395, Carol 222provably false: the split gives 333 and 445

Why 333/445/222: the floors are 333, 444 and 222, which sum to 999. The leftover unit goes to the largest remainder, Bob's (1000 · 1024 mod 2304 = 1024, against 768 for Alice and 512 for Carol).

Try it

Rendered from soprinter/snps/SNP-05.md. The full text has every rule; this page condenses it.