Skip to content

Commit

Permalink
Version 1.2.1 Release init
Browse files Browse the repository at this point in the history
- Export Keys Function added
- Import Keys Function added
- Fixed StakeOnly Command via Walletpassphrase
- Version Update
- Zapwallettxes now as native RPC command
  • Loading branch information
Oliver Ziegler authored and Oliver Ziegler committed Mar 20, 2019
1 parent e36d025 commit 2355302
Show file tree
Hide file tree
Showing 18 changed files with 359 additions and 10 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -2,7 +2,7 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 1)
define(_CLIENT_VERSION_MINOR, 2)
define(_CLIENT_VERSION_REVISION, 0)
define(_CLIENT_VERSION_REVISION, 1)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2018)
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Expand Up @@ -16,7 +16,7 @@
//! These need to be macros, as clientversion.cpp's and bitcoin*-res.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 1
#define CLIENT_VERSION_MINOR 2
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_REVISION 1
#define CLIENT_VERSION_BUILD 0

//! Set to true for release, false for prerelease or test build
Expand Down
2 changes: 2 additions & 0 deletions src/qt/bitcoin.qrc
Expand Up @@ -52,6 +52,8 @@
<file alias="transaction_abandoned">res/icons/transaction_abandoned.png</file>
<file alias="staking_on">res/icons/staking_on.png</file>
<file alias="staking_off">res/icons/staking_off.png</file>
<file alias="key_export">res/icons/key_export.png</file>
<file alias="key_import">res/icons/key_import.png</file>
</qresource>
<qresource prefix="/movies">
<file alias="spinner-000">res/movies/spinner-000.png</file>
Expand Down
19 changes: 19 additions & 0 deletions src/qt/bitcoingui.cpp
Expand Up @@ -51,6 +51,7 @@
#include <QDesktopWidget>
#include <QDir>
#include <QDragEnterEvent>
#include <QFileDialog>
#include <QInputDialog>
#include <QListWidget>
#include <QMenuBar>
Expand Down Expand Up @@ -146,6 +147,8 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *n
lockWalletAction(0),
toggleStakingAction(0),
easysplitAction(0),
exportWalletAction(0),
importWalletAction(0),
platformStyle(platformStyle)
{
GUIUtil::restoreWindowGeometry("nWindow", QSize(840, 600), this);
Expand Down Expand Up @@ -406,9 +409,18 @@ void BitcoinGUI::createActions()
changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption"));
signMessageAction = new QAction(platformStyle->TextColorIcon(":/icons/edit"), tr("Sign &message..."), this);
signMessageAction->setStatusTip(tr("Sign messages with your Trezarcoin addresses to prove you own them"));

verifyMessageAction = new QAction(platformStyle->TextColorIcon(":/icons/verify"), tr("&Verify message..."), this);
verifyMessageAction->setStatusTip(tr("Verify messages to ensure they were signed with specified Trezarcoin addresses"));

//Export PrivKeys
exportWalletAction = new QAction(platformStyle->TextColorIcon(":/icons/key_export"), tr("&Export keys"), this);
exportWalletAction->setStatusTip(tr("Export your PrivateKeys and PublicKeys into a Textfile."));

//Import PrivKeys
importWalletAction = new QAction(platformStyle->TextColorIcon(":/icons/key_import"), tr("&Import keys"), this);
importWalletAction->setStatusTip(tr("Import your PrivateKeys and PublicKeys from a Textfile."));

openRPCConsoleAction = new QAction(platformStyle->TextColorIcon(":/icons/debugwindow"), tr("&Debug window"), this);
openRPCConsoleAction->setStatusTip(tr("Open debugging and diagnostic console"));
// initially disable the debug window menu item
Expand Down Expand Up @@ -448,6 +460,8 @@ void BitcoinGUI::createActions()
connect(usedSendingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedSendingAddresses()));
connect(usedReceivingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedReceivingAddresses()));
connect(openAction, SIGNAL(triggered()), this, SLOT(openClicked()));
connect(exportWalletAction, SIGNAL(triggered()), walletFrame, SLOT(exportWallet()));
connect(importWalletAction, SIGNAL(triggered()), walletFrame, SLOT(importWallet()));
}
#endif // ENABLE_WALLET

Expand Down Expand Up @@ -476,6 +490,9 @@ void BitcoinGUI::createMenuBar()
file->addSeparator();
file->addAction(usedSendingAddressesAction);
file->addAction(usedReceivingAddressesAction);
file->addSeparator();
file->addAction(exportWalletAction);
file->addAction(importWalletAction);
}
file->addAction(quitAction);

