peerpay

package
v0.2.2 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: 17 Imported by: 0 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 peerpay delivers a BRC-29 payment to its recipient the way PeerPay does: the payment token, encrypted to the recipient, put in the recipient's payment_inbox at a message box server (BRC-33).

It follows @bsv/message-box-client: the token's JSON, the message id as an HMAC of that JSON, and the body as {"encryptedMessage": base64}, each under the protocol [1, "messagebox"], key id "1", with the recipient as counterparty. Every request is mutually authenticated (BRC-103/104) by go-sdk's AuthFetch under the sender's wallet. A box that asks to be paid for delivery is refused rather than paid: nothing here spends.

Index

Constants

View Source
const Inbox = "payment_inbox"

Inbox is the message box PeerPay reads payments from.

Variables

View Source
var ErrPayment = errors.New("peerpay: the message box asks to be paid for delivery, which beefcat does not do")

ErrPayment is a box that wants paying for delivery.

View Source
var Protocol = wallet.Protocol{SecurityLevel: wallet.SecurityLevelEveryApp, Protocol: "messagebox"}

Protocol is the message box protocol every id and body is derived under.

Functions

func CheckBox

func CheckBox(box string) error

CheckBox refuses a message box that is not an https URL, or http on loopback.

func CheckKey

func CheckKey(keyHex string) error

CheckKey refuses anything but a canonical compressed public key in lowercase hex. One key has one spelling: a message box files a payment under the recipient as it is written, and a key is compared as a string.

func IDInput

func IDInput(token []byte) []byte

IDInput is what a message's id is the HMAC of. The TypeScript client is handed the token as a string and hashes that string's JSON form, quotes and escapes included, while it encrypts the string itself.

func ParseURI

func ParseURI(s string) (keyHex, box string, err error)

ParseURI reads a PeerPay URI, peerpay:<identity key>?url=<message box>, and returns the identity key in hex and the message box, which is empty when the URI names none.

func Send

func Send(ctx context.Context, base string, w wallet.Interface, m Message) error

Send puts m in the recipient's payment inbox at the message box server.

Types

type Instructions

type Instructions struct {
	DerivationPrefix string `json:"derivationPrefix"`
	DerivationSuffix string `json:"derivationSuffix"`
}

Instructions are the BRC-29 derivation the recipient re-derives its key from, with the sender's identity key, which the message box supplies.

type Message

type Message struct {
	Recipient string
	ID        string
	Body      string
}

Message is what is put in the recipient's box.

func Seal

func Seal(ctx context.Context, w wallet.Interface, originator, recipientHex string, t Token) (Message, error)

Seal makes the message for a token: its id and its encrypted body.

type Token

type Token struct {
	CustomInstructions Instructions `json:"customInstructions"`
	Transaction        []uint16     `json:"transaction"`
	Amount             uint64       `json:"amount"`
}

Token is PeerPay's payment token. Transaction is the payment as Atomic BEEF, written as a JSON array of numbers, as the TypeScript client writes a byte array.

func NewToken

func NewToken(beef []byte, sats uint64, prefix, suffix string) Token

NewToken is the token for a payment whose output 0 pays sats under the derivation.

Jump to

Keyboard shortcuts

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