Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manage names tab merged against current master #187

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ QT_FORMS_UI = \
qt/forms/debugwindow.ui \
qt/forms/sendcoinsdialog.ui \
qt/forms/sendcoinsentry.ui \
qt/forms/managenamespage.ui \
qt/forms/configurenamedialog.ui \
qt/forms/signverifymessagedialog.ui \
qt/forms/transactiondescdialog.ui

Expand All @@ -126,13 +128,16 @@ QT_MOC_CPP = \
qt/moc_clientmodel.cpp \
qt/moc_coincontroldialog.cpp \
qt/moc_coincontroltreewidget.cpp \
qt/moc_configurenamedialog.cpp \
qt/moc_csvmodelwriter.cpp \
qt/moc_editaddressdialog.cpp \
qt/moc_guiutil.cpp \
qt/moc_intro.cpp \
qt/moc_macdockiconhandler.cpp \
qt/moc_macnotificationhandler.cpp \
qt/moc_modaloverlay.cpp \
qt/moc_managenamespage.cpp \
qt/moc_nametablemodel.cpp \
qt/moc_notificator.cpp \
qt/moc_openuridialog.cpp \
qt/moc_optionsdialog.cpp \
Expand Down Expand Up @@ -195,16 +200,20 @@ BITCOIN_QT_H = \
qt/clientmodel.h \
qt/coincontroldialog.h \
qt/coincontroltreewidget.h \
qt/configurenamedialog.h \
qt/csvmodelwriter.h \
qt/configurenamedialog.h \
qt/editaddressdialog.h \
qt/guiconstants.h \
qt/guiutil.h \
qt/intro.h \
qt/macdockiconhandler.h \
qt/macnotificationhandler.h \
qt/modaloverlay.h \
qt/managenamespage.h \
qt/networkstyle.h \
qt/notificator.h \
qt/nametablemodel.h \
qt/openuridialog.h \
qt/optionsdialog.h \
qt/optionsmodel.h \
Expand Down Expand Up @@ -291,8 +300,10 @@ RES_ICONS = \
qt/res/icons/tx_input.png \
qt/res/icons/tx_output.png \
qt/res/icons/tx_mined.png \
qt/res/icons/tx_nameop.png \
qt/res/icons/warning.png \
qt/res/icons/verify.png
qt/res/icons/verify.png \
qt/res/icons/transaction_abandoned.png

BITCOIN_QT_BASE_CPP = \
qt/bantablemodel.cpp \
Expand Down Expand Up @@ -326,7 +337,10 @@ BITCOIN_QT_WALLET_CPP = \
qt/askpassphrasedialog.cpp \
qt/coincontroldialog.cpp \
qt/coincontroltreewidget.cpp \
qt/configurenamedialog.cpp \
qt/editaddressdialog.cpp \
qt/managenamespage.cpp \
qt/nametablemodel.cpp \
qt/openuridialog.cpp \
qt/overviewpage.cpp \
qt/paymentrequestplus.cpp \
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile.qttest.include
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ TEST_QT_MOC_CPP = \

if ENABLE_WALLET
TEST_QT_MOC_CPP += \
qt/test/moc_managenamestests.cpp \
qt/test/moc_paymentservertests.cpp \
qt/test/moc_wallettests.cpp
endif
Expand All @@ -20,6 +21,7 @@ TEST_QT_H = \
qt/test/compattests.h \
qt/test/rpcnestedtests.h \
qt/test/uritests.h \
qt/test/managenamestests.h \
qt/test/paymentrequestdata.h \
qt/test/paymentservertests.h \
qt/test/wallettests.h
Expand All @@ -43,6 +45,7 @@ qt_test_test_namecoin_qt_SOURCES = \
$(TEST_BITCOIN_H)
if ENABLE_WALLET
qt_test_test_namecoin_qt_SOURCES += \
qt/test/managenamestests.cpp \
qt/test/paymentservertests.cpp \
qt/test/wallettests.cpp \
wallet/test/wallet_test_fixture.cpp
Expand Down
3 changes: 2 additions & 1 deletion src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ BITCOIN_TESTS += \
wallet/test/wallet_test_fixture.h \
wallet/test/accounting_tests.cpp \
wallet/test/wallet_tests.cpp \
wallet/test/crypto_tests.cpp
wallet/test/crypto_tests.cpp \
wallet/test/wallet_name_pending_tests.cpp
endif

