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 ¶
const Inbox = "payment_inbox"
Inbox is the message box PeerPay reads payments from.
Variables ¶
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.
var Protocol = wallet.Protocol{SecurityLevel: wallet.SecurityLevelEveryApp, Protocol: "messagebox"}
Protocol is the message box protocol every id and body is derived under.
Functions ¶
func IDInput ¶
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.
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 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.