diff --git a/pkg/primitives/namestate.go b/pkg/primitives/namestate.go index 410a973..2604cbc 100644 --- a/pkg/primitives/namestate.go +++ b/pkg/primitives/namestate.go @@ -15,9 +15,7 @@ func (ns NameState) Clone() NameState { // IsNull reports whether the name state carries any non-default data. func (ns NameState) IsNull() bool { - return len(ns.Name) == 0 && - ns.NameHash == (Hash{}) && - ns.Height == 0 && + return ns.Height == 0 && ns.Renewal == 0 && (ns.Owner == (Outpoint{}) || ns.Owner.IsNull()) && ns.Value == 0 && diff --git a/pkg/primitives/namestate_test.go b/pkg/primitives/namestate_test.go index 3a077d0..4d1f041 100644 --- a/pkg/primitives/namestate_test.go +++ b/pkg/primitives/namestate_test.go @@ -11,9 +11,17 @@ func TestNameStateIsNull(t *testing.T) { t.Fatal("zero name state should be null") } - ns := NameState{Name: []byte("foo")} + ns := NameState{ + Name: []byte("foo"), + NameHash: Hash{1, 2, 3}, + } + if got := ns.IsNull(); !got { + t.Fatal("name metadata alone should not make the state non-null") + } + + ns.Height = 1 if got := ns.IsNull(); got { - t.Fatal("name state with data should not be null") + t.Fatal("name state with chain data should not be null") } }