test_test_namecoin_SOURCES = $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES)
Expand Down
48 changes: 48 additions & 0 deletions src/names/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
#ifndef H_BITCOIN_NAMES_COMMON
#define H_BITCOIN_NAMES_COMMON

#include <base58.h>
#include <compat/endian.h>
#include <primitives/transaction.h>
#include <script/script.h>
#include <serialize.h>
#include <uint256.h>

#include <map>
#include <set>
Expand Down Expand Up @@ -477,4 +479,50 @@ class CNameCache

};

/* ************************************************************************** */
/* CNamePendingData. */

/**
* Keeps track of name_new data for a pending name_firstupdate. This is
* serialized to the wallet so that the firstupdate can be broadcast
* between client runs.
*/
class CNamePendingData
{
private:
CScript toAddress;
uint256 hex;
uint160 rand;
valtype vchData;

public:
ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE (*(CScriptBase*)(&toAddress));
READWRITE(hex);
READWRITE(rand);
READWRITE(vchData);
}

inline const std::string getToAddress()
{
CTxDestination dest;
if (ExtractDestination (toAddress, dest))
return EncodeDestination (dest);
return "";
}
inline const std::string getHex() { return hex.GetHex(); }
inline const std::string getRand() { return rand.GetHex(); }
inline const std::string getData() { return ValtypeToString(vchData); }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand the code correctly, you are actually storing the address in its string representation in the vchType. Similarly for hex and rand, which are stored as hex strings, right?

I think since you have this wrapper class and already need to convert between string and vchType, you should actually encode the data properly: The address can be a CScript, and hex/rand can be the actual binary data in vchType, not the hex string.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm down to this last one before I start doing more testing, but I'm a little confused. Do you want me to not return std::string and instead return standard internal types like CScript etc? Or are you saying I can leave it accepting/returning std::string but encode internally and serialize to the reference types (CScript, etc)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got it working the first way, accepting/returning std::string but serializing toAddress, txid, rand to CScript, uint256, uint160 respectively. If you had something different in mind, let me know. For the way the UI code is using the wallet, it's easier for me to just use strings and it allows me to not have to mess with internal types in the Qt code. But I can change if required.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Yes, that's exactly what I meant - storing and serialising as raw data. Interfacing to the UI as strings is certainly fine.


inline void setToAddress(const std::string &strToAddress) {
toAddress = GetScriptForDestination(DecodeDestination(strToAddress));
}
inline void setHex(const std::string &strHex) { hex.SetHex(strHex); }
inline void setRand(const std::string &strRand) { rand.SetHex(strRand); }
inline void setData(const std::string &strData) { vchData = ValtypeFromString(strData); }
};

#endif // H_BITCOIN_NAMES_COMMON
1 change: 1 addition & 0 deletions src/qt/bitcoin.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<file alias="tx_input">res/icons/tx_input.png</file>
<file alias="tx_output">res/icons/tx_output.png</file>
<file alias="tx_inout">res/icons/tx_inout.png</file>
<file alias="tx_nameop">res/icons/tx_nameop.png</file>
<file alias="lock_closed">res/icons/lock_closed.png</file>
<file alias="lock_open">res/icons/lock_open.png</file>
<file alias="key">res/icons/key.png</file>
Expand Down
24 changes: 24 additions & 0 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <qt/clientmodel.h>
#include <qt/guiconstants.h>
#include <qt/guiutil.h>
#include <qt/managenamespage.h>
#include <qt/modaloverlay.h>
#include <qt/networkstyle.h>
#include <qt/notificator.h>
Expand Down Expand Up @@ -43,6 +44,7 @@
#include <QMenuBar>
#include <QMessageBox>
#include <QMimeData>
#include <QProgressBar>
#include <QProgressDialog>
#include <QSettings>
#include <QShortcut>
Expand Down Expand Up @@ -313,6 +315,17 @@ void BitcoinGUI::createActions()
historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
tabGroup->addAction(historyAction);

manageNamesAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Manage Names"), this);
manageNamesAction->setStatusTip(tr("Manage names registered via Namecoin"));
manageNamesAction->setToolTip(manageNamesAction->statusTip());
manageNamesAction->setCheckable(true);
manageNamesAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6));
tabGroup->addAction(manageNamesAction);

manageNamesMenuAction = new QAction(QIcon(":/icons/bitcoin"), manageNamesAction->text(), this);
manageNamesMenuAction->setStatusTip(manageNamesAction->statusTip());
manageNamesMenuAction->setToolTip(manageNamesMenuAction->statusTip());

#ifdef ENABLE_WALLET
// These showNormalIfMinimized are needed because Send Coins and Receive Coins
// can be triggered from the tray menu, and need to show the GUI to be useful.
Expand All @@ -328,6 +341,8 @@ void BitcoinGUI::createActions()
connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
connect(manageNamesAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(manageNamesAction, SIGNAL(triggered()), this, SLOT(gotoManageNamesPage()));
#endif // ENABLE_WALLET

quitAction = new QAction(platformStyle->TextColorIcon(":/icons/quit"), tr("E&xit"), this);
Expand Down Expand Up @@ -462,6 +477,7 @@ void BitcoinGUI::createToolBars()
toolbar->addAction(sendCoinsAction);
toolbar->addAction(receiveCoinsAction);
toolbar->addAction(historyAction);
toolbar->addAction(manageNamesAction);
overviewAction->setChecked(true);
}
}
Expand Down Expand Up @@ -561,6 +577,7 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
receiveCoinsAction->setEnabled(enabled);
receiveCoinsMenuAction->setEnabled(enabled);
historyAction->setEnabled(enabled);
manageNamesAction->setEnabled(enabled);
encryptWalletAction->setEnabled(enabled);
backupWalletAction->setEnabled(enabled);
changePassphraseAction->setEnabled(enabled);
Expand Down Expand Up @@ -608,6 +625,7 @@ void BitcoinGUI::createTrayIconMenu()
trayIconMenu->addSeparator();
trayIconMenu->addAction(sendCoinsMenuAction);
trayIconMenu->addAction(receiveCoinsMenuAction);
trayIconMenu->addAction(manageNamesMenuAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(signMessageAction);
trayIconMenu->addAction(verifyMessageAction);
Expand Down Expand Up @@ -703,6 +721,12 @@ void BitcoinGUI::gotoSendCoinsPage(QString addr)
if (walletFrame) walletFrame->gotoSendCoinsPage(addr);
}

void BitcoinGUI::gotoManageNamesPage()
{
manageNamesAction->setChecked(true);
if (walletFrame) walletFrame->gotoManageNamesPage();
}

void BitcoinGUI::gotoSignMessageTab(QString addr)
{
if (walletFrame) walletFrame->gotoSignMessageTab(addr);
Expand Down
4 changes: 4 additions & 0 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class BitcoinGUI : public QMainWindow
QAction *sendCoinsMenuAction;
QAction *usedSendingAddressesAction;
QAction *usedReceivingAddressesAction;
QAction *manageNamesAction;
QAction *manageNamesMenuAction;
QAction *signMessageAction;
QAction *verifyMessageAction;
QAction *aboutAction;
Expand Down Expand Up @@ -199,6 +201,8 @@ private Q_SLOTS:
void gotoReceiveCoinsPage();
/** Switch to send coins page */
void gotoSendCoinsPage(QString addr = "");
/** Switch to manage names page */
void gotoManageNamesPage();

/** Show Sign/Verify Message dialog and switch to sign message tab */
void gotoSignMessageTab(QString addr = "");
Expand Down
Loading