@@ -45,7 +45,7 @@ type LightningClient interface {
45
45
46
46
// ListTransactions returns all known transactions of the backing lnd
47
47
// node.
48
- ListTransactions (ctx context.Context ) ([]* wire. MsgTx , error )
48
+ ListTransactions (ctx context.Context ) ([]Transaction , error )
49
49
50
50
// ListChannels retrieves all channels of the backing lnd node.
51
51
ListChannels (ctx context.Context ) ([]ChannelInfo , error )
@@ -257,6 +257,35 @@ func (c Initiator) String() string {
257
257
}
258
258
}
259
259
260
+ // Transaction represents an on chain transaction.
261
+ type Transaction struct {
262
+ // Tx is the on chain transaction.
263
+ Tx * wire.MsgTx
264
+
265
+ // TxHash is the transaction hash string.
266
+ TxHash string
267
+
268
+ // Timestamp is the timestamp our wallet has for the transaction.
269
+ Timestamp time.Time
270
+
271
+ // Amount is the balance change that this transaction had on addresses
272
+ // controlled by our wallet.
273
+ Amount btcutil.Amount
274
+
275
+ // Fee is the amount of fees our wallet committed to this transaction.
276
+ // Note that this field is not exhaustive, as it does not account for
277
+ // fees taken from inputs that that wallet doesn't know it owns (for
278
+ // example, the fees taken from our channel balance when we close a
279
+ // channel).
280
+ Fee btcutil.Amount
281
+
282
+ // Confirmations is the number of confirmations the transaction has.
283
+ Confirmations int32
284
+
285
+ // Label is an optional label set for on chain transactions.
286
+ Label string
287
+ }
288
+
260
289
var (
261
290
// ErrMalformedServerResponse is returned when the swap and/or prepay
262
291
// invoice is malformed.
@@ -675,7 +704,7 @@ func unmarshalInvoice(resp *lnrpc.Invoice) (*Invoice, error) {
675
704
}
676
705
677
706
// ListTransactions returns all known transactions of the backing lnd node.
678
- func (s * lightningClient ) ListTransactions (ctx context.Context ) ([]* wire. MsgTx , error ) {
707
+ func (s * lightningClient ) ListTransactions (ctx context.Context ) ([]Transaction , error ) {
679
708
rpcCtx , cancel := context .WithTimeout (ctx , rpcTimeout )
680
709
defer cancel ()
681
710
@@ -686,8 +715,8 @@ func (s *lightningClient) ListTransactions(ctx context.Context) ([]*wire.MsgTx,
686
715
return nil , err
687
716
}
688
717
689
- txs := make ([]* wire. MsgTx , 0 , len (resp .Transactions ))
690
- for _ , respTx := range resp .Transactions {
718
+ txs := make ([]Transaction , len (resp .Transactions ))
719
+ for i , respTx := range resp .Transactions {
691
720
rawTx , err := hex .DecodeString (respTx .RawTxHex )
692
721
if err != nil {
693
722
return nil , err
@@ -697,7 +726,16 @@ func (s *lightningClient) ListTransactions(ctx context.Context) ([]*wire.MsgTx,
697
726
if err := tx .Deserialize (bytes .NewReader (rawTx )); err != nil {
698
727
return nil , err
699
728
}
700
- txs = append (txs , & tx )
729
+
730
+ txs [i ] = Transaction {
731
+ Tx : & tx ,
732
+ TxHash : tx .TxHash ().String (),
733
+ Timestamp : time .Unix (respTx .TimeStamp , 0 ),
734
+ Amount : btcutil .Amount (respTx .Amount ),
735
+ Fee : btcutil .Amount (respTx .TotalFees ),
736
+ Confirmations : respTx .NumConfirmations ,
737
+ Label : respTx .Label ,
738
+ }
701
739
}
702
740
703
741
return txs , nil
0 commit comments