aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-01-09 04:41:32 +0800
committerobscuren <geffobscura@gmail.com>2015-01-09 04:41:32 +0800
commit4a0ade4788b0e8d53c6b0eabaf9652643b6a073a (patch)
tree57a477ec1419547130ca75638fb2df71f883b4f4
parent5f958a582d1326ada1cb34b4c6578590a7c40e6c (diff)
downloaddexon-4a0ade4788b0e8d53c6b0eabaf9652643b6a073a.tar
dexon-4a0ade4788b0e8d53c6b0eabaf9652643b6a073a.tar.gz
dexon-4a0ade4788b0e8d53c6b0eabaf9652643b6a073a.tar.bz2
dexon-4a0ade4788b0e8d53c6b0eabaf9652643b6a073a.tar.lz
dexon-4a0ade4788b0e8d53c6b0eabaf9652643b6a073a.tar.xz
dexon-4a0ade4788b0e8d53c6b0eabaf9652643b6a073a.tar.zst
dexon-4a0ade4788b0e8d53c6b0eabaf9652643b6a073a.zip
Fixed some whisper issues
-rw-r--r--cmd/mist/assets/ext/eth.js/main.js1
-rw-r--r--cmd/mist/assets/qml/browser.qml44
-rw-r--r--ui/qt/qwhisper/whisper.go10
-rw-r--r--whisper/message.go2
-rw-r--r--whisper/peer.go2
-rw-r--r--whisper/whisper.go2
6 files changed, 37 insertions, 24 deletions
diff --git a/cmd/mist/assets/ext/eth.js/main.js b/cmd/mist/assets/ext/eth.js/main.js
index 5c7ca0603..71e304a55 100644
--- a/cmd/mist/assets/ext/eth.js/main.js
+++ b/cmd/mist/assets/ext/eth.js/main.js
@@ -352,6 +352,7 @@
web3.provider = new ProviderManager();
web3.setProvider = function(provider) {
+ console.log("setprovider", provider)
provider.onmessage = messageHandler;
web3.provider.set(provider);
web3.provider.sendQueued();
diff --git a/cmd/mist/assets/qml/browser.qml b/cmd/mist/assets/qml/browser.qml
index 4cf6b2470..c2f8741bc 100644
--- a/cmd/mist/assets/qml/browser.qml
+++ b/cmd/mist/assets/qml/browser.qml
@@ -59,7 +59,7 @@ Rectangle {
}
Component.onCompleted: {
- webview.url = "/Users/jeffrey/test.html"
+ webview.url = "http://etherian.io"
}
signal messages(var messages, int id);
@@ -153,7 +153,9 @@ Rectangle {
}
function injectJs(js) {
- experimental.evaluateJavaScript(js)
+ //webview.experimental.navigatorQtObjectEnabled = true;
+ //webview.experimental.evaluateJavaScript(js)
+ //webview.experimental.javascriptEnabled = true;
}
function sendMessage(data) {
@@ -164,7 +166,7 @@ Rectangle {
experimental.preferences.javascriptEnabled: true
experimental.preferences.navigatorQtObjectEnabled: true
experimental.preferences.developerExtrasEnabled: true
- //experimental.userScripts: ["../ext/q.js", "../ext/eth.js/main.js", "../ext/eth.js/qt.js", "../ext/setup.js"]
+ experimental.userScripts: ["../ext/q.js", "../ext/eth.js/main.js", "../ext/eth.js/qt.js", "../ext/setup.js"]
experimental.onMessageReceived: {
console.log("[onMessageReceived]: ", message.data)
// TODO move to messaging.js
@@ -344,24 +346,28 @@ Rectangle {
break;
case "newIdentity":
- postData(data._id, shh.newIdentity())
- break
+ var id = shh.newIdentity()
+ console.log("newIdentity", id)
+ postData(data._id, id)
+
+ break
case "post":
- require(1);
- var params = data.args[0];
- var fields = ["payload", "to", "from"];
- for(var i = 0; i < fields.length; i++) {
- params[fields[i]] = params[fields[i]] || "";
- }
- if(typeof params.payload !== "object") { params.payload = [params.payload]; } //params.payload = params.payload.join(""); }
- params.topics = params.topics || [];
- params.priority = params.priority || 1000;
- params.ttl = params.ttl || 100;
-
- console.log(JSON.stringify(params))
- shh.post(params.payload, params.to, params.from, params.topics, params.priority, params.ttl);
- break;
+ require(1);
+
+ var params = data.args[0];
+ var fields = ["payload", "to", "from"];
+ for(var i = 0; i < fields.length; i++) {
+ params[fields[i]] = params[fields[i]] || "";
+ }
+ if(typeof params.payload !== "object") { params.payload = [params.payload]; } //params.payload = params.payload.join(""); }
+ params.topics = params.topics || [];
+ params.priority = params.priority || 1000;
+ params.ttl = params.ttl || 100;
+
+ shh.post(params.payload, params.to, params.from, params.topics, params.priority, params.ttl);
+
+ break;
}
} catch(e) {
console.log(data.call + ": " + e)
diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go
index 0627acd29..8a064c81c 100644
--- a/ui/qt/qwhisper/whisper.go
+++ b/ui/qt/qwhisper/whisper.go
@@ -6,10 +6,13 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/whisper"
"gopkg.in/qml.v1"
)
+var qlogger = logger.NewLogger("QSHH")
+
func fromHex(s string) []byte {
if len(s) > 1 {
return ethutil.Hex2Bytes(s[2:])
@@ -36,9 +39,10 @@ func (self *Whisper) SetView(view qml.Object) {
func (self *Whisper) Post(payload []string, to, from string, topics []string, priority, ttl uint32) {
var data []byte
for _, d := range payload {
- data = append(data, fromHex(d)...)
+ data = append(data, ethutil.Hex2Bytes(d)...)
}
+ fmt.Println(payload, data, "from", from, fromHex(from), crypto.ToECDSA(fromHex(from)))
msg := whisper.NewMessage(data)
envelope, err := msg.Seal(time.Duration(priority*100000), whisper.Opts{
Ttl: time.Duration(ttl),
@@ -47,13 +51,13 @@ func (self *Whisper) Post(payload []string, to, from string, topics []string, pr
Topics: whisper.TopicsFromString(topics...),
})
if err != nil {
- fmt.Println(err)
+ qlogger.Infoln(err)
// handle error
return
}
if err := self.Whisper.Send(envelope); err != nil {
- fmt.Println(err)
+ qlogger.Infoln(err)
// handle error
return
}
diff --git a/whisper/message.go b/whisper/message.go
index db0110b4a..5bda849ec 100644
--- a/whisper/message.go
+++ b/whisper/message.go
@@ -2,6 +2,7 @@ package whisper
import (
"crypto/ecdsa"
+ "fmt"
"time"
"github.com/ethereum/go-ethereum/crypto"
@@ -53,6 +54,7 @@ type Opts struct {
}
func (self *Message) Seal(pow time.Duration, opts Opts) (*Envelope, error) {
+ fmt.Println(opts)
if opts.From != nil {
err := self.sign(opts.From)
if err != nil {
diff --git a/whisper/peer.go b/whisper/peer.go
index d42b374b5..f82cc6e3e 100644
--- a/whisper/peer.go
+++ b/whisper/peer.go
@@ -55,7 +55,7 @@ out:
case <-relay.C:
err := self.broadcast(self.host.envelopes())
if err != nil {
- self.peer.Infoln(err)
+ self.peer.Infoln("broadcast err:", err)
break out
}
diff --git a/whisper/whisper.go b/whisper/whisper.go
index ffcdd7d40..3ff4bac5a 100644
--- a/whisper/whisper.go
+++ b/whisper/whisper.go
@@ -229,11 +229,11 @@ func (self *Whisper) envelopes() (envelopes []*Envelope) {
func (self *Whisper) postEvent(envelope *Envelope) {
for _, key := range self.keys {
if message, err := envelope.Open(key); err == nil || (err != nil && err == ecies.ErrInvalidPublicKey) {
- // Create a custom filter?
self.filters.Notify(filter.Generic{
Str1: string(crypto.FromECDSA(key)), Str2: string(crypto.FromECDSAPub(message.Recover())),
Data: bytesToMap(envelope.Topics),
}, message)
+ break
} else {
wlogger.Infoln(err)
}