| 1870 | } |
| 1871 | |
| 1872 | RPCHelpMan backupwallet() |
| 1873 | { |
| 1874 | return RPCHelpMan{"backupwallet", |
| 1875 | "\nSafely copies current wallet file to destination, which can be a directory or a path with filename.\n", |
| 1876 | { |
| 1877 | {"destination", RPCArg::Type::STR, RPCArg::Optional::NO, "The destination directory or file"}, |
| 1878 | }, |
| 1879 | RPCResult{RPCResult::Type::NONE, "", ""}, |
| 1880 | RPCExamples{ |
| 1881 | HelpExampleCli("backupwallet", "\"backup.dat\"") |
| 1882 | + HelpExampleRpc("backupwallet", "\"backup.dat\"") |
| 1883 | }, |
| 1884 | [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue |
| 1885 | { |
| 1886 | const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request); |
| 1887 | if (!pwallet) return NullUniValue; |
| 1888 | |
| 1889 | // Make sure the results are valid at least up to the most recent block |
| 1890 | // the user could have gotten from another RPC command prior to now |
| 1891 | pwallet->BlockUntilSyncedToCurrentChain(); |
| 1892 | |
| 1893 | LOCK(pwallet->cs_wallet); |
| 1894 | |
| 1895 | std::string strDest = request.params[0].get_str(); |
| 1896 | if (!pwallet->BackupWallet(strDest)) { |
| 1897 | throw JSONRPCError(RPC_WALLET_ERROR, "Error: Wallet backup failed!"); |
| 1898 | } |
| 1899 | |
| 1900 | return NullUniValue; |
| 1901 | }, |
| 1902 | }; |
| 1903 | } |
| 1904 | |
| 1905 | |
| 1906 | RPCHelpMan restorewallet() |
nothing calls this directly
no test coverage detected