Added some lookup helper methods for name reg

pull/136/head
obscuren 10 years ago
parent d5d1e50365
commit dc944f7518
  1. 8
      mist/assets/qml/views/jeffcoin/jeffcoin.qml
  2. 4
      mist/assets/qml/views/wallet.qml
  3. 26
      mist/ui_lib.go

@ -22,6 +22,8 @@ Rectangle {
var me = eth.key().address; var me = eth.key().address;
if((to == me|| from == me) && message.input.length == 128) { 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}) txModel.insert(0, {confirmations: blockNumber - message.number, from: from, to: to, value: value})
} }
} }
@ -151,7 +153,11 @@ Rectangle {
Button { Button {
text: "Send" text: "Send"
onClicked: { 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]})
} }
} }
} }

@ -160,7 +160,9 @@ Rectangle {
function addTxs(messages) { function addTxs(messages) {
for(var i = 0; i < messages.length; i++) { for(var i = 0; i < messages.length; i++) {
var message = messages.get(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)})
} }
} }
} }

@ -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 { func (self *UiLib) PastPeers() *ethutil.List {
return ethutil.NewList(eth.PastPeers()) return ethutil.NewList(eth.PastPeers())
} }

Loading…
Cancel
Save