Assert that RPCArg names are equal to CRPCCommand ones (rawtransaction)

This commit is contained in:
MarcoFalke 2020-08-31 18:29:48 +02:00
parent fa80c81487
commit fa6bb0ce5d
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548

View File

@ -67,9 +67,9 @@ static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue&
} }
} }
static UniValue getrawtransaction(const JSONRPCRequest& request) static RPCHelpMan getrawtransaction()
{ {
RPCHelpMan{ return RPCHelpMan{
"getrawtransaction", "getrawtransaction",
"\nReturn the raw transaction data.\n" "\nReturn the raw transaction data.\n"
@ -155,8 +155,8 @@ static UniValue getrawtransaction(const JSONRPCRequest& request)
+ HelpExampleCli("getrawtransaction", "\"mytxid\" false \"myblockhash\"") + HelpExampleCli("getrawtransaction", "\"mytxid\" false \"myblockhash\"")
+ HelpExampleCli("getrawtransaction", "\"mytxid\" true \"myblockhash\"") + HelpExampleCli("getrawtransaction", "\"mytxid\" true \"myblockhash\"")
}, },
}.Check(request); [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
const NodeContext& node = EnsureNodeContext(request.context); const NodeContext& node = EnsureNodeContext(request.context);
bool in_active_chain = true; bool in_active_chain = true;
@ -217,11 +217,13 @@ static UniValue getrawtransaction(const JSONRPCRequest& request)
if (blockindex) result.pushKV("in_active_chain", in_active_chain); if (blockindex) result.pushKV("in_active_chain", in_active_chain);
TxToJSON(*tx, hash_block, result); TxToJSON(*tx, hash_block, result);
return result; return result;
},
};
} }
static UniValue gettxoutproof(const JSONRPCRequest& request) static RPCHelpMan gettxoutproof()
{ {
RPCHelpMan{"gettxoutproof", return RPCHelpMan{"gettxoutproof",
"\nReturns a hex-encoded proof that \"txid\" was included in a block.\n" "\nReturns a hex-encoded proof that \"txid\" was included in a block.\n"
"\nNOTE: By default this function only works sometimes. This is when there is an\n" "\nNOTE: By default this function only works sometimes. This is when there is an\n"
"unspent output in the utxo for this transaction. To make it always work,\n" "unspent output in the utxo for this transaction. To make it always work,\n"
@ -239,8 +241,8 @@ static UniValue gettxoutproof(const JSONRPCRequest& request)
RPCResult::Type::STR, "data", "A string that is a serialized, hex-encoded data for the proof." RPCResult::Type::STR, "data", "A string that is a serialized, hex-encoded data for the proof."
}, },
RPCExamples{""}, RPCExamples{""},
}.Check(request); [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
std::set<uint256> setTxids; std::set<uint256> setTxids;
uint256 oneTxid; uint256 oneTxid;
UniValue txids = request.params[0].get_array(); UniValue txids = request.params[0].get_array();
@ -315,11 +317,13 @@ static UniValue gettxoutproof(const JSONRPCRequest& request)
ssMB << mb; ssMB << mb;
std::string strHex = HexStr(ssMB); std::string strHex = HexStr(ssMB);
return strHex; return strHex;
},
};
} }
static UniValue verifytxoutproof(const JSONRPCRequest& request) static RPCHelpMan verifytxoutproof()
{ {
RPCHelpMan{"verifytxoutproof", return RPCHelpMan{"verifytxoutproof",
"\nVerifies that a proof points to a transaction in a block, returning the transaction it commits to\n" "\nVerifies that a proof points to a transaction in a block, returning the transaction it commits to\n"
"and throwing an RPC error if the block is not in our best chain\n", "and throwing an RPC error if the block is not in our best chain\n",
{ {
@ -332,8 +336,8 @@ static UniValue verifytxoutproof(const JSONRPCRequest& request)
} }
}, },
RPCExamples{""}, RPCExamples{""},
}.Check(request); [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
CDataStream ssMB(ParseHexV(request.params[0], "proof"), SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS); CDataStream ssMB(ParseHexV(request.params[0], "proof"), SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
CMerkleBlock merkleBlock; CMerkleBlock merkleBlock;
ssMB >> merkleBlock; ssMB >> merkleBlock;
@ -360,11 +364,13 @@ static UniValue verifytxoutproof(const JSONRPCRequest& request)
} }
return res; return res;
},
};
} }
static UniValue createrawtransaction(const JSONRPCRequest& request) static RPCHelpMan createrawtransaction()
{ {
RPCHelpMan{"createrawtransaction", return RPCHelpMan{"createrawtransaction",
"\nCreate a transaction spending the given inputs and creating new outputs.\n" "\nCreate a transaction spending the given inputs and creating new outputs.\n"
"Outputs can be addresses or data.\n" "Outputs can be addresses or data.\n"
"Returns hex-encoded raw transaction.\n" "Returns hex-encoded raw transaction.\n"
@ -412,8 +418,8 @@ static UniValue createrawtransaction(const JSONRPCRequest& request)
+ HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"address\\\":0.01}]\"") + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"address\\\":0.01}]\"")
+ HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"") + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
}, },
}.Check(request); [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
RPCTypeCheck(request.params, { RPCTypeCheck(request.params, {
UniValue::VARR, UniValue::VARR,
UniValueType(), // ARR or OBJ, checked later UniValueType(), // ARR or OBJ, checked later
@ -429,11 +435,13 @@ static UniValue createrawtransaction(const JSONRPCRequest& request)
CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], rbf); CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], rbf);
return EncodeHexTx(CTransaction(rawTx)); return EncodeHexTx(CTransaction(rawTx));
},
};
} }
static UniValue decoderawtransaction(const JSONRPCRequest& request) static RPCHelpMan decoderawtransaction()
{ {
RPCHelpMan{"decoderawtransaction", return RPCHelpMan{"decoderawtransaction",
"\nReturn a JSON object representing the serialized, hex-encoded transaction.\n", "\nReturn a JSON object representing the serialized, hex-encoded transaction.\n",
{ {
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction hex string"}, {"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction hex string"},
@ -498,8 +506,8 @@ static UniValue decoderawtransaction(const JSONRPCRequest& request)
HelpExampleCli("decoderawtransaction", "\"hexstring\"") HelpExampleCli("decoderawtransaction", "\"hexstring\"")
+ HelpExampleRpc("decoderawtransaction", "\"hexstring\"") + HelpExampleRpc("decoderawtransaction", "\"hexstring\"")
}, },
}.Check(request); [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL}); RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL});
CMutableTransaction mtx; CMutableTransaction mtx;
@ -515,6 +523,8 @@ static UniValue decoderawtransaction(const JSONRPCRequest& request)
TxToUniv(CTransaction(std::move(mtx)), uint256(), result, false); TxToUniv(CTransaction(std::move(mtx)), uint256(), result, false);
return result; return result;
},
};
} }
static std::string GetAllOutputTypes() static std::string GetAllOutputTypes()
@ -527,9 +537,9 @@ static std::string GetAllOutputTypes()
return Join(ret, ", "); return Join(ret, ", ");
} }
static UniValue decodescript(const JSONRPCRequest& request) static RPCHelpMan decodescript()
{ {
RPCHelpMan{"decodescript", return RPCHelpMan{"decodescript",
"\nDecode a hex-encoded script.\n", "\nDecode a hex-encoded script.\n",
{ {
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hex-encoded script"}, {"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hex-encoded script"},
@ -563,8 +573,8 @@ static UniValue decodescript(const JSONRPCRequest& request)
HelpExampleCli("decodescript", "\"hexstring\"") HelpExampleCli("decodescript", "\"hexstring\"")
+ HelpExampleRpc("decodescript", "\"hexstring\"") + HelpExampleRpc("decodescript", "\"hexstring\"")
}, },
}.Check(request); [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
RPCTypeCheck(request.params, {UniValue::VSTR}); RPCTypeCheck(request.params, {UniValue::VSTR});
UniValue r(UniValue::VOBJ); UniValue r(UniValue::VOBJ);
@ -616,11 +626,13 @@ static UniValue decodescript(const JSONRPCRequest& request)
} }
return r; return r;
},
};
} }
static UniValue combinerawtransaction(const JSONRPCRequest& request) static RPCHelpMan combinerawtransaction()
{ {
RPCHelpMan{"combinerawtransaction", return RPCHelpMan{"combinerawtransaction",
"\nCombine multiple partially signed transactions into one transaction.\n" "\nCombine multiple partially signed transactions into one transaction.\n"
"The combined transaction may be another partially signed transaction or a \n" "The combined transaction may be another partially signed transaction or a \n"
"fully signed transaction.", "fully signed transaction.",
@ -637,8 +649,8 @@ static UniValue combinerawtransaction(const JSONRPCRequest& request)
RPCExamples{ RPCExamples{
HelpExampleCli("combinerawtransaction", R"('["myhex1", "myhex2", "myhex3"]')") HelpExampleCli("combinerawtransaction", R"('["myhex1", "myhex2", "myhex3"]')")
}, },
}.Check(request); [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
UniValue txs = request.params[0].get_array(); UniValue txs = request.params[0].get_array();
std::vector<CMutableTransaction> txVariants(txs.size()); std::vector<CMutableTransaction> txVariants(txs.size());
@ -699,11 +711,13 @@ static UniValue combinerawtransaction(const JSONRPCRequest& request)
} }
return EncodeHexTx(CTransaction(mergedTx)); return EncodeHexTx(CTransaction(mergedTx));
},
};
} }
static UniValue signrawtransactionwithkey(const JSONRPCRequest& request) static RPCHelpMan signrawtransactionwithkey()
{ {
RPCHelpMan{"signrawtransactionwithkey", return RPCHelpMan{"signrawtransactionwithkey",
"\nSign inputs for raw transaction (serialized, hex-encoded).\n" "\nSign inputs for raw transaction (serialized, hex-encoded).\n"
"The second argument is an array of base58-encoded private\n" "The second argument is an array of base58-encoded private\n"
"keys that will be the only keys used to sign the transaction.\n" "keys that will be the only keys used to sign the transaction.\n"
@ -761,8 +775,8 @@ static UniValue signrawtransactionwithkey(const JSONRPCRequest& request)
HelpExampleCli("signrawtransactionwithkey", "\"myhex\" \"[\\\"key1\\\",\\\"key2\\\"]\"") HelpExampleCli("signrawtransactionwithkey", "\"myhex\" \"[\\\"key1\\\",\\\"key2\\\"]\"")
+ HelpExampleRpc("signrawtransactionwithkey", "\"myhex\", \"[\\\"key1\\\",\\\"key2\\\"]\"") + HelpExampleRpc("signrawtransactionwithkey", "\"myhex\", \"[\\\"key1\\\",\\\"key2\\\"]\"")
}, },
}.Check(request); [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR, UniValue::VARR, UniValue::VSTR}, true); RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR, UniValue::VARR, UniValue::VSTR}, true);
CMutableTransaction mtx; CMutableTransaction mtx;
@ -795,11 +809,13 @@ static UniValue signrawtransactionwithkey(const JSONRPCRequest& request)
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
SignTransaction(mtx, &keystore, coins, request.params[3], result); SignTransaction(mtx, &keystore, coins, request.params[3], result);
return result; return result;
},
};
} }
static UniValue sendrawtransaction(const JSONRPCRequest& request) static RPCHelpMan sendrawtransaction()
{ {
RPCHelpMan{"sendrawtransaction", return RPCHelpMan{"sendrawtransaction",
"\nSubmit a raw transaction (serialized, hex-encoded) to local node and network.\n" "\nSubmit a raw transaction (serialized, hex-encoded) to local node and network.\n"
"\nNote that the transaction will be sent unconditionally to all peers, so using this\n" "\nNote that the transaction will be sent unconditionally to all peers, so using this\n"
"for manual rebroadcast may degrade privacy by leaking the transaction's origin, as\n" "for manual rebroadcast may degrade privacy by leaking the transaction's origin, as\n"
@ -824,8 +840,8 @@ static UniValue sendrawtransaction(const JSONRPCRequest& request)
"\nAs a JSON-RPC call\n" "\nAs a JSON-RPC call\n"
+ HelpExampleRpc("sendrawtransaction", "\"signedhex\"") + HelpExampleRpc("sendrawtransaction", "\"signedhex\"")
}, },
}.Check(request); [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
RPCTypeCheck(request.params, { RPCTypeCheck(request.params, {
UniValue::VSTR, UniValue::VSTR,
UniValueType(), // VNUM or VSTR, checked inside AmountFromValue() UniValueType(), // VNUM or VSTR, checked inside AmountFromValue()
@ -853,11 +869,13 @@ static UniValue sendrawtransaction(const JSONRPCRequest& request)
} }
return tx->GetHash().GetHex(); return tx->GetHash().GetHex();
},
};
} }
static UniValue testmempoolaccept(const JSONRPCRequest& request) static RPCHelpMan testmempoolaccept()
{ {
RPCHelpMan{"testmempoolaccept", return RPCHelpMan{"testmempoolaccept",
"\nReturns result of mempool acceptance tests indicating if raw transaction (serialized, hex-encoded) would be accepted by mempool.\n" "\nReturns result of mempool acceptance tests indicating if raw transaction (serialized, hex-encoded) would be accepted by mempool.\n"
"\nThis checks if the transaction violates the consensus or policy rules.\n" "\nThis checks if the transaction violates the consensus or policy rules.\n"
"\nSee sendrawtransaction call.\n", "\nSee sendrawtransaction call.\n",
@ -892,8 +910,8 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request)
"\nAs a JSON-RPC call\n" "\nAs a JSON-RPC call\n"
+ HelpExampleRpc("testmempoolaccept", "[\"signedhex\"]") + HelpExampleRpc("testmempoolaccept", "[\"signedhex\"]")
}, },
}.Check(request); [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
RPCTypeCheck(request.params, { RPCTypeCheck(request.params, {
UniValue::VARR, UniValue::VARR,
UniValueType(), // VNUM or VSTR, checked inside AmountFromValue() UniValueType(), // VNUM or VSTR, checked inside AmountFromValue()
@ -944,11 +962,13 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request)
result.push_back(std::move(result_0)); result.push_back(std::move(result_0));
return result; return result;
},
};
} }
UniValue decodepsbt(const JSONRPCRequest& request) static RPCHelpMan decodepsbt()
{ {
RPCHelpMan{"decodepsbt", return RPCHelpMan{"decodepsbt",
"\nReturn a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.\n", "\nReturn a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.\n",
{ {
{"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, "The PSBT base64 string"}, {"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, "The PSBT base64 string"},
@ -1060,8 +1080,8 @@ UniValue decodepsbt(const JSONRPCRequest& request)
RPCExamples{ RPCExamples{
HelpExampleCli("decodepsbt", "\"psbt\"") HelpExampleCli("decodepsbt", "\"psbt\"")
}, },
}.Check(request); [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
RPCTypeCheck(request.params, {UniValue::VSTR}); RPCTypeCheck(request.params, {UniValue::VSTR});
// Unserialize the transactions // Unserialize the transactions
@ -1253,11 +1273,13 @@ UniValue decodepsbt(const JSONRPCRequest& request)
} }
return result; return result;
},
};
} }
UniValue combinepsbt(const JSONRPCRequest& request) static RPCHelpMan combinepsbt()
{ {
RPCHelpMan{"combinepsbt", return RPCHelpMan{"combinepsbt",
"\nCombine multiple partially signed Bitcoin transactions into one transaction.\n" "\nCombine multiple partially signed Bitcoin transactions into one transaction.\n"
"Implements the Combiner role.\n", "Implements the Combiner role.\n",
{ {
@ -1273,8 +1295,8 @@ UniValue combinepsbt(const JSONRPCRequest& request)
RPCExamples{ RPCExamples{
HelpExampleCli("combinepsbt", R"('["mybase64_1", "mybase64_2", "mybase64_3"]')") HelpExampleCli("combinepsbt", R"('["mybase64_1", "mybase64_2", "mybase64_3"]')")
}, },
}.Check(request); [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
RPCTypeCheck(request.params, {UniValue::VARR}, true); RPCTypeCheck(request.params, {UniValue::VARR}, true);
// Unserialize the transactions // Unserialize the transactions
@ -1301,11 +1323,13 @@ UniValue combinepsbt(const JSONRPCRequest& request)
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
ssTx << merged_psbt; ssTx << merged_psbt;
return EncodeBase64(MakeUCharSpan(ssTx)); return EncodeBase64(MakeUCharSpan(ssTx));
},
};
} }
UniValue finalizepsbt(const JSONRPCRequest& request) static RPCHelpMan finalizepsbt()
{ {
RPCHelpMan{"finalizepsbt", return RPCHelpMan{"finalizepsbt",
"Finalize the inputs of a PSBT. If the transaction is fully signed, it will produce a\n" "Finalize the inputs of a PSBT. If the transaction is fully signed, it will produce a\n"
"network serialized transaction which can be broadcast with sendrawtransaction. Otherwise a PSBT will be\n" "network serialized transaction which can be broadcast with sendrawtransaction. Otherwise a PSBT will be\n"
"created which has the final_scriptSig and final_scriptWitness fields filled for inputs that are complete.\n" "created which has the final_scriptSig and final_scriptWitness fields filled for inputs that are complete.\n"
@ -1326,8 +1350,8 @@ UniValue finalizepsbt(const JSONRPCRequest& request)
RPCExamples{ RPCExamples{
HelpExampleCli("finalizepsbt", "\"psbt\"") HelpExampleCli("finalizepsbt", "\"psbt\"")
}, },
}.Check(request); [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL}, true); RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL}, true);
// Unserialize the transactions // Unserialize the transactions
@ -1358,11 +1382,13 @@ UniValue finalizepsbt(const JSONRPCRequest& request)
result.pushKV("complete", complete); result.pushKV("complete", complete);
return result; return result;
},
};
} }
UniValue createpsbt(const JSONRPCRequest& request) static RPCHelpMan createpsbt()
{ {
RPCHelpMan{"createpsbt", return RPCHelpMan{"createpsbt",
"\nCreates a transaction in the Partially Signed Transaction format.\n" "\nCreates a transaction in the Partially Signed Transaction format.\n"
"Implements the Creator role.\n", "Implements the Creator role.\n",
{ {
@ -1404,8 +1430,8 @@ UniValue createpsbt(const JSONRPCRequest& request)
RPCExamples{ RPCExamples{
HelpExampleCli("createpsbt", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") HelpExampleCli("createpsbt", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
}, },
}.Check(request); [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
RPCTypeCheck(request.params, { RPCTypeCheck(request.params, {
UniValue::VARR, UniValue::VARR,
@ -1436,11 +1462,13 @@ UniValue createpsbt(const JSONRPCRequest& request)
ssTx << psbtx; ssTx << psbtx;
return EncodeBase64(MakeUCharSpan(ssTx)); return EncodeBase64(MakeUCharSpan(ssTx));
},
};
} }
UniValue converttopsbt(const JSONRPCRequest& request) static RPCHelpMan converttopsbt()
{ {
RPCHelpMan{"converttopsbt", return RPCHelpMan{"converttopsbt",
"\nConverts a network serialized transaction to a PSBT. This should be used only with createrawtransaction and fundrawtransaction\n" "\nConverts a network serialized transaction to a PSBT. This should be used only with createrawtransaction and fundrawtransaction\n"
"createpsbt and walletcreatefundedpsbt should be used for new applications.\n", "createpsbt and walletcreatefundedpsbt should be used for new applications.\n",
{ {
@ -1464,8 +1492,8 @@ UniValue converttopsbt(const JSONRPCRequest& request)
"\nConvert the transaction to a PSBT\n" "\nConvert the transaction to a PSBT\n"
+ HelpExampleCli("converttopsbt", "\"rawtransaction\"") + HelpExampleCli("converttopsbt", "\"rawtransaction\"")
}, },
}.Check(request); [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VBOOL}, true); RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VBOOL}, true);
// parse hex string from parameter // parse hex string from parameter
@ -1503,11 +1531,13 @@ UniValue converttopsbt(const JSONRPCRequest& request)
ssTx << psbtx; ssTx << psbtx;
return EncodeBase64(MakeUCharSpan(ssTx)); return EncodeBase64(MakeUCharSpan(ssTx));
},
};
} }
UniValue utxoupdatepsbt(const JSONRPCRequest& request) static RPCHelpMan utxoupdatepsbt()
{ {
RPCHelpMan{"utxoupdatepsbt", return RPCHelpMan{"utxoupdatepsbt",
"\nUpdates all segwit inputs and outputs in a PSBT with data from output descriptors, the UTXO set or the mempool.\n", "\nUpdates all segwit inputs and outputs in a PSBT with data from output descriptors, the UTXO set or the mempool.\n",
{ {
{"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, "A base64 string of a PSBT"}, {"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, "A base64 string of a PSBT"},
@ -1524,8 +1554,9 @@ UniValue utxoupdatepsbt(const JSONRPCRequest& request)
}, },
RPCExamples { RPCExamples {
HelpExampleCli("utxoupdatepsbt", "\"psbt\"") HelpExampleCli("utxoupdatepsbt", "\"psbt\"")
}}.Check(request); },
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR}, true); RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR}, true);
// Unserialize the transactions // Unserialize the transactions
@ -1591,11 +1622,13 @@ UniValue utxoupdatepsbt(const JSONRPCRequest& request)
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
ssTx << psbtx; ssTx << psbtx;
return EncodeBase64(MakeUCharSpan(ssTx)); return EncodeBase64(MakeUCharSpan(ssTx));
},
};
} }
UniValue joinpsbts(const JSONRPCRequest& request) static RPCHelpMan joinpsbts()
{ {
RPCHelpMan{"joinpsbts", return RPCHelpMan{"joinpsbts",
"\nJoins multiple distinct PSBTs with different inputs and outputs into one PSBT with inputs and outputs from all of the PSBTs\n" "\nJoins multiple distinct PSBTs with different inputs and outputs into one PSBT with inputs and outputs from all of the PSBTs\n"
"No input in any of the PSBTs can be in more than one of the PSBTs.\n", "No input in any of the PSBTs can be in more than one of the PSBTs.\n",
{ {
@ -1609,8 +1642,9 @@ UniValue joinpsbts(const JSONRPCRequest& request)
}, },
RPCExamples { RPCExamples {
HelpExampleCli("joinpsbts", "\"psbt\"") HelpExampleCli("joinpsbts", "\"psbt\"")
}}.Check(request); },
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
RPCTypeCheck(request.params, {UniValue::VARR}, true); RPCTypeCheck(request.params, {UniValue::VARR}, true);
// Unserialize the transactions // Unserialize the transactions
@ -1684,11 +1718,13 @@ UniValue joinpsbts(const JSONRPCRequest& request)
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
ssTx << shuffled_psbt; ssTx << shuffled_psbt;
return EncodeBase64(MakeUCharSpan(ssTx)); return EncodeBase64(MakeUCharSpan(ssTx));
},
};
} }
UniValue analyzepsbt(const JSONRPCRequest& request) static RPCHelpMan analyzepsbt()
{ {
RPCHelpMan{"analyzepsbt", return RPCHelpMan{"analyzepsbt",
"\nAnalyzes and provides information about the current status of a PSBT and its inputs\n", "\nAnalyzes and provides information about the current status of a PSBT and its inputs\n",
{ {
{"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, "A base64 string of a PSBT"} {"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, "A base64 string of a PSBT"}
@ -1727,8 +1763,9 @@ UniValue analyzepsbt(const JSONRPCRequest& request)
}, },
RPCExamples { RPCExamples {
HelpExampleCli("analyzepsbt", "\"psbt\"") HelpExampleCli("analyzepsbt", "\"psbt\"")
}}.Check(request); },
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
RPCTypeCheck(request.params, {UniValue::VSTR}); RPCTypeCheck(request.params, {UniValue::VSTR});
// Unserialize the transaction // Unserialize the transaction
@ -1792,6 +1829,8 @@ UniValue analyzepsbt(const JSONRPCRequest& request)
} }
return result; return result;
},
};
} }
void RegisterRawTransactionRPCCommands(CRPCTable &t) void RegisterRawTransactionRPCCommands(CRPCTable &t)