aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/ui_lib.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-15 19:45:34 +0800
committerobscuren <geffobscura@gmail.com>2014-08-15 19:45:34 +0800
commit203c4b99a0c5e3b826f5a131af2d7ec035b73107 (patch)
tree5680a5afc1dd3cef302b0d2f92baf0d61ae6d525 /ethereal/ui_lib.go
parent9f4886839fbd3cf4872d721e5be1c1d61bbb64e7 (diff)
downloadgo-tangerine-203c4b99a0c5e3b826f5a131af2d7ec035b73107.tar
go-tangerine-203c4b99a0c5e3b826f5a131af2d7ec035b73107.tar.gz
go-tangerine-203c4b99a0c5e3b826f5a131af2d7ec035b73107.tar.bz2
go-tangerine-203c4b99a0c5e3b826f5a131af2d7ec035b73107.tar.lz
go-tangerine-203c4b99a0c5e3b826f5a131af2d7ec035b73107.tar.xz
go-tangerine-203c4b99a0c5e3b826f5a131af2d7ec035b73107.tar.zst
go-tangerine-203c4b99a0c5e3b826f5a131af2d7ec035b73107.zip
LookupDomain method to uilib
Diffstat (limited to 'ethereal/ui_lib.go')
-rw-r--r--ethereal/ui_lib.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/ethereal/ui_lib.go b/ethereal/ui_lib.go
index 9220581cd..ade9bf381 100644
--- a/ethereal/ui_lib.go
+++ b/ethereal/ui_lib.go
@@ -1,11 +1,15 @@
package main
import (
+ "bytes"
"fmt"
"path"
+ "strconv"
+ "strings"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethchain"
+ "github.com/ethereum/eth-go/ethcrypto"
"github.com/ethereum/eth-go/ethpipe"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/javascript"
@@ -36,6 +40,30 @@ func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib {
return &UiLib{JSPipe: ethpipe.NewJSPipe(eth), engine: engine, eth: eth, assetPath: assetPath, jsEngine: javascript.NewJSRE(eth)}
}
+func (self *UiLib) LookupDomain(domain string) string {
+ world := self.World()
+
+ if len(domain) > 32 {
+ domain = string(ethcrypto.Sha3Bin([]byte(domain)))
+ }
+ data := world.Config().Get("DnsReg").StorageString(domain).Bytes()
+
+ // Left padded = A record, Right padded = CNAME
+ if data[0] == 0 {
+ data = bytes.TrimLeft(data, "\x00")
+ var ipSlice []string
+ for _, d := range data {
+ ipSlice = append(ipSlice, strconv.Itoa(int(d)))
+ }
+
+ return strings.Join(ipSlice, ".")
+ } else {
+ data = bytes.TrimRight(data, "\x00")
+
+ return string(data)
+ }
+}
+
func (self *UiLib) ImportTx(rlpTx string) {
tx := ethchain.NewTransactionFromBytes(ethutil.Hex2Bytes(rlpTx))
self.eth.TxPool().QueueTransaction(tx)