2020-03-10 12:20:34 -07:00
|
|
|
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
|
|
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
|
2020-03-23 13:40:37 -07:00
|
|
|
package ava
|
2020-03-10 12:20:34 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/ava-labs/gecko/vms/components/verify"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
errNilUTXO = errors.New("nil utxo is not valid")
|
|
|
|
errEmptyUTXO = errors.New("empty utxo is not valid")
|
|
|
|
)
|
|
|
|
|
|
|
|
// UTXO ...
|
|
|
|
type UTXO struct {
|
|
|
|
UTXOID `serialize:"true"`
|
|
|
|
Asset `serialize:"true"`
|
|
|
|
|
2020-03-27 13:54:47 -07:00
|
|
|
Out verify.Verifiable `serialize:"true" json:"output"`
|
2020-03-10 12:20:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Verify implements the verify.Verifiable interface
|
|
|
|
func (utxo *UTXO) Verify() error {
|
|
|
|
switch {
|
|
|
|
case utxo == nil:
|
|
|
|
return errNilUTXO
|
|
|
|
case utxo.Out == nil:
|
|
|
|
return errEmptyUTXO
|
|
|
|
default:
|
|
|
|
return verify.All(&utxo.UTXOID, &utxo.Asset, utxo.Out)
|
|
|
|
}
|
|
|
|
}
|