Skip to content

Commit

Permalink
taprpc: Updated ListAssetRequest to include additional filter options
Browse files Browse the repository at this point in the history
  • Loading branch information
itsrachelfish committed Nov 20, 2024
1 parent 77e8b28 commit f189364
Show file tree
Hide file tree
Showing 4 changed files with 1,008 additions and 881 deletions.
26 changes: 22 additions & 4 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/lightninglabs/taproot-assets/rfqmsg"
"github.com/lightninglabs/taproot-assets/rpcperms"
"github.com/lightninglabs/taproot-assets/tapchannel"
"github.com/lightninglabs/taproot-assets/tapdb"
"github.com/lightninglabs/taproot-assets/tapfreighter"
"github.com/lightninglabs/taproot-assets/tapgarden"
"github.com/lightninglabs/taproot-assets/tappsbt"
Expand Down Expand Up @@ -953,8 +954,13 @@ func (r *rpcServer) ListAssets(ctx context.Context,
}

rpcAssets, err := r.fetchRpcAssets(
ctx, req.WithWitness, req.IncludeSpent, req.IncludeLeased,
ctx,
req.WithWitness,
req.IncludeSpent,
req.IncludeLeased,
req.MinAmount,
)

if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1007,10 +1013,19 @@ func (r *rpcServer) ListAssets(ctx context.Context,
}

func (r *rpcServer) fetchRpcAssets(ctx context.Context, withWitness,
includeSpent, includeLeased bool) ([]*taprpc.Asset, error) {
includeSpent, includeLeased bool,
minAmountFilter uint64) ([]*taprpc.Asset, error) {

constraints := tapfreighter.CommitmentConstraints{
MinAmt: minAmountFilter,
}

filters := &tapdb.AssetQueryFilters{
CommitmentConstraints: constraints,
}

assets, err := r.cfg.AssetStore.FetchAllAssets(
ctx, includeSpent, includeLeased, nil,
ctx, includeSpent, includeLeased, filters,
)
if err != nil {
return nil, fmt.Errorf("unable to read chain assets: %w", err)
Expand Down Expand Up @@ -1161,7 +1176,10 @@ func (r *rpcServer) listBalancesByGroupKey(ctx context.Context,
func (r *rpcServer) ListUtxos(ctx context.Context,
req *taprpc.ListUtxosRequest) (*taprpc.ListUtxosResponse, error) {

rpcAssets, err := r.fetchRpcAssets(ctx, false, false, req.IncludeLeased)
rpcAssets, err := r.fetchRpcAssets(
ctx, false, false, req.IncludeLeased, 0,
)

if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit f189364

Please sign in to comment.