X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=blobdiff_plain;f=protocol%2Fvalidation%2Fvmcontext.go;h=7ac617c92282f04f3d268c2a8a42796164dc56af;hp=10b77d8f29957e021dfc59f60f8b4b4435a7d643;hb=2e4f5f11ae3bec54e4918a7aac5c8b3e2381de44;hpb=15e9d82900038c86a740d0dbb344ab32ce3d2f2c diff --git a/protocol/validation/vmcontext.go b/protocol/validation/vmcontext.go index 10b77d8f..7ac617c9 100644 --- a/protocol/validation/vmcontext.go +++ b/protocol/validation/vmcontext.go @@ -26,29 +26,31 @@ func NewTxVMContext(vs *validationState, entry bc.Entry, prog *bc.Program, args switch e := entry.(type) { case *bc.CrossChainInput: - a1 := e.Value.AssetId.Bytes() + mainchainOutput := tx.Entries[*e.MainchainOutputId].(*bc.IntraChainOutput) + a1 := mainchainOutput.Source.Value.AssetId.Bytes() assetID = &a1 - amount = &e.Value.Amount + amount = &mainchainOutput.Source.Value.Amount destPos = &e.WitnessDestination.Position + s := e.MainchainOutputId.Bytes() + spentOutputID = &s case *bc.Spend: - switch spentOutput := tx.Entries[*e.SpentOutputId].(type) { - case *bc.IntraChainOutput: - a1 := spentOutput.Source.Value.AssetId.Bytes() - assetID = &a1 - amount = &spentOutput.Source.Value.Amount - destPos = &e.WitnessDestination.Position - s := e.SpentOutputId.Bytes() - spentOutputID = &s + spentOutput := tx.Entries[*e.SpentOutputId].(*bc.IntraChainOutput) + a1 := spentOutput.Source.Value.AssetId.Bytes() + assetID = &a1 + amount = &spentOutput.Source.Value.Amount + destPos = &e.WitnessDestination.Position + s := e.SpentOutputId.Bytes() + spentOutputID = &s - case *bc.VoteOutput: - a1 := spentOutput.Source.Value.AssetId.Bytes() - assetID = &a1 - amount = &spentOutput.Source.Value.Amount - 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 @@ -173,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