From 601457c2fe92127523370669dd2ffc3fb7977d6a Mon Sep 17 00:00:00 2001 From: vertoe Date: Fri, 5 Dec 2014 10:09:38 +0100 Subject: [PATCH] Change Darkcoin units to DRK and added duffs. --- TODO.md | 3 +- src/qt/bitcoinunits.cpp | 63 +++++++++++++++---------- src/qt/bitcoinunits.h | 14 +++--- src/qt/clientmodel.h | 2 +- src/qt/coincontroldialog.cpp | 9 ++-- src/qt/forms/sendcoinsentry.ui | 4 +- src/qt/forms/signverifymessagedialog.ui | 8 ++-- src/qt/guiutil.cpp | 37 ++++++++------- src/qt/optionsmodel.cpp | 3 +- src/qt/overviewpage.cpp | 7 +-- src/qt/signverifymessagedialog.cpp | 5 +- 11 files changed, 88 insertions(+), 67 deletions(-) diff --git a/TODO.md b/TODO.md index 5803f6cd25..afdb074934 100644 --- a/TODO.md +++ b/TODO.md @@ -21,6 +21,8 @@ DONE: - Defined regression test genesis block - Updated wallet layout and branding - Reset testnet (v4) with new genesis and address version (start with x) +- BIP0032 addresses xpub and xpriv start with x (unchanged by design) +- Changed Darkcoin units to DRK and added duffs MANDATORY: @@ -33,7 +35,6 @@ MANDATORY: OPTIONAL: --------- -- Define BIP0032 addresses EXT_PUBLIC_KEY and EXT_SECRET_KEY for Darkcoin - Include Evan's public key for msg signing - Darksend, Instant Transactions, Atomic Transfers, etc. pp. - Include centralized checkpoint syncing (peercoin style) diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp index 2fed443cf2..7fdc32fc3f 100644 --- a/src/qt/bitcoinunits.cpp +++ b/src/qt/bitcoinunits.cpp @@ -1,4 +1,5 @@ -// Copyright (c) 2011-2013 The Bitcoin developers +// Copyright (c) 2011-2014 The Bitcoin developers +// Copyright (c) 2014 vertoe & the Darkcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -15,9 +16,10 @@ BitcoinUnits::BitcoinUnits(QObject *parent): QList BitcoinUnits::availableUnits() { QList unitlist; - unitlist.append(BTC); - unitlist.append(mBTC); - unitlist.append(uBTC); + unitlist.append(DRK); + unitlist.append(mDRK); + unitlist.append(uDRK); + unitlist.append(duffs); return unitlist; } @@ -25,9 +27,10 @@ bool BitcoinUnits::valid(int unit) { switch(unit) { - case BTC: - case mBTC: - case uBTC: + case DRK: + case mDRK: + case uDRK: + case duffs: return true; default: return false; @@ -38,9 +41,10 @@ QString BitcoinUnits::name(int unit) { switch(unit) { - case BTC: return QString("BTC"); - case mBTC: return QString("mBTC"); - case uBTC: return QString::fromUtf8("μBTC"); + case DRK: return QString("DRK"); + case mDRK: return QString("mDRK"); + case uDRK: return QString::fromUtf8("μDRK"); + case duffs: return QString::fromUtf8("duffs"); default: return QString("???"); } } @@ -49,9 +53,10 @@ QString BitcoinUnits::description(int unit) { switch(unit) { - case BTC: return QString("Bitcoins"); - case mBTC: return QString("Milli-Bitcoins (1 / 1,000)"); - case uBTC: return QString("Micro-Bitcoins (1 / 1,000,000)"); + case DRK: return QString("Darkcoins"); + case mDRK: return QString("Milli-Darkcoins (1 / 1,000)"); + case uDRK: return QString("Micro-Darkcoins (1 / 1,000,000)"); + case duffs: return QString("Ten Nano-Darkcoins (1 / 100,000,000)"); default: return QString("???"); } } @@ -60,9 +65,10 @@ qint64 BitcoinUnits::factor(int unit) { switch(unit) { - case BTC: return 100000000; - case mBTC: return 100000; - case uBTC: return 100; + case DRK: return 100000000; + case mDRK: return 100000; + case uDRK: return 100; + case duffs: return 1; default: return 100000000; } } @@ -71,9 +77,10 @@ qint64 BitcoinUnits::maxAmount(int unit) { switch(unit) { - case BTC: return Q_INT64_C(21000000); - case mBTC: return Q_INT64_C(21000000000); - case uBTC: return Q_INT64_C(21000000000000); + case DRK: return Q_INT64_C(21000000); + case mDRK: return Q_INT64_C(21000000000); + case uDRK: return Q_INT64_C(21000000000000); + case duffs: return Q_INT64_C(2100000000000000); default: return 0; } } @@ -82,9 +89,10 @@ int BitcoinUnits::amountDigits(int unit) { switch(unit) { - case BTC: return 8; // 21,000,000 (# digits, without commas) - case mBTC: return 11; // 21,000,000,000 - case uBTC: return 14; // 21,000,000,000,000 + case DRK: return 8; // 21,000,000 (# digits, without commas) + case mDRK: return 11; // 21,000,000,000 + case uDRK: return 14; // 21,000,000,000,000 + case duffs: return 16; // 2,100,000,000,000,000 default: return 0; } } @@ -93,9 +101,10 @@ int BitcoinUnits::decimals(int unit) { switch(unit) { - case BTC: return 8; - case mBTC: return 5; - case uBTC: return 2; + case DRK: return 8; + case mDRK: return 5; + case uDRK: return 2; + case duffs: return 0; default: return 0; } } @@ -124,6 +133,10 @@ QString BitcoinUnits::format(int unit, qint64 n, bool fPlus) quotient_str.insert(0, '-'); else if (fPlus && n > 0) quotient_str.insert(0, '+'); + + if (num_decimals <= 0) + return quotient_str; + return quotient_str + QString(".") + remainder_str; } diff --git a/src/qt/bitcoinunits.h b/src/qt/bitcoinunits.h index 46517fc07b..549e80a04d 100644 --- a/src/qt/bitcoinunits.h +++ b/src/qt/bitcoinunits.h @@ -1,4 +1,5 @@ -// Copyright (c) 2011-2013 The Bitcoin developers +// Copyright (c) 2011-2014 The Bitcoin developers +// Copyright (c) 2014 vertoe & the Darkcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -8,7 +9,7 @@ #include #include -/** Bitcoin unit definitions. Encapsulates parsing and formatting +/** Darkcoin unit definitions. Encapsulates parsing and formatting and serves as list model for drop-down selection boxes. */ class BitcoinUnits: public QAbstractListModel @@ -18,14 +19,15 @@ class BitcoinUnits: public QAbstractListModel public: explicit BitcoinUnits(QObject *parent); - /** Bitcoin units. + /** Darkcoin units. @note Source: https://en.bitcoin.it/wiki/Units . Please add only sensible ones */ enum Unit { - BTC, - mBTC, - uBTC + DRK, + mDRK, + uDRK, + duffs }; //! @name Static API diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index b3747cfede..a225931642 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -33,7 +33,7 @@ enum NumConnections { CONNECTIONS_ALL = (CONNECTIONS_IN | CONNECTIONS_OUT), }; -/** Model for Bitcoin network client. */ +/** Model for Darkcoin network client. */ class ClientModel : public QObject { Q_OBJECT diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index dc9d2afe27..7b78c59509 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -1,4 +1,5 @@ -// Copyright (c) 2011-2013 The Bitcoin developers +// Copyright (c) 2011-2014 The Bitcoin developers +// Copyright (c) 2014 vertoe & the Darkcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -573,7 +574,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) } // actually update labels - int nDisplayUnit = BitcoinUnits::BTC; + int nDisplayUnit = BitcoinUnits::DRK; if (model && model->getOptionsModel()) nDisplayUnit = model->getOptionsModel()->getDisplayUnit(); @@ -606,7 +607,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) l5->setStyleSheet((nBytes >= 1000) ? "color:red;" : ""); // Bytes >= 1000 l6->setStyleSheet((dPriority > 0 && !AllowFree(dPriority)) ? "color:red;" : ""); // Priority < "medium" l7->setStyleSheet((fLowOutput) ? "color:red;" : ""); // Low Output = "yes" - l8->setStyleSheet((nChange > 0 && nChange < CENT) ? "color:red;" : ""); // Change < 0.01BTC + l8->setStyleSheet((nChange > 0 && nChange < CENT) ? "color:red;" : ""); // Change < 0.01DRK // tool tips QString toolTip1 = tr("This label turns red, if the transaction size is greater than 1000 bytes.") + "

