Files
zeekay ede37547f6 refactor(platformvm): consolidate block code, drop atomic_block, add v0 lift
- Drop atomic_block.go + legacy *_block_test.go (consolidated)
- Add block/v0/ subdir + lift_v0.go for old version handling
- Copyright header: 'Lux Industries, Inc.' → 'Lux Industries Inc' (no comma)
- block_adapter.go: new adapter layer
2026-06-01 15:22:27 -07:00

67 lines
1.6 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package stakeable
import (
"errors"
lux "github.com/luxfi/utxo"
"github.com/luxfi/runtime"
)
var (
errInvalidLocktime = errors.New("invalid locktime")
errNestedStakeableLocks = errors.New("shouldn't nest stakeable locks")
)
type LockOut struct {
Locktime uint64 `serialize:"true" json:"locktime"`
lux.TransferableOut `serialize:"true" json:"output"`
}
func (s *LockOut) InitRuntime(rt *runtime.Runtime) {
// Initialize the context for the underlying output if it supports it
if contextOutput, ok := s.TransferableOut.(interface{ InitRuntime(*runtime.Runtime) }); ok {
contextOutput.InitRuntime(rt)
}
}
func (s *LockOut) Addresses() [][]byte {
if addressable, ok := s.TransferableOut.(lux.Addressable); ok {
return addressable.Addresses()
}
return nil
}
func (s *LockOut) Verify() error {
if s.Locktime == 0 {
return errInvalidLocktime
}
if _, nested := s.TransferableOut.(*LockOut); nested {
return errNestedStakeableLocks
}
return s.TransferableOut.Verify()
}
type LockIn struct {
Locktime uint64 `serialize:"true" json:"locktime"`
lux.TransferableIn `serialize:"true" json:"input"`
}
func (s *LockIn) Verify() error {
if s.Locktime == 0 {
return errInvalidLocktime
}
if _, nested := s.TransferableIn.(*LockIn); nested {
return errNestedStakeableLocks
}
return s.TransferableIn.Verify()
}
func (s *LockIn) InitRuntime(rt *runtime.Runtime) {
if contextInput, ok := s.TransferableIn.(interface{ InitRuntime(*runtime.Runtime) }); ok {
contextInput.InitRuntime(rt)
}
}