Documentation
¶
Overview ¶
Package heldpay is a BRC-105 client's side of a payment the server holds for confirmation. A server that takes a payment it cannot yet trust broadcasts it and answers 202 with the code ERR_PAYMENT_HELD; the same payment, sent again once it is mined, buys the answer. (Servers built before that answered 402 with the same code and no BRC-105 headers, which a BRC-105 client such as go-sdk's AuthFetch takes for a price it cannot read; Tap recognizes both.)
A client wraps its HTTP transport in a Tap, makes its paid request, and when Tap.Held reports a hold, waits for the payment to mine (Mined) and sends the request again with Tap.Payment as its x-bsv-payment header, paying nothing more.
Index ¶
Constants ¶
const Code = "ERR_PAYMENT_HELD"
Code is the error code of a held payment's answer.
Variables ¶
This section is empty.
Functions ¶
func Mined ¶
func Mined(ctx context.Context, chain nodeapi.Chain, tx *transaction.Transaction, wait, poll time.Duration) error
Mined waits, up to wait, for tx to be mined on chain, asking every poll (zero is nodeapi's default). An error is a payment not mined in time, or one the chain shows spent elsewhere.
Types ¶
type Tap ¶
type Tap struct {
Next http.RoundTripper
// contains filtered or unexported fields
}
Tap is an http.RoundTripper over Next (nil is http.DefaultTransport) that keeps the x-bsv-payment header of the last request that sent one, and whether, and why, the server held a payment. Its methods are safe for concurrent use; a client makes one paid call at a time through it.
func (*Tap) Held ¶
Held reports whether the server held a payment since the last Reset, and the reason it gave.