"; @@ -704,7 +705,7 @@ void CoinControlDialog::updateView() { sAddress = CBitcoinAddress(outputAddress).ToString().c_str(); - // if listMode or change => show bitcoin address. In tree mode, address is not shown again for direct wallet address outputs + // if listMode or change => show darkcoin address. In tree mode, address is not shown again for direct wallet address outputs if (!treeMode || (!(sAddress == sWalletAddress))) itemOutput->setText(COLUMN_ADDRESS, sAddress); diff --git a/src/qt/forms/sendcoinsentry.ui b/src/qt/forms/sendcoinsentry.ui index e77de0d9b8..d29f07258e 100644 --- a/src/qt/forms/sendcoinsentry.ui +++ b/src/qt/forms/sendcoinsentry.ui @@ -51,7 +51,7 @@ - The address to send the payment to (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L) + The address to send the payment to (e.g. XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg) @@ -154,7 +154,7 @@ - A message that was attached to the bitcoin: URI which will be stored with the transaction for your reference. Note: This message will not be sent over the Bitcoin network. + A message that was attached to the darkcoin: URI which will be stored with the transaction for your reference. Note: This message will not be sent over the Darkcoin network. Qt::PlainText diff --git a/src/qt/forms/signverifymessagedialog.ui b/src/qt/forms/signverifymessagedialog.ui index aa271b4f2a..a25d8cc18f 100644 --- a/src/qt/forms/signverifymessagedialog.ui +++ b/src/qt/forms/signverifymessagedialog.ui @@ -45,7 +45,7 @@ - The address to sign the message with (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L) + The address to sign the message with (e.g. XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg) @@ -149,7 +149,7 @@ - Sign the message to prove you own this Bitcoin address + Sign the message to prove you own this Darkcoin address Sign &Message @@ -255,7 +255,7 @@ - The address the message was signed with (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L) + The address the message was signed with (e.g. XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg) @@ -292,7 +292,7 @@ - Verify the message to ensure it was signed with the specified Bitcoin address + Verify the message to ensure it was signed with the specified Darkcoin address Verify &Message diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 004befe3cc..c51c5df246 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -1,4 +1,5 @@ -// Copyright (c) 2011-2013 The Bitcoin developers +// Copyright (c) 2011-2014 The Bitcoin developers +// Copyright (c) 2014 vertoe & the Darkcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -97,7 +98,7 @@ void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent) widget->setFont(bitcoinAddressFont()); #if QT_VERSION >= 0x040700 - widget->setPlaceholderText(QObject::tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)")); + widget->setPlaceholderText(QObject::tr("Enter a Darkcoin address (e.g. XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg)")); #endif widget->setValidator(new BitcoinAddressEntryValidator(parent)); widget->setCheckValidator(new BitcoinAddressCheckValidator(parent)); @@ -114,8 +115,8 @@ void setupAmountWidget(QLineEdit *widget, QWidget *parent) bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out) { - // return if URI is not valid or is no bitcoin: URI - if(!uri.isValid() || uri.scheme() != QString("bitcoin")) + // return if URI is not valid or is no darkcoin: URI + if(!uri.isValid() || uri.scheme() != QString("darkcoin")) return false; SendCoinsRecipient rv; @@ -151,7 +152,7 @@ bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out) { if(!i->second.isEmpty()) { - if(!BitcoinUnits::parse(BitcoinUnits::BTC, i->second, &rv.amount)) + if(!BitcoinUnits::parse(BitcoinUnits::DRK, i->second, &rv.amount)) { return false; } @@ -171,13 +172,13 @@ bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out) bool parseBitcoinURI(QString uri, SendCoinsRecipient *out) { - // Convert bitcoin:// to bitcoin: + // Convert darkcoin:// to darkcoin: // - // Cannot handle this later, because bitcoin:// will cause Qt to see the part after // as host, + // Cannot handle this later, because darkcoin:// will cause Qt to see the part after // as host, // which will lower-case it (and thus invalidate the address). - if(uri.startsWith("bitcoin://", Qt::CaseInsensitive)) + if(uri.startsWith("darkcoin://", Qt::CaseInsensitive)) { - uri.replace(0, 10, "bitcoin:"); + uri.replace(0, 10, "darkcoin:"); } QUrl uriInstance(uri); return parseBitcoinURI(uriInstance, out); @@ -185,12 +186,12 @@ bool parseBitcoinURI(QString uri, SendCoinsRecipient *out) QString formatBitcoinURI(const SendCoinsRecipient &info) { - QString ret = QString("bitcoin:%1").arg(info.address); + QString ret = QString("darkcoin:%1").arg(info.address); int paramCount = 0; if (info.amount) { - ret += QString("?amount=%1").arg(BitcoinUnits::format(BitcoinUnits::BTC, info.amount)); + ret += QString("?amount=%1").arg(BitcoinUnits::format(BitcoinUnits::DRK, info.amount)); paramCount++; } @@ -537,12 +538,12 @@ TableViewLastColumnResizingFixer::TableViewLastColumnResizingFixer(QTableView* t #ifdef WIN32 boost::filesystem::path static StartupShortcutPath() { - return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin.lnk"; + return GetSpecialFolderPath(CSIDL_STARTUP) / "Darkcoin.lnk"; } bool GetStartOnSystemStartup() { - // check for Bitcoin.lnk + // check for Darkcoin.lnk return boost::filesystem::exists(StartupShortcutPath()); } @@ -619,7 +620,7 @@ boost::filesystem::path static GetAutostartDir() boost::filesystem::path static GetAutostartFilePath() { - return GetAutostartDir() / "bitcoin.desktop"; + return GetAutostartDir() / "darkcoin.desktop"; } bool GetStartOnSystemStartup() @@ -657,10 +658,10 @@ bool SetStartOnSystemStartup(bool fAutoStart) boost::filesystem::ofstream optionFile(GetAutostartFilePath(), std::ios_base::out|std::ios_base::trunc); if (!optionFile.good()) return false; - // Write a bitcoin.desktop file to the autostart directory: + // Write a darkcoin.desktop file to the autostart directory: optionFile << "[Desktop Entry]\n"; optionFile << "Type=Application\n"; - optionFile << "Name=Bitcoin\n"; + optionFile << "Name=Darkcoin\n"; optionFile << "Exec=" << pszExePath << " -min\n"; optionFile << "Terminal=false\n"; optionFile << "Hidden=false\n"; @@ -679,7 +680,7 @@ bool SetStartOnSystemStartup(bool fAutoStart) LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl); LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl) { - // loop through the list of startup items and try to find the bitcoin app + // loop through the list of startup items and try to find the darkcoin app CFArrayRef listSnapshot = LSSharedFileListCopySnapshot(list, NULL); for(int i = 0; i < CFArrayGetCount(listSnapshot); i++) { LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(listSnapshot, i); @@ -713,7 +714,7 @@ bool SetStartOnSystemStartup(bool fAutoStart) LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl); if(fAutoStart && !foundItem) { - // add bitcoin app to startup item list + // add darkcoin app to startup item list LSSharedFileListInsertItemURL(loginItems, kLSSharedFileListItemBeforeFirst, NULL, NULL, bitcoinAppUrl, NULL, NULL); } else if(!fAutoStart && foundItem) { diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index e87a1d97e7..711878800a 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2011-2014 The Bitcoin developers +// Copyright (c) 2014 vertoe & the Darkcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -56,7 +57,7 @@ void OptionsModel::Init() // Display if (!settings.contains("nDisplayUnit")) - settings.setValue("nDisplayUnit", BitcoinUnits::BTC); + settings.setValue("nDisplayUnit", BitcoinUnits::DRK); nDisplayUnit = settings.value("nDisplayUnit").toInt(); if (!settings.contains("bDisplayAddresses")) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 1a9d1de571..3844356c9b 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -1,4 +1,5 @@ -// Copyright (c) 2011-2013 The Bitcoin developers +// Copyright (c) 2011-2014 The Bitcoin developers +// Copyright (c) 2014 vertoe & the Darkcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -24,7 +25,7 @@ class TxViewDelegate : public QAbstractItemDelegate { Q_OBJECT public: - TxViewDelegate(): QAbstractItemDelegate(), unit(BitcoinUnits::BTC) + TxViewDelegate(): QAbstractItemDelegate(), unit(BitcoinUnits::DRK) { } @@ -188,7 +189,7 @@ void OverviewPage::setWalletModel(WalletModel *model) connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); } - // update the display unit, to not use the default ("BTC") + // update the display unit, to not use the default ("DRK") updateDisplayUnit(); } diff --git a/src/qt/signverifymessagedialog.cpp b/src/qt/signverifymessagedialog.cpp index 3e56412c7c..b3268faf8b 100644 --- a/src/qt/signverifymessagedialog.cpp +++ b/src/qt/signverifymessagedialog.cpp @@ -1,4 +1,5 @@ -// Copyright (c) 2011-2013 The Bitcoin developers +// Copyright (c) 2011-2014 The Bitcoin developers +// Copyright (c) 2014 vertoe & the Darkcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -27,7 +28,7 @@ SignVerifyMessageDialog::SignVerifyMessageDialog(QWidget *parent) : #if QT_VERSION >= 0x040700 ui->signatureOut_SM->setPlaceholderText(tr("Click \"Sign Message\" to generate signature")); - ui->addressIn_VM->setPlaceholderText(tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)")); + ui->addressIn_VM->setPlaceholderText(tr("Enter a Darkcoin address (e.g. XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg)")); #endif GUIUtil::setupAddressWidget(ui->addressIn_SM, this);