OSDN Git Service

Merge pull request #41 from Bytom/dev
[bytom/vapor.git] / api / transact.go
index 1c0f274..2b11215 100644 (file)
@@ -34,6 +34,8 @@ func (a *API) actionDecoder(action string) (func([]byte) (txbuilder.Action, erro
                "retire":                       txbuilder.DecodeRetireAction,
                "spend_account":                a.wallet.AccountMgr.DecodeSpendAction,
                "spend_account_unspent_output": a.wallet.AccountMgr.DecodeSpendUTXOAction,
+               "dpos":                         a.wallet.AccountMgr.DecodeDposAction,
+               "ipfs_data":                    txbuilder.DecodeIpfsDataAction,
        }
        decoder, ok := decoders[action]
        return decoder, ok
@@ -41,17 +43,24 @@ func (a *API) actionDecoder(action string) (func([]byte) (txbuilder.Action, erro
 
 func onlyHaveInputActions(req *BuildRequest) (bool, error) {
        count := 0
+       dpos := false
        for i, act := range req.Actions {
                actionType, ok := act["type"].(string)
                if !ok {
                        return false, errors.WithDetailf(ErrBadActionType, "no action type provided on action %d", i)
                }
-
+               if strings.HasPrefix(actionType, "dpos") {
+                       dpos = true
+               }
                if strings.HasPrefix(actionType, "spend") || actionType == "issue" {
                        count++
                }
        }
 
+       if dpos == true && count == 0 {
+               return false, nil
+       }
+
        return count == len(req.Actions), nil
 }