Add missing primitive aliases and outpoint helper
This commit is contained in:
parent
545b2a711a
commit
1935f5d878
2 changed files with 89 additions and 0 deletions
52
lns.go
52
lns.go
|
|
@ -402,6 +402,17 @@ func (s *Service) GetNewClaim() *Claim {
|
|||
return s.NewClaim()
|
||||
}
|
||||
|
||||
// NewOutpoint returns the null outpoint used by coinbase inputs and empty
|
||||
// name-state owner references.
|
||||
func (s *Service) NewOutpoint() Outpoint {
|
||||
return primitives.NewOutpoint()
|
||||
}
|
||||
|
||||
// GetNewOutpoint is an alias for NewOutpoint.
|
||||
func (s *Service) GetNewOutpoint() Outpoint {
|
||||
return s.NewOutpoint()
|
||||
}
|
||||
|
||||
// NewNameView constructs an empty cached name-state view.
|
||||
func (s *Service) NewNameView() *NameView {
|
||||
return primitives.NewNameView()
|
||||
|
|
@ -1159,6 +1170,33 @@ type NameFlags = covenant.NameFlags
|
|||
// NameRules mirrors the covenant rollout and lockup rule inputs.
|
||||
type NameRules = covenant.NameRules
|
||||
|
||||
// Address mirrors the primitive output-address container.
|
||||
type Address = primitives.Address
|
||||
|
||||
// Outpoint mirrors the primitive previous-output reference type.
|
||||
type Outpoint = primitives.Outpoint
|
||||
|
||||
// OutpointJSON mirrors the primitive JSON representation for outpoints.
|
||||
type OutpointJSON = primitives.OutpointJSON
|
||||
|
||||
// Input mirrors the primitive transaction input type.
|
||||
type Input = primitives.Input
|
||||
|
||||
// Output mirrors the primitive transaction output type.
|
||||
type Output = primitives.Output
|
||||
|
||||
// Transaction mirrors the primitive transaction container.
|
||||
type Transaction = primitives.Transaction
|
||||
|
||||
// BlockHeader mirrors the primitive block-header container.
|
||||
type BlockHeader = primitives.BlockHeader
|
||||
|
||||
// Covenant mirrors the primitive covenant payload type.
|
||||
type Covenant = primitives.Covenant
|
||||
|
||||
// CovenantJSON mirrors the primitive covenant JSON representation.
|
||||
type CovenantJSON = primitives.CovenantJSON
|
||||
|
||||
// NameState mirrors the name-state record type from pkg/primitives.
|
||||
type NameState = primitives.NameState
|
||||
|
||||
|
|
@ -1181,6 +1219,9 @@ type NameUndoEntry = primitives.NameUndoEntry
|
|||
// Claim mirrors the raw ownership-proof claim wrapper from pkg/primitives.
|
||||
type Claim = primitives.Claim
|
||||
|
||||
// NameStateJSON mirrors the primitive JSON representation for a name state.
|
||||
type NameStateJSON = primitives.NameStateJSON
|
||||
|
||||
// NameStateRules mirrors the phase-timing rule set from pkg/primitives.
|
||||
type NameStateRules = primitives.NameStateRules
|
||||
|
||||
|
|
@ -1223,6 +1264,17 @@ func GetNewClaim() *Claim {
|
|||
return NewClaim()
|
||||
}
|
||||
|
||||
// NewOutpoint returns the null outpoint used by coinbase inputs and empty
|
||||
// name-state owner references.
|
||||
func NewOutpoint() Outpoint {
|
||||
return primitives.NewOutpoint()
|
||||
}
|
||||
|
||||
// GetNewOutpoint is an alias for NewOutpoint.
|
||||
func GetNewOutpoint() Outpoint {
|
||||
return NewOutpoint()
|
||||
}
|
||||
|
||||
// NewNameView constructs an empty cached name-state view.
|
||||
func NewNameView() *NameView {
|
||||
return primitives.NewNameView()
|
||||
|
|
|
|||
|
|
@ -1409,6 +1409,43 @@ func TestPackageTypeConstants(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPackagePrimitiveAliases(t *testing.T) {
|
||||
hash := primitives.Hash{1, 2, 3}
|
||||
address := Address{Version: 1, Hash: hash[:]}
|
||||
prevout := NewOutpoint()
|
||||
prevout.Index = 7
|
||||
|
||||
var (
|
||||
_ = primitives.Address(address)
|
||||
_ = primitives.Outpoint(prevout)
|
||||
_ = OutpointJSON{Hash: prevout.GetJSON().Hash, Index: prevout.Index}
|
||||
_ = Input{Prevout: prevout}
|
||||
_ = Output{Address: address}
|
||||
_ = Transaction{Inputs: []Input{{Prevout: prevout}}}
|
||||
_ = BlockHeader{}
|
||||
_ = Covenant{}
|
||||
_ = CovenantJSON{}
|
||||
_ = NameStateJSON{}
|
||||
)
|
||||
|
||||
if got, want := NewOutpoint(), primitives.NewOutpoint(); got != want {
|
||||
t.Fatalf("NewOutpoint() = %+v, want %+v", got, want)
|
||||
}
|
||||
|
||||
if got, want := GetNewOutpoint(), primitives.NewOutpoint(); got != want {
|
||||
t.Fatalf("GetNewOutpoint() = %+v, want %+v", got, want)
|
||||
}
|
||||
|
||||
service := NewService(nil)
|
||||
if got, want := service.NewOutpoint(), primitives.NewOutpoint(); got != want {
|
||||
t.Fatalf("Service.NewOutpoint() = %+v, want %+v", got, want)
|
||||
}
|
||||
|
||||
if got, want := service.GetNewOutpoint(), primitives.NewOutpoint(); got != want {
|
||||
t.Fatalf("Service.GetNewOutpoint() = %+v, want %+v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPackageCovenantTypePredicates(t *testing.T) {
|
||||
if !IsName(TypeOpen) || !GetIsName(TypeOpen) {
|
||||
t.Fatal("IsName should report open covenants")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue