Skip to content

Commit ccf4b76

Browse files
committed
taprpc: Updated ListAssetRequest to include additional filter options
1 parent 77e8b28 commit ccf4b76

File tree

4 files changed

+1009
-881
lines changed

4 files changed

+1009
-881
lines changed

rpcserver.go

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"github.com/lightninglabs/taproot-assets/rfqmsg"
3838
"github.com/lightninglabs/taproot-assets/rpcperms"
3939
"github.com/lightninglabs/taproot-assets/tapchannel"
40+
"github.com/lightninglabs/taproot-assets/tapdb"
4041
"github.com/lightninglabs/taproot-assets/tapfreighter"
4142
"github.com/lightninglabs/taproot-assets/tapgarden"
4243
"github.com/lightninglabs/taproot-assets/tappsbt"
@@ -953,8 +954,13 @@ func (r *rpcServer) ListAssets(ctx context.Context,
953954
}
954955

955956
rpcAssets, err := r.fetchRpcAssets(
956-
ctx, req.WithWitness, req.IncludeSpent, req.IncludeLeased,
957+
ctx,
958+
req.WithWitness,
959+
req.IncludeSpent,
960+
req.IncludeLeased,
961+
req.MinAmount,
957962
)
963+
958964
if err != nil {
959965
return nil, err
960966
}
@@ -1007,10 +1013,20 @@ func (r *rpcServer) ListAssets(ctx context.Context,
10071013
}
10081014

10091015
func (r *rpcServer) fetchRpcAssets(ctx context.Context, withWitness,
1010-
includeSpent, includeLeased bool) ([]*taprpc.Asset, error) {
1016+
includeSpent, includeLeased bool,
1017+
minAmountFilter uint64) ([]*taprpc.Asset, error) {
1018+
1019+
constraints := tapfreighter.CommitmentConstraints{
1020+
CoinSelectType: tapsend.ScriptTreesAllowed,
1021+
MinAmt: minAmountFilter,
1022+
}
1023+
1024+
filters := &tapdb.AssetQueryFilters{
1025+
CommitmentConstraints: constraints,
1026+
}
10111027

10121028
assets, err := r.cfg.AssetStore.FetchAllAssets(
1013-
ctx, includeSpent, includeLeased, nil,
1029+
ctx, includeSpent, includeLeased, filters,
10141030
)
10151031
if err != nil {
10161032
return nil, fmt.Errorf("unable to read chain assets: %w", err)
@@ -1161,7 +1177,10 @@ func (r *rpcServer) listBalancesByGroupKey(ctx context.Context,
11611177
func (r *rpcServer) ListUtxos(ctx context.Context,
11621178
req *taprpc.ListUtxosRequest) (*taprpc.ListUtxosResponse, error) {
11631179

1164-
rpcAssets, err := r.fetchRpcAssets(ctx, false, false, req.IncludeLeased)
1180+
rpcAssets, err := r.fetchRpcAssets(
1181+
ctx, false, false, req.IncludeLeased, 0,
1182+
)
1183+
11651184
if err != nil {
11661185
return nil, err
11671186
}

0 commit comments

Comments
 (0)