Skip to content

Commit

Permalink
listtransactions fix, various GUI fixes.
Browse files Browse the repository at this point in the history
* listtransactions now includes name operations
* transaction details (double-click) show correct amounts for name operations
* added address column in the name table (maybe need to make it hideable? It clutters the table)
* added address to the Configure Name dialog
* added red notice about 12 blocks delay to the Configure Name dialog
* "Expires in" now shows "pending" instead of empty cell
* value length in Configure Name limited to 519 bytes (due to limitation in CScript)
* HtmlEscape for names in the GUI
  • Loading branch information
namecoin-qt committed Aug 23, 2013
1 parent f4dd400 commit bfd788d
Show file tree
Hide file tree
Showing 62 changed files with 3,935 additions and 1,269 deletions.
2 changes: 1 addition & 1 deletion project/namecoin-qt.pro
@@ -1,7 +1,7 @@
TEMPLATE = app
TARGET = namecoin-qt
macx:TARGET = "Namecoin-Qt"
VERSION = 0.3.66
VERSION = 0.3.67
QT += network
DEFINES += GUI QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE
CONFIG += no_include_pwd
Expand Down
17 changes: 11 additions & 6 deletions src/db.cpp
Expand Up @@ -8,6 +8,7 @@
#include "auxpow.h"
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/algorithm/string/predicate.hpp> // for starts_with(), ends_with()

using namespace std;
using namespace boost;
Expand Down Expand Up @@ -145,16 +146,20 @@ void CDB::Close()
unsigned int nMinutes = 0;
if (fReadOnly)
nMinutes = 1;

if (strFile == "addr.dat")
nMinutes = 2;
if (strFile == "blkindex.dat")
nMinutes = 2;
if (strFile == "blk0001.dat" || strFile == "blk0002.dat" || strFile == "blk0003.dat") // todo: make this proper :)
else if (strFile == "nameindex.dat" || strFile == "nameindexfull.dat")
nMinutes = 2;
if (strFile == "nameindex.dat" || strFile == "nameindexfull.dat")
else if (strFile == "blkindex.dat")
{
nMinutes = 2;
if (strFile == "blkindex.dat" && IsInitialBlockDownload() && nBestHeight % 5000 != 0)
nMinutes = 5;
if (IsInitialBlockDownload() && nBestHeight % 5000 != 0)
nMinutes = 5;
}
else if (boost::algorithm::starts_with(strFile, "blk") && boost::algorithm::ends_with(strFile, ".dat"))
nMinutes = 2;

dbenv.txn_checkpoint(0, nMinutes, 0);

CRITICAL_BLOCK(cs_db)
Expand Down
1 change: 1 addition & 0 deletions src/namecoin.h
Expand Up @@ -86,6 +86,7 @@ bool GetNameOfTx(const CTransaction& tx, std::vector<unsigned char>& name);
bool GetValueOfNameTx(const CTransaction& tx, std::vector<unsigned char>& value);
bool DecodeNameTx(const CTransaction& tx, int& op, int& nOut, std::vector<std::vector<unsigned char> >& vvch);
bool DecodeNameScript(const CScript& script, int& op, std::vector<std::vector<unsigned char> > &vvch);
bool GetNameAddress(const CTransaction& tx, std::string& strAddress);
std::string SendMoneyWithInputTx(CScript scriptPubKey, int64 nValue, int64 nNetFee, CWalletTx& wtxIn, CWalletTx& wtxNew, bool fAskFee);
bool CreateTransactionWithInputTx(const std::vector<std::pair<CScript, int64> >& vecSend, CWalletTx& wtxIn, int nTxOut, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet);
int64 GetNetworkFee(int nHeight);
Expand Down
26 changes: 19 additions & 7 deletions src/qt/configurenamedialog.cpp
Expand Up @@ -4,6 +4,7 @@
#include "guiutil.h"
#include "addressbookpage.h"
#include "walletmodel.h"
#include "guiconstants.h"
#include "../main.h"
#include "../hook.h"
#include "../wallet.h"
Expand All @@ -19,10 +20,11 @@
#include <QMessageBox>
#include <QClipboard>

