Browse Source

Allow 0x prefix for address entry in AZ

cl-refactor
arkpar 10 years ago
parent
commit
76ad4daede
  1. 12
      alethzero/MainWin.cpp

12
alethzero/MainWin.cpp

@ -638,18 +638,22 @@ pair<Address, bytes> Main::fromString(std::string const& _n) const
if (_n == "(Create Contract)") if (_n == "(Create Contract)")
return make_pair(Address(), bytes()); return make_pair(Address(), bytes());
std::string n = _n;
if (n.find_first_of("0x") == 0)
n.erase(0, 2);
auto g_newNameReg = getNameReg(); auto g_newNameReg = getNameReg();
if (g_newNameReg) if (g_newNameReg)
{ {
Address a = abiOut<Address>(ethereum()->call(g_newNameReg, abiIn("addr(bytes32)", ::toString32(_n))).output); Address a = abiOut<Address>(ethereum()->call(g_newNameReg, abiIn("addr(bytes32)", ::toString32(n))).output);
if (a) if (a)
return make_pair(a, bytes()); return make_pair(a, bytes());
} }
if (_n.size() == 40) if (n.size() == 40)
{ {
try try
{ {
return make_pair(Address(fromHex(_n, WhenError::Throw)), bytes()); return make_pair(Address(fromHex(n, WhenError::Throw)), bytes());
} }
catch (BadHexCharacter& _e) catch (BadHexCharacter& _e)
{ {
@ -665,7 +669,7 @@ pair<Address, bytes> Main::fromString(std::string const& _n) const
} }
else else
try { try {
return ICAP::decoded(_n).address([&](Address const& a, bytes const& b) -> bytes return ICAP::decoded(n).address([&](Address const& a, bytes const& b) -> bytes
{ {
return ethereum()->call(a, b).output; return ethereum()->call(a, b).output;
}, g_newNameReg); }, g_newNameReg);

Loading…
Cancel
Save