Expand Down Expand Up @@ -625,6 +642,8 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
usedSendingAddressesAction->setEnabled(enabled);
usedReceivingAddressesAction->setEnabled(enabled);
openAction->setEnabled(enabled);
exportWalletAction->setEnabled(enabled);
importWalletAction->setEnabled(enabled);
}

void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
Expand Down
6 changes: 6 additions & 0 deletions src/qt/bitcoingui.h
Expand Up @@ -126,6 +126,8 @@ class BitcoinGUI : public QMainWindow
QAction *lockWalletAction;
QAction *toggleStakingAction;
QAction *easysplitAction;
QAction *exportWalletAction;
QAction *importWalletAction;

QSystemTrayIcon *trayIcon;
QMenu *trayIconMenu;
Expand Down Expand Up @@ -160,6 +162,10 @@ class BitcoinGUI : public QMainWindow
/** Disconnect core signals from GUI client */
void unsubscribeFromCoreSignals();

/* Wallet keys export / import */
void exportWallet();
void importWallet();

Q_SIGNALS:
/** Signal raised when a URI was entered or dragged to the GUI */
void receivedURI(const QString &uri);
Expand Down
Binary file added src/qt/res/icons/key_export.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/qt/res/icons/key_import.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions src/qt/walletframe.cpp
Expand Up @@ -246,3 +246,17 @@ WalletView *WalletFrame::currentWalletView()
return qobject_cast<WalletView*>(walletStack->currentWidget());
}

void WalletFrame::exportWallet()
{
WalletView *walletView = currentWalletView();
if (walletView)
walletView->exportWallet();
}

void WalletFrame::importWallet()
{
WalletView *walletView = currentWalletView();
if (walletView)
walletView->importWallet();
}

4 changes: 4 additions & 0 deletions src/qt/walletframe.h
Expand Up @@ -89,6 +89,10 @@ public Q_SLOTS:
void usedSendingAddresses();
/** Show used receiving addresses */
void usedReceivingAddresses();

/* Wallet keys export / import */
void exportWallet();
void importWallet();
};

#endif // BITCOIN_QT_WALLETFRAME_H
8 changes: 8 additions & 0 deletions src/qt/walletmodel.cpp
Expand Up @@ -469,6 +469,14 @@ bool WalletModel::backupWallet(const QString &filename)
return wallet->BackupWallet(filename.toLocal8Bit().data());
}

bool WalletModel::exportWallet(const QString &filename) {
return(wallet->ExportWallet(wallet, filename.toLocal8Bit().data()));
}

bool WalletModel::importWallet(const QString &filename) {
return(wallet->ImportWallet(wallet, filename.toLocal8Bit().data()));
}

void WalletModel::getStakeWeightQuick(const int64_t& nTime, const int64_t& nValue, uint64_t& nWeight) {
wallet->GetStakeWeightQuick(nTime, nValue, nWeight);
}
Expand Down
3 changes: 3 additions & 0 deletions src/qt/walletmodel.h
Expand Up @@ -166,6 +166,9 @@ class WalletModel : public QObject
bool backupWallet(const QString &filename);
// Stake weight calculation
void getStakeWeightQuick(const int64_t& nTime, const int64_t& nValue, uint64_t& nWeight);
/* Wallet keys export / import */
bool exportWallet(const QString &filename);
bool importWallet(const QString &filename);
// RAI object for unlocking wallet, returned by requestUnlock()
class UnlockContext
{
Expand Down
64 changes: 64 additions & 0 deletions src/qt/walletview.cpp
Expand Up @@ -279,6 +279,70 @@ void WalletView::backupWallet()
}
}


void WalletView::exportWallet() {

if (!walletModel)
return;
// Unlock wallet when requested by wallet model
WalletModel::UnlockContext ctx(walletModel->requestUnlock());
if (!ctx.isValid())
return;

#if (QT_VERSION < 0x050000)
QString saveDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
#else
QString saveDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
#endif

QString filename = GUIUtil::getSaveFileName(this, tr("Export Wallet Keys"), saveDir, tr("Wallet Text (*.txt)"), NULL);
if (!filename.isEmpty()) {
if (walletModel->exportWallet(filename)) {
QMessageBox::information(this,
tr("Export Complete"),
tr("All keys of your wallet have been exported into:<br>%1").arg(filename));
}
else {
QMessageBox::critical(this,
tr("Export Failed"),
tr("There was an error while exporting your wallet keys."));
}
}
walletModel->setWalletLocked(true);
}

