diff --git a/mist/assets/qml/views/jeffcoin/jeffcoin.qml b/mist/assets/qml/views/jeffcoin/jeffcoin.qml index 6506b53b8..23502d334 100644 --- a/mist/assets/qml/views/jeffcoin/jeffcoin.qml +++ b/mist/assets/qml/views/jeffcoin/jeffcoin.qml @@ -22,6 +22,8 @@ Rectangle { var me = eth.key().address; if((to == me|| from == me) && message.input.length == 128) { + var to = eth.lookupName(to) + var from = eth.lookupName(from) txModel.insert(0, {confirmations: blockNumber - message.number, from: from, to: to, value: value}) } } @@ -151,7 +153,11 @@ Rectangle { Button { text: "Send" onClicked: { - eth.transact({from: eth.key().privateKey, to:address, gas: "9000", gasPrice: "10000000000000", data: ["0x"+txTo.text, txValue.text]}) + var lookup = eth.lookupAddress(address) + if(lookup.length == 0) + lookup = address + + eth.transact({from: eth.key().privateKey, to:lookup, gas: "9000", gasPrice: "10000000000000", data: ["0x"+txTo.text, txValue.text]}) } } } diff --git a/mist/assets/qml/views/wallet.qml b/mist/assets/qml/views/wallet.qml index a3a4a6e7c..a57e7869a 100644 --- a/mist/assets/qml/views/wallet.qml +++ b/mist/assets/qml/views/wallet.qml @@ -160,7 +160,9 @@ Rectangle { function addTxs(messages) { for(var i = 0; i < messages.length; i++) { var message = messages.get(i); - txModel.insert(0, {num: txModel.count, from: message.from, to: message.to, value: eth.numberToHuman(message.value)}) + var to = eth.lookupName(message.to); + var from = eth.lookupName(message.from); + txModel.insert(0, {num: txModel.count, from: from, to: to, value: eth.numberToHuman(message.value)}) } } } diff --git a/mist/ui_lib.go b/mist/ui_lib.go index e1963aa86..e77336c90 100644 --- a/mist/ui_lib.go +++ b/mist/ui_lib.go @@ -71,6 +71,32 @@ func (self *UiLib) LookupDomain(domain string) string { } } +func (self *UiLib) LookupName(addr string) string { + var ( + nameReg = self.World().Config().Get("NameReg") + lookup = nameReg.Storage(ethutil.Hex2Bytes(addr)) + ) + + if lookup.Len() != 0 { + return strings.Trim(lookup.Str(), "\x00") + } + + return addr +} + +func (self *UiLib) LookupAddress(name string) string { + var ( + nameReg = self.World().Config().Get("NameReg") + lookup = nameReg.Storage(ethutil.RightPadBytes([]byte(name), 32)) + ) + + if lookup.Len() != 0 { + return ethutil.Bytes2Hex(lookup.Bytes()) + } + + return "" +} + func (self *UiLib) PastPeers() *ethutil.List { return ethutil.NewList(eth.PastPeers()) }