MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / descriptorprocesspsbt

Function descriptorprocesspsbt

src/rpc/rawtransaction.cpp:2067–2150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2065}
2066
2067RPCMethod descriptorprocesspsbt()
2068{
2069 return RPCMethod{
2070 "descriptorprocesspsbt",
2071 "Update all segwit inputs in a PSBT with information from output descriptors, the UTXO set or the mempool. \n"
2072 "Then, sign the inputs we are able to with information from the output descriptors. ",
2073 {
2074 {"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction base64 string"},
2075 {"descriptors", RPCArg::Type::ARR, RPCArg::Optional::NO, "An array of either strings or objects", {
2076 {"", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "An output descriptor"},
2077 {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "An object with an output descriptor and extra information", {
2078 {"desc", RPCArg::Type::STR, RPCArg::Optional::NO, "An output descriptor"},
2079 {"range", RPCArg::Type::RANGE, RPCArg::Default{1000}, "Up to what index HD chains should be explored (either end or [begin,end])"},
2080 }},
2081 }},
2082 {"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"
2083 " \"DEFAULT\"\n"
2084 " \"ALL\"\n"
2085 " \"NONE\"\n"
2086 " \"SINGLE\"\n"
2087 " \"ALL|ANYONECANPAY\"\n"
2088 " \"NONE|ANYONECANPAY\"\n"
2089 " \"SINGLE|ANYONECANPAY\""},
2090 {"bip32derivs", RPCArg::Type::BOOL, RPCArg::Default{true}, "Include BIP 32 derivation paths for public keys if we know them"},
2091 {"finalize", RPCArg::Type::BOOL, RPCArg::Default{true}, "Also finalize inputs if possible"},
2092 },
2093 RPCResult{
2094 RPCResult::Type::OBJ, "", "",
2095 {
2096 {RPCResult::Type::STR, "psbt", "The base64-encoded partially signed transaction"},
2097 {RPCResult::Type::BOOL, "complete", "If the transaction has a complete set of signatures"},
2098 {RPCResult::Type::STR_HEX, "hex", /*optional=*/true, "The hex-encoded network transaction if complete"},
2099 }
2100 },
2101 RPCExamples{
2102 HelpExampleCli("descriptorprocesspsbt", "\"psbt\" \"[\\\"descriptor1\\\", \\\"descriptor2\\\"]\"") +
2103 HelpExampleCli("descriptorprocesspsbt", "\"psbt\" \"[{\\\"desc\\\":\\\"mydescriptor\\\", \\\"range\\\":21}]\"")
2104 },
2105 [](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue
2106{
2107 // Add descriptor information to a signing provider
2108 FlatSigningProvider provider;
2109
2110 auto descs = request.params[1].get_array();
2111 for (size_t i = 0; i < descs.size(); ++i) {
2112 EvalDescriptorStringOrObject(descs[i], provider, /*expand_priv=*/true);
2113 }
2114
2115 std::optional<int> sighash_type = ParseSighashString(request.params[2]);
2116 bool bip32derivs = request.params[3].isNull() ? true : request.params[3].get_bool();
2117 bool finalize = request.params[4].isNull() ? true : request.params[4].get_bool();
2118
2119 const PartiallySignedTransaction& psbtx = ProcessPSBT(
2120 request.params[0].get_str(),
2121 request.context,
2122 HidingSigningProvider(&provider, /*hide_secret=*/false, !bip32derivs),
2123 sighash_type,
2124 finalize);

Callers

nothing calls this directly

Calls 13

HelpExampleCliFunction · 0.85
ParseSighashStringFunction · 0.85
ProcessPSBTFunction · 0.85
PSBTInputSignedFunction · 0.85
FinalizeAndExtractPSBTFunction · 0.85
isNullMethod · 0.80
get_boolMethod · 0.80
pushKVMethod · 0.80
EncodeBase64Function · 0.50
HexStrFunction · 0.50

Tested by

no test coverage detected