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

Function parsepsbt

src/rpc/rawtransaction.cpp:2395–2433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2393}
2394
2395static RPCHelpMan parsepsbt()
2396{
2397 return RPCHelpMan{"parsepsbt",
2398 "\nparse and print a PSBT.\n",
2399 {
2400 {"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, "A base64 string of a PSBT"}
2401 },
2402 RPCResult {
2403 RPCResult::Type::OBJ, "", "",
2404 {
2405 {RPCResult::Type::STR, "psbt", "The base64-encoded partially signed transaction"},
2406 {RPCResult::Type::BOOL, "canonical", "Whether the input PSBT matches the output PSBT"}
2407 }
2408 },
2409 RPCExamples {
2410 HelpExampleCli("parsepsbt", "\"psbt\"")
2411 },
2412 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
2413{
2414 RPCTypeCheck(request.params, {UniValue::VSTR}, true);
2415
2416 // Unserialize the PSBT
2417 PartiallySignedTransaction psbtx;
2418 std::string error;
2419 if (!DecodeBase64PSBT(psbtx, request.params[0].get_str(), error)) {
2420 throw JSONRPCError(RPC_DESERIALIZATION_ERROR, strprintf("PSBT decode failed %s", error));
2421 }
2422
2423 // Serialize the PSBT
2424 CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
2425 ssTx << psbtx;
2426 const std::string encoded = EncodeBase64(ssTx);
2427 UniValue result(UniValue::VOBJ);
2428 result.pushKV("psbt", encoded);
2429 result.pushKV("canonical", encoded == request.params[0].get_str());
2430 return result;
2431},
2432 };
2433}
2434#if 0
2435static RPCHelpMan joinpsbts()
2436{

Callers

nothing calls this directly

Calls 6

HelpExampleCliFunction · 0.85
RPCTypeCheckFunction · 0.85
DecodeBase64PSBTFunction · 0.85
JSONRPCErrorFunction · 0.85
EncodeBase64Function · 0.50
pushKVMethod · 0.45

Tested by

no test coverage detected