diff --git a/alethzero/Transact.cpp b/alethzero/Transact.cpp index 6c0f1d2bf..d7a60469a 100644 --- a/alethzero/Transact.cpp +++ b/alethzero/Transact.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #if ETH_SOLIDITY || !ETH_TRUE @@ -118,6 +119,11 @@ u256 Transact::gasPrice() const return ui->gasPrice->value() * units()[units().size() - 1 - ui->gasPriceUnits->currentIndex()].first; } +Address Transact::to() const +{ + return m_context->fromString(ui->destination->currentText().toStdString()).first; +} + u256 Transact::total() const { return value() + fee(); @@ -133,7 +139,7 @@ void Transact::updateDestination() if (ui->destination->findText(s, Qt::MatchExactly | Qt::MatchCaseSensitive) == -1) ui->destination->addItem(s); for (int i = 0; i < ui->destination->count(); ++i) - if (ui->destination->itemText(i) != "(Create Contract)" && !m_context->fromString(ui->destination->itemText(i).toStdString()).first) + if (ui->destination->itemText(i) != "(Create Contract)" && !to()) ui->destination->removeItem(i--); } @@ -181,7 +187,23 @@ void Transact::on_destination_currentTextChanged(QString) else ui->calculatedName->setText("Create Contract"); rejigData(); -// updateFee(); + // updateFee(); +} + +void Transact::on_copyUnsigned_clicked() +{ + auto a = fromAccount(); + u256 nonce = ui->autoNonce->isChecked() ? ethereum()->countAt(a, PendingBlock) : ui->nonce->value(); + + Transaction t; + if (isCreation()) + // If execution is a contract creation, add Natspec to + // a local Natspec LEVELDB + t = Transaction(value(), gasPrice(), ui->gas->value(), m_data, nonce); + else + // TODO: cache like m_data. + t = Transaction(value(), gasPrice(), ui->gas->value(), to(), m_data, nonce); + qApp->clipboard()->setText(QString::fromStdString(toHex(t.rlp()))); } static std::string toString(TransactionException _te) diff --git a/alethzero/Transact.h b/alethzero/Transact.h index e2c1a6662..a1ce544f9 100644 --- a/alethzero/Transact.h +++ b/alethzero/Transact.h @@ -54,6 +54,7 @@ private slots: void on_gasPrice_valueChanged(int) { updateFee(); rejigData(); } void on_data_textChanged() { rejigData(); } void on_optimize_clicked() { rejigData(); } + void on_copyUnsigned_clicked(); void on_send_clicked(); void on_debug_clicked(); void on_cancel_clicked() { close(); } @@ -71,6 +72,7 @@ private: dev::u256 total() const; dev::u256 value() const; dev::u256 gasPrice() const; + dev::Address to() const; std::string natspecNotice(dev::Address _to, dev::bytes const& _data); dev::Secret findSecret(dev::u256 _totalReq) const; diff --git a/alethzero/Transact.ui b/alethzero/Transact.ui index fe1fc4c3e..bd19808fd 100644 --- a/alethzero/Transact.ui +++ b/alethzero/Transact.ui @@ -254,6 +254,13 @@ + + + + Copy &Unsigned + + +