routing+channeldb: send payment metadata from invoice

This commit is contained in:
Joost Jager committed 2022-04-13 22:55:40 +02:00
1 parent 135e27ddd3
commit 9195f29e61
17 files changed
+1580 -1401

No files matched your search

+16
View File
@@ -16,6 +16,10 @@ const (
// NextHopOnionType is the type used in the onion to reference the ID
// of the next hop.
NextHopOnionType tlv.Type = 6
// MetadataOnionType is the type used in the onion for the payment
// metadata.
MetadataOnionType tlv.Type = 16
)
// NewAmtToFwdRecord creates a tlv.Record that encodes the amount_to_forward
@@ -45,3 +49,15 @@ func NewLockTimeRecord(lockTime *uint32) tlv.Record {
func NewNextHopIDRecord(cid *uint64) tlv.Record {
return tlv.MakePrimitiveRecord(NextHopOnionType, cid)
}
// NewMetadataRecord creates a tlv.Record that encodes the metadata (type 10)
// for an onion payload.
func NewMetadataRecord(metadata *[]byte) tlv.Record {
return tlv.MakeDynamicRecord(
MetadataOnionType, metadata,
func() uint64 {
return uint64(len(*metadata))
},
tlv.EVarBytes, tlv.DVarBytes,
)
}