[Dev] Documenting Feathercoin Specific Software settings - Part 9
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/bitcoingui.cpp
+ + multiSigAction = new QAction(QIcon(":/icons/multisig"), tr("&MultiSig"), this); + multiSigAction->setStatusTip(tr("Manage MultiSig transactions")); + multiSigAction->setToolTip(multiSigAction->statusTip()); + multiSigAction->setCheckable(true); + multiSigAction->setShortcut(QKeySequence(Qt::ALT+ Qt::Key_6)); + tabGroup->addAction(multiSigAction);
Code added
+ connect(multiSigAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(multiSigAction, SIGNAL(triggered()), this, SLOT(gotoMultiSigPage())); + advanced->addAction(multiSigAction); + toolbar->addAction(multiSigAction); + multiSigAction->setEnabled(enabled); +void BitcoinGUI::gotoMultiSigPage() +{ + multiSigAction->setChecked(true); + if (walletFrame) walletFrame->gotoMultiSigPage(); +} +
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/bitcoingui.h
+ QAction *multiSigAction;
Code added
+ /** Switch to MultiSig page */ + void gotoMultiSigPage(); +
Code replaced
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/createmultisigaddrdialog.cpp
New file Large amount of new code, 298 lines
+#include "createmultisigaddrdialog.h" +#include "ui_createmultisigaddrdialog.h" + +#include "addresstablemodel.h" +#include "guiutil.h" + +#include "wallet.h" +#include "base58.h" +#include "init.h" +#include "util.h" + +#include "json/json_spirit.h" +#include "json/json_spirit_reader_template.h" +#include "json/json_spirit_writer_template.h" +using namespace json_spirit; + +#include <QSortFilterProxyModel> +#include <QClipboard> +#include <QMessageBox> +#include <QMenu> +#include <QTextDocument> +#include <QScrollBar> +#include <QFile> +#include <QTextStream> +#include <QDataWidgetMapper> + +CreateMultiSigAddrDialog::CreateMultiSigAddrDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::CreateMultiSigAddrDialog) +{ + ui->setupUi(this); + + connect(ui->btnCreate, SIGNAL(clicked()), this, SLOT(create())); + connect(ui->btnCancel, SIGNAL(clicked()), this, SLOT(cancel())); + + ui->comboBoxRequire->addItem(QString("1"), QVariant(1)); + ui->comboBoxRequire->addItem(QString("2"), QVariant(2)); + ui->comboBoxRequire->addItem(QString("3"), QVariant(3)); + ui->comboBoxRequire->setCurrentIndex(1); + + ui->comboBoxTotal->addItem(QString("2"), QVariant(2)); + ui->comboBoxTotal->addItem(QString("3"), QVariant(3)); + ui->comboBoxTotal->setCurrentIndex(0); + currentPubkeyNum = 2; + connect(ui->comboBoxTotal, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int)));
Start of new file code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/createmultisigaddrdialog.h
New file 40 lines code
+#ifndef CREATEMULTISIGADDRESSDIALOG_H +#define CREATEMULTISIGADDRESSDIALOG_H + +#include <QDialog> + +QT_BEGIN_NAMESPACE +class QLabel; +QT_END_NAMESPACE + +namespace Ui { + class CreateMultiSigAddrDialog; +} + +/** Dialog for editing an address and associated information. + */ +class CreateMultiSigAddrDialog : public QDialog +{ + Q_OBJECT + +public: + explicit CreateMultiSigAddrDialog(QWidget *parent = 0); + ~CreateMultiSigAddrDialog(); + +public slots: + void create(); + void cancel(); + void handleSelectionChanged(int idx); + void onTextChanged0(const QString & text); + void onTextChanged1(const QString & text); + void onTextChanged2(const QString & text); + void importAddress(); + void updatePromptText(); + +private: + Ui::CreateMultiSigAddrDialog *ui; + int currentPubkeyNum; + void onTextChanged(QLabel* label, const QString & text); +}; + +#endif // CREATEMULTISIGADDRESSDIALOG_H
Code added new file
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/editaddressdialog.cpp
+ tr("The entered address \"%1\" is not a valid Feathercoin address.").arg(ui->addressEdit->text()),
Name change to Feathercoin
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/feathercoin.qrc
+ <file alias="multisig">res/icons/multisig.png</file>
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/forms/addressbookpage.ui
Amount of ui changes
+ <string>&New Address</string> + </property> + <property name="icon"> + <iconset resource="../feathercoin.qrc"> + <normaloff>:/icons/add</normaloff>:/icons/add</iconset> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="newMultiSigAddress"> + <property name="text"> + <string>New MultiSig</string>
Example code replaced
+ <widget class="QPushButton" name="signMessage"> + <property name="toolTip"> + <string>Sign a message to prove you own a FTC address</string> + </property> + <property name="text"> + <string>Sign &Message</string> + </property> + <property name="icon"> + <iconset resource="../feathercoin.qrc"> + <normaloff>:/icons/edit</normaloff>:/icons/edit</iconset> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="verifyMessage"> + <property name="toolTip"> + <string>Verify a message to ensure it was signed with a specified FTC address</string> + </property> + <property name="text"> + <string>&Verify Message</string> + </property> + <property name="icon"> + <iconset resource="../feathercoin.qrc"> + <normaloff>:/icons/transaction_0</normaloff>:/icons/transaction_0</iconset> + </property> + </widget> + </item> + <item>
Code replaced
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/forms/createmultisigaddrdialog.ui
Large new file, 159 lines of code
+<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>CreateMultiSigAddrDialog</class> + <widget class="QDialog" name="CreateMultiSigAddrDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>506</width> + <height>209</height> + </rect> + </property> + <property name="windowTitle"> + <string>Create MultiSig Address</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QLabel" name="label0"> + <property name="text"> + <string>PublicKey</string> + </property> + </widget> + </item>
Example new code
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/forms/multisigdialog.ui
New file, 729 lines of code
+<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MultiSigDialog</class> + <widget class="QDialog" name="MultiSigDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>850</width> + <height>400</height> + </rect> + </property> + <property name="windowTitle"> + <string>Send Coins</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0"> + <property name="bottomMargin"> + <number>8</number> + </property> + <item> + <widget class="QFrame" name="frameCoinControl">
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/guiutil.cpp
+QString getLoadFileName(QWidget *parent, const QString &caption, + const QString &dir, + const QString &filter, + QString *selectedSuffixOut) +{ + QString selectedFilter; + QString myDir; + if(dir.isEmpty()) // Default to user documents location + { +#if QT_VERSION < 0x050000 + myDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); +#else + myDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); +#endif + } + else + { + myDir = dir; + } + QString result = QFileDialog::getOpenFileName(parent, caption, myDir, filter, &selectedFilter); + + /* Extract first suffix from filter pattern "Description (*.foo)" or "Description (*.foo *.bar ...) */ + QRegExp filter_re(".* \\(\\*\\.(.*)[ \\)]"); + QString selectedSuffix; + if(filter_re.exactMatch(selectedFilter)) + { + selectedSuffix = filter_re.cap(1); + } + + /* Add suffix if needed */ + QFileInfo info(result); + if(!result.isEmpty()) + { + if(info.suffix().isEmpty() && !selectedSuffix.isEmpty()) + { + /* No suffix specified, add selected suffix */ + if(!result.endsWith(".")) + result.append("."); + result.append(selectedSuffix); + } + } + + /* Return selected suffix if asked to */ + if(selectedSuffixOut) + { + *selectedSuffixOut = selectedSuffix; + } + return result; +} +
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/guiutil.h
+ QString getLoadFileName(QWidget *parent=0, const QString &caption=QString(), + const QString &dir=QString(), const QString &filter=QString(), + QString *selectedSuffixOut=0);
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/locale/bitcoin_zh_CN.ts
Translation file
+ <source>&New Address</source> + <translation>新建(&N)地址</translation> + </message> + <message> + <source>New MultiSig</source> + <translation>新建多重签名</translation>
Code replaced
+ <message> + <source>Sign &Message</source> + <translation>消息签名(&M)</translation> + </message> + <message> + <source>&Verify Message</source> + <translation>验证消息(&V)</translation> + </message> + <message> + <source>Copy &Public Key</source> + <translation>复制公匙(&P)</translation> + </message> + <message> + <source>Copy Private Key</source> + <translation>复制私匙</translation> + </message> + <message> + <source>Export MultiSig Address</source> + <translation>导出多重签名地址</translation> + </message> + <message> + <source>Address "%1" doesn't have public key </source> + <translation>%1在地址簿中不存在公匙</translation> + </message> + <message> + <source>Address "%1" doesn't have private key </source> + <translation>%1在地址簿中不存在死匙</translation> + </message> + <message> + <source>Save MultiSig Address</source> + <translation>保存多重签名地址</translation> + </message> + <message> + <source>Could not write to file %1.</source> + <translation>不能写入文件%1</translation> + </message>
Code added
+ <name>CreateMultiSigAddrDialog</name> + <message> + <source>Create MultiSig Address</source> + <translation>创建多重签名地址</translation> + </message> + <message> + <source>PublicKey</source> + <translation>公匙</translation> + </message> + <message> + <source>You need y keys to create a x-of-y Multisig address</source> + <translation>你需要创建多重签名地址的签名组合</translation> + </message> + <message> + <source>Require</source> + <translation>满足</translation> + </message> + <message> + <source>of</source> + <translation>总数</translation> + </message> + <message> + <source>Import</source> + <translation>导入</translation> + </message> + <message> + <source>Create</source> + <translation>创建</translation> + </message> + <message> + <source>Cancel</source> + <translation>取消</translation> + </message> + <message> + <source>All public keys belong to this wallet!</source> + <translation>所有的公私属于这个钱包!</translation> + </message> + <message> + <source>You need </source> + <translation>你需要</translation> + </message> + <message> + <source> keys to create a </source> + <translation>把钥匙创建一个满足</translation> + </message> + <message> + <source>-of-</source> + <translation>总共</translation> + </message> + <message> + <source> MultiSig address</source> + <translation>的多重签名地址</translation> + </message> + <message> + <source>Load MultiSig Address</source> + <translation>加载多重签名地址</translation> + </message> + <message> + <source>Invalid public key "%1" </source> + <translation>不可用的公匙%1</translation> + </message> +</context> +<context> + <name>MultiSigDialog</name> + <message> + <source>Total balance:</source> + <translation>总额:</translation> + </message> + <message> + <source> Addresses:</source> + <translation> 地址:</translation> + </message> + <message> + <source>Address</source> + <translation>地址</translation> + </message> + <message> + <source>Available: </source> + <translation>可用:</translation> + </message> + <message> + <source>Require 0 of 0 signatures</source> + <translation>要求签名数量满足条件</translation> + </message> + <message> + <source>Import Raw Tx</source> + <translation>导入交易</translation> + </message> + <message> + <source>Export Raw Tx</source> + <translation>导出交易</translation> + </message> + <message> + <source>Unsigned</source> + <translation>未签名</translation> + </message> + <message> + <source>Signed</source> + <translation>签名</translation> + </message> + <message> + <source>Add &Recipient</source> + <translation>添加收款人</translation> + </message> + <message> + <source>Clear &All</source> + <translation>全部清除</translation> + </message> + <message> + <source>S&end</source> + <translation>发送</translation> + </message> + <message> + <source>Send Coins</source> + <translation>支付硬币</translation> + </message> + <message> + <source>Confirm send coins</source> + <translation>确认支付</translation> + </message> + <message> + <source>Are you sure you want to send %1?</source> + <translation>你确定要支付%1个币吗?</translation> + </message> + <message> + <source> and </source> + <translation>和</translation> + </message> + <message> + <source>Load Feathercoin Transaction</source> + <translation>加载羽毛币交易</translation> + </message> + <message> + <source>Feathercoin transaction file (*.ftc)</source> + <translation>羽毛币交易文件(*.ftc)</translation> + </message> + <message> + <source>Save Feathercoin Transaction</source> + <translation>保存羽毛币交易</translation> + </message> + <message> + <source>Error exporting</source> + <translation>导出错误</translation> + </message> + <message> + <source>Could not write to file %1.</source> + <translation>不能写入文件%1。</translation> + </message> + <message> + <source>Require </source> + <translation>满足 </translation> + </message> + <message> + <source> of </source> + <translation> 总共 </translation> + </message> + <message> + <source> signatures </source> + <translation> 签名 </translation> + </message> + <message> + <source>The recipient address is not valid, please recheck.</source> + <translation>收款人地址不合法,请检查。</translation> + </message> + <message> + <source>The amount to pay must be larger than 0.</source> + <translation>支付金额必须大于0。</translation> + </message> + <message> + <source>The amount exceeds your balance.</source> + <translation>金额超出您的账上余额。</translation> + </message> + <message> + <source>The total exceeds your balance when the %1 transaction fee is included.</source> + <translation>计入 %1 交易费后的金额超出您的账上余额。</translation> + </message> + <message> + <source>Duplicate address found, can only send to each address once per send operation.</source> + <translation>发现重复的地址, 每次只能对同一地址发送一次。</translation> + </message> + <message> + <source>Transaction creation failed!</source> + <translation>交易创建失败!</translation> + </message> + <message> + <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>错误:该交易被拒绝!发生这种错误的原因可能是:钱包中的羽毛币已经被用掉,有可能您复制了wallet.dat钱包文件,然后用复制的钱包文件支付了羽毛币,但是这个钱包文件中没有记录。</translation> + </message> +</context> +<context>
Code added
+ <source>Get my account report</source> + <translation>查看我的账户报表</translation> + </message> + <message> + <source>Manage MultiSig transactions</source> + <translation>管理多重签名交易</translation> + </message> + <message>
Code added
+ <source>&MultiSig</source> + <translation>重签签名</translation> + </message> + <message>
Code added
+ <source>Address "%1" doesn't have public key </source> + <translation>地址“%1”公匙不存在于地址簿中</translation> + </message> + <message> + <source>Address "%1" doesn't have private key </source> + <translation>地址“%1”私匙不存在于地址簿中</translation> + </message> + <message>
Code added
+ <message> + <source>Public Key</source> + <translation>公匙</translation> + </message> + <message> + <source>Private Key</source> + <translation>私匙</translation> + </message> + <message> + <source>Scan Pubkey</source> + <translation>扫描公匙</translation> + </message> + <message> + <source>Scan Secret</source> + <translation>扫描私匙</translation> + </message> + <message> + <source>Spend Pubkey</source> + <translation>发送公匙</translation> + </message> + <message> + <source>Spend Secret</source> + <translation>发送私匙</translation> + </message>
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/multisigdialog.cpp
Large new file, 966 lines of code
+#include "multisigdialog.h" +#include "ui_multisigdialog.h" + +#include "wallet.h" +#include "walletmodel.h" +#include "bitcoinunits.h" +#include "addressbookpage.h" +#include "optionsmodel.h" +#include "sendcoinsentry.h" +#include "guiutil.h" +#include "askpassphrasedialog.h" +#include "base58.h" +#include "init.h" +#include "coincontrol.h" +#include "createmultisigaddrdialog.h" +#include "rpcprotocol.h" + +#include "json/json_spirit.h" +#include "json/json_spirit_reader_template.h" +#include "json/json_spirit_writer_template.h" +#include "json/json_spirit_utils.h" +#include "json/json_spirit_value.h" +using namespace json_spirit; + +#include <QMessageBox> +#include <QTextDocument> +#include <QScrollBar> +#include <QFile> +#include <QTextStream> + +CCoinControl* MultiSigDialog::coinControl = new CCoinControl(); +CTransaction* MultiSigDialog::rawTx = new CTransaction(); + +MultiSigDialog::MultiSigDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::MultiSigDialog), + model(0) +{ + ui->setupUi(this);
Example / start of new code
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/multisigdialog.h
Large new file 91 lines o code
+#ifndef MULTISIGDIALOG_H +#define MULTISIGDIALOG_H + +#include <QDialog> +#include <QString> + +namespace Ui { + class MultiSigDialog; +} + +class CWallet; +class WalletModel; +class SendCoinsEntry; +class SendCoinsRecipient; +class CCoinControl; +class CTransaction; + +QT_BEGIN_NAMESPACE +class QUrl; +QT_END_NAMESPACE + +/** Dialog for sending bitcoins */ +class MultiSigDialog : public QDialog +{ + Q_OBJECT + +public: + explicit MultiSigDialog(QWidget *parent = 0); + ~MultiSigDialog(); + + void setModel(WalletModel *model); + + /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907). + */ + QWidget *setupTabChain(QWidget *prev); + + void setAddress(const QString &address); + void pasteEntry(const SendCoinsRecipient &rv); + bool handleURI(const QString &uri); + + static CCoinControl *coinControl; + static CTransaction *rawTx; + +public slots: + void clear(); + void reject(); + void accept(); + void exportDraft(); + void importDraft(); + void editEnable(bool enable); + + void signAddress0(); + void signAddress1(); + void signAddress2(); + void signTransaction(QString *addrStr = NULL); + + SendCoinsEntry *addEntry(); + void updateRemoveEnabled(); + void setSharedBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance);
Start of new file code
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/res/icons/*
src/qt/res/icons/multisig.png
Icon File added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/sendcoinsentry.cpp
+void SendCoinsEntry::setRemoveEnabled(bool enabled) +{ + ui->deleteButton->setEnabled(enabled); +} +
Code added
+void SendCoinsEntry::setFieldEnable(bool enable) +{ + ui->payTo->setEnabled(enable); + ui->addAsLabel->setEnabled(enable); + ui->payAmount->setEnabled(enable); + ui->addressBookButton->setEnabled(enable); + ui->pasteButton->setEnabled(enable); + ui->deleteButton->setEnabled(enable); +} +
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/sendcoinsentry.h
+ void setFieldEnable(bool enable);
Code added
+ void setRemoveEnabled(bool enabled);
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/walletframe.cpp
+void WalletFrame::gotoMultiSigPage() +{ + QMap<QString, WalletView*>::const_iterator i; + for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) + i.value()->gotoMultiSigPage(); +} +
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/walletframe.cpp
+qint64 WalletModel::getSharedBalance(const CCoinControl *coinControl) const +{ + if (coinControl) + { + int64 nBalance = 0; + std::vector<COutput> vCoins; + wallet->AvailableSharedCoins(vCoins, true, coinControl); + BOOST_FOREACH(const COutput& out, vCoins) + nBalance += out.tx->vout[out.i].nValue; + + return nBalance; + } + + return wallet->GetSharedBalance(); +} + +qint64 WalletModel::getSharedUnconfirmedBalance() const +{ + return wallet->GetSharedUnconfirmedBalance(); +} + +qint64 WalletModel::getSharedImmatureBalance() const +{ + return wallet->GetSharedImmatureBalance(); +} +
Code added
+WalletModel::SendCoinsReturn WalletModel::createRawTransaction( + const QList<SendCoinsRecipient> &recipients, CTransaction& txNew, const CCoinControl *coinControl, bool isMultiSig) +{ + qint64 total = 0; + QSet<QString> setAddress; + QString hex; + + if(recipients.empty()) + { + return OK; + } + + // Pre-check input data for validity + foreach(const SendCoinsRecipient &rcp, recipients) + { + if(!validateAddress(rcp.address)) + { + return InvalidAddress; + } + setAddress.insert(rcp.address); + + if(rcp.amount <= 0) + { + return InvalidAmount; + } + total += rcp.amount; + } + + if(recipients.size() > setAddress.size()) + { + return DuplicateAddress; + } + + int64 nBalance; + if ( isMultiSig ) + nBalance = getSharedBalance(coinControl); + else + nBalance = getBalance(coinControl); + + if(total > nBalance) + { + return AmountExceedsBalance; + } + + if((total + nTransactionFee) > nBalance) + { + return SendCoinsReturn(AmountWithFeeExceedsBalance, nTransactionFee); + } + + { + LOCK2(cs_main, wallet->cs_wallet); + + // Sendmany + std::vector<std::pair<CScript, int64> > vecSend; + foreach(const SendCoinsRecipient &rcp, recipients) + { + CScript scriptPubKey; + scriptPubKey.SetDestination(CBitcoinAddress(rcp.address.toStdString()).Get()); + vecSend.push_back(make_pair(scriptPubKey, rcp.amount)); + } + + int64 nFeeRequired = 0; + std::string strFailReason; + CReserveKey reservekey(wallet); + bool fCreated = wallet->CreateRawTransaction(vecSend, txNew, nFeeRequired, strFailReason, isMultiSig, reservekey, coinControl); + + if(!fCreated) + { + if((total + nFeeRequired) > nBalance) + { + return SendCoinsReturn(AmountWithFeeExceedsBalance, nFeeRequired); + } + emit message(tr("Send Coins"), QString::fromStdString(strFailReason), + CClientUIInterface::MSG_ERROR); + return TransactionCreationFailed; + } + /*if(!uiInterface.ThreadSafeAskFee(nFeeRequired)) + { + return Aborted; + }*/ + hex = QString::fromStdString(txNew.GetHash().GetHex()); + } + + // Add addresses / update labels that we've sent to to the address book + foreach(const SendCoinsRecipient &rcp, recipients) + { + std::string strAddress = rcp.address.toStdString(); + CTxDestination dest = CBitcoinAddress(strAddress).Get(); + std::string strLabel = rcp.label.toStdString(); + { + LOCK(wallet->cs_wallet); + + //std::map<CTxDestination, std::string>::iterator mi = wallet->mapAddressBook.find(dest); + std::map<CTxDestination, CAddressBookData>::iterator mi = wallet->mapAddressBook.find(dest); + + // Check if we have a new address or an updated label + if (mi == wallet->mapAddressBook.end() || mi->second.name != strLabel) + { + std::string purpose; + //wallet->SetAddressBookName(dest, strLabel); + wallet->SetAddressBook(dest, strLabel,purpose); + } + } + } + + return SendCoinsReturn(OK, 0, hex); +} +
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Multisgin Page : - commit
https://github.com/FeatherCoin/Feathercoin/commit/83737e90c292f18fe0285677cefbd70125492e1a
Include a multi-signature address Page
src/qt/walletmodel.h
+ + qint64 getSharedBalance(const CCoinControl *coinControl=NULL) const; + qint64 getSharedUnconfirmedBalance() const; + qint64 getSharedImmatureBalance() const;
Code added
+ /*SendCoinsReturn(StatusCode status = OK): + status(status) {}*/ + SendCoinsReturn(StatusCode status=Aborted, + qint64 fee=0, + QString hex=QString()): + status(status), fee(fee), hex(hex) {}
Code replaced
+ qint64 fee; // is used in case status is "AmountWithFeeExceedsBalance" + QString hex; // is filled with the transaction hash if status is "OK"
Code added
+ SendCoinsReturn createRawTransaction(const QList<SendCoinsRecipient> &recipients, CTransaction& txNew, const CCoinControl *coinControl, bool isMultiSig); + bool isMultiSig; + bool was_locked; + CWallet *getWallet(){ return wallet; }
Code added