(cmd *Command, args []string)
| 87 | } |
| 88 | |
| 89 | func runRPC(cmd *Command, args []string) { |
| 90 | commonFlagsInit(cmd) |
| 91 | configInit() |
| 92 | |
| 93 | if callBP { |
| 94 | rpcEndpoint = string(conf.GConf.BP.NodeID) |
| 95 | } |
| 96 | |
| 97 | if rpcEndpoint == "" || rpcName == "" || rpcReq == "" { |
| 98 | // error |
| 99 | ConsoleLog.Error("rpc endpoint/name/request payload is required for rpc tool") |
| 100 | SetExitStatus(1) |
| 101 | printCommandHelp(cmd) |
| 102 | Exit() |
| 103 | } |
| 104 | |
| 105 | req, resp := resolveRPCEntities() |
| 106 | ExitIfErrors() |
| 107 | |
| 108 | if rpcName == route.MCCAddTx.String() { |
| 109 | // special type of query |
| 110 | if addTxReqType, ok := req.(*types.AddTxReq); ok { |
| 111 | addTxReqType.TTL = 1 |
| 112 | addTxReqType.Tx = &pi.TransactionWrapper{} |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | // fill the req with request body |
| 117 | if err := json.Unmarshal([]byte(rpcReq), req); err != nil { |
| 118 | ConsoleLog.WithError(err).Error("decode request body failed") |
| 119 | SetExitStatus(1) |
| 120 | return |
| 121 | } |
| 122 | |
| 123 | // fill nonce if this is a AddTx request |
| 124 | var tx pi.Transaction |
| 125 | if rpcName == route.MCCAddTx.String() { |
| 126 | if addTxReqType, ok := req.(*types.AddTxReq); ok { |
| 127 | tx = addTxReqType.Tx |
| 128 | for { |
| 129 | if txWrapper, ok := tx.(*pi.TransactionWrapper); ok { |
| 130 | tx = txWrapper.Unwrap() |
| 131 | } else { |
| 132 | break |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | // unwrapped tx, find account nonce field and set |
| 137 | if err := fillTxNonce(tx); err != nil { |
| 138 | ConsoleLog.WithError(err).Error("fill block producer transaction nonce failed") |
| 139 | SetExitStatus(1) |
| 140 | return |
| 141 | } |
| 142 | |
| 143 | if err := checkAndSign(tx); err != nil { |
| 144 | ConsoleLog.WithError(err).Error("sign transaction failed") |
| 145 | SetExitStatus(1) |
| 146 | return |
nothing calls this directly
no test coverage detected