Documentation
¶
Overview ¶
Package tokens holds no state and imports only the standard library, so the browser build, which cannot take pkg/logic/common, runs the same code as the desktop. pkg/logic/common keeps the wallet, the session and the reveal loop.
Index ¶
- Constants
- func BuyURLFor(base, claim string) string
- func ChainHash(seed [32]byte, position int) [32]byte
- func ClaimSurface(claim string) string
- func CollectDelay(age, tick time.Duration) time.Duration
- func CollectURL(base, claim string) string
- func DecodeCode(code string) (seed [32]byte, units int, err error)
- func EncodeCode(seed [32]byte, units int) string
- func NewClaim(surface string) (string, error)
- func PayPreamble(anchor [32]byte, token [32]byte) []byte
Constants ¶
const ( AckPaid = 1 << 0 // the bridge took the anchor: the pair has priority AckContention = 1 << 1 // the bridge is busy: the free lane is being shared )
The bits of the bridge's one ack byte.
const ( CollectTick = 3 * time.Second CollectWindow = 30 * time.Minute )
The collect schedule. A payment usually lands within two minutes of the buy page opening, so the first two minutes poll at the tick; after that the person is likely still typing card details, or gone. CollectWindow ends it: past it the code still waits on the token service, and on the page Stripe returns to, for a paste.
const BuyURL = ServiceBase + "/buy"
BuyURL is the buy page without a claim: what a person can type or paste.
const MaxChainUnits = 1_000_000
MaxChainUnits bounds the units a code may carry.
const ServiceBase = "https://tokens.keibidrop.com" //nolint:gosec // G101: URL, not a credential
ServiceBase is the token service. Prices live on its buy page and in its pack table, never in a client.
const UnitBytes int64 = 10 << 20
UnitBytes is the bandwidth one chain step buys. PROTOCOL CONSTANT shared with the relay ledger, the bridge and the token service.
Variables ¶
This section is empty.
Functions ¶
func ChainHash ¶
ChainHash is the chain value at position: seed hashed position times. The anchor is the value at the chain's full length; spending reveals values toward the seed.
func ClaimSurface ¶
ClaimSurface is the surface a claim names, or "" for a bare ref. A bare ref is 22 base64url characters, which may contain '_' themselves, so only a claim longer than that has a surface.
func CollectDelay ¶
CollectDelay is the wait before the next collect poll for a purchase opened age ago, on a schedule scaled by tick (CollectTick in production): the tick for two minutes, three ticks until ten, then ten ticks. An unpaid claim costs the token service about 130 polls over the window instead of 600.
func CollectURL ¶
CollectURL is where the purchase made under claim is picked up as JSON.
func DecodeCode ¶
DecodeCode validates a pasted "KDT1." code (seed, units, checksum).
func EncodeCode ¶
EncodeCode is the pasteable form of a chain.
func NewClaim ¶
NewClaim is a fresh one-shot purchase ref: the surface that started the purchase ("desktop", "web", "kd", "cli", "mcp"), an underscore, then 16 random bytes in base64url. The token service stores the claim with the purchase and Stripe shows it as the payment's client_reference_id, so every sale says where it was made. Both accept letters, digits, '-' and '_' only, and at most 200 characters; the surface is cut to lower-case letters and digits so the claim always fits. An empty surface gives the bare random ref that clients before 0.5.0 send.
func PayPreamble ¶
PayPreamble assembles magic || ver || anchor || tier || token, the single write a funded native leg sends where a free one sends the bare token.
Types ¶
This section is empty.