diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -102,43 +102,39 @@ return NullUniValue; } - if (request.fHelp || request.params.size() < 1 || - request.params.size() > 3) { - throw std::runtime_error(RPCHelpMan{ - "importprivkey", - "\nAdds a private key (as returned by dumpprivkey) to " - "your wallet. Requires a new wallet backup.\n" - "Hint: use importmulti to import more than one private key.\n" - "\nNote: This call can take minutes to complete if rescan is true, " - "during that time, other rpc calls\n" - "may report that the imported key exists but related transactions " - "are still missing, leading to temporarily incorrect/bogus " - "balances and unspent outputs until rescan completes.\n", - { - {"privkey", RPCArg::Type::STR, RPCArg::Optional::NO, - "The private key (see dumpprivkey)"}, - {"label", RPCArg::Type::STR, /* default */ - "current label if address exists, otherwise \"\"", - "An optional label"}, - {"rescan", RPCArg::Type::BOOL, /* default */ "true", - "Rescan the wallet for transactions"}, - }, - RPCResults{}, - RPCExamples{ - "\nDump a private key\n" + - HelpExampleCli("dumpprivkey", "\"myaddress\"") + - "\nImport the private key with rescan\n" + - HelpExampleCli("importprivkey", "\"mykey\"") + - "\nImport using a label and without rescan\n" + - HelpExampleCli("importprivkey", "\"mykey\" \"testing\" false") + - "\nImport using default blank label and without rescan\n" + - HelpExampleCli("importprivkey", "\"mykey\" \"\" false") + - "\nAs a JSON-RPC call\n" + - HelpExampleRpc("importprivkey", - "\"mykey\", \"testing\", false")}, - } - .ToString()); - } + RPCHelpMan{ + "importprivkey", + "\nAdds a private key (as returned by dumpprivkey) to your wallet. " + "Requires a new wallet backup.\n" + "Hint: use importmulti to import more than one private key.\n" + "\nNote: This call can take minutes to complete if rescan is true, " + "during that time, other rpc calls\n" + "may report that the imported key exists but related transactions are " + "still missing, leading to temporarily incorrect/bogus balances and " + "unspent outputs until rescan completes.\n", + { + {"privkey", RPCArg::Type::STR, RPCArg::Optional::NO, + "The private key (see dumpprivkey)"}, + {"label", RPCArg::Type::STR, /* default */ + "current label if address exists, otherwise \"\"", + "An optional label"}, + {"rescan", RPCArg::Type::BOOL, /* default */ "true", + "Rescan the wallet for transactions"}, + }, + RPCResults{}, + RPCExamples{ + "\nDump a private key\n" + + HelpExampleCli("dumpprivkey", "\"myaddress\"") + + "\nImport the private key with rescan\n" + + HelpExampleCli("importprivkey", "\"mykey\"") + + "\nImport using a label and without rescan\n" + + HelpExampleCli("importprivkey", "\"mykey\" \"testing\" false") + + "\nImport using default blank label and without rescan\n" + + HelpExampleCli("importprivkey", "\"mykey\" \"\" false") + + "\nAs a JSON-RPC call\n" + + HelpExampleRpc("importprivkey", "\"mykey\", \"testing\", false")}, + } + .Check(request); if (pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) { throw JSONRPCError(RPC_WALLET_ERROR, @@ -219,22 +215,20 @@ return NullUniValue; } - if (request.fHelp || request.params.size() > 0) { - throw std::runtime_error(RPCHelpMan{ - "abortrescan", - "\nStops current wallet rescan triggered by " - "an RPC call, e.g. by an importprivkey call.\n", - {}, - RPCResults{}, - RPCExamples{"\nImport a private key\n" + - HelpExampleCli("importprivkey", "\"mykey\"") + - "\nAbort the running wallet rescan\n" + - HelpExampleCli("abortrescan", "") + - "\nAs a JSON-RPC call\n" + - HelpExampleRpc("abortrescan", "")}, - } - .ToString()); + RPCHelpMan{ + "abortrescan", + "\nStops current wallet rescan triggered by an RPC call, e.g. by an " + "importprivkey call.\n", + {}, + RPCResults{}, + RPCExamples{"\nImport a private key\n" + + HelpExampleCli("importprivkey", "\"mykey\"") + + "\nAbort the running wallet rescan\n" + + HelpExampleCli("abortrescan", "") + + "\nAs a JSON-RPC call\n" + + HelpExampleRpc("abortrescan", "")}, } + .Check(request); if (!pwallet->IsScanning() || pwallet->IsAbortingRescan()) { return false; @@ -250,46 +244,42 @@ return NullUniValue; } - if (request.fHelp || request.params.size() < 1 || - request.params.size() > 4) { - throw std::runtime_error(RPCHelpMan{ - "importaddress", - "\nAdds an address or script (in hex) that can be " - "watched as if it were in your wallet but cannot be " - "used to spend. Requires a new wallet backup.\n" - "\nNote: This call can take minutes to complete if rescan is true, " - "during that time, other rpc calls\n" - "may report that the imported address exists but related " - "transactions are still missing, leading to temporarily " - "incorrect/bogus balances and unspent outputs until rescan " - "completes.\n" - "If you have the full public key, you should call importpubkey " - "instead of this.\n" - "\nNote: If you import a non-standard raw script in hex form, " - "outputs sending to it will be treated\n" - "as change, and not show up in many RPCs.\n", - { - {"address", RPCArg::Type::STR, RPCArg::Optional::NO, - "The Bitcoin address (or hex-encoded script)"}, - {"label", RPCArg::Type::STR, /* default */ "\"\"", - "An optional label"}, - {"rescan", RPCArg::Type::BOOL, /* default */ "true", - "Rescan the wallet for transactions"}, - {"p2sh", RPCArg::Type::BOOL, /* default */ "false", - "Add the P2SH version of the script as well"}, - }, - RPCResults{}, - RPCExamples{"\nImport an address with rescan\n" + - HelpExampleCli("importaddress", "\"myaddress\"") + - "\nImport using a label without rescan\n" + - HelpExampleCli("importaddress", - "\"myaddress\" \"testing\" false") + - "\nAs a JSON-RPC call\n" + - HelpExampleRpc("importaddress", - "\"myaddress\", \"testing\", false")}, - } - .ToString()); - } + RPCHelpMan{ + "importaddress", + "\nAdds an address or script (in hex) that can be watched as if it " + "were in your wallet but cannot be used to spend. Requires a new " + "wallet backup.\n" + "\nNote: This call can take minutes to complete if rescan is true, " + "during that time, other rpc calls\n" + "may report that the imported address exists but related transactions " + "are still missing, leading to temporarily incorrect/bogus balances " + "and unspent outputs until rescan completes.\n" + "If you have the full public key, you should call importpubkey instead " + "of this.\n" + "\nNote: If you import a non-standard raw script in hex form, outputs " + "sending to it will be treated\n" + "as change, and not show up in many RPCs.\n", + { + {"address", RPCArg::Type::STR, RPCArg::Optional::NO, + "The Bitcoin address (or hex-encoded script)"}, + {"label", RPCArg::Type::STR, /* default */ "\"\"", + "An optional label"}, + {"rescan", RPCArg::Type::BOOL, /* default */ "true", + "Rescan the wallet for transactions"}, + {"p2sh", RPCArg::Type::BOOL, /* default */ "false", + "Add the P2SH version of the script as well"}, + }, + RPCResults{}, + RPCExamples{ + "\nImport an address with rescan\n" + + HelpExampleCli("importaddress", "\"myaddress\"") + + "\nImport using a label without rescan\n" + + HelpExampleCli("importaddress", "\"myaddress\" \"testing\" false") + + "\nAs a JSON-RPC call\n" + + HelpExampleRpc("importaddress", + "\"myaddress\", \"testing\", false")}, + } + .Check(request); std::string strLabel; if (!request.params[1].isNull()) { @@ -379,28 +369,24 @@ return NullUniValue; } - if (request.fHelp || request.params.size() != 2) { - throw std::runtime_error(RPCHelpMan{ - "importprunedfunds", - "\nImports funds without rescan. Corresponding address or script " - "must previously be included in wallet. Aimed towards pruned " - "wallets. The end-user is responsible to import additional " - "transactions that subsequently spend the imported outputs or " - "rescan after the point in the blockchain the transaction is " - "included.\n", - { - {"rawtransaction", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, - "A raw transaction in hex funding an already-existing " - "address in wallet"}, - {"txoutproof", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, - "The hex output from gettxoutproof that contains the " - "transaction"}, - }, - RPCResults{}, - RPCExamples{""}, - } - .ToString()); + RPCHelpMan{ + "importprunedfunds", + "\nImports funds without rescan. Corresponding address or script must " + "previously be included in wallet. Aimed towards pruned wallets. The " + "end-user is responsible to import additional transactions that " + "subsequently spend the imported outputs or rescan after the point in " + "the blockchain the transaction is included.\n", + { + {"rawtransaction", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, + "A raw transaction in hex funding an already-existing address in " + "wallet"}, + {"txoutproof", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, + "The hex output from gettxoutproof that contains the transaction"}, + }, + RPCResults{}, + RPCExamples{""}, } + .Check(request); CMutableTransaction tx; if (!DecodeHexTx(tx, request.params[0].get_str())) { @@ -465,30 +451,25 @@ return NullUniValue; } - if (request.fHelp || request.params.size() != 1) { - throw std::runtime_error(RPCHelpMan{ - "removeprunedfunds", - "\nDeletes the specified transaction from the wallet. Meant " - "for use with pruned wallets and as a companion to " - "importprunedfunds. This will affect wallet balances.\n", - { - {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, - "The hex-encoded id of the transaction you are deleting"}, - }, - RPCResults{}, - RPCExamples{ - HelpExampleCli("removeprunedfunds", - "\"a8d0c0184dde994a09ec054286f1" - "ce581bebf46446a512166eae762873" - "4ea0a5\"") + - "\nAs a JSON-RPC call\n" + - HelpExampleRpc( - "removeprunedfunds", - "\"a8d0c0184dde994a09ec054286f1ce581bebf46446a512166" - "eae7628734ea0a5\"")}, - } - .ToString()); - } + RPCHelpMan{ + "removeprunedfunds", + "\nDeletes the specified transaction from the wallet. Meant for use " + "with pruned wallets and as a companion to importprunedfunds. This " + "will affect wallet balances.\n", + { + {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, + "The hex-encoded id of the transaction you are deleting"}, + }, + RPCResults{}, + RPCExamples{HelpExampleCli("removeprunedfunds", + "\"a8d0c0184dde994a09ec054286f1ce581bebf4644" + "6a512166eae7628734ea0a5\"") + + "\nAs a JSON-RPC call\n" + + HelpExampleRpc("removeprunedfunds", + "\"a8d0c0184dde994a09ec054286f1ce581bebf4644" + "6a512166eae7628734ea0a5\"")}, + } + .Check(request); auto locked_chain = pwallet->chain().lock(); LOCK(pwallet->cs_wallet); @@ -518,39 +499,34 @@ return NullUniValue; } - if (request.fHelp || request.params.size() < 1 || - request.params.size() > 3) { - throw std::runtime_error(RPCHelpMan{ - "importpubkey", - "\nAdds a public key (in hex) that can be watched as if " - "it were in your wallet but cannot be used to spend. " - "Requires a new wallet backup.\n" - "\nNote: This call can take minutes to complete if rescan is true, " - "during that time, other rpc calls\n" - "may report that the imported pubkey exists but related " - "transactions are still missing, leading to temporarily " - "incorrect/bogus balances and unspent outputs until rescan " - "completes.\n", - { - {"pubkey", RPCArg::Type::STR, RPCArg::Optional::NO, - "The hex-encoded public key"}, - {"label", RPCArg::Type::STR, /* default */ "\"\"", - "An optional label"}, - {"rescan", RPCArg::Type::BOOL, /* default */ "true", - "Rescan the wallet for transactions"}, - }, - RPCResults{}, - RPCExamples{"\nImport a public key with rescan\n" + - HelpExampleCli("importpubkey", "\"mypubkey\"") + - "\nImport using a label without rescan\n" + - HelpExampleCli("importpubkey", - "\"mypubkey\" \"testing\" false") + - "\nAs a JSON-RPC call\n" + - HelpExampleRpc("importpubkey", - "\"mypubkey\", \"testing\", false")}, - } - .ToString()); - } + RPCHelpMan{ + "importpubkey", + "\nAdds a public key (in hex) that can be watched as if it were in " + "your wallet but cannot be used to spend. Requires a new wallet " + "backup.\n" + "\nNote: This call can take minutes to complete if rescan is true, " + "during that time, other rpc calls\n" + "may report that the imported pubkey exists but related transactions " + "are still missing, leading to temporarily incorrect/bogus balances " + "and unspent outputs until rescan completes.\n", + { + {"pubkey", RPCArg::Type::STR, RPCArg::Optional::NO, + "The hex-encoded public key"}, + {"label", RPCArg::Type::STR, /* default */ "\"\"", + "An optional label"}, + {"rescan", RPCArg::Type::BOOL, /* default */ "true", + "Rescan the wallet for transactions"}, + }, + RPCResults{}, + RPCExamples{ + "\nImport a public key with rescan\n" + + HelpExampleCli("importpubkey", "\"mypubkey\"") + + "\nImport using a label without rescan\n" + + HelpExampleCli("importpubkey", "\"mypubkey\" \"testing\" false") + + "\nAs a JSON-RPC call\n" + + HelpExampleRpc("importpubkey", "\"mypubkey\", \"testing\", false")}, + } + .Check(request); std::string strLabel; if (!request.params[1].isNull()) { @@ -624,25 +600,23 @@ return NullUniValue; } - if (request.fHelp || request.params.size() != 1) { - throw std::runtime_error(RPCHelpMan{ - "importwallet", - "\nImports keys from a wallet dump file (see dumpwallet). " - "Requires a new wallet backup to include imported keys.\n", - { - {"filename", RPCArg::Type::STR, RPCArg::Optional::NO, - "The wallet file"}, - }, - RPCResults{}, - RPCExamples{"\nDump the wallet\n" + - HelpExampleCli("dumpwallet", "\"test\"") + - "\nImport the wallet\n" + - HelpExampleCli("importwallet", "\"test\"") + - "\nImport using the json rpc call\n" + - HelpExampleRpc("importwallet", "\"test\"")}, - } - .ToString()); - } + RPCHelpMan{ + "importwallet", + "\nImports keys from a wallet dump file (see dumpwallet). Requires a " + "new wallet backup to include imported keys.\n", + { + {"filename", RPCArg::Type::STR, RPCArg::Optional::NO, + "The wallet file"}, + }, + RPCResults{}, + RPCExamples{"\nDump the wallet\n" + + HelpExampleCli("dumpwallet", "\"test\"") + + "\nImport the wallet\n" + + HelpExampleCli("importwallet", "\"test\"") + + "\nImport using the json rpc call\n" + + HelpExampleRpc("importwallet", "\"test\"")}, + } + .Check(request); if (pwallet->chain().getPruneMode()) { throw JSONRPCError(RPC_WALLET_ERROR, @@ -823,22 +797,20 @@ return NullUniValue; } - if (request.fHelp || request.params.size() != 1) { - throw std::runtime_error(RPCHelpMan{ - "dumpprivkey", - "\nReveals the private key corresponding to 'address'.\n" - "Then the importprivkey can be used with this output\n", - { - {"address", RPCArg::Type::STR, RPCArg::Optional::NO, - "The bitcoin address for the private key"}, - }, - RPCResult{"\"key\" (string) The private key\n"}, - RPCExamples{HelpExampleCli("dumpprivkey", "\"myaddress\"") + - HelpExampleCli("importprivkey", "\"mykey\"") + - HelpExampleRpc("dumpprivkey", "\"myaddress\"")}, - } - .ToString()); + RPCHelpMan{ + "dumpprivkey", + "\nReveals the private key corresponding to 'address'.\n" + "Then the importprivkey can be used with this output\n", + { + {"address", RPCArg::Type::STR, RPCArg::Optional::NO, + "The bitcoin address for the private key"}, + }, + RPCResult{"\"key\" (string) The private key\n"}, + RPCExamples{HelpExampleCli("dumpprivkey", "\"myaddress\"") + + HelpExampleCli("importprivkey", "\"mykey\"") + + HelpExampleRpc("dumpprivkey", "\"myaddress\"")}, } + .Check(request); auto locked_chain = pwallet->chain().lock(); LOCK(pwallet->cs_wallet); @@ -871,35 +843,29 @@ return NullUniValue; } - if (request.fHelp || request.params.size() != 1) { - throw std::runtime_error(RPCHelpMan{ - "dumpwallet", - "\nDumps all wallet keys in a human-readable format to " - "a server-side file. This does not allow overwriting " - "existing files.\n" - "Imported scripts are included in the dumpsfile, but " - "corresponding addresses may not be added automatically " - "by importwallet.\n" - "Note that if your wallet contains keys which are not " - "derived from your HD seed (e.g. imported keys), these " - "are not covered by\n" - "only backing up the seed itself, and must be backed up " - "too (e.g. ensure you back up the whole dumpfile).\n", - { - {"filename", RPCArg::Type::STR, RPCArg::Optional::NO, - "The filename with path (either absolute or relative to " - "bitcoind)"}, - }, - RPCResult{ - "{ (json object)\n" - " \"filename\" : { (string) The filename with full " - "absolute path\n" - "}\n"}, - RPCExamples{HelpExampleCli("dumpwallet", "\"test\"") + - HelpExampleRpc("dumpwallet", "\"test\"")}, - } - .ToString()); - } + RPCHelpMan{ + "dumpwallet", + "\nDumps all wallet keys in a human-readable format to a server-side " + "file. This does not allow overwriting existing files.\n" + "Imported scripts are included in the dumpsfile, but corresponding " + "addresses may not be added automatically by importwallet.\n" + "Note that if your wallet contains keys which are not derived from " + "your HD seed (e.g. imported keys), these are not covered by\n" + "only backing up the seed itself, and must be backed up too (e.g. " + "ensure you back up the whole dumpfile).\n", + { + {"filename", RPCArg::Type::STR, RPCArg::Optional::NO, + "The filename with path (either absolute or relative to " + "bitcoind)"}, + }, + RPCResult{"{ (json object)\n" + " \"filename\" : { (string) The filename with full " + "absolute path\n" + "}\n"}, + RPCExamples{HelpExampleCli("dumpwallet", "\"test\"") + + HelpExampleRpc("dumpwallet", "\"test\"")}, + } + .Check(request); auto locked_chain = pwallet->chain().lock(); LOCK(pwallet->cs_wallet); @@ -1542,155 +1508,147 @@ return NullUniValue; } - if (mainRequest.fHelp || mainRequest.params.size() < 1 || - mainRequest.params.size() > 2) { - throw std::runtime_error(RPCHelpMan{ - "importmulti", - "\nImport addresses/scripts (with private or public keys, redeem " - "script (P2SH)), rescanning all addresses in one-shot-only (rescan " - "can be disabled via options). Requires a new wallet backup.\n", - { - {"requests", - RPCArg::Type::ARR, - RPCArg::Optional::NO, - "Data to be imported", + RPCHelpMan{ + "importmulti", + "\nImport addresses/scripts (with private or public keys, redeem " + "script (P2SH)), rescanning all addresses in one-shot-only (rescan can " + "be disabled via options). Requires a new wallet backup.\n", + { + {"requests", + RPCArg::Type::ARR, + RPCArg::Optional::NO, + "Data to be imported", + { { + "", + RPCArg::Type::OBJ, + RPCArg::Optional::OMITTED, + "", { - "", - RPCArg::Type::OBJ, - RPCArg::Optional::OMITTED, - "", - { - {"desc", RPCArg::Type::STR, - RPCArg::Optional::OMITTED, - "Descriptor to import. If using descriptor, do " - "not also provide address/scriptPubKey, scripts, " - "or pubkeys"}, - {"scriptPubKey", - RPCArg::Type::STR, - RPCArg::Optional::NO, - "Type of scriptPubKey (string for script, json " - "for address). Should not be provided if using a " - "descriptor", - /* oneline_description */ "", - {"\"