Documentation
¶
Overview ¶
Package paidhost is a stand-in for an overlay host's terms route, for an application's tests: the terms document, and lookups over BRC-104 in which a priced class is answered 402 (BRC-105) until a payment pays the price to the key BRC-29 derives for the payee, and verifies against the chain. The application gives it its lookup service: the name, the classes and how a question is asked and answered. Never for a network.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Paid ¶
type Paid struct {
Service Service
Prices map[string]uint64
// Payments are the payments it accepted: txid, satoshis, the remittance
// and the Atomic BEEF, as a host's payment ledger records them.
Payments []Payment
// Again answers 402 to every priced question, a payment or none: a
// host that keeps asking. FailPaid records a payment and then answers
// 500: a host that took the money and did not answer.
Again bool
FailPaid bool
// OnPayment, when set, runs when a request carrying a payment arrives,
// before anything is done with it.
OnPayment func()
// contains filtered or unexported fields
}
Paid is the route: the terms document, and lookups over BRC-104 in which a priced class is answered 402 (BRC-105) until a payment pays the price to the key BRC-29 derives for the payee, the prefix it issued, the payer's suffix and the payer, and verifies against Headers. Requests are served one at a time.
type Payment ¶
type Payment struct {
Txid string `json:"txid"`
Beef string `json:"beef"`
OutputIndex int `json:"outputIndex"`
Satoshis uint64 `json:"satoshis"`
DerivationPrefix string `json:"derivationPrefix"`
DerivationSuffix string `json:"derivationSuffix"`
SenderIdentityKey string `json:"senderIdentityKey"`
Class string `json:"class"`
}
Payment is one accepted payment, in the host ledger's shape.
type Service ¶
type Service struct {
// Name is the lookup service ("ls_<app>"): the terms document is at
// /<Name>/terms and a question names it.
Name string
// Classes are the classes the terms document lists, in its order; a
// class with no price is left out.
Classes []string
// Ask parses a question's query and returns its class and how to
// answer it; an error is answered 400. Answer runs only once a priced
// class is paid, and an error from it is answered 400 too.
Ask func(query json.RawMessage) (class string, answer func() (any, error), err error)
// Headers is what a payment's proof is verified against.
Headers chaintracker.ChainTracker
}
Service is the application's lookup service, as the route answers it.