Documentation ¶
Index ¶
- func Amount(milliSat lnwire.MilliSatoshi) func(*Invoice)
- func CLTVExpiry(delta uint64) func(*Invoice)
- func Description(description string) func(*Invoice)
- func DescriptionHash(descriptionHash [32]byte) func(*Invoice)
- func Destination(destination *btcec.PublicKey) func(*Invoice)
- func Expiry(expiry time.Duration) func(*Invoice)
- func FallbackAddr(fallbackAddr btcutil.Address) func(*Invoice)
- func RouteHint(routeHint []routing.HopHint) func(*Invoice)
- type Invoice
- type MessageSigner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Amount ¶
func Amount(milliSat lnwire.MilliSatoshi) func(*Invoice)
Amount is a functional option that allows callers of NewInvoice to set the amount in millisatoshis that the Invoice should encode.
func CLTVExpiry ¶
CLTVExpiry is an optional value which allows the receiver of the payment to specify the delta between the current height and the HTLC extended to the receiver.
func Description ¶
Description is a functional option that allows callers of NewInvoice to set the payment description of the created Invoice.
NOTE: Must be used if and only if DescriptionHash is not used.
func DescriptionHash ¶
DescriptionHash is a functional option that allows callers of NewInvoice to set the payment description hash of the created Invoice.
NOTE: Must be used if and only if Description is not used.
func Destination ¶
Destination is a functional option that allows callers of NewInvoice to explicitly set the pubkey of the Invoice's destination node.
func Expiry ¶
Expiry is a functional option that allows callers of NewInvoice to set the expiry of the created Invoice. If not set, a default expiry of 60 min will be implied.
func FallbackAddr ¶
FallbackAddr is a functional option that allows callers of NewInvoice to set the Invoice's fallback on-chain address that can be used for payment in case the Lightning payment fails
Types ¶
type Invoice ¶
type Invoice struct { // Net specifies what network this Lightning invoice is meant for. Net *chaincfg.Params // MilliSat specifies the amount of this invoice in millisatoshi. // Optional. MilliSat *lnwire.MilliSatoshi // Timestamp specifies the time this invoice was created. // Mandatory Timestamp time.Time // PaymentHash is the payment hash to be used for a payment to this // invoice. PaymentHash *[32]byte // Destination is the public key of the target node. This will always // be set after decoding, and can optionally be set before encoding to // include the pubkey as an 'n' field. If this is not set before // encoding then the destination pubkey won't be added as an 'n' field, // and the pubkey will be extracted from the signature during decoding. Destination *btcec.PublicKey // Description is a short description of the purpose of this invoice. // Optional. Non-nil iff DescriptionHash is nil. Description *string // DescriptionHash is the SHA256 hash of a description of the purpose of // this invoice. // Optional. Non-nil iff Description is nil. DescriptionHash *[32]byte // FallbackAddr is an on-chain address that can be used for payment in // case the Lightning payment fails. // Optional. FallbackAddr btcutil.Address // RouteHints represents one or more different route hints. Each route // hint can be individually used to reach the destination. These usually // represent private routes. // // NOTE: This is optional. RouteHints [][]routing.HopHint // contains filtered or unexported fields }
Invoice represents a decoded invoice, or to-be-encoded invoice. Some of the fields are optional, and will only be non-nil if the invoice this was parsed from contains that field. When encoding, only the non-nil fields will be added to the encoded invoice.
func Decode ¶
Decode parses the provided encoded invoice and returns a decoded Invoice if it is valid by BOLT-0011 and matches the provided active network.
func NewInvoice ¶
func NewInvoice(net *chaincfg.Params, paymentHash [32]byte, timestamp time.Time, options ...func(*Invoice)) (*Invoice, error)
NewInvoice creates a new Invoice object. The last parameter is a set of variadic arguments for setting optional fields of the invoice.
NOTE: Either Description or DescriptionHash must be provided for the Invoice to be considered valid.
func (*Invoice) Encode ¶
func (invoice *Invoice) Encode(signer MessageSigner) (string, error)
Encode takes the given MessageSigner and returns a string encoding this invoice signed by the node key of the signer.
func (*Invoice) Expiry ¶
Expiry returns the expiry time for this invoice. If expiry time is not set explicitly, the default 3600 second expiry will be returned.
func (*Invoice) MinFinalCLTVExpiry ¶
MinFinalCLTVExpiry returns the minimum final CLTV expiry delta as specified by the creator of the invoice. This value specifies the delta between the current height and the expiry height of the HTLC extended in the last hop.
type MessageSigner ¶
type MessageSigner struct { // SignCompact signs the passed hash with the node's privkey. The // returned signature should be 65 bytes, where the last 64 are the // compact signature, and the first one is a header byte. This is the // format returned by btcec.SignCompact. SignCompact func(hash []byte) ([]byte, error) }
MessageSigner is passed to the Encode method to provide a signature corresponding to the node's pubkey.