@@ -90,9 +90,9 @@ static void RescanWallet(CWallet& wallet, const WalletRescanReserver& reserver,
90
90
}
91
91
}
92
92
93
- UniValue importprivkey (const JSONRPCRequest& request )
93
+ RPCHelpMan importprivkey ()
94
94
{
95
- RPCHelpMan{" importprivkey" ,
95
+ return RPCHelpMan{" importprivkey" ,
96
96
" \n Adds a private key (as returned by dumpprivkey) to your wallet. Requires a new wallet backup.\n "
97
97
" Hint: use importmulti to import more than one private key.\n "
98
98
" \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)
116
116
" \n As a JSON-RPC call\n "
117
117
+ HelpExampleRpc (" importprivkey" , " \" mykey\" , \" testing\" , false" )
118
118
},
119
- }. Check ( request);
120
-
119
+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
120
+ {
121
121
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
122
122
if (!wallet) return NullUniValue;
123
123
CWallet* const pwallet = wallet.get ();
@@ -189,11 +189,13 @@ UniValue importprivkey(const JSONRPCRequest& request)
189
189
}
190
190
191
191
return NullUniValue;
192
+ },
193
+ };
192
194
}
193
195
194
- UniValue abortrescan (const JSONRPCRequest& request )
196
+ RPCHelpMan abortrescan ()
195
197
{
196
- RPCHelpMan{" abortrescan" ,
198
+ return RPCHelpMan{" abortrescan" ,
197
199
" \n Stops current wallet rescan triggered by an RPC call, e.g. by an importprivkey call.\n "
198
200
" Note: Use \" getwalletinfo\" to query the scanning progress.\n " ,
199
201
{},
@@ -206,20 +208,22 @@ UniValue abortrescan(const JSONRPCRequest& request)
206
208
" \n As a JSON-RPC call\n "
207
209
+ HelpExampleRpc (" abortrescan" , " " )
208
210
},
209
- }. Check ( request);
210
-
211
+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
212
+ {
211
213
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
212
214
if (!wallet) return NullUniValue;
213
215
CWallet* const pwallet = wallet.get ();
214
216
215
217
if (!pwallet->IsScanning () || pwallet->IsAbortingRescan ()) return false ;
216
218
pwallet->AbortRescan ();
217
219
return true ;
220
+ },
221
+ };
218
222
}
219
223
220
- UniValue importaddress (const JSONRPCRequest& request )
224
+ RPCHelpMan importaddress ()
221
225
{
222
- RPCHelpMan{" importaddress" ,
226
+ return RPCHelpMan{" importaddress" ,
223
227
" \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 "
224
228
" \n Note: This call can take over an hour to complete if rescan is true, during that time, other rpc calls\n "
225
229
" 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)
243
247
" \n As a JSON-RPC call\n "
244
248
+ HelpExampleRpc (" importaddress" , " \" myaddress\" , \" testing\" , false" )
245
249
},
246
- }. Check ( request);
247
-
250
+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
251
+ {
248
252
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
249
253
if (!wallet) return NullUniValue;
250
254
CWallet* const pwallet = wallet.get ();
@@ -315,20 +319,22 @@ UniValue importaddress(const JSONRPCRequest& request)
315
319
}
316
320
317
321
return NullUniValue;
322
+ },
323
+ };
318
324
}
319
325
320
- UniValue importprunedfunds (const JSONRPCRequest& request )
326
+ RPCHelpMan importprunedfunds ()
321
327
{
322
- RPCHelpMan{" importprunedfunds" ,
328
+ return RPCHelpMan{" importprunedfunds" ,
323
329
" \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 " ,
324
330
{
325
331
{" rawtransaction" , RPCArg::Type::STR_HEX, RPCArg::Optional::NO, " A raw transaction in hex funding an already-existing address in wallet" },
326
332
{" txoutproof" , RPCArg::Type::STR_HEX, RPCArg::Optional::NO, " The hex output from gettxoutproof that contains the transaction" },
327
333
},
328
334
RPCResult{RPCResult::Type::NONE, " " , " " },
329
335
RPCExamples{" " },
330
- }. Check ( request);
331
-
336
+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
337
+ {
332
338
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
333
339
if (!wallet) return NullUniValue;
334
340
CWallet* const pwallet = wallet.get ();
@@ -371,11 +377,13 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
371
377
}
372
378
373
379
throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " No addresses in wallet correspond to included transaction" );
380
+ },
381
+ };
374
382
}
375
383
376
- UniValue removeprunedfunds (const JSONRPCRequest& request )
384
+ RPCHelpMan removeprunedfunds ()
377
385
{
378
- RPCHelpMan{" removeprunedfunds" ,
386
+ return RPCHelpMan{" removeprunedfunds" ,
379
387
" \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 " ,
380
388
{
381
389
{" 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)
386
394
" \n As a JSON-RPC call\n "
387
395
+ HelpExampleRpc (" removeprunedfunds" , " \" a8d0c0184dde994a09ec054286f1ce581bebf46446a512166eae7628734ea0a5\" " )
388
396
},
389
- }. Check ( request);
390
-
397
+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
398
+ {
391
399
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
392
400
if (!wallet) return NullUniValue;
393
401
CWallet* const pwallet = wallet.get ();
@@ -408,11 +416,13 @@ UniValue removeprunedfunds(const JSONRPCRequest& request)
408
416
}
409
417
410
418
return NullUniValue;
419
+ },
420
+ };
411
421
}
412
422
413
- UniValue importpubkey (const JSONRPCRequest& request )
423
+ RPCHelpMan importpubkey ()
414
424
{
415
- RPCHelpMan{" importpubkey" ,
425
+ return RPCHelpMan{" importpubkey" ,
416
426
" \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 "
417
427
" Hint: use importmulti to import more than one public key.\n "
418
428
" \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)
432
442
" \n As a JSON-RPC call\n "
433
443
+ HelpExampleRpc (" importpubkey" , " \" mypubkey\" , \" testing\" , false" )
434
444
},
435
- }. Check ( request);
436
-
445
+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
446
+ {
437
447
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
438
448
if (!wallet) return NullUniValue;
439
449
CWallet* const pwallet = wallet.get ();
@@ -492,12 +502,14 @@ UniValue importpubkey(const JSONRPCRequest& request)
492
502
}
493
503
494
504
return NullUniValue;
505
+ },
506
+ };
495
507
}
496
508
497
509
498
- UniValue importwallet (const JSONRPCRequest& request )
510
+ RPCHelpMan importwallet ()
499
511
{
500
- RPCHelpMan{" importwallet" ,
512
+ return RPCHelpMan{" importwallet" ,
501
513
" \n Imports keys from a wallet dump file (see dumpwallet). Requires a new wallet backup to include imported keys.\n "
502
514
" Note: Use \" getwalletinfo\" to query the scanning progress.\n " ,
503
515
{
@@ -512,8 +524,8 @@ UniValue importwallet(const JSONRPCRequest& request)
512
524
" \n Import using the json rpc call\n "
513
525
+ HelpExampleRpc (" importwallet" , " \" test\" " )
514
526
},
515
- }. Check ( request);
516
-
527
+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
528
+ {
517
529
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
518
530
if (!wallet) return NullUniValue;
519
531
CWallet* const pwallet = wallet.get ();
@@ -649,11 +661,13 @@ UniValue importwallet(const JSONRPCRequest& request)
649
661
throw JSONRPCError (RPC_WALLET_ERROR, " Error adding some keys/scripts to wallet" );
650
662
651
663
return NullUniValue;
664
+ },
665
+ };
652
666
}
653
667
654
- UniValue dumpprivkey (const JSONRPCRequest& request )
668
+ RPCHelpMan dumpprivkey ()
655
669
{
656
- RPCHelpMan{" dumpprivkey" ,
670
+ return RPCHelpMan{" dumpprivkey" ,
657
671
" \n Reveals the private key corresponding to 'address'.\n "
658
672
" Then the importprivkey can be used with this output\n " ,
659
673
{
@@ -667,8 +681,8 @@ UniValue dumpprivkey(const JSONRPCRequest& request)
667
681
+ HelpExampleCli (" importprivkey" , " \" mykey\" " )
668
682
+ HelpExampleRpc (" dumpprivkey" , " \" myaddress\" " )
669
683
},
670
- }. Check ( request);
671
-
684
+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
685
+ {
672
686
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
673
687
if (!wallet) return NullUniValue;
674
688
const CWallet* const pwallet = wallet.get ();
@@ -693,12 +707,14 @@ UniValue dumpprivkey(const JSONRPCRequest& request)
693
707
throw JSONRPCError (RPC_WALLET_ERROR, " Private key for address " + strAddress + " is not known" );
694
708
}
695
709
return EncodeSecret (vchSecret);
710
+ },
711
+ };
696
712
}
697
713
698
714
699
- UniValue dumpwallet (const JSONRPCRequest& request )
715
+ RPCHelpMan dumpwallet ()
700
716
{
701
- RPCHelpMan{" dumpwallet" ,
717
+ return RPCHelpMan{" dumpwallet" ,
702
718
" \n Dumps all wallet keys in a human-readable format to a server-side file. This does not allow overwriting existing files.\n "
703
719
" Imported scripts are included in the dumpfile, but corresponding BIP173 addresses, etc. may not be added automatically by importwallet.\n "
704
720
" 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)
716
732
HelpExampleCli (" dumpwallet" , " \" test\" " )
717
733
+ HelpExampleRpc (" dumpwallet" , " \" test\" " )
718
734
},
719
- }. Check ( request);
720
-
735
+ [&]( const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
736
+ {
721
737
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest (request);
722
738
if (!pwallet) return NullUniValue;
723
739
@@ -829,6 +845,8 @@ UniValue dumpwallet(const JSONRPCRequest& request)
829
845
reply.pushKV (" filename" , filepath.string ());
830
846
831
847
return reply;
848
+ },
849
+ };
832
850
}
833
851
834
852
struct ImportData
@@ -1239,9 +1257,9 @@ static int64_t GetImportTimestamp(const UniValue& data, int64_t now)
1239
1257
throw JSONRPCError (RPC_TYPE_ERROR, " Missing required timestamp field for key" );
1240
1258
}
1241
1259
1242
- UniValue importmulti (const JSONRPCRequest& mainRequest )
1260
+ RPCHelpMan importmulti ()
1243
1261
{
1244
- RPCHelpMan{" importmulti" ,
1262
+ return RPCHelpMan{" importmulti" ,
1245
1263
" \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 "
1246
1264
" 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 "
1247
1265
" 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)
1314
1332
" { \" scriptPubKey\" : { \" address\" : \" <my 2nd address>\" }, \" label\" : \" example 2\" , \" timestamp\" : 1455191480 }]'" ) +
1315
1333
HelpExampleCli (" importmulti" , " '[{ \" scriptPubKey\" : { \" address\" : \" <my address>\" }, \" timestamp\" :1455191478 }]' '{ \" rescan\" : false}'" )
1316
1334
},
1317
- }. Check ( mainRequest);
1318
-
1335
+ [&]( const RPCHelpMan& self, const JSONRPCRequest& mainRequest) -> UniValue
1336
+ {
1319
1337
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (mainRequest);
1320
1338
if (!wallet) return NullUniValue;
1321
1339
CWallet* const pwallet = wallet.get ();
@@ -1423,6 +1441,8 @@ UniValue importmulti(const JSONRPCRequest& mainRequest)
1423
1441
}
1424
1442
1425
1443
return response;
1444
+ },
1445
+ };
1426
1446
}
1427
1447
1428
1448
static 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&
1564
1584
return result;
1565
1585
}
1566
1586
1567
- UniValue importdescriptors (const JSONRPCRequest& main_request )
1587
+ RPCHelpMan importdescriptors ()
1568
1588
{
1569
- RPCHelpMan{" importdescriptors" ,
1589
+ return RPCHelpMan{" importdescriptors" ,
1570
1590
" \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 "
1571
1591
" \n Note: This call can take over an hour to complete if using an early timestamp; during that time, other rpc calls\n "
1572
1592
" 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)
1615
1635
" { \" desc\" : \" <my desccriptor 2>\" , \" label\" : \" example 2\" , \" timestamp\" : 1455191480 }]'" ) +
1616
1636
HelpExampleCli (" importdescriptors" , " '[{ \" desc\" : \" <my descriptor>\" , \" timestamp\" :1455191478, \" active\" : true, \" range\" : [0,100], \" label\" : \" <my bech32 wallet>\" }]'" )
1617
1637
},
1618
- }. Check ( main_request);
1619
-
1638
+ [&]( const RPCHelpMan& self, const JSONRPCRequest& main_request) -> UniValue
1639
+ {
1620
1640
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (main_request);
1621
1641
if (!wallet) return NullUniValue;
1622
1642
CWallet* const pwallet = wallet.get ();
@@ -1713,4 +1733,6 @@ UniValue importdescriptors(const JSONRPCRequest& main_request)
1713
1733
}
1714
1734
1715
1735
return response;
1736
+ },
1737
+ };
1716
1738
}
0 commit comments