heldpay

package
v0.37.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func (t *Tap) Held() (string, bool)

Held reports whether the server held a payment since the last Reset, and the reason it gave.

func (*Tap) Payment

func (t *Tap) Payment() string

Payment is the x-bsv-payment header last sent, "" when none was.

func (*Tap) Reset

func (t *Tap) Reset()

Reset forgets the hold seen, keeping the payment: what a client calls before it sends the held payment again.

func (*Tap) RoundTrip

func (t *Tap) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip sends req, noting a payment it carries and a held answer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL