}
type Coinbase struct {
- Program *Program `protobuf:"bytes,1,opt,name=program" json:"program,omitempty"`
- ExtHash *Hash `protobuf:"bytes,2,opt,name=ext_hash,json=extHash" json:"ext_hash,omitempty"`
- WitnessArguments [][]byte `protobuf:"bytes,3,rep,name=witness_arguments,json=witnessArguments,proto3" json:"witness_arguments,omitempty"`
+ WitnessDestination *ValueDestination `protobuf:"bytes,1,opt,name=witness_destination,json=witnessDestination" json:"witness_destination,omitempty"`
}
func (m *Coinbase) Reset() { *m = Coinbase{} }
func (*Coinbase) ProtoMessage() {}
func (*Coinbase) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} }
-func (m *Coinbase) GetProgram() *Program {
+func (m *Coinbase) GetWitnessDestination() *ValueDestination {
if m != nil {
- return m.Program
- }
- return nil
-}
-
-func (m *Coinbase) GetExtHash() *Hash {
- if m != nil {
- return m.ExtHash
- }
- return nil
-}
-
-func (m *Coinbase) GetWitnessArguments() [][]byte {
- if m != nil {
- return m.WitnessArguments
+ return m.WitnessDestination
}
return nil
}
}
message Coinbase {
- Program program = 1;
- Hash ext_hash = 2;
- repeated bytes witness_arguments = 3;
+ ValueDestination witness_destination = 1;
}
message Output {
import "io"
func (Coinbase) typ() string { return "coinbase1" }
-func (n *Coinbase) writeForHash(w io.Writer) {
- mustWriteForHash(w, n.Program)
+func (c *Coinbase) writeForHash(w io.Writer) {
+ mustWriteForHash(w, c.WitnessDestination)
}
// NewCoinbase creates a new Coinbase.
-func NewCoinbase(p *Program) *Coinbase {
+func NewCoinbase(id *Hash, val *AssetAmount, pos uint64) *Coinbase {
return &Coinbase{
- Program: p,
+ WitnessDestination: &ValueDestination{
+ Ref: id,
+ Value: val,
+ Position: pos,
+ },
}
}
return errWrongCoinbaseTransaction
}
+ vs2 := *vs
+ vs2.destPos = 0
+ err = checkValidDest(&vs2, e.WitnessDestination)
+ if err != nil {
+ return errors.Wrap(err, "checking coinbase destination")
+ }
+
case *bc.Mux:
parity := make(map[bc.AssetID]int64)
for i, src := range e.Sources {
var dest *bc.ValueDestination
switch ref := e.(type) {
+ case *bc.Coinbase:
+ if vs.Position != 0 {
+ return errors.Wrapf(errPosition, "invalid position %d for coinbase source", vs.Position)
+ }
+ dest = ref.WitnessDestination
case *bc.Issuance:
if vs.Position != 0 {
return errors.Wrapf(errPosition, "invalid position %d for issuance source", vs.Position)
dest = ref.WitnessDestinations[vs.Position]
default:
- return errors.Wrapf(bc.ErrEntryType, "value source is %T, should be issuance, spend, or mux", e)
+ return errors.Wrapf(bc.ErrEntryType, "value source is %T, should be coinbase, issuance, spend, or mux", e)
}
if dest.Ref == nil || *dest.Ref != vstate.entryID {