| 231 | } // namespace RPC_PARAM |
| 232 | |
| 233 | Object SubmitOrderTx(const CKeyID &txKeyid, const DexOperatorDetail &operatorDetail, |
| 234 | shared_ptr<CDEXOrderBaseTx> &pOrderBaseTx) { |
| 235 | |
| 236 | if (!pWalletMain->HasKey(txKeyid)) { |
| 237 | throw JSONRPCError(RPC_WALLET_ERROR, "tx user address not found in wallet"); |
| 238 | } |
| 239 | const uint256 txHash = pOrderBaseTx->GetHash(); |
| 240 | if (!pWalletMain->Sign(txKeyid, txHash, pOrderBaseTx->signature)) { |
| 241 | throw JSONRPCError(RPC_WALLET_ERROR, "Sign failed"); |
| 242 | } |
| 243 | |
| 244 | shared_ptr<CBaseTx> pBaseTx = static_pointer_cast<CBaseTx>(pOrderBaseTx); |
| 245 | if (pOrderBaseTx->has_operator_config) { |
| 246 | CAccount operatorAccount = RPC_PARAM::GetUserAccount(*pCdMan->pAccountCache, operatorDetail.fee_receiver_regid); |
| 247 | const CKeyID &operatorKeyid = operatorAccount.keyid; |
| 248 | if (!pWalletMain->HasKey(operatorKeyid)) { |
| 249 | CDataStream ds(SER_DISK, CLIENT_VERSION); |
| 250 | ds << pBaseTx; |
| 251 | throw JSONRPCError(RPC_WALLET_ERROR, strprintf("dex operator address not found in wallet! " |
| 252 | "tx_raw_with_sign=%s", HexStr(ds.begin(), ds.end()))); |
| 253 | } |
| 254 | if (!pWalletMain->Sign(operatorKeyid, txHash, pOrderBaseTx->operator_signature)) { |
| 255 | throw JSONRPCError(RPC_WALLET_ERROR, "Sign failed"); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | CValidationState state; |
| 260 | if (!pWalletMain->CommitTx(pBaseTx.get(), state)) |
| 261 | throw JSONRPCError(RPC_WALLET_ERROR, |
| 262 | strprintf("CommitTx failed: code=%d, reason=%s", state.GetRejectCode(), |
| 263 | state.GetRejectReason())); |
| 264 | |
| 265 | Object obj; |
| 266 | obj.push_back( Pair("txid", pBaseTx->GetHash().GetHex()) ); |
| 267 | |
| 268 | return obj; |
| 269 | } |
| 270 | |
| 271 | static void CheckDexId0BeforeV3(uint64_t dexId, int32_t height) { |
| 272 | if (dexId != 0) |
no test coverage detected