diff --git a/pkg/covenant/blind.go b/pkg/covenant/blind.go index 6c542e4..f2904c0 100644 --- a/pkg/covenant/blind.go +++ b/pkg/covenant/blind.go @@ -39,3 +39,10 @@ func Blind(value uint64, nonce primitives.Hash) (primitives.Hash, error) { copy(blind[:], sum.Sum(nil)) return blind, nil } + +// GetBlind is an alias for Blind. +// +// bid, err := covenant.GetBlind(1000, nonce) +func GetBlind(value uint64, nonce primitives.Hash) (primitives.Hash, error) { + return Blind(value, nonce) +} diff --git a/pkg/covenant/blind_test.go b/pkg/covenant/blind_test.go index 85872e4..a6a4d62 100644 --- a/pkg/covenant/blind_test.go +++ b/pkg/covenant/blind_test.go @@ -31,3 +31,24 @@ func TestBlind(t *testing.T) { t.Fatalf("Blind returned %x, want %x", got, want) } } + +func TestGetBlind(t *testing.T) { + var nonce primitives.Hash + for i := range nonce { + nonce[i] = byte(i) + } + + got, err := GetBlind(0x1122334455667788, nonce) + if err != nil { + t.Fatalf("GetBlind returned error: %v", err) + } + + want, err := Blind(0x1122334455667788, nonce) + if err != nil { + t.Fatalf("Blind returned error: %v", err) + } + + if got != want { + t.Fatalf("GetBlind returned %x, want %x", got, want) + } +} diff --git a/pkg/covenant/covenant.go b/pkg/covenant/covenant.go index a8fce51..5bd8174 100644 --- a/pkg/covenant/covenant.go +++ b/pkg/covenant/covenant.go @@ -87,6 +87,13 @@ func TypeName(ct CovenantType) string { return "UNKNOWN" } +// GetTypeName is an alias for TypeName. +// +// name := covenant.GetTypeName(covenant.TypeBid) +func GetTypeName(ct CovenantType) string { + return TypeName(ct) +} + // IsName returns true if the covenant type is a name-related operation // (anything from CLAIM through REVOKE, inclusive). // diff --git a/pkg/covenant/name_test.go b/pkg/covenant/name_test.go index d003cd3..74e59e6 100644 --- a/pkg/covenant/name_test.go +++ b/pkg/covenant/name_test.go @@ -43,6 +43,16 @@ func TestNameFlags(t *testing.T) { } } +func TestGetTypeName(t *testing.T) { + if got := GetTypeName(TypeBid); got != "BID" { + t.Fatalf("GetTypeName(TypeBid) = %q, want %q", got, "BID") + } + + if got := GetTypeName(CovenantType(99)); got != "UNKNOWN" { + t.Fatalf("GetTypeName(99) = %q, want %q", got, "UNKNOWN") + } +} + func TestVerifyString(t *testing.T) { cases := []struct { name string diff --git a/pkg/dns/resolve.go b/pkg/dns/resolve.go index 61bbaa0..f8fe30b 100644 --- a/pkg/dns/resolve.go +++ b/pkg/dns/resolve.go @@ -17,6 +17,9 @@ import ( "dappco.re/go/lns/pkg/primitives" ) +// ServiceName is the registered name for the DNS service group. +const ServiceName = "dns" + // Service handles DNS resolution for .lthn names against the LNS chain state. // // svc := dns.NewService() @@ -68,6 +71,13 @@ func (s *Service) GetCore() *core.Core { return s.Core() } +// GetServiceName returns the registered name for the DNS service group. +// +// name := svc.GetServiceName() +func (s *Service) GetServiceName() string { + return ServiceName +} + // Resolve normalises a .lthn name and returns its canonical hash. // // The resolver accepts either a bare name ("example") or a fully qualified diff --git a/pkg/dns/resolve_test.go b/pkg/dns/resolve_test.go index b9bd99a..307710f 100644 --- a/pkg/dns/resolve_test.go +++ b/pkg/dns/resolve_test.go @@ -322,3 +322,11 @@ func TestCoreAccessors(t *testing.T) { t.Fatal("GetCore should alias Core") } } + +func TestServiceName(t *testing.T) { + svc := NewService() + + if got := svc.GetServiceName(); got != ServiceName { + t.Fatalf("GetServiceName() = %q, want %q", got, ServiceName) + } +}