Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

chore: rename custom_records to tlv_records #448

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lnclient/ldk/ldk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -1011,11 +1012,15 @@ func (ls *LDKService) ldkPaymentToTransaction(payment *ldk_node.PaymentDetails)
if spontaneousPaymentKind.Preimage != nil {
preimage = *spontaneousPaymentKind.Preimage
}
customRecords := map[string]string{}

tlvRecords := []lnclient.TLVRecord{}
for _, tlv := range spontaneousPaymentKind.CustomTlvs {
customRecords[strconv.FormatUint(tlv.Type, 10)] = b64.StdEncoding.EncodeToString(tlv.Value)
tlvRecords = append(tlvRecords, lnclient.TLVRecord{
Type: tlv.Type,
Value: hex.EncodeToString(tlv.Value),
})
}
metadata["custom_records"] = customRecords
metadata["tlv_records"] = tlvRecords
}

var amount uint64 = 0
Expand Down
3 changes: 2 additions & 1 deletion lnclient/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (
)

type TLVRecord struct {
Type uint64 `json:"type"`
Type uint64 `json:"type"`
// hex-encoded value
Value string `json:"value"`
}

Expand Down
Loading