| 324 | } |
| 325 | |
| 326 | void SignTransactionResultToJSON(CMutableTransaction& mtx, bool complete, const std::map<COutPoint, Coin>& coins, const std::map<int, bilingual_str>& input_errors, UniValue& result) |
| 327 | { |
| 328 | // Make errors UniValue |
| 329 | UniValue vErrors(UniValue::VARR); |
| 330 | for (const auto& err_pair : input_errors) { |
| 331 | if (err_pair.second.original == "Missing amount") { |
| 332 | // This particular error needs to be an exception for some reason |
| 333 | throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing amount for %s", coins.at(mtx.vin.at(err_pair.first).prevout).out.ToString())); |
| 334 | } |
| 335 | TxInErrorToJSON(mtx.vin.at(err_pair.first), vErrors, err_pair.second.original); |
| 336 | } |
| 337 | |
| 338 | result.pushKV("hex", EncodeHexTx(CTransaction(mtx))); |
| 339 | result.pushKV("complete", complete); |
| 340 | if (!vErrors.empty()) { |
| 341 | if (result.exists("errors")) { |
| 342 | vErrors.push_backV(result["errors"].getValues()); |
| 343 | } |
| 344 | result.pushKV("errors", std::move(vErrors)); |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | std::vector<RPCResult> TxDoc(const TxDocOptions& opts) |
| 349 | { |
no test coverage detected