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 6abd778
Show file tree
Hide file tree
Showing 5 changed files with 1,011 additions and 883 deletions.
27 changes: 23 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,20 @@ 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{
CoinSelectType: tapsend.ScriptTreesAllowed,
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 +1177,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
4 changes: 2 additions & 2 deletions sample-tapd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@
; universe.multiverse-caches.syncer-cache-pre-alloc-size=100000

; The size of the root node page cache for all requests that aren't served by
; the syncer cache. (default: 10240)
; universe.multiverse-caches.root-node-page-cache-size=10240
; the syncer cache. (default: 327680)
universe.multiverse-caches.root-node-page-cache-size=327680


[address]
Expand Down
Loading

0 comments on commit 6abd778

Please sign in to comment.