Re-add paperwallet printer (#1467)
* Add paper wallet generator to QT wallet * Replace print icon with Typeicons equivalent * Re-add printer support to Qt * depends: fix fontconfig with newer glibc See comment for more detail * Set fixed size for paper wallet dialog
This commit is contained in:
parent
b38bb8e768
commit
64c2ef2699
|
@ -152,8 +152,9 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
|
|||
Q_IMPORT_PLUGIN(qjpcodecs)
|
||||
Q_IMPORT_PLUGIN(qtwcodecs)
|
||||
Q_IMPORT_PLUGIN(qkrcodecs)
|
||||
Q_IMPORT_PLUGIN(AccessibleFactory)],
|
||||
[-lqcncodecs -lqjpcodecs -lqtwcodecs -lqkrcodecs -lqtaccessiblewidgets])
|
||||
Q_IMPORT_PLUGIN(AccessibleFactory)
|
||||
Q_IMPORT_PLUGIN(QWindowsPrinterSupportPlugin)],
|
||||
[-lqcncodecs -lqjpcodecs -lqtwcodecs -lqkrcodecs -lqtaccessiblewidgets -lwindowsprintersupport])
|
||||
fi
|
||||
fi
|
||||
CPPFLAGS=$TEMP_CPPFLAGS
|
||||
|
|
|
@ -19,3 +19,7 @@ FORMS += \
|
|||
|
||||
RESOURCES += \
|
||||
../src/qt/bitcoin.qrc
|
||||
|
||||
|
||||
QT += \
|
||||
printsupport
|
||||
|
|
|
@ -13,7 +13,13 @@ define $(package)_config_cmds
|
|||
$($(package)_autoconf)
|
||||
endef
|
||||
|
||||
# 2.12.1 uses CHAR_WIDTH which is reserved and clashes with some glibc versions, but newer versions of fontconfig
|
||||
# have broken makefiles which needlessly attempt to re-generate headers with gperf.
|
||||
# Instead, change all uses of CHAR_WIDTH, and disable the rule that forces header re-generation.
|
||||
# This can be removed once the upstream build is fixed.
|
||||
define $(package)_build_cmds
|
||||
sed -i 's/CHAR_WIDTH/CHARWIDTH/g' fontconfig/fontconfig.h src/fcobjshash.gperf src/fcobjs.h src/fcobjshash.h && \
|
||||
sed -i 's/fcobjshash.h: fcobjshash.gperf/fcobjshash.h:/' src/Makefile && \
|
||||
$(MAKE)
|
||||
endef
|
||||
|
||||
|
|
|
@ -78,8 +78,6 @@ $(package)_config_opts += -reduce-exports
|
|||
$(package)_config_opts += -static
|
||||
$(package)_config_opts += -silent
|
||||
$(package)_config_opts += -v
|
||||
$(package)_config_opts += -no-feature-printer
|
||||
$(package)_config_opts += -no-feature-printdialog
|
||||
|
||||
ifneq ($(build_os),darwin)
|
||||
$(package)_config_opts_darwin = -xplatform macx-clang-linux
|
||||
|
|
|
@ -105,6 +105,7 @@ QT_FORMS_UI = \
|
|||
qt/forms/openuridialog.ui \
|
||||
qt/forms/optionsdialog.ui \
|
||||
qt/forms/overviewpage.ui \
|
||||
qt/forms/paperwalletdialog.ui \
|
||||
qt/forms/receivecoinsdialog.ui \
|
||||
qt/forms/receiverequestdialog.ui \
|
||||
qt/forms/debugwindow.ui \
|
||||
|
@ -156,6 +157,7 @@ QT_MOC_CPP = \
|
|||
qt/moc_transactiontablemodel.cpp \
|
||||
qt/moc_transactionview.cpp \
|
||||
qt/moc_utilitydialog.cpp \
|
||||
qt/moc_verticallabel.cpp \
|
||||
qt/moc_walletframe.cpp \
|
||||
qt/moc_walletmodel.cpp \
|
||||
qt/moc_walletview.cpp
|
||||
|
@ -228,6 +230,7 @@ BITCOIN_QT_H = \
|
|||
qt/transactiontablemodel.h \
|
||||
qt/transactionview.h \
|
||||
qt/utilitydialog.h \
|
||||
qt/verticallabel.h \
|
||||
qt/walletframe.h \
|
||||
qt/walletmodel.h \
|
||||
qt/walletmodeltransaction.h \
|
||||
|
@ -275,6 +278,8 @@ RES_ICONS = \
|
|||
qt/res/icons/network_disabled.png \
|
||||
qt/res/icons/open.png \
|
||||
qt/res/icons/overview.png \
|
||||
qt/res/icons/paper_wallet.png \
|
||||
qt/res/icons/print.png \
|
||||
qt/res/icons/quit.png \
|
||||
qt/res/icons/receive.png \
|
||||
qt/res/icons/remove.png \
|
||||
|
@ -313,7 +318,8 @@ BITCOIN_QT_BASE_CPP = \
|
|||
qt/rpcconsole.cpp \
|
||||
qt/splashscreen.cpp \
|
||||
qt/trafficgraphwidget.cpp \
|
||||
qt/utilitydialog.cpp
|
||||
qt/utilitydialog.cpp \
|
||||
qt/verticallabel.cpp
|
||||
|
||||
BITCOIN_QT_WINDOWS_CPP = qt/winshutdownmonitor.cpp
|
||||
|
||||
|
@ -340,6 +346,7 @@ BITCOIN_QT_WALLET_CPP = \
|
|||
qt/transactionrecord.cpp \
|
||||
qt/transactiontablemodel.cpp \
|
||||
qt/transactionview.cpp \
|
||||
qt/verticallabel.cpp \
|
||||
qt/walletframe.cpp \
|
||||
qt/walletmodel.cpp \
|
||||
qt/walletmodeltransaction.cpp \
|
||||
|
|
|
@ -525,7 +525,7 @@ std::string LicenseInfo()
|
|||
_("This is experimental software.") + "\n" +
|
||||
strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s"), "COPYING", "<https://opensource.org/licenses/MIT>") + "\n" +
|
||||
"\n" +
|
||||
strprintf(_("This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit %s and cryptographic software written by Eric Young and UPnP software written by Thomas Bernard."), "<https://www.openssl.org>") +
|
||||
strprintf(_("This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit %s and cryptographic software written by Eric Young and UPnP software written by Thomas Bernard. Paper wallet art provided by Anacoluthia."), "<https://www.openssl.org>") +
|
||||
"\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -211,6 +211,19 @@ bool CPubKey::IsFullyValid() const {
|
|||
return secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, &(*this)[0], size());
|
||||
}
|
||||
|
||||
bool CPubKey::Compress() {
|
||||
if (!IsValid())
|
||||
return false;
|
||||
secp256k1_pubkey pubkey;
|
||||
if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, &(*this)[0], size()))
|
||||
return false;
|
||||
unsigned char pub[33];
|
||||
size_t publen = 33;
|
||||
secp256k1_ec_pubkey_serialize(secp256k1_context_verify, pub, &publen, &pubkey, SECP256K1_EC_COMPRESSED);
|
||||
Set(pub, pub + publen);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPubKey::Decompress() {
|
||||
if (!IsValid())
|
||||
return false;
|
||||
|
|
|
@ -183,6 +183,9 @@ public:
|
|||
//! Recover a public key from a compact signature.
|
||||
bool RecoverCompact(const uint256& hash, const std::vector<unsigned char>& vchSig);
|
||||
|
||||
//! Turn this public key into a compressed public key.
|
||||
bool Compress();
|
||||
|
||||
//! Turn this public key into an uncompressed public key.
|
||||
bool Decompress();
|
||||
|
||||
|
|
|
@ -67,7 +67,9 @@ Q_IMPORT_PLUGIN(AccessibleFactory)
|
|||
#if defined(QT_QPA_PLATFORM_XCB)
|
||||
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);
|
||||
#elif defined(QT_QPA_PLATFORM_WINDOWS)
|
||||
Q_IMPORT_PLUGIN(QMinimalIntegrationPlugin);
|
||||
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
|
||||
Q_IMPORT_PLUGIN(QWindowsPrinterSupportPlugin);
|
||||
#elif defined(QT_QPA_PLATFORM_COCOA)
|
||||
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
|
||||
#endif
|
||||
|
|
|
@ -54,6 +54,8 @@
|
|||
<file alias="hd_disabled">res/icons/hd_disabled.png</file>
|
||||
<file alias="network_disabled">res/icons/network_disabled.png</file>
|
||||
<file alias="wallet_bgcoin">res/icons/wallet_bgcoin.png</file>
|
||||
<file alias="paper_wallet">res/icons/paper_wallet.png</file>
|
||||
<file alias="print">res/icons/print.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/movies">
|
||||
<file alias="spinner-000">res/movies/spinner-000.png</file>
|
||||
|
|
|
@ -374,6 +374,8 @@ void BitcoinGUI::createActions()
|
|||
signMessageAction->setStatusTip(tr("Sign messages with your Dogecoin 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 Dogecoin addresses"));
|
||||
paperWalletAction = new QAction(QIcon(":/icons/print"), tr("&Print paper wallets"), this);
|
||||
paperWalletAction->setStatusTip(tr("Print paper wallets"));
|
||||
|
||||
openRPCConsoleAction = new QAction(platformStyle->TextColorIcon(":/icons/debugwindow"), tr("&Debug window"), this);
|
||||
openRPCConsoleAction->setStatusTip(tr("Open debugging and diagnostic console"));
|
||||
|
@ -413,6 +415,7 @@ 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(paperWalletAction, SIGNAL(triggered()), walletFrame, SLOT(printPaperWallets()));
|
||||
}
|
||||
#endif // ENABLE_WALLET
|
||||
|
||||
|
@ -438,6 +441,7 @@ void BitcoinGUI::createMenuBar()
|
|||
file->addAction(backupWalletAction);
|
||||
file->addAction(signMessageAction);
|
||||
file->addAction(verifyMessageAction);
|
||||
file->addAction(paperWalletAction);
|
||||
file->addSeparator();
|
||||
file->addAction(usedSendingAddressesAction);
|
||||
file->addAction(usedReceivingAddressesAction);
|
||||
|
@ -583,6 +587,7 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
|
|||
usedSendingAddressesAction->setEnabled(enabled);
|
||||
usedReceivingAddressesAction->setEnabled(enabled);
|
||||
openAction->setEnabled(enabled);
|
||||
paperWalletAction->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
|
||||
|
|
|
@ -101,6 +101,7 @@ private:
|
|||
QAction *usedReceivingAddressesAction;
|
||||
QAction *signMessageAction;
|
||||
QAction *verifyMessageAction;
|
||||
QAction *paperWalletAction;
|
||||
QAction *aboutAction;
|
||||
QAction *receiveCoinsAction;
|
||||
QAction *receiveCoinsMenuAction;
|
||||
|
|
339
src/qt/forms/paperwalletdialog.ui
Normal file
339
src/qt/forms/paperwalletdialog.ui
Normal file
|
@ -0,0 +1,339 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PaperWalletDialog</class>
|
||||
<widget class="QDialog" name="PaperWalletDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>716</width>
|
||||
<height>450</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Print Your Paper Wallets</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="privateKeyQRCode">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>524</x>
|
||||
<y>159</y>
|
||||
<width>149</width>
|
||||
<height>149</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="addressQRCode">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>47</x>
|
||||
<y>86</y>
|
||||
<width>120</width>
|
||||
<height>120</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="getNewAddress">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>415</y>
|
||||
<width>151</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Very New Address</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../bitcoin.qrc">
|
||||
<normaloff>:/icons/add</normaloff>:/icons/add</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="paperTemplate">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>10</y>
|
||||
<width>675</width>
|
||||
<height>362</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../bitcoin.qrc">:/icons/paper_wallet</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="VerticalLabel" name="addressText">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>212</x>
|
||||
<y>20</y>
|
||||
<width>31</width>
|
||||
<height>341</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Monospace</family>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<italic>false</italic>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="VerticalLabel" name="privateKeyText">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>500</x>
|
||||
<y>10</y>
|
||||
<width>31</width>
|
||||
<height>361</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Monospace</family>
|
||||
<pointsize>8</pointsize>
|
||||
<weight>50</weight>
|
||||
<italic>false</italic>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="printButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>420</x>
|
||||
<y>415</y>
|
||||
<width>111</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>So Print</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../bitcoin.qrc">
|
||||
<normaloff>:/icons/receiving_addresses</normaloff>:/icons/receiving_addresses</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>610</x>
|
||||
<y>415</y>
|
||||
<width>81</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::NoButton</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>190</x>
|
||||
<y>415</y>
|
||||
<width>91</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Many Wallets?</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="walletCount">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>290</x>
|
||||
<y>415</y>
|
||||
<width>74</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>6</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>7</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>8</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>9</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>10</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>11</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>12</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="publicKey">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>378</y>
|
||||
<width>600</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="undoRedoEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string>
|
||||
</property>
|
||||
<property name="acceptRichText">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>380</y>
|
||||
<width>91</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Public Key:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<zorder>getNewAddress</zorder>
|
||||
<zorder>paperTemplate</zorder>
|
||||
<zorder>addressQRCode</zorder>
|
||||
<zorder>privateKeyQRCode</zorder>
|
||||
<zorder>addressText</zorder>
|
||||
<zorder>privateKeyText</zorder>
|
||||
<zorder>printButton</zorder>
|
||||
<zorder>buttonBox</zorder>
|
||||
<zorder>label</zorder>
|
||||
<zorder>walletCount</zorder>
|
||||
<zorder>publicKey</zorder>
|
||||
<zorder>label_2</zorder>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>VerticalLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>verticallabel.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../bitcoin.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>PaperWalletDialog</receiver>
|
||||
<slot>close()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>650</x>
|
||||
<y>408</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>357</x>
|
||||
<y>214</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -448,6 +448,16 @@
|
|||
<source>Verify messages to ensure they were signed with specified Dogecoin addresses</source>
|
||||
<translation type="unfinished">Verify messages to ensure they were signed with specified Dogecoin addresses</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+1"/>
|
||||
<source>&Print paper wallets</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+1"/>
|
||||
<source>Print paper wallets</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+2"/>
|
||||
<source>&Debug window</source>
|
||||
|
@ -499,12 +509,12 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+41"/>
|
||||
<location line="+42"/>
|
||||
<source>&File</source>
|
||||
<translation type="unfinished">&File</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+14"/>
|
||||
<location line="+15"/>
|
||||
<source>&Settings</source>
|
||||
<translation type="unfinished">&Settings</translation>
|
||||
</message>
|
||||
|
@ -519,7 +529,7 @@
|
|||
<translation type="unfinished">Tabs toolbar</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+121"/>
|
||||
<location line="+122"/>
|
||||
<source>%1 client</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -718,7 +728,7 @@
|
|||
<translation type="unfinished">Wallet is <b>encrypted</b> and currently <b>locked</b></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../bitcoin.cpp" line="+518"/>
|
||||
<location filename="../bitcoin.cpp" line="+520"/>
|
||||
<source>A fatal error occurred. Dogecoin can no longer continue safely and will quit.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -1012,7 +1022,7 @@
|
|||
<context>
|
||||
<name>HelpMessageDialog</name>
|
||||
<message>
|
||||
<location filename="../utilitydialog.cpp" line="+40"/>
|
||||
<location filename="../utilitydialog.cpp" line="+71"/>
|
||||
<source>version</source>
|
||||
<translation type="unfinished">version</translation>
|
||||
</message>
|
||||
|
@ -1626,6 +1636,219 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PaperWalletDialog</name>
|
||||
<message>
|
||||
<location filename="../forms/paperwalletdialog.ui" line="+14"/>
|
||||
<source>Print Your Paper Wallets</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+44"/>
|
||||
<source>Very New Address</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+92"/>
|
||||
<source>So Print</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+33"/>
|
||||
<source>Many Wallets?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+17"/>
|
||||
<source>1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>3</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>4</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>5</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>6</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>7</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>8</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>9</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>10</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>11</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>12</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+20"/>
|
||||
<source><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+20"/>
|
||||
<source>Public Key:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../utilitydialog.cpp" line="+78"/>
|
||||
<source>Close</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+13"/>
|
||||
<source>It is recommended to disconnect from the internet before printing paper wallets. Even though paper wallets are generated on your local computer, it is still possible to unknowingly have malware that transmits your screen to a remote location. It is also recommended to print to a local printer vs a network printer since that network traffic can be monitored. Some advanced printers also store copies of each printed document. Proceed with caution relative to the amount of value you plan to store on each address.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+39"/>
|
||||
<source>Error encoding Address into QR Code.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+18"/>
|
||||
<source>Error encoding private key into QR Code.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+87"/>
|
||||
<source>failed to open file, is it writable?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+38"/>
|
||||
<source>Load Paper Wallets</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+0"/>
|
||||
<source>The paper wallet printing process has begun.<br/>Please wait for the wallets to print completely and verify that everything printed correctly.<br/>Check for misalignments, ink bleeding, smears, or anything else that could make the private keys unreadable.<br/>Now, enter the number of DOGE you wish to send to each wallet:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+15"/>
|
||||
<source>Paper wallet %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+1"/>
|
||||
<source><b>%1</b> to Paper Wallet <span style='font-family: monospace;'>%2</span></source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+12"/>
|
||||
<location line="+2"/>
|
||||
<location line="+2"/>
|
||||
<location line="+2"/>
|
||||
<location line="+2"/>
|
||||
<location line="+2"/>
|
||||
<location line="+45"/>
|
||||
<source>Send Coins</source>
|
||||
<translation type="unfinished">Send Coins</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-55"/>
|
||||
<source>The recipient address is not valid, please recheck.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+2"/>
|
||||
<source>The amount to pay must be larger than 0</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+2"/>
|
||||
<source>The amount exceeds your balance.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+2"/>
|
||||
<source>The total exceeds your balance when the transaction fee is included</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+2"/>
|
||||
<source>Duplicate address found, can only send to each address once per send operation.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+2"/>
|
||||
<source>Transaction creation failed!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+11"/>
|
||||
<source>Are you sure you want to send?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+8"/>
|
||||
<source>added as transaction fee</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+12"/>
|
||||
<source>Total Amount %1 (= %2)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+2"/>
|
||||
<source>or</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+2"/>
|
||||
<source>Confirm send coins</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+10"/>
|
||||
<source>The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PaymentServer</name>
|
||||
<message>
|
||||
|
@ -3023,7 +3246,7 @@
|
|||
<context>
|
||||
<name>ShutdownWindow</name>
|
||||
<message>
|
||||
<location filename="../utilitydialog.cpp" line="+78"/>
|
||||
<location filename="../utilitydialog.cpp" line="+13"/>
|
||||
<source>%1 is shutting down...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -3836,7 +4059,7 @@
|
|||
<context>
|
||||
<name>WalletFrame</name>
|
||||
<message>
|
||||
<location filename="../walletframe.cpp" line="+27"/>
|
||||
<location filename="../walletframe.cpp" line="+28"/>
|
||||
<source>No wallet has been loaded.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -3852,7 +4075,7 @@
|
|||
<context>
|
||||
<name>WalletView</name>
|
||||
<message>
|
||||
<location filename="../walletview.cpp" line="+46"/>
|
||||
<location filename="../walletview.cpp" line="+47"/>
|
||||
<source>&Export</source>
|
||||
<translation type="unfinished">&Export</translation>
|
||||
</message>
|
||||
|
|
BIN
src/qt/res/icons/paper_wallet.png
Normal file
BIN
src/qt/res/icons/paper_wallet.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 209 KiB |
BIN
src/qt/res/icons/print.png
Normal file
BIN
src/qt/res/icons/print.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
|
@ -9,7 +9,17 @@
|
|||
#include "utilitydialog.h"
|
||||
|
||||
#include "ui_helpmessagedialog.h"
|
||||
#include "ui_paperwalletdialog.h"
|
||||
|
||||
#include "bitcoinunits.h"
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
#include "sendcoinsdialog.h"
|
||||
#include "sendcoinsentry.h"
|
||||
#include "coincontroldialog.h"
|
||||
#endif
|
||||
|
||||
#include "optionsmodel.h"
|
||||
#include "bitcoingui.h"
|
||||
#include "clientmodel.h"
|
||||
#include "guiconstants.h"
|
||||
|
@ -20,15 +30,36 @@
|
|||
#include "clientversion.h"
|
||||
#include "init.h"
|
||||
#include "util.h"
|
||||
#include "net.h"
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QFont>
|
||||
#include <QLabel>
|
||||
#include <QRegExp>
|
||||
#include <QTextTable>
|
||||
#include <QTextCursor>
|
||||
#include <QVBoxLayout>
|
||||
#include <QInputDialog>
|
||||
|
||||
#ifdef USE_QRCODE
|
||||
#include <qrencode.h>
|
||||
#endif
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
#include <QPrinter>
|
||||
#include <QPrintDialog>
|
||||
#include <QPrintPreviewDialog>
|
||||
#else
|
||||
// Use QT5's new modular classes
|
||||
#include <QtPrintSupport/QPrinter>
|
||||
#include <QtPrintSupport/QPrintDialog>
|
||||
#include <QtPrintSupport/QPrintPreviewDialog>
|
||||
#endif
|
||||
#include <QPainter>
|
||||
#include "walletmodel.h"
|
||||
|
||||
/** "Help message" or "About" dialog box */
|
||||
HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
|
||||
|
@ -159,6 +190,304 @@ void HelpMessageDialog::on_okButton_accepted()
|
|||
close();
|
||||
}
|
||||
|
||||
/** "PaperWallet" dialog box */
|
||||
PaperWalletDialog::PaperWalletDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::PaperWalletDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->buttonBox->addButton(tr("Close"), QDialogButtonBox::RejectRole);
|
||||
|
||||
// Begin with a small bold monospace font for the textual version of the key and address.
|
||||
QFont font("Monospace");
|
||||
font.setBold(true);
|
||||
font.setStyleHint(QFont::TypeWriter);
|
||||
font.setPixelSize(1);
|
||||
ui->addressText->setFont(font);
|
||||
ui->privateKeyText->setFont(font);
|
||||
ui->addressText->setAlignment(Qt::AlignJustify);
|
||||
ui->privateKeyText->setAlignment(Qt::AlignJustify);
|
||||
setFixedSize(size());
|
||||
}
|
||||
|
||||
void PaperWalletDialog::setClientModel(ClientModel *_clientModel)
|
||||
{
|
||||
this->clientModel = _clientModel;
|
||||
|
||||
// FIXME: This cannot be the right way of doing something on open
|
||||
if (_clientModel && _clientModel->getNetworkActive()) {
|
||||
QMessageBox::critical(this, "Warning: Network Activity Detected", tr("It is recommended to disconnect from the internet before printing paper wallets. Even though paper wallets are generated on your local computer, it is still possible to unknowingly have malware that transmits your screen to a remote location. It is also recommended to print to a local printer vs a network printer since that network traffic can be monitored. Some advanced printers also store copies of each printed document. Proceed with caution relative to the amount of value you plan to store on each address."), QMessageBox::Ok, QMessageBox::Ok);
|
||||
}
|
||||
}
|
||||
|
||||
void PaperWalletDialog::setModel(WalletModel *model)
|
||||
{
|
||||
RandAddSeed();
|
||||
this->model = model;
|
||||
this->on_getNewAddress_clicked();
|
||||
}
|
||||
|
||||
PaperWalletDialog::~PaperWalletDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PaperWalletDialog::on_getNewAddress_clicked()
|
||||
{
|
||||
// Create a new private key
|
||||
CKey privKey;
|
||||
privKey.MakeNewKey(true);
|
||||
|
||||
// Derive the public key
|
||||
CPubKey pubkey = privKey.GetPubKey();
|
||||
|
||||
// Derive the public key hash
|
||||
CBitcoinAddress pubkeyhash;
|
||||
pubkeyhash.Set(pubkey.GetID());
|
||||
|
||||
// Create String versions of each
|
||||
std::string myPrivKey = CBitcoinSecret(privKey).ToString();
|
||||
std::string myPubKey = HexStr(pubkey.begin(), pubkey.end());
|
||||
std::string myAddress = pubkeyhash.ToString();
|
||||
|
||||
|
||||
#ifdef USE_QRCODE
|
||||
// Generate the address QR code
|
||||
QRcode *code = QRcode_encodeString(myAddress.c_str(), 0, QR_ECLEVEL_M, QR_MODE_8, 1);
|
||||
if (!code) {
|
||||
ui->addressQRCode->setText(tr("Error encoding Address into QR Code."));
|
||||
return;
|
||||
}
|
||||
QImage myImage = QImage(code->width, code->width, QImage::Format_ARGB32);
|
||||
myImage.fill(QColor(0, 0, 0, 0));
|
||||
unsigned char* p = code->data;
|
||||
for (int y = 0; y < code->width; y++) {
|
||||
for (int x = 0; x < code->width; x++) {
|
||||
myImage.setPixel(x, y, ((*p & 1) ? 0xff000000 : 0x0));
|
||||
p++;
|
||||
}
|
||||
}
|
||||
QRcode_free(code);
|
||||
|
||||
|
||||
// Generate the private key QR code
|
||||
code = QRcode_encodeString(myPrivKey.c_str(), 0, QR_ECLEVEL_M, QR_MODE_8, 1);
|
||||
if (!code) {
|
||||
ui->privateKeyQRCode->setText(tr("Error encoding private key into QR Code."));
|
||||
return;
|
||||
}
|
||||
QImage myImagePriv = QImage(code->width, code->width, QImage::Format_ARGB32);
|
||||
myImagePriv.fill(QColor(0, 0, 0, 0));
|
||||
p = code->data;
|
||||
for (int y = 0; y < code->width; y++) {
|
||||
for (int x = 0; x < code->width; x++) {
|
||||
myImagePriv.setPixel(x, y, ((*p & 1) ? 0xff000000 : 0x0));
|
||||
p++;
|
||||
}
|
||||
}
|
||||
QRcode_free(code);
|
||||
|
||||
// Populate the QR Codes
|
||||
ui->addressQRCode->setPixmap(QPixmap::fromImage(myImage).scaled(ui->addressQRCode->width(), ui->addressQRCode->height()));
|
||||
ui->privateKeyQRCode->setPixmap(QPixmap::fromImage(myImagePriv).scaled(ui->privateKeyQRCode->width(), ui->privateKeyQRCode->height()));
|
||||
#endif
|
||||
|
||||
// Populate the Texts
|
||||
ui->addressText->setText(myAddress.c_str());
|
||||
ui->privateKeyText->setText(tr(myPrivKey.c_str()));
|
||||
|
||||
ui->publicKey->setHtml(myPubKey.c_str());
|
||||
|
||||
// Update the fonts to fit the height of the wallet.
|
||||
// This should only really trigger the first time since the font size persists.
|
||||
double paperHeight = (double)ui->paperTemplate->height();
|
||||
double maxTextWidth = paperHeight * 0.99;
|
||||
double minTextWidth = paperHeight * 0.95;
|
||||
int pixelSizeStep = 1;
|
||||
|
||||
int addressTextLength = ui->addressText->fontMetrics().boundingRect(ui->addressText->text()).width();
|
||||
QFont font = ui->addressText->font();
|
||||
for (int i = 0; i < PAPER_WALLET_READJUST_LIMIT; i++) {
|
||||
if (addressTextLength < minTextWidth) {
|
||||
font.setPixelSize(font.pixelSize() + pixelSizeStep);
|
||||
ui->addressText->setFont(font);
|
||||
addressTextLength = ui->addressText->fontMetrics().boundingRect(ui->addressText->text()).width();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (addressTextLength > maxTextWidth) {
|
||||
font.setPixelSize(font.pixelSize() - pixelSizeStep);
|
||||
ui->addressText->setFont(font);
|
||||
addressTextLength = ui->addressText->fontMetrics().boundingRect(ui->addressText->text()).width();
|
||||
}
|
||||
|
||||
int privateKeyTextLength = ui->privateKeyText->fontMetrics().boundingRect(ui->privateKeyText->text()).width();
|
||||
font = ui->privateKeyText->font();
|
||||
for (int i = 0; i < PAPER_WALLET_READJUST_LIMIT; i++) {
|
||||
if (privateKeyTextLength < minTextWidth) {
|
||||
font.setPixelSize(font.pixelSize() + pixelSizeStep);
|
||||
ui->privateKeyText->setFont(font);
|
||||
privateKeyTextLength = ui->privateKeyText->fontMetrics().boundingRect(ui->privateKeyText->text()).width();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (privateKeyTextLength > maxTextWidth) {
|
||||
font.setPixelSize(font.pixelSize() - pixelSizeStep);
|
||||
ui->privateKeyText->setFont(font);
|
||||
privateKeyTextLength = ui->privateKeyText->fontMetrics().boundingRect(ui->privateKeyText->text()).width();
|
||||
}
|
||||
}
|
||||
|
||||
void PaperWalletDialog::on_printButton_clicked()
|
||||
{
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
QPrintDialog* qpd = new QPrintDialog(&printer, this);
|
||||
|
||||
qpd->setPrintRange(QAbstractPrintDialog::AllPages);
|
||||
|
||||
QList<QString> recipientPubKeyHashes;
|
||||
|
||||
if (qpd->exec() != QDialog::Accepted) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Hardcode these values
|
||||
printer.setOrientation(QPrinter::Portrait);
|
||||
printer.setPaperSize(QPrinter::A4);
|
||||
printer.setFullPage(true);
|
||||
|
||||
QPainter painter;
|
||||
if (!painter.begin(&printer)) { // failed to open file
|
||||
QMessageBox::critical(this, "Printing Error", tr("failed to open file, is it writable?"), QMessageBox::Ok, QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
int walletCount = ui->walletCount->currentIndex() + 1;
|
||||
int walletsPerPage = 4;
|
||||
|
||||
int pageHeight = printer.pageRect().height() - PAPER_WALLET_PAGE_MARGIN;
|
||||
int walletHeight = ui->paperTemplate->height();
|
||||
double computedWalletHeight = 0.9 * pageHeight / walletsPerPage;
|
||||
double scale = computedWalletHeight / walletHeight;
|
||||
double walletPadding = pageHeight * 0.05 / (walletsPerPage - 1) / scale;
|
||||
|
||||
QRegion walletRegion = QRegion(ui->paperTemplate->x(), ui->paperTemplate->y(), ui->paperTemplate->width(), ui->paperTemplate->height());
|
||||
painter.scale(scale, scale);
|
||||
|
||||
for (int i = 0; i < walletCount; i++) {
|
||||
QPoint point = QPoint(PAPER_WALLET_PAGE_MARGIN, (PAPER_WALLET_PAGE_MARGIN / 2) + (i % walletsPerPage) * (walletHeight + walletPadding));
|
||||
this->render(&painter, point, walletRegion);
|
||||
recipientPubKeyHashes.append(ui->addressText->text());
|
||||
|
||||
if (i % walletsPerPage == (walletsPerPage - 1)) {
|
||||
printer.newPage();
|
||||
}
|
||||
|
||||
this->on_getNewAddress_clicked();
|
||||
}
|
||||
|
||||
painter.end();
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
QStringList formatted;
|
||||
|
||||
WalletModelTransaction* tx;
|
||||
while (true) {
|
||||
bool ok;
|
||||
|
||||
// Ask for an amount to send to each paper wallet. It might be better to try to use the BitcoinAmountField, but this works fine.
|
||||
double amountInput = QInputDialog::getDouble(this, tr("Load Paper Wallets"), tr("The paper wallet printing process has begun.<br/>Please wait for the wallets to print completely and verify that everything printed correctly.<br/>Check for misalignments, ink bleeding, smears, or anything else that could make the private keys unreadable.<br/>Now, enter the number of DOGE you wish to send to each wallet:"), 0, 0, 2147483647, 8, &ok);
|
||||
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WalletModel::UnlockContext ctx(this->model->requestUnlock());
|
||||
if (!ctx.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QList<SendCoinsRecipient> recipients;
|
||||
quint64 amount = (quint64)(amountInput * COIN);
|
||||
Q_FOREACH (const QString& dest, recipientPubKeyHashes) {
|
||||
recipients.append(SendCoinsRecipient(dest, tr("Paper wallet %1").arg(dest), amount, ""));
|
||||
formatted.append(tr("<b>%1</b> to Paper Wallet <span style='font-family: monospace;'>%2</span>").arg(QString::number(amountInput, 'f', 8), GUIUtil::HtmlEscape(dest)));
|
||||
}
|
||||
|
||||
tx = new WalletModelTransaction(recipients);
|
||||
|
||||
WalletModel::SendCoinsReturn prepareStatus;
|
||||
if (this->model->getOptionsModel()->getCoinControlFeatures()) // coin control enabled
|
||||
prepareStatus = this->model->prepareTransaction(*tx, CoinControlDialog::coinControl);
|
||||
else
|
||||
prepareStatus = this->model->prepareTransaction(*tx);
|
||||
|
||||
if (prepareStatus.status == WalletModel::InvalidAddress) {
|
||||
QMessageBox::critical(this, tr("Send Coins"), tr("The recipient address is not valid, please recheck."), QMessageBox::Ok, QMessageBox::Ok);
|
||||
} else if (prepareStatus.status == WalletModel::InvalidAmount) {
|
||||
QMessageBox::critical(this, tr("Send Coins"), tr("The amount to pay must be larger than 0"), QMessageBox::Ok, QMessageBox::Ok);
|
||||
} else if (prepareStatus.status == WalletModel::AmountExceedsBalance) {
|
||||
QMessageBox::critical(this, tr("Send Coins"), tr("The amount exceeds your balance."), QMessageBox::Ok, QMessageBox::Ok);
|
||||
} else if (prepareStatus.status == WalletModel::AmountWithFeeExceedsBalance) {
|
||||
QMessageBox::critical(this, tr("Send Coins"), tr("The total exceeds your balance when the transaction fee is included"), QMessageBox::Ok, QMessageBox::Ok);
|
||||
} else if (prepareStatus.status == WalletModel::DuplicateAddress) {
|
||||
QMessageBox::critical(this, tr("Send Coins"), tr("Duplicate address found, can only send to each address once per send operation."), QMessageBox::Ok, QMessageBox::Ok);
|
||||
} else if (prepareStatus.status == WalletModel::TransactionCreationFailed) {
|
||||
QMessageBox::critical(this, tr("Send Coins"), tr("Transaction creation failed!"), QMessageBox::Ok, QMessageBox::Ok);
|
||||
} else if (prepareStatus.status == WalletModel::OK) {
|
||||
break;
|
||||
} else {
|
||||
delete tx;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Stolen from sendcoinsdialog.cpp
|
||||
qint64 txFee = tx->getTransactionFee();
|
||||
QString questionString = tr("Are you sure you want to send?");
|
||||
questionString.append("<br /><br />%1");
|
||||
|
||||
if (txFee > 0) {
|
||||
// append fee string if a fee is required
|
||||
questionString.append("<hr /><span style='color:#aa0000;'>");
|
||||
questionString.append(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), txFee));
|
||||
questionString.append("</span> ");
|
||||
questionString.append(tr("added as transaction fee"));
|
||||
}
|
||||
|
||||
// add total amount in all subdivision units
|
||||
questionString.append("<hr />");
|
||||
qint64 totalAmount = tx->getTotalTransactionAmount() + txFee;
|
||||
QStringList alternativeUnits;
|
||||
Q_FOREACH (BitcoinUnits::Unit u, BitcoinUnits::availableUnits()) {
|
||||
if (u != model->getOptionsModel()->getDisplayUnit())
|
||||
alternativeUnits.append(BitcoinUnits::formatWithUnit(u, totalAmount));
|
||||
}
|
||||
|
||||
questionString.append(tr("Total Amount %1 (= %2)")
|
||||
.arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), totalAmount))
|
||||
.arg(alternativeUnits.join(" " + tr("or") + " ")));
|
||||
|
||||
QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send coins"), questionString.arg(formatted.join("<br />")), QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
|
||||
|
||||
if (retval != QMessageBox::Yes) {
|
||||
delete tx;
|
||||
return;
|
||||
}
|
||||
|
||||
WalletModel::SendCoinsReturn sendStatus = this->model->sendCoins(*tx);
|
||||
|
||||
if (sendStatus.status == WalletModel::TransactionCommitFailed) {
|
||||
QMessageBox::critical(this, tr("Send Coins"), tr("The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."), QMessageBox::Ok, QMessageBox::Ok);
|
||||
}
|
||||
delete tx;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
/** "Shutdown" window */
|
||||
ShutdownWindow::ShutdownWindow(QWidget *parent, Qt::WindowFlags f):
|
||||
|
|
|
@ -7,14 +7,40 @@
|
|||
|
||||
#include <QDialog>
|
||||
#include <QObject>
|
||||
#include "walletmodel.h"
|
||||
|
||||
class BitcoinGUI;
|
||||
class ClientModel;
|
||||
|
||||
namespace Ui {
|
||||
class HelpMessageDialog;
|
||||
class PaperWalletDialog;
|
||||
}
|
||||
|
||||
/** "Paper Wallet" dialog box */
|
||||
class PaperWalletDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PaperWalletDialog(QWidget *parent);
|
||||
~PaperWalletDialog();
|
||||
|
||||
void setClientModel(ClientModel *clientModel);
|
||||
void setModel(WalletModel *model);
|
||||
|
||||
private:
|
||||
Ui::PaperWalletDialog *ui;
|
||||
ClientModel *clientModel;
|
||||
WalletModel *model;
|
||||
static const int PAPER_WALLET_READJUST_LIMIT = 20;
|
||||
static const int PAPER_WALLET_PAGE_MARGIN = 50;
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_getNewAddress_clicked();
|
||||
void on_printButton_clicked();
|
||||
};
|
||||
|
||||
/** "Help message" dialog box */
|
||||
class HelpMessageDialog : public QDialog
|
||||
{
|
||||
|
|
40
src/qt/verticallabel.cpp
Normal file
40
src/qt/verticallabel.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include "verticallabel.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
VerticalLabel::VerticalLabel(QWidget* parent)
|
||||
: QLabel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
VerticalLabel::VerticalLabel(const QString& text, QWidget* parent)
|
||||
: QLabel(text, parent)
|
||||
{
|
||||
}
|
||||
|
||||
VerticalLabel::~VerticalLabel()
|
||||
{
|
||||
}
|
||||
|
||||
void VerticalLabel::paintEvent(QPaintEvent*)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setPen(Qt::black);
|
||||
painter.setBrush(Qt::Dense1Pattern);
|
||||
painter.translate(width() / 2, height());
|
||||
painter.rotate(270);
|
||||
|
||||
painter.drawText(0, 0, text());
|
||||
}
|
||||
|
||||
QSize VerticalLabel::minimumSizeHint() const
|
||||
{
|
||||
QSize s = QLabel::minimumSizeHint();
|
||||
return QSize(s.height(), s.width());
|
||||
}
|
||||
|
||||
QSize VerticalLabel::sizeHint() const
|
||||
{
|
||||
QSize s = QLabel::sizeHint();
|
||||
return QSize(s.height(), s.width());
|
||||
}
|
21
src/qt/verticallabel.h
Normal file
21
src/qt/verticallabel.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#ifndef VERTICALLABEL_H
|
||||
#define VERTICALLABEL_H
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
class VerticalLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit VerticalLabel(QWidget *parent = 0);
|
||||
explicit VerticalLabel(const QString& text, QWidget *parent = 0);
|
||||
~VerticalLabel();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent*);
|
||||
QSize sizeHint() const;
|
||||
QSize minimumSizeHint() const;
|
||||
};
|
||||
|
||||
#endif // VERTICALLABEL_H
|
|
@ -8,6 +8,7 @@
|
|||
#include "walletview.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
|
@ -178,6 +179,13 @@ void WalletFrame::unlockWallet()
|
|||
walletView->unlockWallet();
|
||||
}
|
||||
|
||||
void WalletFrame::printPaperWallets()
|
||||
{
|
||||
WalletView *walletView = currentWalletView();
|
||||
if (walletView)
|
||||
walletView->printPaperWallets();
|
||||
}
|
||||
|
||||
void WalletFrame::usedSendingAddresses()
|
||||
{
|
||||
WalletView *walletView = currentWalletView();
|
||||
|
|
|
@ -85,6 +85,8 @@ public Q_SLOTS:
|
|||
/** Ask for passphrase to unlock wallet temporarily */
|
||||
void unlockWallet();
|
||||
|
||||
void printPaperWallets();
|
||||
|
||||
/** Show used sending addresses */
|
||||
void usedSendingAddresses();
|
||||
/** Show used receiving addresses */
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "transactiontablemodel.h"
|
||||
#include "transactionview.h"
|
||||
#include "walletmodel.h"
|
||||
#include "utilitydialog.h"
|
||||
|
||||
#include "ui_interface.h"
|
||||
|
||||
|
@ -328,3 +329,14 @@ void WalletView::requestedSyncWarningInfo()
|
|||
{
|
||||
Q_EMIT outOfSyncWarningClicked();
|
||||
}
|
||||
|
||||
void WalletView::printPaperWallets()
|
||||
{
|
||||
if(!walletModel)
|
||||
return;
|
||||
|
||||
PaperWalletDialog dlg(this);
|
||||
dlg.setModel(walletModel);
|
||||
dlg.setClientModel(clientModel);
|
||||
dlg.exec();
|
||||
}
|
||||
|
|
|
@ -98,6 +98,8 @@ public Q_SLOTS:
|
|||
void changePassphrase();
|
||||
/** Ask for passphrase to unlock wallet temporarily */
|
||||
void unlockWallet();
|
||||
/** Open the print paper wallets dialog **/
|
||||
void printPaperWallets();
|
||||
|
||||
/** Show used sending addresses */
|
||||
void usedSendingAddresses();
|
||||
|
|
Loading…
Reference in a new issue