| 397 | } |
| 398 | |
| 399 | static RPCMethod decoderawtransaction() |
| 400 | { |
| 401 | return RPCMethod{"decoderawtransaction", |
| 402 | "Return a JSON object representing the serialized, hex-encoded transaction.", |
| 403 | { |
| 404 | {"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction hex string"}, |
| 405 | {"iswitness", RPCArg::Type::BOOL, RPCArg::DefaultHint{"depends on heuristic tests"}, "Whether the transaction hex is a serialized witness transaction.\n" |
| 406 | "If iswitness is not present, heuristic tests will be used in decoding.\n" |
| 407 | "If true, only witness deserialization will be tried.\n" |
| 408 | "If false, only non-witness deserialization will be tried.\n" |
| 409 | "This boolean should reflect whether the transaction has inputs\n" |
| 410 | "(e.g. fully valid, or on-chain transactions), if known by the caller." |
| 411 | }, |
| 412 | }, |
| 413 | RPCResult{ |
| 414 | RPCResult::Type::OBJ, "", "", |
| 415 | TxDoc(), |
| 416 | }, |
| 417 | RPCExamples{ |
| 418 | HelpExampleCli("decoderawtransaction", "\"hexstring\"") |
| 419 | + HelpExampleRpc("decoderawtransaction", "\"hexstring\"") |
| 420 | }, |
| 421 | [](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue |
| 422 | { |
| 423 | CMutableTransaction mtx; |
| 424 | |
| 425 | bool try_witness = request.params[1].isNull() ? true : request.params[1].get_bool(); |
| 426 | bool try_no_witness = request.params[1].isNull() ? true : !request.params[1].get_bool(); |
| 427 | |
| 428 | if (!DecodeHexTx(mtx, request.params[0].get_str(), try_no_witness, try_witness)) { |
| 429 | throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); |
| 430 | } |
| 431 | |
| 432 | UniValue result(UniValue::VOBJ); |
| 433 | TxToUniv(CTransaction(std::move(mtx)), /*block_hash=*/uint256(), /*entry=*/result, /*include_hex=*/false); |
| 434 | |
| 435 | return result; |
| 436 | }, |
| 437 | }; |
| 438 | } |
| 439 | |
| 440 | static RPCMethod decodescript() |
| 441 | { |
nothing calls this directly
no test coverage detected