zpay32

package
v0.2.1-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2017 License: MIT Imports: 9 Imported by: 0

README

zpay32

Build Status MIT licensed GoDoc

The zpay32 package implements a basic scheme for the encoding of payment requests between two lnd nodes within the Lightning Network. The zpay32 encoding scheme uses the zbase32 scheme along with a checksum to encode a serialized payment request.

The payment request serialized by the package consist of: the destination's public key, the payment hash to use for the payment, and the value of payment to send.

Installation and Updating

$ go get -u github.com/lightningnetwork/lnd/zpay32

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCheckSumMismatch = errors.New("the checksum is incorrect")

ErrCheckSumMismatch is returned byt he Decode function fi when decoding an encoded invoice, the checksum doesn't match indicating an error somewhere in the bitstream.

View Source
var ErrDataTooShort = errors.New("the decoded data is too short")

ErrDataTooShort is returned by the Decode function if when decoding an encoded payment request, the number of bytes decoded is too few for a valid invoice indicating invalid input.

Functions

func Encode

func Encode(payReq *PaymentRequest) string

Encode encodes the passed payment request using zbase32 with an added 4-byte crc32 checksum. The resulting encoding is 77-bytes long and consists of 124 ASCII characters. TODO(roasbeef): add version byte?

Types

type PaymentRequest

type PaymentRequest struct {
	// Destination is the public key of the node to be paid.
	Destination *btcec.PublicKey

	// PaymentHash is the has to use within the HTLC extended throughout
	// the payment path to the destination.
	PaymentHash [32]byte

	// Amount is the amount to be sent to the destination expressed in
	// satoshis.
	Amount btcutil.Amount
}

PaymentRequest is a bare-bones invoice for a payment within the Lightning Network. With the details of the invoice, the sender has all the data necessary to send a payment to the recipient.

func Decode

func Decode(payData string) (*PaymentRequest, error)

Decode attempts to decode the zbase32 encoded payment request. If the trailing checksum doesn't match, then an error is returned.

Jump to

Keyboard shortcuts

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