#include <QDialog>
#include <QMessageBox>
#include <QScrollBar>
+#include <QKeyEvent>
#include <vector>
#include "addresstablemodel.h"
#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)
+ {
+ QMessageBox::warning(this, tr("Error"), tr("Redeem script exceeds size limit: %1 > %2\nReduce the number of addresses involved in the address creation.").arg(script.size()).arg(MAX_SCRIPT_ELEMENT_SIZE), QMessageBox::Ok);
+ return;
+ }
CScriptID scriptID = script.GetID();
CBitcoinAddress address(scriptID);
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());
- int64 amount = recipient.amount;
+ 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;
}
{
ss >> tx;
}
- catch(std::exception &e)
+ catch(const std::exception&)
{
return;
}
// Fetch previous transactions (inputs)
std::map<COutPoint, CScript> mapPrevOut;
- for(int i = 0; i < mergedTx.vin.size(); i++)
+ for(unsigned int i = 0; i < mergedTx.vin.size(); i++)
{
CTransaction tempTx;
MapPrevTx mapPrevTx;
// Sign what we can
bool fComplete = true;
- for(int i = 0; i < mergedTx.vin.size(); i++)
+ for(unsigned int i = 0; i < mergedTx.vin.size(); i++)
{
CTxIn& txin = mergedTx.vin[i];
if(mapPrevOut.count(txin.prevout) == 0)
void MultisigDialog::on_sendTransactionButton_clicked()
{
- int64 transactionSize = ui->signedTransaction->text().size() / 2;
+ int64_t transactionSize = ui->signedTransaction->text().size() / 2;
if(transactionSize == 0)
return;
// Check the fee
- int64 fee = (int64 ) (ui->fee->text().toDouble() * COIN);
- int64 minFee = MIN_TX_FEE * (1 + (int64) transactionSize / 1000);
+ int64_t fee = (int64_t ) (ui->fee->text().toDouble() * COIN);
+ int64_t minFee = MIN_TX_FEE * (1 + (int64_t) transactionSize / 1000);
if(fee < minFee)
{
QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Confirm send transaction"), tr("The fee of the transaction (%1 NVC) is smaller than the expected fee (%2 NVC). Do you want to send the transaction anyway?").arg((double) fee / COIN).arg((double) minFee / COIN), QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
{
ssData >> tx;
}
- catch(std::exception &e)
+ catch(const std::exception&)
{
return;
}
void MultisigDialog::updateAmounts()
{
// Update inputs amount
- int64 inputsAmount = 0;
+ int64_t inputsAmount = 0;
for(int i = 0; i < ui->inputs->count(); i++)
{
MultisigInputEntry *entry = qobject_cast<MultisigInputEntry *>(ui->inputs->itemAt(i)->widget());
ui->inputsAmount->setText(inputsAmountStr);
// Update outputs amount
- int64 outputsAmount = 0;
+ int64_t outputsAmount = 0;
for(int i = 0; i < ui->outputs->count(); i++)
{
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry *>(ui->outputs->itemAt(i)->widget());
ui->outputsAmount->setText(outputsAmountStr);
// Update Fee amount
- int64 fee = inputsAmount - outputsAmount;
+ int64_t fee = inputsAmount - outputsAmount;
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
+}