Skip to content

Commit 8b91b0b

Browse files
committed
asset: add AssertNotEmpty method to specifier
We add a helper to the asset specifier which checks whether it is empty, returning an error if empty.
1 parent d3b34d2 commit 8b91b0b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

asset/asset.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,16 @@ func (s *Specifier) UnwrapToPtr() (*ID, *btcec.PublicKey) {
438438
return s.UnwrapIdToPtr(), s.UnwrapGroupKeyToPtr()
439439
}
440440

441+
// AssertNotEmpty checks whether the specifier is empty, returning an error if
442+
// so.
443+
func (s *Specifier) AssertNotEmpty() error {
444+
if !s.HasId() && !s.HasGroupPubKey() {
445+
return fmt.Errorf("asset specifier is empty")
446+
}
447+
448+
return nil
449+
}
450+
441451
// Type denotes the asset types supported by the Taproot Asset protocol.
442452
type Type uint8
443453

0 commit comments

Comments
 (0)