Skip to content
Open
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
7 changes: 7 additions & 0 deletions cmd/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2288,6 +2288,12 @@ var listChainTxnsCommand = cli.Command{
"all transactions",
Value: 0,
},
cli.StringFlag{
Name: "label",
Usage: "an optional label to filter " +
"transactions by; only transactions with " +
"a matching label will be returned",
},
},
Description: `
List all transactions an address of the wallet was involved in.
Expand Down Expand Up @@ -2338,6 +2344,7 @@ func listChainTxns(ctx *cli.Context) error {
MaxTransactions: uint32(ctx.Uint64("max_transactions")),
StartHeight: startHeight,
EndHeight: endHeight,
Label: ctx.String("label"),
}

resp, err := client.GetTransactions(ctxc, req)
Expand Down
9 changes: 9 additions & 0 deletions docs/release-notes/release-notes-0.22.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,21 @@
channels](https://github.com/lightningnetwork/lnd/pull/10501) via the new
`outgoing_chan_ids` field in `RouteFeeRequest`.

* [`GetTransactions`](https://github.com/lightningnetwork/lnd/pull/10806)
Comment thread
saraogiraj94 marked this conversation as resolved.
now accepts an optional `label` field to filter returned transactions by
their label. Only transactions whose label exactly matches the provided
value are returned; omitting the field returns all transactions as before.

## lncli Additions

* The `estimateroutefee` command now supports [restricting fee estimates to
specific first-hop outgoing
channels](https://github.com/lightningnetwork/lnd/pull/10501) via the new
`--outgoing_chan_id` flag.

* `listchaintxns` now accepts an optional `--label` flag to filter returned
transactions by their label.

# Improvements

## Functional Updates
Expand Down Expand Up @@ -89,3 +97,4 @@

* Boris Nagaev
* Erick Cestari
* saraogiraj94
12 changes: 11 additions & 1 deletion lnrpc/lightning.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lnrpc/lightning.proto
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,9 @@ message GetTransactionsRequest {
This value should be set to 0 to return all transactions.
*/
uint32 max_transactions = 5;

// An optional filter to only include transactions with a matching label.
string label = 6;
}

message TransactionDetails {
Expand Down
7 changes: 7 additions & 0 deletions lnrpc/lightning.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2701,6 +2701,13 @@
"required": false,
"type": "integer",
"format": "int64"
},
{
"name": "label",
"description": "An optional filter to only include transactions with a matching label.",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
Expand Down
2 changes: 1 addition & 1 deletion lntest/mock/walletcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (w *WalletController) ListUnspentWitness(int32, int32,

// ListTransactionDetails currently returns dummy values.
func (w *WalletController) ListTransactionDetails(int32, int32,
string, uint32, uint32) ([]*lnwallet.TransactionDetail,
string, string, uint32, uint32) ([]*lnwallet.TransactionDetail,
uint64, uint64, error) {

return nil, 0, 0, nil
Expand Down
14 changes: 13 additions & 1 deletion lnwallet/btcwallet/btcwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ func unminedTransactionsToDetail(
//
// This is a part of the WalletController interface.
Comment thread
saraogiraj94 marked this conversation as resolved.
func (b *BtcWallet) ListTransactionDetails(startHeight, endHeight int32,
accountFilter string, indexOffset uint32,
accountFilter string, labelFilter string, indexOffset uint32,
maxTransactions uint32) ([]*lnwallet.TransactionDetail, uint64, uint64,
error) {

Expand Down Expand Up @@ -1523,6 +1523,18 @@ func (b *BtcWallet) ListTransactionDetails(startHeight, endHeight int32,
txDetails = append(txDetails, detail)
}

// If a label filter is specified, only include transactions whose label
// matches exactly.
if labelFilter != "" {
Comment thread
saraogiraj94 marked this conversation as resolved.
filtered := txDetails[:0]
for _, tx := range txDetails {
if tx.Label == labelFilter {
filtered = append(filtered, tx)
}
}
txDetails = filtered
}

// Return empty transaction list, if offset is more than all
// transactions.
if int(indexOffset) >= len(txDetails) {
Expand Down
6 changes: 4 additions & 2 deletions lnwallet/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,11 @@ type WalletController interface {
// the tip of the chain until the start height (inclusive) and
// unconfirmed transactions. The account parameter serves as a filter to
// retrieve the transactions relevant to a specific account. When
// empty, transactions of all wallet accounts are returned.
// empty, transactions of all wallet accounts are returned. The label
// parameter serves as an optional filter to retrieve only transactions
// with a matching label. When empty, all transactions are returned.
ListTransactionDetails(startHeight, endHeight int32,
accountFilter string, indexOffset uint32,
accountFilter string, labelFilter string, indexOffset uint32,
maxTransactions uint32) ([]*TransactionDetail, uint64, uint64,
error)

Expand Down
3 changes: 2 additions & 1 deletion lnwallet/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ func (w *mockWalletController) ListUnspentWitness(int32, int32,

// ListTransactionDetails currently returns dummy values.
func (w *mockWalletController) ListTransactionDetails(int32, int32,
string, uint32, uint32) ([]*TransactionDetail, uint64, uint64, error) {
string, string, uint32, uint32) ([]*TransactionDetail, uint64, uint64,
error) {

return nil, 0, 0, nil
}
Expand Down
Loading
Loading