Skip to content

Commit

Permalink
Re-add paperwallet printer (dogecoin#1467)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
langerhans authored and Ross Nicoll committed Mar 25, 2019
1 parent 74814cf commit 2a0c660
Show file tree
Hide file tree
Showing 24 changed files with 1,058 additions and 14 deletions.
5 changes: 3 additions & 2 deletions build-aux/m4/bitcoin_qt.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions contrib/bitcoin-qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ FORMS += \

RESOURCES += \
../src/qt/bitcoin.qrc


QT += \
printsupport
6 changes: 6 additions & 0 deletions depends/packages/fontconfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions depends/packages/qt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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

Expand All @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down
13 changes: 13 additions & 0 deletions src/pubkey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/pubkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ class CPubKey
//! 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();

Expand Down
2 changes: 2 additions & 0 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/qt/bitcoin.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 5 additions & 0 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -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

Expand All @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class BitcoinGUI : public QMainWindow
QAction *usedReceivingAddressesAction;
QAction *signMessageAction;
QAction *verifyMessageAction;
QAction *paperWalletAction;
QAction *aboutAction;
QAction *receiveCoinsAction;
QAction *receiveCoinsMenuAction;
Expand Down
Loading

0 comments on commit 2a0c660

Please sign in to comment.