OSDN Git Service

Test crossin (#213)
[bytom/vapor.git] / blockchain / txbuilder / finalize.go
index b9e85bb..f701548 100644 (file)
@@ -39,8 +39,8 @@ func FinalizeTx(ctx context.Context, c *protocol.Chain, tx *types.Tx) error {
                return err
        }
 
-       if len(tx.GasInputIDs) == 0 {
-               return ErrNoGasInput
+       if err := checkGasInputIDs(tx); err != nil {
+               return err
        }
 
        // This part is use for prevent tx size  is 0
@@ -151,3 +151,17 @@ func CalculateTxFee(tx *types.Tx) (fee uint64) {
        fee = totalInputBTM - totalOutputBTM
        return
 }
+
+func checkGasInputIDs(tx *types.Tx) error {
+       for _, inp := range tx.Inputs {
+               switch inp.InputType() {
+               case types.CrossChainInputType:
+                       return nil
+               }
+       }
+
+       if len(tx.GasInputIDs) == 0 {
+               return ErrNoGasInput
+       }
+       return nil
+}