OSDN Git Service

feat(warder): add warder backbone (#181)
[bytom/vapor.git] / protocol / validation / tx.go
index 0768d88..0d25751 100644 (file)
@@ -6,7 +6,6 @@ import (
 
        "github.com/vapor/config"
        "github.com/vapor/consensus"
-       "github.com/vapor/consensus/segwit"
        "github.com/vapor/errors"
        "github.com/vapor/math/checked"
        "github.com/vapor/protocol/bc"
@@ -251,8 +250,9 @@ func checkValid(vs *validationState, e bc.Entry) (err error) {
                // check assetID
                assetID := e.AssetDefinition.ComputeAssetID()
                if *e.Value.AssetId != *consensus.BTMAssetID && *e.Value.AssetId != assetID {
-                       return errors.New("incorrect asset_id while check CrossChainInput")
+                       return errors.New("incorrect asset_id while checking CrossChainInput")
                }
+
                code := config.FederationProgrom(config.CommonConfig)
                prog := &bc.Program{
                        VmVersion: e.ControlProgram.VmVersion,
@@ -524,37 +524,12 @@ func checkValidDest(vs *validationState, vd *bc.ValueDestination) error {
        return nil
 }
 
-func checkStandardTx(tx *bc.Tx, blockHeight uint64) error {
+func checkInputID(tx *bc.Tx, blockHeight uint64) error {
        for _, id := range tx.InputIDs {
                if blockHeight >= ruleAA && id.IsZero() {
                        return ErrEmptyInputIDs
                }
        }
-
-       for _, id := range tx.GasInputIDs {
-               spend, err := tx.Spend(id)
-               if err != nil {
-                       continue
-               }
-
-               code := []byte{}
-               outputEntry, err := tx.Entry(*spend.SpentOutputId)
-               if err != nil {
-                       return err
-               }
-               switch output := outputEntry.(type) {
-               case *bc.IntraChainOutput:
-                       code = output.ControlProgram.Code
-               case *bc.VoteOutput:
-                       code = output.ControlProgram.Code
-               default:
-                       return errors.Wrapf(bc.ErrEntryType, "entry %x has unexpected type %T", id.Bytes(), outputEntry)
-               }
-
-               if !segwit.IsP2WScript(code) {
-                       return ErrNotStandardTx
-               }
-       }
        return nil
 }
 
@@ -582,7 +557,7 @@ func ValidateTx(tx *bc.Tx, block *bc.Block) (*GasState, error) {
        if err := checkTimeRange(tx, block); err != nil {
                return gasStatus, err
        }
-       if err := checkStandardTx(tx, block.Height); err != nil {
+       if err := checkInputID(tx, block.Height); err != nil {
                return gasStatus, err
        }