From dfb3b30c24bce487ab644d4b211655e69426ceda Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Fri, 14 Jun 2024 21:15:19 +0200 Subject: [PATCH 1/2] chore: rename custom_records to tlv_records This makes it more consistent with the usage in the keysend functions --- lnclient/ldk/ldk.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lnclient/ldk/ldk.go b/lnclient/ldk/ldk.go index 2e8f3765..b038a71a 100644 --- a/lnclient/ldk/ldk.go +++ b/lnclient/ldk/ldk.go @@ -1011,11 +1011,11 @@ func (ls *LDKService) ldkPaymentToTransaction(payment *ldk_node.PaymentDetails) if spontaneousPaymentKind.Preimage != nil { preimage = *spontaneousPaymentKind.Preimage } - customRecords := map[string]string{} + tlvRecords := map[string]string{} for _, tlv := range spontaneousPaymentKind.CustomTlvs { - customRecords[strconv.FormatUint(tlv.Type, 10)] = b64.StdEncoding.EncodeToString(tlv.Value) + tlvRecords[strconv.FormatUint(tlv.Type, 10)] = b64.StdEncoding.EncodeToString(tlv.Value) } - metadata["custom_records"] = customRecords + metadata["tlv_records"] = tlvRecords } var amount uint64 = 0 From 5110d86dec0032eda85cd5bdee4387ebb1aa2124 Mon Sep 17 00:00:00 2001 From: Roland Bewick Date: Mon, 17 Jun 2024 16:20:58 +0700 Subject: [PATCH 2/2] fix: use new NWC tlv_records format --- lnclient/ldk/ldk.go | 11 ++++++++--- lnclient/models.go | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lnclient/ldk/ldk.go b/lnclient/ldk/ldk.go index b038a71a..97279a0e 100644 --- a/lnclient/ldk/ldk.go +++ b/lnclient/ldk/ldk.go @@ -17,7 +17,8 @@ import ( "github.com/getAlby/ldk-node-go/ldk_node" // "github.com/getAlby/nostr-wallet-connect/ldk_node" - b64 "encoding/base64" + + "encoding/hex" decodepay "github.com/nbd-wtf/ln-decodepay" "github.com/sirupsen/logrus" @@ -1011,9 +1012,13 @@ func (ls *LDKService) ldkPaymentToTransaction(payment *ldk_node.PaymentDetails) if spontaneousPaymentKind.Preimage != nil { preimage = *spontaneousPaymentKind.Preimage } - tlvRecords := map[string]string{} + + tlvRecords := []lnclient.TLVRecord{} for _, tlv := range spontaneousPaymentKind.CustomTlvs { - tlvRecords[strconv.FormatUint(tlv.Type, 10)] = b64.StdEncoding.EncodeToString(tlv.Value) + tlvRecords = append(tlvRecords, lnclient.TLVRecord{ + Type: tlv.Type, + Value: hex.EncodeToString(tlv.Value), + }) } metadata["tlv_records"] = tlvRecords } diff --git a/lnclient/models.go b/lnclient/models.go index 4a5e81ed..9f183d22 100644 --- a/lnclient/models.go +++ b/lnclient/models.go @@ -6,7 +6,8 @@ import ( ) type TLVRecord struct { - Type uint64 `json:"type"` + Type uint64 `json:"type"` + // hex-encoded value Value string `json:"value"` }