@@ -17,6 +17,8 @@ import (
17
17
18
18
"github.com/getAlby/ldk-node-go/ldk_node"
19
19
// "github.com/getAlby/nostr-wallet-connect/ldk_node"
20
+ b64 "encoding/base64"
21
+
20
22
decodepay "github.com/nbd-wtf/ln-decodepay"
21
23
"github.com/sirupsen/logrus"
22
24
@@ -964,6 +966,7 @@ func (ls *LDKService) ldkPaymentToTransaction(payment *ldk_node.PaymentDetails)
964
966
var settledAt * int64
965
967
preimage := ""
966
968
paymentHash := ""
969
+ metadata := map [string ]interface {}{}
967
970
968
971
bolt11PaymentKind , isBolt11PaymentKind := payment .Kind .(ldk_node.PaymentKindBolt11 )
969
972
@@ -998,10 +1001,8 @@ func (ls *LDKService) ldkPaymentToTransaction(payment *ldk_node.PaymentDetails)
998
1001
spontaneousPaymentKind , isSpontaneousPaymentKind := payment .Kind .(ldk_node.PaymentKindSpontaneous )
999
1002
if isSpontaneousPaymentKind {
1000
1003
// keysend payment
1001
- // currently no access to created at or the TLVs to get the description
1002
- // TODO: store these in NWC database
1003
1004
lastUpdate := int64 (payment .LastUpdate )
1004
- // TODO: use proper created at time
1005
+ // TODO: use proper created at time (currently no access to created time for keysend payments)
1005
1006
createdAt = lastUpdate
1006
1007
if payment .Status == ldk_node .PaymentStatusSucceeded {
1007
1008
settledAt = & lastUpdate
@@ -1010,6 +1011,11 @@ func (ls *LDKService) ldkPaymentToTransaction(payment *ldk_node.PaymentDetails)
1010
1011
if spontaneousPaymentKind .Preimage != nil {
1011
1012
preimage = * spontaneousPaymentKind .Preimage
1012
1013
}
1014
+ customRecords := map [string ]string {}
1015
+ for _ , tlv := range spontaneousPaymentKind .CustomTlvs {
1016
+ customRecords [strconv .FormatUint (tlv .Type , 10 )] = b64 .StdEncoding .EncodeToString (tlv .Value )
1017
+ }
1018
+ metadata ["custom_records" ] = customRecords
1013
1019
}
1014
1020
1015
1021
var amount uint64 = 0
@@ -1034,6 +1040,7 @@ func (ls *LDKService) ldkPaymentToTransaction(payment *ldk_node.PaymentDetails)
1034
1040
Description : description ,
1035
1041
DescriptionHash : descriptionHash ,
1036
1042
ExpiresAt : expiresAt ,
1043
+ Metadata : metadata ,
1037
1044
}, nil
1038
1045
}
1039
1046
0 commit comments