[Dev] Documenting Feathercoin Specific Software settings - Part 7
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Restore experimental notice : - commit
https://github.com/FeatherCoin/Feathercoin/commit/96aad5e0265f0892b8d8c434d9c54fb6d68bad5a
User interface changes
COPYING
+ Copyright (c) 2013-2014 Feathercoin Developers
One file updated, copyright. How to handle copy rights - just do a sweep / search and replace in one commit?
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
fix Total Line 1 : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3307d437c2fb98806ee2a83bc5e7455d7985b0a4
User interface changes
src/qt/reportview.cpp
+ //view->setFixedHeight(360); vlayout->addWidget(view); + + QTableView *viewT = new QTableView(this); + viewT->setFixedHeight(26); + vlayout->addWidget(viewT);
fix Total Line 1 Code added.
+ reportViewT=viewT;
Code added
- reportView->setShowGrid(false); + reportView->setShowGrid(false); + + reportModelT = new QStandardItemModel(this); + reportViewT->setModel(reportModelT); + reportViewT->setAlternatingRowColors(true); + reportViewT->setSelectionBehavior(QAbstractItemView::SelectRows); + reportViewT->setSelectionMode(QAbstractItemView::ExtendedSelection); + reportViewT->verticalHeader()->hide(); + reportViewT->setShowGrid(false); +
Code replaced / added.
- reportModel->setRowCount(addresslist.size()+1); + reportModel->setRowCount(addresslist.size());
Code replaced
- reportModel->setItem(i,0,new QStandardItem(tr("Total"))); - reportModel->setItem(i,1,new QStandardItem(dateWidget->currentText())); - reportModel->setItem(i,2,new QStandardItem(typeWidget->currentText())); - reportModel->setItem(i,3,new QStandardItem(QObject::tr("%1").arg(QObject::tr("%1").arg(fTotal)))); - reportModel->setItem(i,4,new QStandardItem(QObject::tr("%1").arg(iTimes))); - reportModel->item(i,0)->setTextAlignment(Qt::AlignCenter); - reportModel->item(i,2)->setTextAlignment(Qt::AlignCenter); - reportModel->item(i,3)->setTextAlignment(Qt::AlignCenter); - reportModel->item(i,4)->setTextAlignment(Qt::AlignCenter); - reportModel->item(i,0)->setFont(QFont("Times", 10, QFont::Black)); - reportModel->item(i,1)->setFont(QFont("Times", 10, QFont::Black)); - reportModel->item(i,2)->setFont(QFont("Times", 10, QFont::Black)); - reportModel->item(i,3)->setFont(QFont("Times", 10, QFont::Black)); - reportModel->item(i,4)->setFont(QFont("Times", 10, QFont::Black));
Code removed
+ //Total Line + reportModelT->clear(); + reportModelT->setRowCount(1); + reportModelT->setHorizontalHeaderItem(0, new QStandardItem(tr("AddressLabel"))); + reportModelT->setHorizontalHeaderItem(1, new QStandardItem(tr("DateRange"))); + reportModelT->setHorizontalHeaderItem(2, new QStandardItem(tr("Type"))); + reportModelT->setHorizontalHeaderItem(3, new QStandardItem(tr("Payment amount"))); + reportModelT->setHorizontalHeaderItem(4, new QStandardItem(tr("Number of payments"))); + reportViewT->horizontalHeader()->resizeSection(0, 270); + reportViewT->horizontalHeader()->resizeSection(1, 120); + reportViewT->horizontalHeader()->resizeSection(2, 120); + reportViewT->horizontalHeader()->resizeSection(3, 140); + reportViewT->horizontalHeader()->resizeSection(4, 140); + reportModelT->setItem(0,0,new QStandardItem(tr("Total"))); + reportModelT->setItem(0,1,new QStandardItem(dateWidget->currentText())); + reportModelT->setItem(0,2,new QStandardItem(typeWidget->currentText())); + reportModelT->setItem(0,3,new QStandardItem(QObject::tr("%1").arg(QObject::tr("%1").arg(fTotal)))); + reportModelT->setItem(0,4,new QStandardItem(QObject::tr("%1").arg(iTimes))); + reportModelT->item(0,0)->setTextAlignment(Qt::AlignCenter); + reportModelT->item(0,1)->setTextAlignment(Qt::AlignCenter); + reportModelT->item(0,2)->setTextAlignment(Qt::AlignCenter); + reportModelT->item(0,3)->setTextAlignment(Qt::AlignCenter); + reportModelT->item(0,4)->setTextAlignment(Qt::AlignCenter); + reportModelT->item(0,0)->setFont(QFont("Times", 10, QFont::Black)); + reportModelT->item(0,1)->setFont(QFont("Times", 10, QFont::Black)); + reportModelT->item(0,2)->setFont(QFont("Times", 10, QFont::Black)); + reportModelT->item(0,3)->setFont(QFont("Times", 10, QFont::Black)); + reportModelT->item(0,4)->setFont(QFont("Times", 10, QFont::Black)); + reportViewT->horizontalHeader()->hide();
Code replaced.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
fix Total Line 2 : - commit
https://github.com/FeatherCoin/Feathercoin/commit/b01ecc54adb6364ddea6360d16c6b39e86e00b84
User interface changes
src/qt/reportview.h
+ QTableView *reportViewT;
Code added
+ QStandardItemModel *reportModelT;
Code added
-#endif // REPORTVIEW_H +#endif // REPORTVIEW_H
Code replaced
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Adds in support for printing paper wallets : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3689244d7b94650c257cc4b7e8151b427b6cd6cf
Adds support for printing paper wallets
contrib/feathercoin-qt.pro
+ ../src/qt/feathercoin.qrc + + QT + = \ + printsupport
Add code to .pro file.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Adds in support for printing paper wallets : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3689244d7b94650c257cc4b7e8151b427b6cd6cf
Adds support for printing paper wallets
src/m4/bitcoin_qt.m4
+ qt5_modules="Qt5Core Qt5Gui Qt5Network Qt5Widgets Qt5PrintSupport"
Replace code to add Qt5PrintSupport
+ QT_INCLUDES="-I$qt_include_path -I$qt_include_path/QtCore -I$qt_include_path/QtGui -I$qt_include_path/QtWidgets -I$qt_include_path/QtNetwork -I$qt_include_path/QtTest -I$qt_include_path/QtDBus -I$qt_include_path/QtPrintSupport"
Code replaced to add I$qt_include_path/QtPrintSupport
+ LIBS="$LIBS -L$qt_plugin_path/printsupport"
Code added
+ BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}PrintSupport],[main],,BITCOIN_QT_FAIL(lib$QT_LIB_PREFIXPrintSupport not found))) + _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QMinimalIntegrationPlugin)],[-lqminimal]) + _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QWindowsPrinterSupportPlugin)],[-lwindowsprintersupport])
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Adds in support for printing paper wallets : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3689244d7b94650c257cc4b7e8151b427b6cd6cf
Adds support for printing paper wallets
src/qt/Makefile.am
+ forms/paperwalletdialog.ui \ + moc_verticallabel.cpp \ + res/icons/print.png \ + RES_FONTS = \ + res/fonts/ComicNeue-Bold.ttf \ + res/fonts/ComicNeue-Bold-Oblique.ttf \ + res/fonts/ComicNeue-Light.ttf \ + res/fonts/ComicNeue-Light-Oblique.ttf \ + res/fonts/ComicNeue-Regular.ttf \ + res/fonts/ComicNeue-Regular-Oblique.ttf + + verticallabel.cpp \ + verticallabel.cpp \ + res/images/paper_wallet.png \
Code added
+ $(QT_QRC) $(QT_TS) $(PROTOBUF_PROTO) $(RES_ICONS) $(RES_IMAGES) $(RES_MOVIES) $(RES_FONTS)
Code replaced
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Adds in support for printing paper wallets : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3689244d7b94650c257cc4b7e8151b427b6cd6cf
Adds support for printing paper wallets
src/qt/bitcoingui.cpp
+ paperWalletAction = new QAction(QIcon(":/icons/print"), tr("&Print paper wallets"), this); + paperWalletAction->setStatusTip(tr("Print paper wallets"));
Code added
+ connect(shapeshiftAction, SIGNAL(triggered()), this, SLOT(openShapeshiftClicked())); + connect(paperWalletAction, SIGNAL(triggered()), walletFrame, SLOT(printPaperWallets()));
Code replaced
+ file->addAction(paperWalletAction); + paperWalletAction->setEnabled(enabled);
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Adds in support for printing paper wallets : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3689244d7b94650c257cc4b7e8151b427b6cd6cf
Adds support for printing paper wallets
src/qt/bitcoingui.h
+ QAction *paperWalletAction;
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Adds in support for printing paper wallets : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3689244d7b94650c257cc4b7e8151b427b6cd6cf
Adds support for printing paper wallets
src/qt/feathercoin.qrc
+ <file alias="print">res/icons/print.png</file>
Code added
+ <file alias="paper_wallet">res/images/paper_wallet.png</file>
Code added
+ <qresource prefix="/fonts"> + <file alias="ComicNeue-Bold">res/fonts/ComicNeue-Bold.ttf</file> + <file alias="ComicNeue-Bold-Oblique">res/fonts/ComicNeue-Bold-Oblique.ttf</file> + <file alias="ComicNeue-Light">res/fonts/ComicNeue-Light.ttf</file> + <file alias="ComicNeue-Light-Oblique">res/fonts/ComicNeue-Light-Oblique.ttf</file> + <file alias="ComicNeue-Regular">res/fonts/ComicNeue-Regular.ttf</file> + <file alias="ComicNeue-Regular-Oblique">res/fonts/ComicNeue-Regular-Oblique.ttf</file> + </qresource>
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Adds in support for printing paper wallets : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3689244d7b94650c257cc4b7e8151b427b6cd6cf
Adds support for printing paper wallets
src/qt/forms/paperwalletdialog.ui
+ <?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>
Initial code of new paper wallet ui file, 339 lines of code
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Adds in support for printing paper wallets : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3689244d7b94650c257cc4b7e8151b427b6cd6cf
Adds support for printing paper wallets
src/qt/locale/bitcoin_zh_CN.ts
Update to translation files text.
+ <source>This is experimental software.</source> + <translation>这是一个实验性软件。</translation> + </message> + <message>
New text
+ <message> + <source>Stealth Address</source> + <translation>隐身地址</translation> + </message>
New text
+ <source>&Print paper wallets</source> + <translation>打印纸钱包(&P)</translation> + </message> + <message>
New text
+ <message> + <source>Stealth Address</source> + <translation>隐身地址</translation> + </message>
New text
+ <name>PaperWalletDialog</name> + <message> + <source>Warning: Network Activity Detected</source> + <translation>警告:网络活动检测</translation> + </message> + <message> + <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>建议打印纸钱包之前从网上断开。尽管纸钱包是在您的本地计算机生成的,恶意软件仍有可能在不知不觉中将你的屏幕发送到远程。还建议打印到本地打印机和网络打印机之后,可以对网络流量进行监控。此外一些先进的打印机会存储每个打印文档的副本。因此,请对你的计划谨慎行事。</translation> + </message> + <message> + <source>Print Your Paper Wallets</source> + <translation>打印你的纸钱包</translation> + </message> + <message> + <source>Very New Address</source> + <translation>最新地址</translation> + </message> + <message> + <source>Public Key:</source> + <translation>公匙:</translation> + </message> + <message> + <source>Many Wallets?</source> + <translation>钱包个数?</translation> + </message> + <message> + <source>So Print</source> + <translation>开始打印</translation> + </message> + <message> + <source>Close</source> + <translation>关闭</translation> + </message> + </context> + <context>
New text
+ <source>&Print paper wallets</source> + <translation>打印纸钱包(&P)</translation> + </message> + <message>
New text
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Adds in support for printing paper wallets : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3689244d7b94650c257cc4b7e8151b427b6cd6cf
Adds support for printing paper wallets
src/qt/res/fonts/*
src/qt/res/fonts/ComicNeue-Bold-Oblique.ttf src/qt/res/fonts/ComicNeue-Bold.ttf src/qt/res/fonts/ComicNeue-Light-Oblique.ttf src/qt/res/fonts/ComicNeue-Light.ttf src/qt/res/fonts/ComicNeue-Regular-Oblique.ttf src/qt/res/fonts/ComicNeue-Regular.ttf src/qt/res/icons/print.png src/qt/res/images/paper_wallet.png
New files added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Adds in support for printing paper wallets : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3689244d7b94650c257cc4b7e8151b427b6cd6cf
Adds support for printing paper wallets
src/qt/utilitydialog.cpp
+#include "ui_paperwalletdialog.h" + #include "bitcoinunits.h" + + #ifdef ENABLE_WALLET + #include "sendcoinsdialog.h" + #include "sendcoinsentry.h" + #include "coincontrol.h" + #include "coincontroldialog.h" + #endif
Code added
+ #include "net.h" + #include <QFont> + #include <QInputDialog> + + #ifdef USE_QRCODE + #include <qrencode.h> + #endif + + + // Use QT5's new modular classes + #include <QtPrintSupport/QPrinter> + #include <QtPrintSupport/QPrintDialog> + #include <QtPrintSupport/QPrintPreviewDialog> + #include <QPainter> + #include "walletmodel.h"
Code added
+ /** "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); + + if (vNodes.size() > 0) { + + QMessageBox::critical(this, tr("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 + string myPrivKey = CBitcoinSecret(privKey).ToString(); + string myPubKey = HexStr(pubkey.begin(), pubkey.end()); + 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 publicKeyImage = QImage(code->width, code->width, QImage::Format_ARGB32); + publicKeyImage.fill(0x000000); + unsigned char *p = code->data; + for (int y = 0; y < code->width; y++ ) + { + for (int x = 0; x < code->width; x++ ) + { + publicKeyImage.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 privateKeyImage = QImage(code->width, code->width, QImage::Format_ARGB32); + privateKeyImage.fill(0x000000); + p = code->data; + for (int y = 0; y < code->width; y++ ) + { + for (int x = 0; x < code->width; x++ ) + { + privateKeyImage.setPixel(x, y, ((*p & 1) ? 0xff000000 : 0x0)); + p++ ; + } + } + QRcode_free(code); + + // Populate the QR Codes + ui->addressQRCode->setPixmap(QPixmap::fromImage(publicKeyImage).scaled(ui->addressQRCode->width(), ui->addressQRCode->height())); + ui->privateKeyQRCode->setPixmap(QPixmap::fromImage(privateKeyImage).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 FTC 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 ); + 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; + 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; + + } + +
Large section of additional code
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Adds in support for printing paper wallets : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3689244d7b94650c257cc4b7e8151b427b6cd6cf
Adds support for printing paper wallets
src/qt/utilitydialog.h
+#include "walletmodel.h" + class PaperWalletDialog;
Code added
+ /** "Paper Wallet" dialog box */ + class PaperWalletDialog : public QDialog + { + Q_OBJECT + + public: + explicit PaperWalletDialog(QWidget *parent); + ~PaperWalletDialog(); + + void setModel(WalletModel *model); + + private: + Ui::PaperWalletDialog *ui; + WalletModel *model; + static const int PAPER_WALLET_READJUST_LIMIT = 20; + static const int PAPER_WALLET_PAGE_MARGIN = 50; + + private slots: + void on_getNewAddress_clicked(); + void on_printButton_clicked(); + }; +
Section of code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Adds in support for printing paper wallets : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3689244d7b94650c257cc4b7e8151b427b6cd6cf
Adds support for printing paper wallets
src/qt/verticallabel.cpp
New files
+ #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()); + }
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Adds in support for printing paper wallets : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3689244d7b94650c257cc4b7e8151b427b6cd6cf
Adds support for printing paper wallets
src/qt/verticallabel.h
+ #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
Code added new file
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Adds in support for printing paper wallets : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3689244d7b94650c257cc4b7e8151b427b6cd6cf
Adds support for printing paper wallets
src/qt/walletframe.cpp
+#include <iostream>
Code added
+ void WalletFrame::printPaperWallets() + { + WalletView *walletView = currentWalletView(); + if (walletView) + walletView->printPaperWallets(); + } +
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Adds in support for printing paper wallets : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3689244d7b94650c257cc4b7e8151b427b6cd6cf
Adds support for printing paper wallets
src/qt/walletframe.h
+ /** Open the print paper wallets dialog **/ + void printPaperWallets();
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Adds in support for printing paper wallets : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3689244d7b94650c257cc4b7e8151b427b6cd6cf
Adds support for printing paper wallets
src/qt/walletview.cpp
+#include "utilitydialog.h" + + void WalletView::printPaperWallets() + { + if(!walletModel) + return; + + PaperWalletDialog dlg(this); + dlg.setModel(walletModel); + dlg.exec(); + }
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Adds in support for printing paper wallets : - commit
https://github.com/FeatherCoin/Feathercoin/commit/3689244d7b94650c257cc4b7e8151b427b6cd6cf
Adds support for printing paper wallets
src/qt/walletview.h
+ /** Open the print paper wallets dialog **/ + void printPaperWallets();
Code added