void WalletView::importWallet() {

if(!walletModel)
return;
// Unlock wallet when requested by wallet model
WalletModel::UnlockContext ctx(walletModel->requestUnlock());
if (!ctx.isValid())
return;

#if (QT_VERSION < 0x050000)
QString openDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
#else
QString openDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
#endif

QString filename = GUIUtil::getOpenFileName(this, tr("Import Wallet Keys"), openDir, tr("Wallet Text (*.txt)"), NULL);
if (!filename.isEmpty()) {
if (walletModel->importWallet(filename)) {
QMessageBox::information(this,
tr("Import Complete"),
tr("All keys have been imported into your wallet from:<br>%1").arg(filename));

}
else {
QMessageBox::critical(this,
tr("Import Failed"),
tr("There was an error while importing wallet keys from:<br>%1").arg(filename));
}
}
walletModel->setWalletLocked(true);
}

void WalletView::changePassphrase()
{
AskPassphraseDialog dlg(AskPassphraseDialog::ChangePass, this);
Expand Down
3 changes: 3 additions & 0 deletions src/qt/walletview.h
Expand Up @@ -104,6 +104,9 @@ public Q_SLOTS:
void unlockWallet();
void unlockWalletStaking();
void lockWallet();
/* Wallet keys export / import */
void exportWallet();
void importWallet();

/** Show used sending addresses */
void usedSendingAddresses();
Expand Down
1 change: 1 addition & 0 deletions src/rpc/client.cpp
Expand Up @@ -57,6 +57,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "listaccounts", 0 },
{ "listaccounts", 1 },
{ "walletpassphrase", 1 },
{ "walletpassphrase", 2 },
{ "getblocktemplate", 0 },
{ "listsinceblock", 1 },
{ "listsinceblock", 2 },
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/rpcdump.cpp
Expand Up @@ -60,7 +60,7 @@ std::string static EncodeDumpString(const std::string &str) {
return ret.str();
}

std::string DecodeDumpString(const std::string &str) {
std::string DecodeDumpString_one(const std::string &str) {
std::stringstream ret;
for (unsigned int pos = 0; pos < str.length(); pos++) {
unsigned char c = str[pos];
Expand Down Expand Up @@ -480,7 +480,7 @@ UniValue importwallet(const UniValue& params, bool fHelp)
if (vstr[nStr] == "reserve=1")
fLabel = false;
if (boost::algorithm::starts_with(vstr[nStr], "label=")) {
strLabel = DecodeDumpString(vstr[nStr].substr(6));
strLabel = DecodeDumpString_one(vstr[nStr].substr(6));
fLabel = true;
}
}
Expand Down
22 changes: 17 additions & 5 deletions src/wallet/rpcwallet.cpp
Expand Up @@ -1930,7 +1930,7 @@ UniValue walletpassphrase(const UniValue& params, bool fHelp)
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;

if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2))
if (pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 3))
throw runtime_error(
"walletpassphrase \"passphrase\" timeout [mintonly]\n"
"\nStores the wallet decryption key in memory for 'timeout' seconds.\n"
Expand Down Expand Up @@ -1984,10 +1984,7 @@ UniValue walletpassphrase(const UniValue& params, bool fHelp)

/* Disables some wallet functionality if unlocked for staking only */
if (params.size() > 2)
{
if ((params[2].get_str() == "true") || (params[2].get_str() == "True"))
fWalletUnlockStakingOnly = true;
}
fWalletUnlockStakingOnly = params[2].get_bool();
else
fWalletUnlockStakingOnly = false;

Expand Down Expand Up @@ -2786,6 +2783,20 @@ UniValue getstakereport(const UniValue& params, bool fHelp)

return result;
}
// zapwallettxes: rescanning the whole blockchain for missing Tx
UniValue zapwallettxes(const UniValue& params, bool fHelp)
{
if ((params.size()>0) || (fHelp))
throw runtime_error(
"zapwallettxes\n"
"Runs a rescan to find missing Tx.\n");

pwalletMain->MarkDirty();
pwalletMain->nTimeFirstKey = 1;
pwalletMain->ScanForWalletTransactions(chainActive.Genesis(), true);

return NullUniValue;
}

extern UniValue dumpprivkey(const UniValue& params, bool fHelp); // in rpcdump.cpp
extern UniValue importprivkey(const UniValue& params, bool fHelp);
Expand Down Expand Up @@ -2852,6 +2863,7 @@ static const CRPCCommand commands[] =
{ "wallet", "walletpassphrasechange", &walletpassphrasechange, true },
{ "wallet", "walletpassphrase", &walletpassphrase, true },
{ "wallet", "removeprunedfunds", &removeprunedfunds, true },
{ "wallet", "zapwallettxes", &zapwallettxes, true },
};

void RegisterWalletRPCCommands(CRPCTable &tableRPC)
Expand Down

0 comments on commit 2355302

Please sign in to comment.