5 #if defined(HAVE_CONFIG_H)
6 #include "config/bitcoin-config.h"
11 #include "ui_helpmessagedialog.h"
12 #include "ui_paperwalletdialog.h"
38 #include <QCloseEvent>
43 #include <QTextCursor>
44 #include <QVBoxLayout>
45 #include <QInputDialog>
51 #if QT_VERSION < 0x050000
53 #include <QPrintDialog>
54 #include <QPrintPreviewDialog>
57 #include <QtPrintSupport/QPrinter>
58 #include <QtPrintSupport/QPrintDialog>
59 #include <QtPrintSupport/QPrintPreviewDialog>
71 QString version = tr(PACKAGE_NAME) +
" " + tr(
"version") +
" " + QString::fromStdString(
FormatFullVersion());
75 #if defined(__x86_64__)
76 version +=
" " + tr(
"(%1-bit)").arg(64);
77 #elif defined(__i386__ )
78 version +=
" " + tr(
"(%1-bit)").arg(32);
83 setWindowTitle(tr(
"About %1").arg(tr(PACKAGE_NAME)));
86 QString licenseInfo = QString::fromStdString(
LicenseInfo());
87 QString licenseInfoHTML = licenseInfo;
89 QRegExp uri(
"<(.*)>", Qt::CaseSensitive, QRegExp::RegExp2);
91 licenseInfoHTML.replace(uri,
"<a href=\"\\1\">\\1</a>");
93 licenseInfoHTML.replace(
"\n",
"<br>");
95 ui->aboutMessage->setTextFormat(Qt::RichText);
96 ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
97 text = version +
"\n" + licenseInfo;
98 ui->aboutMessage->setText(version +
"<br><br>" + licenseInfoHTML);
99 ui->aboutMessage->setWordWrap(
true);
100 ui->helpMessage->setVisible(
false);
102 setWindowTitle(tr(
"Command-line options"));
103 QString header = tr(
"Usage:") +
"\n" +
104 " dogecoin-qt [" + tr(
"command-line options") +
"] " +
"\n";
105 QTextCursor cursor(
ui->helpMessage->document());
106 cursor.insertText(version);
107 cursor.insertBlock();
108 cursor.insertText(header);
109 cursor.insertBlock();
112 const bool showDebug =
GetBoolArg(
"-help-debug",
false);
115 strUsage +=
HelpMessageOpt(
"-allowselfsignedrootcertificates",
strprintf(
"Allow self signed root certificates (default: %u)", DEFAULT_SELFSIGNED_ROOTCERTS));
117 strUsage +=
HelpMessageOpt(
"-choosedatadir",
strprintf(tr(
"Choose data directory on startup (default: %u)").toStdString(), DEFAULT_CHOOSE_DATADIR));
118 strUsage +=
HelpMessageOpt(
"-lang=<lang>", tr(
"Set language, for example \"de_DE\" (default: system locale)").toStdString());
119 strUsage +=
HelpMessageOpt(
"-min", tr(
"Start minimized").toStdString());
120 strUsage +=
HelpMessageOpt(
"-rootcertificates=<file>", tr(
"Set SSL root certificates for payment request (default: -system-)").toStdString());
121 strUsage +=
HelpMessageOpt(
"-splash",
strprintf(tr(
"Show splash screen on startup (default: %u)").toStdString(), DEFAULT_SPLASHSCREEN));
122 strUsage +=
HelpMessageOpt(
"-resetguisettings", tr(
"Reset all settings changed in the GUI").toStdString());
126 QString coreOptions = QString::fromStdString(strUsage);
127 text = version +
"\n" + header +
"\n" + coreOptions;
130 tf.setBorderStyle(QTextFrameFormat::BorderStyle_None);
131 tf.setCellPadding(2);
132 QVector<QTextLength> widths;
133 widths << QTextLength(QTextLength::PercentageLength, 35);
134 widths << QTextLength(QTextLength::PercentageLength, 65);
135 tf.setColumnWidthConstraints(widths);
137 QTextCharFormat bold;
138 bold.setFontWeight(QFont::Bold);
140 Q_FOREACH (
const QString &line, coreOptions.split(
"\n")) {
141 if (line.startsWith(
" -"))
143 cursor.currentTable()->appendRows(1);
144 cursor.movePosition(QTextCursor::PreviousCell);
145 cursor.movePosition(QTextCursor::NextRow);
146 cursor.insertText(line.trimmed());
147 cursor.movePosition(QTextCursor::NextCell);
148 }
else if (line.startsWith(
" ")) {
149 cursor.insertText(line.trimmed()+
' ');
150 }
else if (line.size() > 0) {
152 if (cursor.currentTable())
153 cursor.currentTable()->appendRows(1);
154 cursor.movePosition(QTextCursor::Down);
155 cursor.insertText(line.trimmed(), bold);
156 cursor.insertTable(1, 2, tf);
160 ui->helpMessage->moveCursor(QTextCursor::Start);
161 ui->scrollArea->setVisible(
false);
162 ui->aboutLogo->setVisible(
false);
174 fprintf(stdout,
"%s\n", qPrintable(
text));
200 ui->buttonBox->addButton(tr(
"Close"), QDialogButtonBox::RejectRole);
203 QFont font(
"Monospace");
205 font.setStyleHint(QFont::TypeWriter);
206 font.setPixelSize(1);
207 ui->addressText->setFont(font);
208 ui->privateKeyText->setFont(font);
209 ui->addressText->setAlignment(Qt::AlignJustify);
210 ui->privateKeyText->setAlignment(Qt::AlignJustify);
211 setFixedSize(size());
220 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);
252 std::string myAddress = pubkeyhash.
ToString();
257 QRcode *code = QRcode_encodeString(myAddress.c_str(), 0, QR_ECLEVEL_M, QR_MODE_8, 1);
259 ui->addressQRCode->setText(tr(
"Error encoding Address into QR Code."));
262 QImage myImage = QImage(code->width, code->width, QImage::Format_ARGB32);
263 myImage.fill(QColor(0, 0, 0, 0));
264 unsigned char* p = code->data;
265 for (
int y = 0; y < code->width; y++) {
266 for (
int x = 0; x < code->width; x++) {
267 myImage.setPixel(x, y, ((*p & 1) ? 0xff000000 : 0x0));
275 code = QRcode_encodeString(myPrivKey.c_str(), 0, QR_ECLEVEL_M, QR_MODE_8, 1);
277 ui->privateKeyQRCode->setText(tr(
"Error encoding private key into QR Code."));
280 QImage myImagePriv = QImage(code->width, code->width, QImage::Format_ARGB32);
281 myImagePriv.fill(QColor(0, 0, 0, 0));
283 for (
int y = 0; y < code->width; y++) {
284 for (
int x = 0; x < code->width; x++) {
285 myImagePriv.setPixel(x, y, ((*p & 1) ? 0xff000000 : 0x0));
292 ui->addressQRCode->setPixmap(QPixmap::fromImage(myImage).scaled(
ui->addressQRCode->width(),
ui->addressQRCode->height()));
293 ui->privateKeyQRCode->setPixmap(QPixmap::fromImage(myImagePriv).scaled(
ui->privateKeyQRCode->width(),
ui->privateKeyQRCode->height()));
297 ui->addressText->setText(myAddress.c_str());
298 ui->privateKeyText->setText(tr(myPrivKey.c_str()));
300 ui->publicKey->setHtml(myPubKey.c_str());
304 double paperHeight = (double)
ui->paperTemplate->height();
305 double maxTextWidth = paperHeight * 0.99;
306 double minTextWidth = paperHeight * 0.95;
307 int pixelSizeStep = 1;
309 int addressTextLength =
ui->addressText->fontMetrics().boundingRect(
ui->addressText->text()).width();
310 QFont font =
ui->addressText->font();
312 if (addressTextLength < minTextWidth) {
313 font.setPixelSize(font.pixelSize() + pixelSizeStep);
314 ui->addressText->setFont(font);
315 addressTextLength =
ui->addressText->fontMetrics().boundingRect(
ui->addressText->text()).width();
320 if (addressTextLength > maxTextWidth) {
321 font.setPixelSize(font.pixelSize() - pixelSizeStep);
322 ui->addressText->setFont(font);
323 addressTextLength =
ui->addressText->fontMetrics().boundingRect(
ui->addressText->text()).width();
326 int privateKeyTextLength =
ui->privateKeyText->fontMetrics().boundingRect(
ui->privateKeyText->text()).width();
327 font =
ui->privateKeyText->font();
329 if (privateKeyTextLength < minTextWidth) {
330 font.setPixelSize(font.pixelSize() + pixelSizeStep);
331 ui->privateKeyText->setFont(font);
332 privateKeyTextLength =
ui->privateKeyText->fontMetrics().boundingRect(
ui->privateKeyText->text()).width();
337 if (privateKeyTextLength > maxTextWidth) {
338 font.setPixelSize(font.pixelSize() - pixelSizeStep);
339 ui->privateKeyText->setFont(font);
340 privateKeyTextLength =
ui->privateKeyText->fontMetrics().boundingRect(
ui->privateKeyText->text()).width();
346 QPrinter printer(QPrinter::HighResolution);
347 QPrintDialog* qpd =
new QPrintDialog(&printer,
this);
349 qpd->setPrintRange(QAbstractPrintDialog::AllPages);
351 QList<QString> recipientPubKeyHashes;
353 if (qpd->exec() != QDialog::Accepted) {
358 printer.setOrientation(QPrinter::Portrait);
359 printer.setPaperSize(QPrinter::A4);
360 printer.setFullPage(
true);
363 if (!painter.begin(&printer)) {
364 QMessageBox::critical(
this,
"Printing Error", tr(
"failed to open file, is it writable?"), QMessageBox::Ok, QMessageBox::Ok);
368 int walletCount =
ui->walletCount->currentIndex() + 1;
369 int walletsPerPage = 4;
372 int walletHeight =
ui->paperTemplate->height();
373 double computedWalletHeight = 0.9 * pageHeight / walletsPerPage;
374 double scale = computedWalletHeight / walletHeight;
375 double walletPadding = pageHeight * 0.05 / (walletsPerPage - 1) / scale;
377 QRegion walletRegion = QRegion(
ui->paperTemplate->x(),
ui->paperTemplate->y(),
ui->paperTemplate->width(),
ui->paperTemplate->height());
378 painter.scale(scale, scale);
380 for (
int i = 0; i < walletCount; i++) {
382 this->render(&painter, point, walletRegion);
383 recipientPubKeyHashes.append(
ui->addressText->text());
385 if (i % walletsPerPage == (walletsPerPage - 1)) {
395 QStringList formatted;
402 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);
414 QList<SendCoinsRecipient> recipients;
415 quint64 amount = (quint64)(amountInput * COIN);
416 Q_FOREACH (
const QString& dest, recipientPubKeyHashes) {
417 recipients.append(
SendCoinsRecipient(dest, tr(
"Paper wallet %1").arg(dest), amount,
""));
418 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)));
430 QMessageBox::critical(
this, tr(
"Send Coins"), tr(
"The recipient address is not valid, please recheck."), QMessageBox::Ok, QMessageBox::Ok);
432 QMessageBox::critical(
this, tr(
"Send Coins"), tr(
"The amount to pay must be larger than 0"), QMessageBox::Ok, QMessageBox::Ok);
434 QMessageBox::critical(
this, tr(
"Send Coins"), tr(
"The amount exceeds your balance."), QMessageBox::Ok, QMessageBox::Ok);
436 QMessageBox::critical(
this, tr(
"Send Coins"), tr(
"The total exceeds your balance when the transaction fee is included"), QMessageBox::Ok, QMessageBox::Ok);
438 QMessageBox::critical(
this, tr(
"Send Coins"), tr(
"Duplicate address found, can only send to each address once per send operation."), QMessageBox::Ok, QMessageBox::Ok);
440 QMessageBox::critical(
this, tr(
"Send Coins"), tr(
"Transaction creation failed!"), QMessageBox::Ok, QMessageBox::Ok);
451 QString questionString = tr(
"Are you sure you want to send?");
452 questionString.append(
"<br /><br />%1");
456 questionString.append(
"<hr /><span style='color:#aa0000;'>");
458 questionString.append(
"</span> ");
459 questionString.append(tr(
"added as transaction fee"));
463 questionString.append(
"<hr />");
465 QStringList alternativeUnits;
471 questionString.append(tr(
"Total Amount %1 (= %2)")
473 .arg(alternativeUnits.join(
" " + tr(
"or") +
" ")));
475 QMessageBox::StandardButton retval = QMessageBox::question(
this, tr(
"Confirm send coins"), questionString.arg(formatted.join(
"<br />")), QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
477 if (retval != QMessageBox::Yes) {
485 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);
496 QVBoxLayout *layout =
new QVBoxLayout();
497 layout->addWidget(
new QLabel(
498 tr(
"%1 is shutting down...").arg(tr(PACKAGE_NAME)) +
"<br /><br />" +
499 tr(
"Do not shut down the computer until this window disappears.")));
510 shutdownWindow->setWindowTitle(window->windowTitle());
513 const QPoint global = window->mapToGlobal(window->rect().center());
514 shutdownWindow->move(global.x() - shutdownWindow->width() / 2, global.y() - shutdownWindow->height() / 2);
515 shutdownWindow->show();
516 return shutdownWindow;
static const std::string DEFAULT_UIPLATFORM
static QList< Unit > availableUnits()
Get list of units, for drop-down box.
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
std::string ToString() const
base58-encoded Bitcoin addresses.
bool Set(const CKeyID &id)
A base58-encoded secret key.
An encapsulated private key.
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
CPubKey GetPubKey() const
Compute the public key from a private key.
An encapsulated public key.
const unsigned char * end() const
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
const unsigned char * begin() const
Model for Bitcoin network client.
bool getNetworkActive() const
Return true if network activity in core is enabled.
static CCoinControl * coinControl
"Help message" dialog box
void on_okButton_accepted()
HelpMessageDialog(QWidget *parent, bool about)
"Help message" or "About" dialog box
Ui::HelpMessageDialog * ui
bool getCoinControlFeatures()
"Paper Wallet" dialog box
ClientModel * clientModel
Ui::PaperWalletDialog * ui
PaperWalletDialog(QWidget *parent)
"PaperWallet" dialog box
void setClientModel(ClientModel *clientModel)
static const int PAPER_WALLET_READJUST_LIMIT
void setModel(WalletModel *model)
void on_getNewAddress_clicked()
static const int PAPER_WALLET_PAGE_MARGIN
void on_printButton_clicked()
static QWidget * showShutdownWindow(BitcoinGUI *window)
ShutdownWindow(QWidget *parent=0, Qt::WindowFlags f=0)
"Shutdown" window
void closeEvent(QCloseEvent *event)
Interface to Bitcoin wallet from Qt view code.
SendCoinsReturn sendCoins(WalletModelTransaction &transaction)
SendCoinsReturn prepareTransaction(WalletModelTransaction &transaction, const CCoinControl *coinControl=NULL)
OptionsModel * getOptionsModel()
UnlockContext requestUnlock()
@ AmountWithFeeExceedsBalance
@ TransactionCreationFailed
@ TransactionCommitFailed
Data model for a walletmodel transaction.
CAmount getTotalTransactionAmount()
CAmount getTransactionFee()
std::string FormatFullVersion()
std::string HelpMessage(HelpMessageMode mode)
Help for options shared between UI and daemon (for -help)
std::string LicenseInfo()
Returns licensing information (for -version)
QString HtmlEscape(const QString &str, bool fMultiLine)
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
std::string HelpMessageGroup(const std::string &message)
Format a string to be used as group of options in help messages.
std::string HelpMessageOpt(const std::string &option, const std::string &message)
Format a string to be used as option description in help messages.
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)