#include <QDialog>
#include <QMessageBox>
#include <QScrollBar>
+#include <QKeyEvent>
#include <vector>
#include "addresstablemodel.h"
#include "util.h"
#include "wallet.h"
#include "walletmodel.h"
-
-#ifdef USE_LEVELDB
#include "txdb-leveldb.h"
-#else
-#include "txdb-bdb.h"
-#endif
-MultisigDialog::MultisigDialog(QWidget *parent) : QDialog(parent), ui(new Ui::MultisigDialog), model(0)
+MultisigDialog::MultisigDialog(QWidget *parent) : QWidget(parent), ui(new Ui::MultisigDialog), model(0)
{
ui->setupUi(this);
if(!model)
return;
- std::vector<CKey> pubkeys;
+ std::vector<CPubKey> pubkeys;
pubkeys.resize(ui->pubkeyEntries->count());
unsigned int required = ui->requiredSignatures->text().toUInt();
CPubKey vchPubKey(ParseHex(str.toStdString().c_str()));
if(!vchPubKey.IsValid())
return;
- pubkeys[i].SetPubKey(vchPubKey);
+ pubkeys[i] = vchPubKey;
}
- if((required == 0) || (required > pubkeys.size()))
+ if(pubkeys.size() > 16)
+ {
+ QMessageBox::warning(this, tr("Error"), tr("Number of addresses involved in the address creation > %1\nReduce the number").arg(16), QMessageBox::Ok);
return;
+ }
+ if(required == 0)
+ {
+ QMessageBox::warning(this, tr("Error"), tr("Number of required signatures is 0\nNumber of required signatures must be between 1 and number of keys involved in the creation of address."), QMessageBox::Ok);
+ return;
+ }
+
+ if(required > pubkeys.size())
+ {
+ QMessageBox::warning(this, tr("Error"), tr("Number of required signatures > Number of keys involved in the creation of address."), QMessageBox::Ok);
+ return;
+ }
+
CScript script;
script.SetMultisig(required, pubkeys);
if (script.size() > MAX_SCRIPT_ELEMENT_SIZE)
LOCK(wallet->cs_wallet);
if(!wallet->HaveCScript(scriptID))
wallet->AddCScript(script);
- if(!wallet->mapAddressBook.count(CBitcoinAddress(address).Get()))
- wallet->SetAddressBookName(CBitcoinAddress(address).Get(), label);
+ if(!wallet->mapAddressBook.count(CBitcoinAddress(address)))
+ wallet->SetAddressBookName(CBitcoinAddress(address), label);
}
void MultisigDialog::clear()
SendCoinsRecipient recipient = entry->getValue();
CBitcoinAddress address(recipient.address.toStdString());
CScript scriptPubKey;
- scriptPubKey.SetDestination(address.Get());
+ scriptPubKey.SetAddress(address);
int64_t amount = recipient.amount;
CTxOut output(amount, scriptPubKey);
transaction.vout.push_back(output);
{
ss >> tx;
}
- catch(std::exception &e)
+ catch(const std::exception&)
{
return;
}
// Fill input list
int index = -1;
- BOOST_FOREACH(const CTxIn& txin, tx.vin)
+ for (const CTxIn& txin : tx.vin)
{
uint256 prevoutHash = txin.prevout.hash;
addInput();
// Fill output list
index = -1;
- BOOST_FOREACH(const CTxOut& txout, tx.vout)
+ for (const CTxOut& txout : tx.vout)
{
CScript scriptPubKey = txout.scriptPubKey;
CTxDestination addr;
{
ss >> tx;
}
- catch(std::exception &e)
+ catch(const std::exception&)
{
return;
}
tempTx.vin.push_back(mergedTx.vin[i]);
tempTx.FetchInputs(txdb, unused, false, false, mapPrevTx, fInvalid);
- BOOST_FOREACH(const CTxIn& txin, tempTx.vin)
+ for (const CTxIn& txin : tempTx.vin)
{
const uint256& prevHash = txin.prevout.hash;
if(mapPrevTx.count(prevHash) && mapPrevTx[prevHash].second.vout.size() > txin.prevout.n)
{
ssData >> tx;
}
- catch(std::exception &e)
+ catch(const std::exception&)
{
return;
}
QString feeStr;
feeStr.sprintf("%.6f", (double) fee / COIN);
ui->fee->setText(feeStr);
-}
\ No newline at end of file
+}
+
+void MultisigDialog::keyPressEvent(QKeyEvent *event)
+{
+#ifdef ANDROID
+ if(windowType() != Qt::Widget && event->key() == Qt::Key_Back)
+ {
+ close();
+ }
+#else
+ if(windowType() != Qt::Widget && event->key() == Qt::Key_Escape)
+ {
+ close();
+ }
+#endif
+}