Browse Source

Copy unsigned transaction to clipboard.

Fixed #2712.
Fixed #2713.
cl-refactor
Gav Wood 10 years ago
parent
commit
c8c8097abe
  1. 24
      alethzero/Transact.cpp
  2. 2
      alethzero/Transact.h
  3. 7
      alethzero/Transact.ui

24
alethzero/Transact.cpp

@ -28,6 +28,7 @@
#include <boost/algorithm/string.hpp>
#include <QFileDialog>
#include <QMessageBox>
#include <QClipboard>
#include <liblll/Compiler.h>
#include <liblll/CodeFragment.h>
#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--);
}
@ -184,6 +190,22 @@ void Transact::on_destination_currentTextChanged(QString)
// 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)
{
switch (_te)

2
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;

7
alethzero/Transact.ui

@ -254,6 +254,13 @@
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QPushButton" name="copyUnsigned">
<property name="text">
<string>Copy &amp;Unsigned</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>

Loading…
Cancel
Save