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

Function walletprocesspsbt

src/wallet/rpc/spend.cpp:1327–1430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1325}
1326
1327RPCHelpMan walletprocesspsbt()
1328{
1329 return RPCHelpMan{"walletprocesspsbt",
1330 "\nUpdate a PSBT with input information from our wallet and then sign inputs\n"
1331 "that we can sign for." +
1332 HELP_REQUIRING_PASSPHRASE,
1333 {
1334 {"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction base64 string"},
1335 {"sign", RPCArg::Type::BOOL, RPCArg::Default{true}, "Also sign the transaction when updating (requires wallet to be unlocked)"},
1336 {"sighashtype", RPCArg::Type::STR, RPCArg::Default{"DEFAULT for Taproot, ALL otherwise"}, "The signature hash type to sign with if not specified by the PSBT. Must be one of\n"
1337 " \"DEFAULT\"\n"
1338 " \"ALL\"\n"
1339 " \"NONE\"\n"
1340 " \"SINGLE\"\n"
1341 " \"ALL|ANYONECANPAY\"\n"
1342 " \"NONE|ANYONECANPAY\"\n"
1343 " \"SINGLE|ANYONECANPAY\""},
1344 {"bip32derivs", RPCArg::Type::BOOL, RPCArg::Default{true}, "Include BIP 32 derivation paths for public keys if we know them"},
1345 {"finalize", RPCArg::Type::BOOL, RPCArg::Default{true}, "Also finalize inputs if possible"},
1346 },
1347 RPCResult{
1348 RPCResult::Type::OBJ, "", "",
1349 {
1350 {RPCResult::Type::STR, "psbt", "The base64-encoded partially signed transaction"},
1351 {RPCResult::Type::BOOL, "complete", "If the transaction has a complete set of signatures"},
1352 },
1353 },
1354 RPCExamples{
1355 HelpExampleCli("walletprocesspsbt", "\"psbt\"")
1356 },
1357 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
1358{
1359 if (!g_con_elementsmode)
1360 throw std::runtime_error("PSBT operations are disabled when not in elementsmode.\n");
1361
1362 const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
1363 if (!pwallet) return NullUniValue;
1364
1365 const CWallet& wallet{*pwallet};
1366 // Make sure the results are valid at least up to the most recent block
1367 // the user could have gotten from another RPC command prior to now
1368 wallet.BlockUntilSyncedToCurrentChain();
1369
1370 RPCTypeCheck(request.params, {UniValue::VSTR});
1371
1372 // Unserialize the transaction
1373 PartiallySignedTransaction psbtx;
1374 std::string error;
1375 if (!DecodeBase64PSBT(psbtx, request.params[0].get_str(), error)) {
1376 throw JSONRPCError(RPC_DESERIALIZATION_ERROR, strprintf("TX decode failed %s", error));
1377 }
1378
1379 // Get the sighash type
1380 int nHashType = ParseSighashString(request.params[2]);
1381
1382 // Don't sign, just fill data.
1383 bool bip32derivs = request.params[3].isNull() ? true : request.params[3].get_bool();
1384 bool finalize = request.params[4].isNull() ? true : request.params[4].get_bool();

Callers

nothing calls this directly

Calls 15

HelpExampleCliFunction · 0.85
RPCTypeCheckFunction · 0.85
DecodeBase64PSBTFunction · 0.85
JSONRPCErrorFunction · 0.85
ParseSighashStringFunction · 0.85
JSONRPCTransactionErrorFunction · 0.85
GetBlindingStatusErrorFunction · 0.85
EnsureWalletIsUnlockedFunction · 0.85
get_boolMethod · 0.80
IsBlindedMethod · 0.80
IsFullyBlindedMethod · 0.80

Tested by

no test coverage detected