mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-22 12:34:24 +00:00
support RPC stop and encryptwallet with UI
This commit is contained in:
parent
5d7cebdadc
commit
1a3f0da922
@ -221,13 +221,9 @@ Value stop(const Array& params, bool fHelp)
|
|||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
"stop\n"
|
"stop\n"
|
||||||
"Stop bitcoin server.");
|
"Stop bitcoin server.");
|
||||||
#ifndef QT_GUI
|
|
||||||
// Shutdown will take long enough that the response should get back
|
// Shutdown will take long enough that the response should get back
|
||||||
CreateThread(Shutdown, NULL);
|
QueueShutdown();
|
||||||
return "bitcoin server stopping";
|
return "bitcoin server stopping";
|
||||||
#else
|
|
||||||
throw runtime_error("NYI: cannot shut down GUI with RPC command");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1676,11 +1672,6 @@ Value encryptwallet(const Array& params, bool fHelp)
|
|||||||
if (pwalletMain->IsCrypted())
|
if (pwalletMain->IsCrypted())
|
||||||
throw JSONRPCError(-15, "Error: running with an encrypted wallet, but encryptwallet was called.");
|
throw JSONRPCError(-15, "Error: running with an encrypted wallet, but encryptwallet was called.");
|
||||||
|
|
||||||
#ifdef QT_GUI
|
|
||||||
// shutting down via RPC while the GUI is running does not work (yet):
|
|
||||||
throw runtime_error("Not Yet Implemented: use GUI to encrypt wallet, not RPC command");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string)
|
// TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string)
|
||||||
// Alternately, find a way to make params[0] mlock()'d to begin with.
|
// Alternately, find a way to make params[0] mlock()'d to begin with.
|
||||||
SecureString strWalletPass;
|
SecureString strWalletPass;
|
||||||
@ -1698,7 +1689,7 @@ Value encryptwallet(const Array& params, bool fHelp)
|
|||||||
// BDB seems to have a bad habit of writing old data into
|
// BDB seems to have a bad habit of writing old data into
|
||||||
// slack space in .dat files; that is bad if the old data is
|
// slack space in .dat files; that is bad if the old data is
|
||||||
// unencrypted private keys. So:
|
// unencrypted private keys. So:
|
||||||
CreateThread(Shutdown, NULL);
|
QueueShutdown();
|
||||||
return "wallet encrypted; bitcoin server stopping, restart to run with encrypted wallet";
|
return "wallet encrypted; bitcoin server stopping, restart to run with encrypted wallet";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2381,9 +2372,7 @@ void ThreadRPCServer2(void* parg)
|
|||||||
strWhatAmI.c_str(),
|
strWhatAmI.c_str(),
|
||||||
GetConfigFile().c_str(),
|
GetConfigFile().c_str(),
|
||||||
EncodeBase58(&rand_pwd[0],&rand_pwd[0]+32).c_str());
|
EncodeBase58(&rand_pwd[0],&rand_pwd[0]+32).c_str());
|
||||||
#ifndef QT_GUI
|
QueueShutdown();
|
||||||
CreateThread(Shutdown, NULL);
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1812,7 +1812,7 @@ bool CheckDiskSpace(uint64 nAdditionalBytes)
|
|||||||
strMiscWarning = strMessage;
|
strMiscWarning = strMessage;
|
||||||
printf("*** %s\n", strMessage.c_str());
|
printf("*** %s\n", strMessage.c_str());
|
||||||
ThreadSafeMessageBox(strMessage, "Bitcoin", wxOK | wxICON_EXCLAMATION);
|
ThreadSafeMessageBox(strMessage, "Bitcoin", wxOK | wxICON_EXCLAMATION);
|
||||||
CreateThread(Shutdown, NULL);
|
QueueShutdown();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "wallet.h"
|
#include "wallet.h"
|
||||||
|
#include "init.h"
|
||||||
|
|
||||||
typedef void wxWindow;
|
typedef void wxWindow;
|
||||||
#define wxYES 0x00000002
|
#define wxYES 0x00000002
|
||||||
@ -71,4 +72,10 @@ inline const char* _(const char* psz)
|
|||||||
return psz;
|
return psz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void QueueShutdown()
|
||||||
|
{
|
||||||
|
// Without UI, Shutdown can simply be started in a new thread
|
||||||
|
CreateThread(Shutdown, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -111,6 +111,11 @@ void InitMessage(const std::string &message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QueueShutdown()
|
||||||
|
{
|
||||||
|
QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Translate string to current locale using Qt.
|
Translate string to current locale using Qt.
|
||||||
*/
|
*/
|
||||||
|
@ -42,6 +42,7 @@ extern bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption,
|
|||||||
extern void ThreadSafeHandleURL(const std::string& strURL);
|
extern void ThreadSafeHandleURL(const std::string& strURL);
|
||||||
extern void MainFrameRepaint();
|
extern void MainFrameRepaint();
|
||||||
extern void AddressBookRepaint();
|
extern void AddressBookRepaint();
|
||||||
|
extern void QueueShutdown();
|
||||||
extern void InitMessage(const std::string &message);
|
extern void InitMessage(const std::string &message);
|
||||||
extern std::string _(const char* psz);
|
extern std::string _(const char* psz);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user