Skip to content

Commit e9364e0

Browse files
committed
cmd: add listburns command
1 parent a21e4eb commit e9364e0

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

cmd/tapcli/assets.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var assetsCommands = []cli.Command{
2929
listAssetBalancesCommand,
3030
sendAssetsCommand,
3131
burnAssetsCommand,
32+
listBurnsCommand,
3233
listTransfersCommand,
3334
fetchMetaCommand,
3435
},
@@ -52,6 +53,7 @@ var (
5253
assetShowUnconfMintsName = "show_unconfirmed_mints"
5354
assetGroupKeyName = "group_key"
5455
assetGroupAnchorName = "group_anchor"
56+
anchorTxidName = "anchor_txid"
5557
batchKeyName = "batch_key"
5658
groupByGroupName = "by_group"
5759
assetIDName = "asset_id"
@@ -858,6 +860,71 @@ func burnAssets(ctx *cli.Context) error {
858860
return nil
859861
}
860862

863+
var listBurnsCommand = cli.Command{
864+
Name: "listburns",
865+
Usage: "list burnt assets",
866+
Description: `
867+
List assets that have been burned by this daemon. These are assets that
868+
have been destroyed and are no longer spendable.
869+
870+
Some filters may be used to return more specific results.
871+
`,
872+
Flags: []cli.Flag{
873+
cli.StringFlag{
874+
Name: assetIDName,
875+
Usage: "the asset ID of the burnt asset",
876+
},
877+
cli.StringFlag{
878+
Name: assetGroupKeyName,
879+
Usage: "the group key of the burnt asset",
880+
},
881+
cli.StringFlag{
882+
Name: anchorTxidName,
883+
Usage: "the txid of the transaction the burn was " +
884+
"anchored to",
885+
},
886+
},
887+
Action: listBurns,
888+
}
889+
890+
func listBurns(ctx *cli.Context) error {
891+
assetIDHex := ctx.String(assetIDName)
892+
assetIDBytes, err := hex.DecodeString(assetIDHex)
893+
if err != nil {
894+
return fmt.Errorf("invalid asset ID: %w", err)
895+
}
896+
897+
groupKeyHex := ctx.String(assetGroupKeyName)
898+
groupKeyBytes, err := hex.DecodeString(groupKeyHex)
899+
if err != nil {
900+
return fmt.Errorf("invalid group key: %w", err)
901+
}
902+
903+
anchorTxidStr := ctx.String(anchorTxidName)
904+
anchorTxid, err := hex.DecodeString(anchorTxidStr)
905+
if err != nil {
906+
return fmt.Errorf("invalid anchor txid: %w", err)
907+
}
908+
909+
ctxc := getContext()
910+
client, cleanUp := getClient(ctx)
911+
defer cleanUp()
912+
913+
resp, err := client.ListBurns(
914+
ctxc, &taprpc.ListBurnsRequest{
915+
AssetId: assetIDBytes,
916+
TweakedGroupKey: groupKeyBytes,
917+
AnchorTxid: anchorTxid,
918+
},
919+
)
920+
if err != nil {
921+
return fmt.Errorf("could not list burns: %w", err)
922+
}
923+
924+
printRespJSON(resp)
925+
return nil
926+
}
927+
861928
var listTransfersCommand = cli.Command{
862929
Name: "transfers",
863930
ShortName: "t",

0 commit comments

Comments
 (0)