zpay32: add payment metadata field

This commit is contained in:
Joost Jager
2022-01-11 13:53:46 +01:00
parent 044286ae2c
commit 135e27ddd3
4 changed files with 75 additions and 5 deletions

View File

@@ -46,6 +46,9 @@ const (
// fieldTypeD contains a short description of the payment.
fieldTypeD = 13
// fieldTypeM contains the payment metadata.
fieldTypeM = 27
// fieldTypeN contains the pubkey of the target node.
fieldTypeN = 19
@@ -183,6 +186,10 @@ type Invoice struct {
// Features represents an optional field used to signal optional or
// required support for features by the receiver.
Features *lnwire.FeatureVector
// Metadata is additional data that is sent along with the payment to
// the payee.
Metadata []byte
}
// Amount is a functional option that allows callers of NewInvoice to set the
@@ -273,6 +280,14 @@ func PaymentAddr(addr [32]byte) func(*Invoice) {
}
}
// Metadata is a functional option that allows callers of NewInvoice to set
// the desired payment Metadata tht is advertised on the invoice.
func Metadata(metadata []byte) func(*Invoice) {
return func(i *Invoice) {
i.Metadata = metadata
}
}
// NewInvoice creates a new Invoice object. The last parameter is a set of
// variadic arguments for setting optional fields of the invoice.
//