lnrpc+rpcserver: encode custom records as custom channel data

With this commit we encode the custom records as a TLV stream into the
custom channel data field of the invoice HTLC.
This allows the custom data parser to parse those records and replace it
with human-readable JSON on the RPC interface.
This commit is contained in:
Oliver Gugger committed 2024-09-19 09:21:38 +02:00
1 parent bbae7148aa
commit d37df75bc0
9 files changed
+144 -5

No files matched your search

+10
View File
@@ -123,6 +123,16 @@ func CreateRPCInvoice(invoice *invoices.Invoice,
MppTotalAmtMsat: uint64(htlc.MppTotalAmt),
}
// The custom channel data is currently just the raw bytes of
// the encoded custom records.
customData, err := lnwire.CustomRecords(
htlc.CustomRecords,
).Serialize()
if err != nil {
return nil, err
}
rpcHtlc.CustomChannelData = customData
// Populate any fields relevant to AMP payments.
if htlc.AMP != nil {
rootShare := htlc.AMP.Record.RootShare()