@@ -4,6 +4,7 @@ import LnMessage from "lnmessage";
44import { v4 as uuidv4 } from "uuid" ;
55import { Account } from "~/types" ;
66
7+ import lightningPayReq from "bolt11-signet" ;
78import { mergeTransactions } from "~/common/utils/helpers" ;
89import Connector , {
910 CheckPaymentArgs ,
@@ -238,18 +239,28 @@ export default class Commando implements Connector {
238239 . then ( ( resp ) => {
239240 const parsed = resp as CommandoListInvoicesResponse ;
240241 return parsed . invoices
241- . map (
242- ( invoice , index ) : ConnectorTransaction => ( {
242+ . map ( ( invoice , index ) : ConnectorTransaction => {
243+ const decoded = invoice . bolt11
244+ ? lightningPayReq . decode ( invoice . bolt11 )
245+ : null ;
246+
247+ const creationDate =
248+ decoded && decoded . timestamp
249+ ? decoded . timestamp * 1000
250+ : new Date ( 0 ) . getTime ( ) ;
251+
252+ return {
243253 id : invoice . label ,
244254 memo : invoice . description ,
245255 settled : invoice . status === "paid" ,
256+ creationDate : creationDate ,
246257 preimage : invoice . payment_preimage ,
247258 payment_hash : invoice . payment_hash ,
248259 settleDate : invoice . paid_at * 1000 ,
249260 type : "received" ,
250261 totalAmount : Math . floor ( invoice . amount_received_msat / 1000 ) ,
251- } )
252- )
262+ } ;
263+ } )
253264 . filter ( ( invoice ) => invoice . settled ) ;
254265 } ) ;
255266 }
@@ -261,7 +272,7 @@ export default class Commando implements Connector {
261272 const transactions : ConnectorTransaction [ ] = mergeTransactions (
262273 incomingInvoicesResponse ,
263274 outgoingInvoicesResponse
264- ) ;
275+ ) . filter ( ( transaction ) => transaction . settled ) ;
265276
266277 return {
267278 data : {
@@ -280,18 +291,28 @@ export default class Commando implements Connector {
280291 . then ( ( resp ) => {
281292 const parsed = resp as CommandoListSendPaysResponse ;
282293 return parsed . payments
283- . map (
284- ( payment , index ) : ConnectorTransaction => ( {
294+ . map ( ( payment , index ) : ConnectorTransaction => {
295+ const decoded = payment . bolt11
296+ ? lightningPayReq . decode ( payment . bolt11 )
297+ : null ;
298+
299+ const creationDate =
300+ decoded && decoded . timestamp
301+ ? decoded . timestamp * 1000
302+ : new Date ( 0 ) . getTime ( ) ;
303+
304+ return {
285305 id : `${ payment . id } ` ,
286306 memo : payment . description ?? "" ,
287307 settled : payment . status === "complete" ,
288308 preimage : payment . payment_preimage ,
309+ creationDate : creationDate ,
289310 payment_hash : payment . payment_hash ,
290311 settleDate : payment . created_at * 1000 ,
291312 type : "sent" ,
292313 totalAmount : payment . amount_sent_msat / 1000 ,
293- } )
294- )
314+ } ;
315+ } )
295316 . filter ( ( payment ) => payment . settled ) ;
296317 } ) ;
297318 }
0 commit comments