ConfigureNameDialog::ConfigureNameDialog(const QString &_name, const QString &data, bool _firstUpdate, QWidget *parent) :
ConfigureNameDialog::ConfigureNameDialog(const QString &name_, const QString &data, const QString &address_, bool firstUpdate_, QWidget *parent) :
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint),
name(_name),
firstUpdate(_firstUpdate),
name(name_),
address(address_),
firstUpdate(firstUpdate_),
initialized(false),
ui(new Ui::ConfigureNameDialog)
{
Expand All @@ -34,15 +36,17 @@ ConfigureNameDialog::ConfigureNameDialog(const QString &_name, const QString &da

GUIUtil::setupAddressWidget(ui->transferTo, this, true);

ui->labelName->setText(name);
ui->labelName->setText(GUIUtil::HtmlEscape(name));
ui->dataEdit->setText(data);
ui->labelAddress->setText(GUIUtil::HtmlEscape(address));
ui->labelAddress->setFont(GUIUtil::bitcoinAddressFont());

ui->dataEdit->setMaxLength(MAX_VALUE_LENGTH);
ui->dataEdit->setMaxLength(GUI_MAX_VALUE_LENGTH);

returnData = data;

if (name.startsWith("d/"))
ui->labelDomain->setText(name.mid(2) + ".bit");
ui->labelDomain->setText(GUIUtil::HtmlEscape(name.mid(2) + ".bit"));
else
ui->labelDomain->setText(tr("(not a domain name)"));

Expand Down Expand Up @@ -164,7 +168,10 @@ ConfigureNameDialog::ConfigureNameDialog(const QString &_name, const QString &da
ui->transferTo->hide();
ui->addressBookButton->hide();
ui->pasteButton->hide();
ui->labelSubmitHint->setText(tr("Name_firstupdate transaction will be queued and broadcasted when corresponding name_new is %1 blocks old").arg(MIN_FIRSTUPDATE_DEPTH));
ui->labelSubmitHint->setText(
tr("Name_firstupdate transaction will be queued and broadcasted when corresponding name_new is %1 blocks old").arg(MIN_FIRSTUPDATE_DEPTH)
+ "<br/><span style='color:red'>" + tr("Do not close your client while the name is pending!") + "</span>"
);
}
else
{
Expand Down Expand Up @@ -244,6 +251,11 @@ void ConfigureNameDialog::setModel(WalletModel *walletModel)
this->walletModel = walletModel;
}

void ConfigureNameDialog::on_copyButton_clicked()
{
QApplication::clipboard()->setText(address);
}

void ConfigureNameDialog::on_pasteButton_clicked()
{
// Paste text from clipboard into recipient field
Expand Down
5 changes: 3 additions & 2 deletions src/qt/configurenamedialog.h
Expand Up @@ -17,7 +17,7 @@ class ConfigureNameDialog : public QDialog

public:

explicit ConfigureNameDialog(const QString &_name, const QString &data, bool _firstUpdate, QWidget *parent = 0);
explicit ConfigureNameDialog(const QString &name_, const QString &data, const QString &address_, bool firstUpdate_, QWidget *parent = 0);
~ConfigureNameDialog();

void setModel(WalletModel *walletModel);
Expand All @@ -27,6 +27,7 @@ public slots:
void accept();
void reject();
void on_addressBookButton_clicked();
void on_copyButton_clicked();
void on_pasteButton_clicked();
void on_nsEdit_textChanged() { if (initialized) SetDNS(); }
void on_nsTranslateEdit_textChanged(const QString &text) { if (initialized) SetDNS(); }
Expand All @@ -39,7 +40,7 @@ public slots:
QString returnData;
Ui::ConfigureNameDialog *ui;
WalletModel *walletModel;
QString name;
QString name, address;
bool firstUpdate;
bool initialized;

Expand Down
91 changes: 84 additions & 7 deletions src/qt/forms/configurenamedialog.ui
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>687</width>
<height>371</height>
<height>369</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -323,7 +323,7 @@ p, li { white-space: pre-wrap; }
</widget>
</widget>
</item>
<item row="7" column="1">
<item row="5" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand All @@ -336,7 +336,17 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item row="8" column="0">
<item row="6" column="0">
<widget class="QLabel" name="labelCurrentAddress">
<property name="text">
<string>&amp;Address:</string>
</property>
<property name="buddy">
<cstring>copyButton</cstring>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="labelTransferTo">
<property name="text">
<string>&amp;Transfer to:</string>
Expand All @@ -346,7 +356,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="8" column="1">
<item row="7" column="1">
<layout class="QHBoxLayout" name="transferToLayout">
<property name="spacing">
<number>0</number>
Expand All @@ -357,10 +367,15 @@ p, li { white-space: pre-wrap; }
<item>
<widget class="QValidatedLineEdit" name="transferTo">
<property name="toolTip">
<string>The Namecoin address to transfer domain to
(e.g. N1KHAL5C1CRzy58NdJwp1tbLze3XrkFxx9).
<string>The Namecoin address to transfer
the domain to, e.g.
N1KHAL5C1CRzy58NdJwp1tbLze3XrkFxx9

Leave empty, if not needed.</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="maxLength">
<number>34</number>
</property>
Expand Down Expand Up @@ -402,13 +417,75 @@ Leave empty, if not needed.</string>
</item>
</layout>
</item>
<item row="9" column="1">
<item row="8" column="1">
<widget class="QLabel" name="labelTransferToHint">
<property name="text">
<string>(can be left empty)</string>
</property>
</widget>
</item>
<item row="6" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="labelAddress">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Namecoin address to which the name is assigned</string>
</property>
<property name="text">
<string notr="true">N1KHAL5C1CRzy58NdJwp1tbLze3XrkFxx9</string>
</property>
<property name="indent">
<number>3</number>
</property>
<property name="buddy">
<cstring>transferTo</cstring>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="copyButton">
<property name="toolTip">
<string>Copy address to clipboard</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/editcopy</normaloff>:/icons/editcopy</iconset>
</property>
<property name="shortcut">
<string>Alt+P</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
Expand Down
16 changes: 16 additions & 0 deletions src/qt/forms/managenamespage.ui
Expand Up @@ -174,6 +174,22 @@ to the network and creates a pending name_firstupdate transaction.</string>
</property>
</widget>
</item>
<item>
<widget class="QValidatedLineEdit" name="addressFilter">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Enter Namecoin address (or prefix of it)</string>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_ExpiresIn">
<property name="orientation">
Expand Down
4 changes: 4 additions & 0 deletions src/qt/guiconstants.h
Expand Up @@ -28,6 +28,10 @@ static const int TOOLTIP_WRAP_THRESHOLD = 80;
/* Maximum allowed URI length */
static const int MAX_URI_LENGTH = 255;

// Should be set to MAX_VALUE_LENGTH (from namecoin.h) when it's supported by the network
// (currently due to limitations of CScript the limit is 519 bytes)
static const int GUI_MAX_VALUE_LENGTH = 519;

/* QRCodeDialog -- size of exported QR Code image */
#define EXPORT_IMAGE_SIZE 256

Expand Down

0 comments on commit bfd788d

Please sign in to comment.