| 573 | } |
| 574 | |
| 575 | void SignTransactionResultToJSON(CMutableTransaction& mtx, bool complete, const std::map<COutPoint, Coin>& coins, const std::map<int, bilingual_str>& input_errors, bool immature_pegin, UniValue& result) |
| 576 | { |
| 577 | // Make errors UniValue |
| 578 | UniValue vErrors(UniValue::VARR); |
| 579 | for (const auto& err_pair : input_errors) { |
| 580 | if (err_pair.second.original == "Missing amount") { |
| 581 | // This particular error needs to be an exception for some reason |
| 582 | throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing amount for %s", coins.at(mtx.vin.at(err_pair.first).prevout).out.ToString())); |
| 583 | } |
| 584 | TxInErrorToJSON(mtx.vin.at(err_pair.first), mtx.witness.vtxinwit.at(err_pair.first), vErrors, err_pair.second.original); |
| 585 | } |
| 586 | |
| 587 | result.pushKV("hex", EncodeHexTx(CTransaction(mtx))); |
| 588 | result.pushKV("complete", complete); |
| 589 | if (!vErrors.empty()) { |
| 590 | if (result.exists("errors")) { |
| 591 | vErrors.push_backV(result["errors"].getValues()); |
| 592 | } |
| 593 | result.pushKV("errors", vErrors); |
| 594 | } |
| 595 | if (immature_pegin) { |
| 596 | result.pushKV("warning", "Possibly immature peg-in input(s) detected, signed anyways."); |
| 597 | } |
| 598 | } |
no test coverage detected