OSDN Git Service

change interval
[bytom/vapor.git] / protocol / validation / vmcontext.go
index f7b62bc..7ac617c 100644 (file)
@@ -25,6 +25,14 @@ func NewTxVMContext(vs *validationState, entry bc.Entry, prog *bc.Program, args
        )
 
        switch e := entry.(type) {
+       case *bc.CrossChainInput:
+               mainchainOutput := tx.Entries[*e.MainchainOutputId].(*bc.IntraChainOutput)
+               a1 := mainchainOutput.Source.Value.AssetId.Bytes()
+               assetID = &a1
+               amount = &mainchainOutput.Source.Value.Amount
+               destPos = &e.WitnessDestination.Position
+               s := e.MainchainOutputId.Bytes()
+               spentOutputID = &s
 
        case *bc.Spend:
                spentOutput := tx.Entries[*e.SpentOutputId].(*bc.IntraChainOutput)
@@ -34,6 +42,15 @@ func NewTxVMContext(vs *validationState, entry bc.Entry, prog *bc.Program, args
                destPos = &e.WitnessDestination.Position
                s := e.SpentOutputId.Bytes()
                spentOutputID = &s
+
+       case *bc.VetoInput:
+               voteOutput := tx.Entries[*e.SpentOutputId].(*bc.VoteOutput)
+               a1 := voteOutput.Source.Value.AssetId.Bytes()
+               assetID = &a1
+               amount = &voteOutput.Source.Value.Amount
+               destPos = &e.WitnessDestination.Position
+               s := e.SpentOutputId.Bytes()
+               spentOutputID = &s
        }
 
        var txSigHash *[]byte
@@ -111,6 +128,9 @@ func (ec *entryContext) checkOutput(index uint64, amount uint64, assetID []byte,
                case *bc.IntraChainOutput:
                        return check(e.ControlProgram, e.Source.Value), nil
 
+               case *bc.VoteOutput:
+                       return check(e.ControlProgram, e.Source.Value), nil
+
                case *bc.Retirement:
                        var prog bc.Program
                        if expansion {
@@ -155,6 +175,19 @@ func (ec *entryContext) checkOutput(index uint64, amount uint64, assetID []byte,
                        return false, errors.Wrapf(vm.ErrBadValue, "index %d >= 1", index)
                }
                return checkEntry(d)
+
+       case *bc.VetoInput:
+               d, ok := ec.entries[*e.WitnessDestination.Ref]
+               if !ok {
+                       return false, errors.Wrapf(bc.ErrMissingEntry, "entry for vetoInput destination %x not found", e.WitnessDestination.Ref.Bytes())
+               }
+               if m, ok := d.(*bc.Mux); ok {
+                       return checkMux(m)
+               }
+               if index != 0 {
+                       return false, errors.Wrapf(vm.ErrBadValue, "index %d >= 1", index)
+               }
+               return checkEntry(d)
        }
 
        return false, vm.ErrContext