aboutsummaryrefslogtreecommitdiffstats
path: root/mist/ui_lib.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-09-25 16:33:05 +0800
committerobscuren <geffobscura@gmail.com>2014-09-25 16:33:05 +0800
commitdc944f75186bbee08ad8cd1dad8a296dc71f99bc (patch)
treebfde1b2f22b32b49ee8a0cd96844e5eac5d562a5 /mist/ui_lib.go
parentd5d1e503652cc6c53a265404d8fdda53fad58fa8 (diff)
downloaddexon-dc944f75186bbee08ad8cd1dad8a296dc71f99bc.tar
dexon-dc944f75186bbee08ad8cd1dad8a296dc71f99bc.tar.gz
dexon-dc944f75186bbee08ad8cd1dad8a296dc71f99bc.tar.bz2
dexon-dc944f75186bbee08ad8cd1dad8a296dc71f99bc.tar.lz
dexon-dc944f75186bbee08ad8cd1dad8a296dc71f99bc.tar.xz
dexon-dc944f75186bbee08ad8cd1dad8a296dc71f99bc.tar.zst
dexon-dc944f75186bbee08ad8cd1dad8a296dc71f99bc.zip
Added some lookup helper methods for name reg
Diffstat (limited to 'mist/ui_lib.go')
-rw-r--r--mist/ui_lib.go26
1 files changed, 26 insertions, 0 deletions
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())
}