std::vector<TaggedOutput> CreateTxDialog::getOutputs() { std::vector<TaggedOutput> outputs; std::set<TxOutLayout*> txOutLayoutsCopy = txOutLayouts; for (auto& txOutLayout: txOutLayoutsCopy) { if (txOutLayout->getAddress().isEmpty()) { removeTxOut(txOutLayout); continue; } TaggedOutput output(txOutLayout->getScript(), txOutLayout->getValue(), txOutLayout->getRecipient().toStdString()); outputs.push_back(output); } if (outputs.empty()) { addTxOut(); throw std::runtime_error("No outputs entered."); } return outputs; }
std::vector<std::shared_ptr<CoinDB::TxOut>> CreateTxDialog::getTxOuts() { std::vector<std::shared_ptr<CoinDB::TxOut>> txouts; std::set<TxOutLayout*> txOutLayoutsCopy = txOutLayouts; for (auto& txOutLayout: txOutLayoutsCopy) { if (txOutLayout->getAddress().isEmpty()) { removeTxOut(txOutLayout); continue; } std::shared_ptr<CoinDB::TxOut> txout(new CoinDB::TxOut(txOutLayout->getValue(), txOutLayout->getScript())); txout->sending_label(txOutLayout->getRecipient().toStdString()); txouts.push_back(txout); } if (txouts.empty()) { addTxOut(); throw std::runtime_error("No outputs entered."); } return txouts; }
CreateTxDialog::CreateTxDialog(const QString& accountName, const PaymentRequest& paymentRequest, QWidget* parent) : QDialog(parent), status(SAVE_ONLY) { // Buttons signAndSendButton = new QPushButton(tr("Sign and Send")); signAndSaveButton = new QPushButton(tr("Sign and Save")); saveButton = new QPushButton(tr("Save Unsigned")); cancelButton = new QPushButton(tr("Cancel")); cancelButton->setDefault(true); /* QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel); */ QDialogButtonBox* buttonBox = new QDialogButtonBox; buttonBox->addButton(signAndSendButton, QDialogButtonBox::ActionRole); buttonBox->addButton(signAndSaveButton, QDialogButtonBox::ActionRole); buttonBox->addButton(saveButton, QDialogButtonBox::AcceptRole); buttonBox->addButton(cancelButton, QDialogButtonBox::RejectRole); connect(signAndSendButton, &QPushButton::clicked, [this]() { status = SIGN_AND_SEND; accept(); }); connect(signAndSaveButton, &QPushButton::clicked, [this]() { status = SIGN_AND_SAVE; accept(); }); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); // Prompt QLabel* promptLabel = new QLabel(tr("Add Outputs:")); // Account QLabel* accountLabel = new QLabel(tr("Account:")); accountComboBox = new QComboBox(); accountComboBox->insertItem(0, accountName); QHBoxLayout* accountLayout = new QHBoxLayout(); accountLayout->addWidget(accountLabel); accountLayout->addWidget(accountComboBox); // Fee QLabel* feeLabel = new QLabel(tr("Fee:")); feeEdit = new QLineEdit(); feeEdit->setValidator(new QRegExpValidator(AMOUNT_REGEXP)); feeEdit->setText("0.0005"); // TODO: suggest more intelligently QHBoxLayout* feeLayout = new QHBoxLayout(); feeLayout->addWidget(feeLabel); feeLayout->addWidget(feeEdit); // TxOuts txOutVBoxLayout = new QVBoxLayout(); txOutVBoxLayout->setSizeConstraint(QLayout::SetMinimumSize); addTxOut(paymentRequest); // Add Output Button QPushButton* addTxOutButton = new QPushButton(tr("Add Output")); connect(addTxOutButton, SIGNAL(clicked()), this, SLOT(addTxOut())); mainLayout = new QVBoxLayout(this); mainLayout->addWidget(promptLabel); mainLayout->addLayout(accountLayout); mainLayout->addLayout(feeLayout); mainLayout->addLayout(txOutVBoxLayout); mainLayout->addWidget(addTxOutButton); mainLayout->addWidget(buttonBox); setLayout(mainLayout); }