MCPcopy Create free account
hub / github.com/ElementsProject/elements / SignTransactionResultToJSON

Function SignTransactionResultToJSON

src/rpc/rawtransaction_util.cpp:575–598  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

573}
574
575void 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}

Callers 2

SignTransactionFunction · 0.85

Calls 9

JSONRPCErrorFunction · 0.85
TxInErrorToJSONFunction · 0.85
EncodeHexTxFunction · 0.85
push_backVMethod · 0.80
CTransactionClass · 0.50
ToStringMethod · 0.45
pushKVMethod · 0.45
emptyMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected