@@ -90,9 +90,9 @@ static void RescanWallet(CWallet& wallet, const WalletRescanReserver& reserver,
9090 }
9191}
9292
93- UniValue importprivkey (const JSONRPCRequest& request )
93+ RPCHelpMan importprivkey ()
9494{
95- RPCHelpMan{" importprivkey" ,
95+ return RPCHelpMan{" importprivkey" ,
9696 " \n Adds a private key (as returned by dumpprivkey) to your wallet. Requires a new wallet backup.\n "
9797 " Hint: use importmulti to import more than one private key.\n "
9898 " \n Note: This call can take over an hour to complete if rescan is true, during that time, other rpc calls\n "
@@ -116,8 +116,8 @@ UniValue importprivkey(const JSONRPCRequest& request)
116116 " \n As a JSON-RPC call\n "
117117 + HelpExampleRpc (" importprivkey" , " \" mykey\" , \" testing\" , false" )
118118 },
119- }. Check ( request);
120-
119+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
120+ {
121121 std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
122122 if (!wallet) return NullUniValue;
123123 CWallet* const pwallet = wallet.get ();
@@ -189,11 +189,13 @@ UniValue importprivkey(const JSONRPCRequest& request)
189189 }
190190
191191 return NullUniValue;
192+ },
193+ };
192194}
193195
194- UniValue abortrescan (const JSONRPCRequest& request )
196+ RPCHelpMan abortrescan ()
195197{
196- RPCHelpMan{" abortrescan" ,
198+ return RPCHelpMan{" abortrescan" ,
197199 " \n Stops current wallet rescan triggered by an RPC call, e.g. by an importprivkey call.\n "
198200 " Note: Use \" getwalletinfo\" to query the scanning progress.\n " ,
199201 {},
@@ -206,20 +208,22 @@ UniValue abortrescan(const JSONRPCRequest& request)
206208 " \n As a JSON-RPC call\n "
207209 + HelpExampleRpc (" abortrescan" , " " )
208210 },
209- }. Check ( request);
210-
211+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
212+ {
211213 std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
212214 if (!wallet) return NullUniValue;
213215 CWallet* const pwallet = wallet.get ();
214216
215217 if (!pwallet->IsScanning () || pwallet->IsAbortingRescan ()) return false ;
216218 pwallet->AbortRescan ();
217219 return true ;
220+ },
221+ };
218222}
219223
220- UniValue importaddress (const JSONRPCRequest& request )
224+ RPCHelpMan importaddress ()
221225{
222- RPCHelpMan{" importaddress" ,
226+ return RPCHelpMan{" importaddress" ,
223227 " \n Adds 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 "
224228 " \n Note: This call can take over an hour to complete if rescan is true, during that time, other rpc calls\n "
225229 " 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 "
@@ -243,8 +247,8 @@ UniValue importaddress(const JSONRPCRequest& request)
243247 " \n As a JSON-RPC call\n "
244248 + HelpExampleRpc (" importaddress" , " \" myaddress\" , \" testing\" , false" )
245249 },
246- }. Check ( request);
247-
250+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
251+ {
248252 std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
249253 if (!wallet) return NullUniValue;
250254 CWallet* const pwallet = wallet.get ();
@@ -315,20 +319,22 @@ UniValue importaddress(const JSONRPCRequest& request)
315319 }
316320
317321 return NullUniValue;
322+ },
323+ };
318324}
319325
320- UniValue importprunedfunds (const JSONRPCRequest& request )
326+ RPCHelpMan importprunedfunds ()
321327{
322- RPCHelpMan{" importprunedfunds" ,
328+ return RPCHelpMan{" importprunedfunds" ,
323329 " \n Imports 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 " ,
324330 {
325331 {" rawtransaction" , RPCArg::Type::STR_HEX, RPCArg::Optional::NO, " A raw transaction in hex funding an already-existing address in wallet" },
326332 {" txoutproof" , RPCArg::Type::STR_HEX, RPCArg::Optional::NO, " The hex output from gettxoutproof that contains the transaction" },
327333 },
328334 RPCResult{RPCResult::Type::NONE, " " , " " },
329335 RPCExamples{" " },
330- }. Check ( request);
331-
336+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
337+ {
332338 std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
333339 if (!wallet) return NullUniValue;
334340 CWallet* const pwallet = wallet.get ();
@@ -371,11 +377,13 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
371377 }
372378
373379 throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " No addresses in wallet correspond to included transaction" );
380+ },
381+ };
374382}
375383
376- UniValue removeprunedfunds (const JSONRPCRequest& request )
384+ RPCHelpMan removeprunedfunds ()
377385{
378- RPCHelpMan{" removeprunedfunds" ,
386+ return RPCHelpMan{" removeprunedfunds" ,
379387 " \n Deletes the specified transaction from the wallet. Meant for use with pruned wallets and as a companion to importprunedfunds. This will affect wallet balances.\n " ,
380388 {
381389 {" txid" , RPCArg::Type::STR_HEX, RPCArg::Optional::NO, " The hex-encoded id of the transaction you are deleting" },
@@ -386,8 +394,8 @@ UniValue removeprunedfunds(const JSONRPCRequest& request)
386394 " \n As a JSON-RPC call\n "
387395 + HelpExampleRpc (" removeprunedfunds" , " \" a8d0c0184dde994a09ec054286f1ce581bebf46446a512166eae7628734ea0a5\" " )
388396 },
389- }. Check ( request);
390-
397+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
398+ {
391399 std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
392400 if (!wallet) return NullUniValue;
393401 CWallet* const pwallet = wallet.get ();
@@ -408,11 +416,13 @@ UniValue removeprunedfunds(const JSONRPCRequest& request)
408416 }
409417
410418 return NullUniValue;
419+ },
420+ };
411421}
412422
413- UniValue importpubkey (const JSONRPCRequest& request )
423+ RPCHelpMan importpubkey ()
414424{
415- RPCHelpMan{" importpubkey" ,
425+ return RPCHelpMan{" importpubkey" ,
416426 " \n Adds 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 "
417427 " Hint: use importmulti to import more than one public key.\n "
418428 " \n Note: This call can take over an hour to complete if rescan is true, during that time, other rpc calls\n "
@@ -432,8 +442,8 @@ UniValue importpubkey(const JSONRPCRequest& request)
432442 " \n As a JSON-RPC call\n "
433443 + HelpExampleRpc (" importpubkey" , " \" mypubkey\" , \" testing\" , false" )
434444 },
435- }. Check ( request);
436-
445+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
446+ {
437447 std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
438448 if (!wallet) return NullUniValue;
439449 CWallet* const pwallet = wallet.get ();
@@ -492,12 +502,14 @@ UniValue importpubkey(const JSONRPCRequest& request)
492502 }
493503
494504 return NullUniValue;
505+ },
506+ };
495507}
496508
497509
498- UniValue importwallet (const JSONRPCRequest& request )
510+ RPCHelpMan importwallet ()
499511{
500- RPCHelpMan{" importwallet" ,
512+ return RPCHelpMan{" importwallet" ,
501513 " \n Imports keys from a wallet dump file (see dumpwallet). Requires a new wallet backup to include imported keys.\n "
502514 " Note: Use \" getwalletinfo\" to query the scanning progress.\n " ,
503515 {
@@ -512,8 +524,8 @@ UniValue importwallet(const JSONRPCRequest& request)
512524 " \n Import using the json rpc call\n "
513525 + HelpExampleRpc (" importwallet" , " \" test\" " )
514526 },
515- }. Check ( request);
516-
527+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
528+ {
517529 std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
518530 if (!wallet) return NullUniValue;
519531 CWallet* const pwallet = wallet.get ();
@@ -649,11 +661,13 @@ UniValue importwallet(const JSONRPCRequest& request)
649661 throw JSONRPCError (RPC_WALLET_ERROR, " Error adding some keys/scripts to wallet" );
650662
651663 return NullUniValue;
664+ },
665+ };
652666}
653667
654- UniValue dumpprivkey (const JSONRPCRequest& request )
668+ RPCHelpMan dumpprivkey ()
655669{
656- RPCHelpMan{" dumpprivkey" ,
670+ return RPCHelpMan{" dumpprivkey" ,
657671 " \n Reveals the private key corresponding to 'address'.\n "
658672 " Then the importprivkey can be used with this output\n " ,
659673 {
@@ -667,8 +681,8 @@ UniValue dumpprivkey(const JSONRPCRequest& request)
667681 + HelpExampleCli (" importprivkey" , " \" mykey\" " )
668682 + HelpExampleRpc (" dumpprivkey" , " \" myaddress\" " )
669683 },
670- }. Check ( request);
671-
684+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
685+ {
672686 std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
673687 if (!wallet) return NullUniValue;
674688 const CWallet* const pwallet = wallet.get ();
@@ -693,12 +707,14 @@ UniValue dumpprivkey(const JSONRPCRequest& request)
693707 throw JSONRPCError (RPC_WALLET_ERROR, " Private key for address " + strAddress + " is not known" );
694708 }
695709 return EncodeSecret (vchSecret);
710+ },
711+ };
696712}
697713
698714
699- UniValue dumpwallet (const JSONRPCRequest& request )
715+ RPCHelpMan dumpwallet ()
700716{
701- RPCHelpMan{" dumpwallet" ,
717+ return RPCHelpMan{" dumpwallet" ,
702718 " \n Dumps all wallet keys in a human-readable format to a server-side file. This does not allow overwriting existing files.\n "
703719 " Imported scripts are included in the dumpfile, but corresponding BIP173 addresses, etc. may not be added automatically by importwallet.\n "
704720 " 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 "
@@ -716,8 +732,8 @@ UniValue dumpwallet(const JSONRPCRequest& request)
716732 HelpExampleCli (" dumpwallet" , " \" test\" " )
717733 + HelpExampleRpc (" dumpwallet" , " \" test\" " )
718734 },
719- }. Check ( request);
720-
735+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
736+ {
721737 std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest (request);
722738 if (!pwallet) return NullUniValue;
723739
@@ -829,6 +845,8 @@ UniValue dumpwallet(const JSONRPCRequest& request)
829845 reply.pushKV (" filename" , filepath.string ());
830846
831847 return reply;
848+ },
849+ };
832850}
833851
834852struct ImportData
@@ -1239,9 +1257,9 @@ static int64_t GetImportTimestamp(const UniValue& data, int64_t now)
12391257 throw JSONRPCError (RPC_TYPE_ERROR, " Missing required timestamp field for key" );
12401258}
12411259
1242- UniValue importmulti (const JSONRPCRequest& mainRequest )
1260+ RPCHelpMan importmulti ()
12431261{
1244- RPCHelpMan{" importmulti" ,
1262+ return RPCHelpMan{" importmulti" ,
12451263 " \n Import addresses/scripts (with private or public keys, redeem script (P2SH)), optionally rescanning the blockchain from the earliest creation time of the imported scripts. Requires a new wallet backup.\n "
12461264 " If an address/script is imported without all of the private keys required to spend from that address, it will be watchonly. The 'watchonly' option must be set to true in this case or a warning will be returned.\n "
12471265 " Conversely, if all the private keys are provided and the address/script is spendable, the watchonly option must be set to false, or a warning will be returned.\n "
@@ -1314,8 +1332,8 @@ UniValue importmulti(const JSONRPCRequest& mainRequest)
13141332 " { \" scriptPubKey\" : { \" address\" : \" <my 2nd address>\" }, \" label\" : \" example 2\" , \" timestamp\" : 1455191480 }]'" ) +
13151333 HelpExampleCli (" importmulti" , " '[{ \" scriptPubKey\" : { \" address\" : \" <my address>\" }, \" timestamp\" :1455191478 }]' '{ \" rescan\" : false}'" )
13161334 },
1317- }. Check ( mainRequest);
1318-
1335+ [&]( const RPCHelpMan& self, const JSONRPCRequest& mainRequest) -> UniValue
1336+ {
13191337 std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (mainRequest);
13201338 if (!wallet) return NullUniValue;
13211339 CWallet* const pwallet = wallet.get ();
@@ -1423,6 +1441,8 @@ UniValue importmulti(const JSONRPCRequest& mainRequest)
14231441 }
14241442
14251443 return response;
1444+ },
1445+ };
14261446}
14271447
14281448static UniValue ProcessDescriptorImport (CWallet * const pwallet, const UniValue& data, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
@@ -1564,9 +1584,9 @@ static UniValue ProcessDescriptorImport(CWallet * const pwallet, const UniValue&
15641584 return result;
15651585}
15661586
1567- UniValue importdescriptors (const JSONRPCRequest& main_request )
1587+ RPCHelpMan importdescriptors ()
15681588{
1569- RPCHelpMan{" importdescriptors" ,
1589+ return RPCHelpMan{" importdescriptors" ,
15701590 " \n Import descriptors. This will trigger a rescan of the blockchain based on the earliest timestamp of all descriptors being imported. Requires a new wallet backup.\n "
15711591 " \n Note: This call can take over an hour to complete if using an early timestamp; during that time, other rpc calls\n "
15721592 " may report that the imported keys, addresses or scripts exist but related transactions are still missing.\n " ,
@@ -1615,8 +1635,8 @@ UniValue importdescriptors(const JSONRPCRequest& main_request)
16151635 " { \" desc\" : \" <my desccriptor 2>\" , \" label\" : \" example 2\" , \" timestamp\" : 1455191480 }]'" ) +
16161636 HelpExampleCli (" importdescriptors" , " '[{ \" desc\" : \" <my descriptor>\" , \" timestamp\" :1455191478, \" active\" : true, \" range\" : [0,100], \" label\" : \" <my bech32 wallet>\" }]'" )
16171637 },
1618- }. Check ( main_request);
1619-
1638+ [&]( const RPCHelpMan& self, const JSONRPCRequest& main_request) -> UniValue
1639+ {
16201640 std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (main_request);
16211641 if (!wallet) return NullUniValue;
16221642 CWallet* const pwallet = wallet.get ();
@@ -1713,4 +1733,6 @@ UniValue importdescriptors(const JSONRPCRequest& main_request)
17131733 }
17141734
17151735 return response;
1736+ },
1737+ };
17161738}
0 commit comments