From 1fc9c01932acb21a2aa82fcf7d3d55351ebc7fa6 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 19 Feb 2014 23:06:59 +0000 Subject: [PATCH] Two way name application. --- alethzero/Main.ui | 55 ++++++++++++++++++++++++++----------------- alethzero/MainWin.cpp | 21 ++++++++++++++++- 2 files changed, 54 insertions(+), 22 deletions(-) diff --git a/alethzero/Main.ui b/alethzero/Main.ui index a09203343..750a33d75 100644 --- a/alethzero/Main.ui +++ b/alethzero/Main.ui @@ -382,21 +382,21 @@ - + Send - + Amount - + @@ -409,10 +409,10 @@ - + - + Qt::Horizontal @@ -425,26 +425,13 @@ - + - - - - - 0 - 0 - - - - To - - - @@ -458,7 +445,7 @@ - + @@ -468,7 +455,7 @@ - + @@ -484,6 +471,32 @@ + + + + false + + + true + + + + + + + + + + + 0 + 0 + + + + To + + + diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 1d8f410df..c6927b047 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -79,7 +79,19 @@ QString Main::render(eth::Address _a) const Address Main::fromString(QString const& _a) const { - return _a.size() ? Address(fromUserHex(_a.toStdString())) : Address(); + static const Address c_nameContract(fromUserHex("f28e4d396cfc7bae483e464221b0d2bd3c27f21f")); + string sn = _a.toStdString(); + if (sn.size() > 32) + sn.resize(32); + h256 n; + memcpy(n.data(), sn.data(), sn.size()); + memset(n.data() + sn.size(), 0, 32 - sn.size()); + if (h256 a = m_client->state().contractMemory(c_nameContract, n)) + return right160(a); + if (_a.size() == 32) + return Address(fromUserHex(_a.toStdString())); + else + return Address(); } void Main::on_about_triggered() @@ -383,6 +395,13 @@ void Main::on_accounts_doubleClicked() void Main::on_destination_textChanged() { + if (ui->destination->text().size()) + if (Address a = fromString(ui->destination->text())) + ui->calculatedName->setText(render(a)); + else + ui->calculatedName->setText("Unknown Address"); + else + ui->calculatedName->setText("Create Contract"); updateFee(); }