| 2393 | } |
| 2394 | |
| 2395 | static 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 |
| 2435 | static RPCHelpMan joinpsbts() |
| 2436 | { |
nothing calls this directly
no test coverage detected