OSDN Git Service

Mov (#518)
[bytom/vapor.git] / application / mov / common / util.go
1 package common
2
3 import (
4         "github.com/bytom/vapor/application/mov/contract"
5         "github.com/bytom/vapor/consensus/segwit"
6         "github.com/bytom/vapor/protocol/bc/types"
7 )
8
9 // IsMatchedTx check if this transaction has trade mov order input
10 func IsMatchedTx(tx *types.Tx) bool {
11         if len(tx.Inputs) < 2 {
12                 return false
13         }
14         for _, input := range tx.Inputs {
15                 if input.InputType() == types.SpendInputType && segwit.IsP2WMCScript(input.ControlProgram()) && contract.IsTradeClauseSelector(input) {
16                         return true
17                 }
18         }
19         return false
20 }
21
22 // IsCancelOrderTx check if this transaction has cancel mov order input
23 func IsCancelOrderTx(tx *types.Tx) bool {
24         for _, input := range tx.Inputs {
25                 if input.InputType() == types.SpendInputType && segwit.IsP2WMCScript(input.ControlProgram()) && contract.IsCancelClauseSelector(input) {
26                         return true
27                 }
28         }
29         return false
30 }