Skip to content

Commit 6236ce5

Browse files
committed
rpcserver: improve error handling when querying for asset group given ID
This commit adds code which handles `err != nil` which was previously absent.
1 parent 3b71255 commit 6236ce5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

rpcserver.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2092,8 +2092,18 @@ func (r *rpcServer) BurnAsset(ctx context.Context,
20922092

20932093
var groupKey *btcec.PublicKey
20942094
assetGroup, err := r.cfg.TapAddrBook.QueryAssetGroup(ctx, assetID)
2095-
if err == nil && assetGroup.GroupKey != nil {
2095+
switch {
2096+
case err == nil && assetGroup.GroupKey != nil:
2097+
// We found the asset group, so we can use the group key to
2098+
// burn the asset.
20962099
groupKey = &assetGroup.GroupPubKey
2100+
case errors.Is(err, address.ErrAssetGroupUnknown):
2101+
// We don't know the asset group, so we'll try to burn the
2102+
// asset using the asset ID only.
2103+
rpcsLog.Debug("Asset group key not found, asset may not be " +
2104+
"part of a group")
2105+
case err != nil:
2106+
return nil, fmt.Errorf("error querying asset group: %w", err)
20972107
}
20982108

20992109
fundResp, err := r.cfg.AssetWallet.FundBurn(

0 commit comments

Comments
 (0)