routing+channeldb: send payment metadata from invoice

This commit is contained in:
Joost Jager
2021-10-04 09:33:12 +02:00
parent 135e27ddd3
commit 9195f29e61
17 changed files with 1580 additions and 1401 deletions

View File

@@ -1141,6 +1141,10 @@ func serializeHop(w io.Writer, h *route.Hop) error {
records = append(records, h.MPP.Record())
}
if h.Metadata != nil {
records = append(records, record.NewMetadataRecord(&h.Metadata))
}
// Final sanity check to absolutely rule out custom records that are not
// custom and write into the standard range.
if err := h.CustomRecords.Validate(); err != nil {
@@ -1255,6 +1259,13 @@ func deserializeHop(r io.Reader) (*route.Hop, error) {
h.MPP = mpp
}
metadataType := uint64(record.MetadataOnionType)
if metadata, ok := tlvMap[metadataType]; ok {
delete(tlvMap, metadataType)
h.Metadata = metadata
}
h.CustomRecords = tlvMap
return h, nil