Skip to content

Commit 47e7875

Browse files
committed
taprpc: track burned assets
1 parent c56b559 commit 47e7875

File tree

9 files changed

+742
-133
lines changed

9 files changed

+742
-133
lines changed

perms/perms.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ var (
7676
Entity: "assets",
7777
Action: "write",
7878
}},
79+
"/taprpc.TaprootAssets/ListBurns": {{
80+
Entity: "assets",
81+
Action: "read",
82+
}},
7983
"/taprpc.TaprootAssets/FetchAssetMeta": {{
8084
Entity: "assets",
8185
Action: "read",

rpcserver.go

Lines changed: 36 additions & 1 deletion
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"
@@ -3290,7 +3291,7 @@ func (r *rpcServer) BurnAsset(ctx context.Context,
32903291
resp, err := r.cfg.ChainPorter.RequestShipment(
32913292
tapfreighter.NewPreSignedParcel(
32923293
[]*tappsbt.VPacket{fundResp.VPacket},
3293-
fundResp.InputCommitments, "",
3294+
fundResp.InputCommitments, in.Note,
32943295
),
32953296
)
32963297
if err != nil {
@@ -3328,6 +3329,40 @@ func (r *rpcServer) BurnAsset(ctx context.Context,
33283329
}, nil
33293330
}
33303331

3332+
// ListBurns returns a list of burnt assets. Some filters may be defined in the
3333+
// request to return more specific results.
3334+
func (r *rpcServer) ListBurns(ctx context.Context,
3335+
in *taprpc.ListBurnsRequest) (*taprpc.ListBurnsResponse, error) {
3336+
3337+
burns, err := r.cfg.AssetStore.QueryBurns(
3338+
ctx, tapdb.QueryBurnsFilters{
3339+
AssetID: in.AssetId,
3340+
GroupKey: in.TweakedGroupKey,
3341+
AnchorTxid: in.AnchorTxid,
3342+
},
3343+
)
3344+
if err != nil {
3345+
return nil, err
3346+
}
3347+
3348+
rpcBurns := fn.Map(burns, marshalRpcBurn)
3349+
3350+
return &taprpc.ListBurnsResponse{
3351+
Burns: rpcBurns,
3352+
}, nil
3353+
}
3354+
3355+
// marshalRpcBurn creates an instance of *taprpc.AssetBurn from the tapdb model.
3356+
func marshalRpcBurn(b *tapfreighter.AssetBurn) *taprpc.AssetBurn {
3357+
return &taprpc.AssetBurn{
3358+
Note: b.Note,
3359+
AssetId: b.AssetID,
3360+
TweakedGroupKey: b.GroupKey,
3361+
Amount: b.Amount,
3362+
AnchorTxid: b.AnchorTxid[:],
3363+
}
3364+
}
3365+
33313366
// marshalOutboundParcel turns a pending parcel into its RPC counterpart.
33323367
func marshalOutboundParcel(
33333368
parcel *tapfreighter.OutboundParcel) (*taprpc.AssetTransfer,

0 commit comments

Comments
 (0)