From 01a6db93241a01e98a0467b628423c9b5b1361cb Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 15 Dec 2014 17:14:02 +0100 Subject: Added whisper debug interface + whisper fixes --- ui/qt/qwhisper/whisper.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'ui/qt') diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go index bed23c8a7..3e1ca7ab9 100644 --- a/ui/qt/qwhisper/whisper.go +++ b/ui/qt/qwhisper/whisper.go @@ -1,11 +1,13 @@ package qwhisper import ( + "fmt" "time" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/whisper" + "gopkg.in/qml.v1" ) func fromHex(s string) []byte { @@ -18,25 +20,33 @@ func toHex(b []byte) string { return "0x" + ethutil.Bytes2Hex(b) } type Whisper struct { *whisper.Whisper + view qml.Object } func New(w *whisper.Whisper) *Whisper { - return &Whisper{w} + return &Whisper{w, nil} } -func (self *Whisper) Post(data string, pow, ttl uint32, to, from string) { +func (self *Whisper) SetView(view qml.Object) { + self.view = view +} + +func (self *Whisper) Post(data string, to, from string, topics []string, pow, ttl uint32) { msg := whisper.NewMessage(fromHex(data)) envelope, err := msg.Seal(time.Duration(pow), whisper.Opts{ - Ttl: time.Duration(ttl), - To: crypto.ToECDSAPub(fromHex(to)), - From: crypto.ToECDSA(fromHex(from)), + Ttl: time.Duration(ttl), + To: crypto.ToECDSAPub(fromHex(to)), + From: crypto.ToECDSA(fromHex(from)), + Topics: whisper.TopicsFromString(topics), }) if err != nil { + fmt.Println(err) // handle error return } if err := self.Whisper.Send(envelope); err != nil { + fmt.Println(err) // handle error return } -- cgit v1.2.3 From c96e504adb4a547b5e293d6930626cf2f9401ac2 Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 15 Dec 2014 17:28:51 +0100 Subject: Typo --- ui/qt/qwhisper/whisper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/qt') diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go index 3e1ca7ab9..62c4c743b 100644 --- a/ui/qt/qwhisper/whisper.go +++ b/ui/qt/qwhisper/whisper.go @@ -56,7 +56,7 @@ func (self *Whisper) NewIdentity() string { return toHex(self.Whisper.NewIdentity().D.Bytes()) } -func (self *Whisper) HasIdentify(key string) bool { +func (self *Whisper) HasIdentity(key string) bool { return self.Whisper.HasIdentity(crypto.ToECDSA(fromHex(key))) } -- cgit v1.2.3 From 0291eff99a79fa1c844a4214c326c4f2b5f913ff Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 15 Dec 2014 21:52:50 +0100 Subject: Identity test --- ui/qt/qwhisper/whisper_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 ui/qt/qwhisper/whisper_test.go (limited to 'ui/qt') diff --git a/ui/qt/qwhisper/whisper_test.go b/ui/qt/qwhisper/whisper_test.go new file mode 100644 index 000000000..efa4e6238 --- /dev/null +++ b/ui/qt/qwhisper/whisper_test.go @@ -0,0 +1,15 @@ +package qwhisper + +import ( + "testing" + + "github.com/ethereum/go-ethereum/whisper" +) + +func TestHasIdentity(t *testing.T) { + qw := New(whisper.New()) + id := qw.NewIdentity() + if !qw.HasIdentity(id) { + t.Error("expected to have identity") + } +} -- cgit v1.2.3 From 52b54631a47dfa46742635be178f2f8d33dd9f41 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 16 Dec 2014 19:55:57 +0100 Subject: Whisper watches fixes --- ui/qt/qwhisper/whisper.go | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'ui/qt') diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go index 62c4c743b..8f05c0695 100644 --- a/ui/qt/qwhisper/whisper.go +++ b/ui/qt/qwhisper/whisper.go @@ -3,6 +3,7 @@ package qwhisper import ( "fmt" "time" + "unsafe" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethutil" @@ -18,13 +19,22 @@ func fromHex(s string) []byte { } func toHex(b []byte) string { return "0x" + ethutil.Bytes2Hex(b) } +type Watch struct { +} + +func (self *Watch) Arrived(v unsafe.Pointer) { + fmt.Println(v) +} + type Whisper struct { *whisper.Whisper view qml.Object + + watches map[int]*Watch } func New(w *whisper.Whisper) *Whisper { - return &Whisper{w, nil} + return &Whisper{w, nil, make(map[int]*Watch)} } func (self *Whisper) SetView(view qml.Object) { @@ -37,7 +47,7 @@ func (self *Whisper) Post(data string, to, from string, topics []string, pow, tt Ttl: time.Duration(ttl), To: crypto.ToECDSAPub(fromHex(to)), From: crypto.ToECDSA(fromHex(from)), - Topics: whisper.TopicsFromString(topics), + Topics: whisper.TopicsFromString(topics...), }) if err != nil { fmt.Println(err) @@ -60,12 +70,15 @@ func (self *Whisper) HasIdentity(key string) bool { return self.Whisper.HasIdentity(crypto.ToECDSA(fromHex(key))) } -func (self *Whisper) Watch(opts map[string]interface{}) { +func (self *Whisper) Watch(opts map[string]interface{}) *Watch { filter := filterFromMap(opts) filter.Fn = func(msg *whisper.Message) { - // TODO POST TO QT WINDOW + fmt.Println(msg) } - self.Whisper.Watch(filter) + i := self.Whisper.Watch(filter) + self.watches[i] = &Watch{} + + return self.watches[i] } func filterFromMap(opts map[string]interface{}) (f whisper.Filter) { @@ -75,6 +88,11 @@ func filterFromMap(opts map[string]interface{}) (f whisper.Filter) { if from, ok := opts["from"].(string); ok { f.From = crypto.ToECDSAPub(fromHex(from)) } + if topicList, ok := opts["topics"].(*qml.List); ok { + var topics []string + topicList.Convert(&topics) + f.Topics = whisper.TopicsFromString(topics...) + } return } -- cgit v1.2.3 From 0e5aed63ddbda716ba7373bed7cfc083ec35ced1 Mon Sep 17 00:00:00 2001 From: obscuren Date: Sun, 21 Dec 2014 15:06:35 +0100 Subject: Updated QWhisper * changed api * general whisper debug interface --- ui/qt/qwhisper/message.go | 23 +++++++++++++++++++++++ ui/qt/qwhisper/watch.go | 13 +++++++++++++ ui/qt/qwhisper/whisper.go | 17 ++++++----------- 3 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 ui/qt/qwhisper/message.go create mode 100644 ui/qt/qwhisper/watch.go (limited to 'ui/qt') diff --git a/ui/qt/qwhisper/message.go b/ui/qt/qwhisper/message.go new file mode 100644 index 000000000..07505ba09 --- /dev/null +++ b/ui/qt/qwhisper/message.go @@ -0,0 +1,23 @@ +package qwhisper + +import ( + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/ethutil" + "github.com/ethereum/go-ethereum/whisper" +) + +type Message struct { + ref *whisper.Message + Flags byte + Payload string + From string +} + +func ToQMessage(msg *whisper.Message) *Message { + return &Message{ + ref: msg, + Flags: msg.Flags, + Payload: ethutil.Bytes2Hex(msg.Payload), + From: ethutil.Bytes2Hex(crypto.FromECDSAPub(msg.Recover())), + } +} diff --git a/ui/qt/qwhisper/watch.go b/ui/qt/qwhisper/watch.go new file mode 100644 index 000000000..0ccedc719 --- /dev/null +++ b/ui/qt/qwhisper/watch.go @@ -0,0 +1,13 @@ +package qwhisper + +import ( + "fmt" + "unsafe" +) + +type Watch struct { +} + +func (self *Watch) Arrived(v unsafe.Pointer) { + fmt.Println(v) +} diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go index 8f05c0695..6fb00cdac 100644 --- a/ui/qt/qwhisper/whisper.go +++ b/ui/qt/qwhisper/whisper.go @@ -3,7 +3,6 @@ package qwhisper import ( "fmt" "time" - "unsafe" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethutil" @@ -19,13 +18,6 @@ func fromHex(s string) []byte { } func toHex(b []byte) string { return "0x" + ethutil.Bytes2Hex(b) } -type Watch struct { -} - -func (self *Watch) Arrived(v unsafe.Pointer) { - fmt.Println(v) -} - type Whisper struct { *whisper.Whisper view qml.Object @@ -70,15 +62,18 @@ func (self *Whisper) HasIdentity(key string) bool { return self.Whisper.HasIdentity(crypto.ToECDSA(fromHex(key))) } -func (self *Whisper) Watch(opts map[string]interface{}) *Watch { +func (self *Whisper) Watch(opts map[string]interface{}, view *qml.Common) int { filter := filterFromMap(opts) filter.Fn = func(msg *whisper.Message) { - fmt.Println(msg) + if view != nil { + view.Call("onMessage", ToQMessage(msg)) + } } + i := self.Whisper.Watch(filter) self.watches[i] = &Watch{} - return self.watches[i] + return i } func filterFromMap(opts map[string]interface{}) (f whisper.Filter) { -- cgit v1.2.3 From 4051c0333f43765a7414a4e0e8ac51e7148b0646 Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 22 Dec 2014 13:23:11 +0100 Subject: Added whisper js api --- ui/qt/qwhisper/message.go | 4 ++-- ui/qt/qwhisper/whisper.go | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'ui/qt') diff --git a/ui/qt/qwhisper/message.go b/ui/qt/qwhisper/message.go index 07505ba09..c87647399 100644 --- a/ui/qt/qwhisper/message.go +++ b/ui/qt/qwhisper/message.go @@ -8,7 +8,7 @@ import ( type Message struct { ref *whisper.Message - Flags byte + Flags int32 Payload string From string } @@ -16,7 +16,7 @@ type Message struct { func ToQMessage(msg *whisper.Message) *Message { return &Message{ ref: msg, - Flags: msg.Flags, + Flags: int32(msg.Flags), Payload: ethutil.Bytes2Hex(msg.Payload), From: ethutil.Bytes2Hex(crypto.FromECDSAPub(msg.Recover())), } diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go index 6fb00cdac..62676daf5 100644 --- a/ui/qt/qwhisper/whisper.go +++ b/ui/qt/qwhisper/whisper.go @@ -33,9 +33,9 @@ func (self *Whisper) SetView(view qml.Object) { self.view = view } -func (self *Whisper) Post(data string, to, from string, topics []string, pow, ttl uint32) { +func (self *Whisper) Post(data, to, from string, topics []string, priority, ttl uint32) { msg := whisper.NewMessage(fromHex(data)) - envelope, err := msg.Seal(time.Duration(pow), whisper.Opts{ + envelope, err := msg.Seal(time.Duration(priority*100000), whisper.Opts{ Ttl: time.Duration(ttl), To: crypto.ToECDSAPub(fromHex(to)), From: crypto.ToECDSA(fromHex(from)), @@ -64,13 +64,14 @@ func (self *Whisper) HasIdentity(key string) bool { func (self *Whisper) Watch(opts map[string]interface{}, view *qml.Common) int { filter := filterFromMap(opts) + var i int filter.Fn = func(msg *whisper.Message) { if view != nil { - view.Call("onMessage", ToQMessage(msg)) + view.Call("onShhMessage", ToQMessage(msg), i) } } - i := self.Whisper.Watch(filter) + i = self.Whisper.Watch(filter) self.watches[i] = &Watch{} return i -- cgit v1.2.3 From e32f7baa0d5d949a84a3b29c57220f837eae356a Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 22 Dec 2014 14:59:52 +0100 Subject: Concat and pad data --- ui/qt/qwhisper/whisper.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'ui/qt') diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go index 62676daf5..0627acd29 100644 --- a/ui/qt/qwhisper/whisper.go +++ b/ui/qt/qwhisper/whisper.go @@ -33,8 +33,13 @@ func (self *Whisper) SetView(view qml.Object) { self.view = view } -func (self *Whisper) Post(data, to, from string, topics []string, priority, ttl uint32) { - msg := whisper.NewMessage(fromHex(data)) +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)...) + } + + msg := whisper.NewMessage(data) envelope, err := msg.Seal(time.Duration(priority*100000), whisper.Opts{ Ttl: time.Duration(ttl), To: crypto.ToECDSAPub(fromHex(to)), -- cgit v1.2.3 From 4a0ade4788b0e8d53c6b0eabaf9652643b6a073a Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 8 Jan 2015 21:41:32 +0100 Subject: Fixed some whisper issues --- ui/qt/qwhisper/whisper.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'ui/qt') 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 } -- cgit v1.2.3 From c9f566269b39780accfb7632b94dd7635be2022b Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 9 Jan 2015 13:28:48 +0100 Subject: merged --- ui/qt/qwhisper/whisper.go | 2 -- 1 file changed, 2 deletions(-) (limited to 'ui/qt') diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go index 8a064c81c..62b68efaf 100644 --- a/ui/qt/qwhisper/whisper.go +++ b/ui/qt/qwhisper/whisper.go @@ -1,7 +1,6 @@ package qwhisper import ( - "fmt" "time" "github.com/ethereum/go-ethereum/crypto" @@ -42,7 +41,6 @@ func (self *Whisper) Post(payload []string, to, from string, topics []string, pr 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), -- cgit v1.2.3 From f9b0d1a8e738a207e6101b27b667ea390def9f69 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 9 Jan 2015 13:36:47 +0100 Subject: Updated to new ethereum.js api --- ui/qt/qwhisper/whisper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/qt') diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go index 62b68efaf..8b4628a1b 100644 --- a/ui/qt/qwhisper/whisper.go +++ b/ui/qt/qwhisper/whisper.go @@ -38,7 +38,7 @@ 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, ethutil.Hex2Bytes(d)...) + data = append(data, fromHex(d)...) } msg := whisper.NewMessage(data) -- cgit v1.2.3 From e3da85faedf21a3ddb73a0fa29decf65364e6c39 Mon Sep 17 00:00:00 2001 From: obscuren Date: Sat, 10 Jan 2015 00:51:56 +0100 Subject: Implemented filter for ws + fixes * proper 0xhex * filters fixed * start of filter manager * accounts for ws. Closes #246 --- ui/qt/filter.go | 5 ----- 1 file changed, 5 deletions(-) (limited to 'ui/qt') diff --git a/ui/qt/filter.go b/ui/qt/filter.go index c68936401..423d5bd43 100644 --- a/ui/qt/filter.go +++ b/ui/qt/filter.go @@ -1,8 +1,6 @@ package qt import ( - "fmt" - "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/ui" "gopkg.in/qml.v1" @@ -23,13 +21,10 @@ func makeAltered(v interface{}) (d []core.AccountChange) { var s []interface{} qList.Convert(&s) - fmt.Println(s) - d = makeAltered(s) } else if qMap, ok := v.(*qml.Map); ok { var m map[string]interface{} qMap.Convert(&m) - fmt.Println(m) d = makeAltered(m) } -- cgit v1.2.3 From 34689cb3f369ad71164b81d0c05238d78cb67945 Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 12 Jan 2015 20:36:45 +0100 Subject: Added manual triggering of filters --- ui/qt/qwhisper/whisper.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ui/qt') diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go index 8b4628a1b..becb2a29b 100644 --- a/ui/qt/qwhisper/whisper.go +++ b/ui/qt/qwhisper/whisper.go @@ -84,6 +84,10 @@ func (self *Whisper) Watch(opts map[string]interface{}, view *qml.Common) int { return i } +func (self *Whisper) Trigger(id int) { + go self.Whisper.Trigger(id) +} + func filterFromMap(opts map[string]interface{}) (f whisper.Filter) { if to, ok := opts["to"].(string); ok { f.To = crypto.ToECDSA(fromHex(to)) -- cgit v1.2.3 From e3cad04decbbc83a0c956850717cb0ae0b2b3eec Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 13 Jan 2015 13:36:44 +0100 Subject: Fixed whisper messages * Whisper protocol wasn't properly suppling envelope slices * Message history wasn't properly propagated * Added 'Messages' method, filtering any current envelope with the supplied filter. --- ui/qt/qwhisper/message.go | 6 +++--- ui/qt/qwhisper/whisper.go | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'ui/qt') diff --git a/ui/qt/qwhisper/message.go b/ui/qt/qwhisper/message.go index c87647399..3a80381ff 100644 --- a/ui/qt/qwhisper/message.go +++ b/ui/qt/qwhisper/message.go @@ -8,9 +8,9 @@ import ( type Message struct { ref *whisper.Message - Flags int32 - Payload string - From string + Flags int32 `json:"flags"` + Payload string `json:"payload"` + From string `json:"from"` } func ToQMessage(msg *whisper.Message) *Message { diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go index becb2a29b..b904678f4 100644 --- a/ui/qt/qwhisper/whisper.go +++ b/ui/qt/qwhisper/whisper.go @@ -43,7 +43,7 @@ func (self *Whisper) Post(payload []string, to, from string, topics []string, pr msg := whisper.NewMessage(data) envelope, err := msg.Seal(time.Duration(priority*100000), whisper.Opts{ - Ttl: time.Duration(ttl), + Ttl: time.Duration(ttl) * time.Second, To: crypto.ToECDSAPub(fromHex(to)), From: crypto.ToECDSA(fromHex(from)), Topics: whisper.TopicsFromString(topics...), @@ -84,8 +84,14 @@ func (self *Whisper) Watch(opts map[string]interface{}, view *qml.Common) int { return i } -func (self *Whisper) Trigger(id int) { - go self.Whisper.Trigger(id) +func (self *Whisper) Messages(id int) (messages *ethutil.List) { + msgs := self.Whisper.Messages(id) + messages = ethutil.EmptyList() + for _, message := range msgs { + messages.Append(ToQMessage(message)) + } + + return } func filterFromMap(opts map[string]interface{}) (f whisper.Filter) { -- cgit v1.2.3 From 62e0e18030c84fa19f54373ebdf25f7adbc64793 Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 14 Jan 2015 18:12:18 +0100 Subject: Changed public whisper api not to reveal temporary private keys --- ui/qt/qwhisper/message.go | 4 ++-- ui/qt/qwhisper/whisper.go | 45 +++++++++++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 20 deletions(-) (limited to 'ui/qt') diff --git a/ui/qt/qwhisper/message.go b/ui/qt/qwhisper/message.go index 3a80381ff..26e72ac93 100644 --- a/ui/qt/qwhisper/message.go +++ b/ui/qt/qwhisper/message.go @@ -17,7 +17,7 @@ func ToQMessage(msg *whisper.Message) *Message { return &Message{ ref: msg, Flags: int32(msg.Flags), - Payload: ethutil.Bytes2Hex(msg.Payload), - From: ethutil.Bytes2Hex(crypto.FromECDSAPub(msg.Recover())), + Payload: "0x" + ethutil.Bytes2Hex(msg.Payload), + From: "0x" + ethutil.Bytes2Hex(crypto.FromECDSAPub(msg.Recover())), } } diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go index b904678f4..644c147b7 100644 --- a/ui/qt/qwhisper/whisper.go +++ b/ui/qt/qwhisper/whisper.go @@ -41,32 +41,41 @@ func (self *Whisper) Post(payload []string, to, from string, topics []string, pr data = append(data, fromHex(d)...) } - msg := whisper.NewMessage(data) - envelope, err := msg.Seal(time.Duration(priority*100000), whisper.Opts{ - Ttl: time.Duration(ttl) * time.Second, - To: crypto.ToECDSAPub(fromHex(to)), - From: crypto.ToECDSA(fromHex(from)), - Topics: whisper.TopicsFromString(topics...), - }) - if err != nil { - qlogger.Infoln(err) - // handle error - return - } + pk := crypto.ToECDSAPub(fromHex(from)) + if key := self.Whisper.GetIdentity(pk); key != nil { + msg := whisper.NewMessage(data) + envelope, err := msg.Seal(time.Duration(priority*100000), whisper.Opts{ + Ttl: time.Duration(ttl) * time.Second, + To: crypto.ToECDSAPub(fromHex(to)), + From: key, + Topics: whisper.TopicsFromString(topics...), + }) + + if err != nil { + qlogger.Infoln(err) + // handle error + return + } - if err := self.Whisper.Send(envelope); err != nil { - qlogger.Infoln(err) - // handle error - return + if err := self.Whisper.Send(envelope); err != nil { + qlogger.Infoln(err) + // handle error + return + } + } else { + qlogger.Infoln("unmatched pub / priv for seal") } + } func (self *Whisper) NewIdentity() string { - return toHex(self.Whisper.NewIdentity().D.Bytes()) + key := self.Whisper.NewIdentity() + + return toHex(crypto.FromECDSAPub(&key.PublicKey)) } func (self *Whisper) HasIdentity(key string) bool { - return self.Whisper.HasIdentity(crypto.ToECDSA(fromHex(key))) + return self.Whisper.HasIdentity(crypto.ToECDSAPub(fromHex(key))) } func (self *Whisper) Watch(opts map[string]interface{}, view *qml.Common) int { -- cgit v1.2.3 From f3e78c8f3cd2196ef70a41f298b6df556543d581 Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 28 Jan 2015 10:23:18 +0100 Subject: reworking messages => log --- ui/qt/filter.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'ui/qt') diff --git a/ui/qt/filter.go b/ui/qt/filter.go index 423d5bd43..cb4d0311b 100644 --- a/ui/qt/filter.go +++ b/ui/qt/filter.go @@ -9,24 +9,21 @@ import ( func NewFilterFromMap(object map[string]interface{}, eth core.EthManager) *core.Filter { filter := ui.NewFilterFromMap(object, eth) - if object["altered"] != nil { - filter.Altered = makeAltered(object["altered"]) + if object["topics"] != nil { + filter.SetTopics(makeTopics(object["topics"])) } return filter } -func makeAltered(v interface{}) (d []core.AccountChange) { +func makeTopics(v interface{}) (d [][]byte) { if qList, ok := v.(*qml.List); ok { - var s []interface{} + var s []string qList.Convert(&s) - d = makeAltered(s) - } else if qMap, ok := v.(*qml.Map); ok { - var m map[string]interface{} - qMap.Convert(&m) - - d = makeAltered(m) + d = ui.MakeTopics(s) + } else if str, ok := v.(string); ok { + d = ui.MakeTopics(str) } return -- cgit v1.2.3 From fb7c03ff4dc759f7dd2fc5cee65b46111cbb7375 Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 28 Jan 2015 14:51:54 +0100 Subject: switched to obscuren/qml --- ui/qt/filter.go | 2 +- ui/qt/qwhisper/whisper.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'ui/qt') diff --git a/ui/qt/filter.go b/ui/qt/filter.go index cb4d0311b..bd3ad0303 100644 --- a/ui/qt/filter.go +++ b/ui/qt/filter.go @@ -3,7 +3,7 @@ package qt import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/ui" - "gopkg.in/qml.v1" + "github.com/obscuren/qml" ) func NewFilterFromMap(object map[string]interface{}, eth core.EthManager) *core.Filter { diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go index 644c147b7..22671f1b5 100644 --- a/ui/qt/qwhisper/whisper.go +++ b/ui/qt/qwhisper/whisper.go @@ -7,7 +7,7 @@ import ( "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/whisper" - "gopkg.in/qml.v1" + "github.com/obscuren/qml" ) var qlogger = logger.NewLogger("QSHH") -- cgit v1.2.3 From adda54ac5537b9f5e93a9b66ea6907a71da45aaf Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 28 Jan 2015 20:50:20 +0100 Subject: Added webengine initializer --- ui/qt/webengine/all.cpp | 1 + ui/qt/webengine/cpp/webengine.cpp | 6 ++++++ ui/qt/webengine/cpp/webengine.h | 14 ++++++++++++++ ui/qt/webengine/webengine.go | 18 ++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 ui/qt/webengine/all.cpp create mode 100644 ui/qt/webengine/cpp/webengine.cpp create mode 100644 ui/qt/webengine/cpp/webengine.h create mode 100644 ui/qt/webengine/webengine.go (limited to 'ui/qt') diff --git a/ui/qt/webengine/all.cpp b/ui/qt/webengine/all.cpp new file mode 100644 index 000000000..3b7c2f7b8 --- /dev/null +++ b/ui/qt/webengine/all.cpp @@ -0,0 +1 @@ +#include "cpp/webengine.cpp" diff --git a/ui/qt/webengine/cpp/webengine.cpp b/ui/qt/webengine/cpp/webengine.cpp new file mode 100644 index 000000000..118b451ef --- /dev/null +++ b/ui/qt/webengine/cpp/webengine.cpp @@ -0,0 +1,6 @@ +#include +#include "webengine.h" + +void webengineInitialize() { + QtWebEngine::initialize(); +} diff --git a/ui/qt/webengine/cpp/webengine.h b/ui/qt/webengine/cpp/webengine.h new file mode 100644 index 000000000..9c3b13bfa --- /dev/null +++ b/ui/qt/webengine/cpp/webengine.h @@ -0,0 +1,14 @@ +#ifndef WEBENGINE_H +#define WEBENGINE_H + +#ifdef __cplusplus +extern "C" { +#endif + +void webengineInitialize(); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // WEBENGINE_H diff --git a/ui/qt/webengine/webengine.go b/ui/qt/webengine/webengine.go new file mode 100644 index 000000000..600dbb6cb --- /dev/null +++ b/ui/qt/webengine/webengine.go @@ -0,0 +1,18 @@ +package webengine + +// #cgo CPPFLAGS: -I./ +// #cgo CXXFLAGS: -std=c++0x -pedantic-errors -Wall -fno-strict-aliasing +// #cgo LDFLAGS: -lstdc++ +// #cgo pkg-config: Qt5WebEngine +// +// #include "cpp/webengine.h" +import "C" + +import "github.com/obscuren/qml" + +// Initializes the WebEngine extension. +func Initialize() { + qml.RunMain(func() { + C.webengineInitialize() + }) +} -- cgit v1.2.3 From c03d403437c20584bcbf3cf3fa9d79ac7a0a8ca7 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 30 Jan 2015 13:25:12 +0100 Subject: Added whisper interface for xeth, added examples, updated RPC * Added RPC methods for whisper * Added whisper example --- ui/qt/qwhisper/whisper.go | 1 + 1 file changed, 1 insertion(+) (limited to 'ui/qt') diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go index 22671f1b5..98bfc69b0 100644 --- a/ui/qt/qwhisper/whisper.go +++ b/ui/qt/qwhisper/whisper.go @@ -1,3 +1,4 @@ +// QWhisper package. This package is temporarily on hold until QML DApp dev will reemerge. package qwhisper import ( -- cgit v1.2.3 From e40c1c62ce0c2d9567066d84ea74fd24b424a81a Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 5 Feb 2015 15:00:59 -0800 Subject: API changed to use Pubkey only. Reflected that change in the rest of the api --- ui/qt/qwhisper/whisper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/qt') diff --git a/ui/qt/qwhisper/whisper.go b/ui/qt/qwhisper/whisper.go index 98bfc69b0..2bc455b0b 100644 --- a/ui/qt/qwhisper/whisper.go +++ b/ui/qt/qwhisper/whisper.go @@ -106,7 +106,7 @@ func (self *Whisper) Messages(id int) (messages *ethutil.List) { func filterFromMap(opts map[string]interface{}) (f whisper.Filter) { if to, ok := opts["to"].(string); ok { - f.To = crypto.ToECDSA(fromHex(to)) + f.To = crypto.ToECDSAPub(fromHex(to)) } if from, ok := opts["from"].(string); ok { f.From = crypto.ToECDSAPub(fromHex(from)) -- cgit v1.2.3 From 8135752a32837748e6d4a986912131736b1a0aa0 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 17 Feb 2015 12:24:51 +0100 Subject: "centralised" mining to backend. Closes #323 --- ui/qt/filter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/qt') diff --git a/ui/qt/filter.go b/ui/qt/filter.go index bd3ad0303..48e8a7fae 100644 --- a/ui/qt/filter.go +++ b/ui/qt/filter.go @@ -6,7 +6,7 @@ import ( "github.com/obscuren/qml" ) -func NewFilterFromMap(object map[string]interface{}, eth core.EthManager) *core.Filter { +func NewFilterFromMap(object map[string]interface{}, eth core.Backend) *core.Filter { filter := ui.NewFilterFromMap(object, eth) if object["topics"] != nil { -- cgit v1.2.3 From 0057bb4ef6d55b5d580a4e0421526a477ef93de9 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 19 Feb 2015 11:51:38 +0100 Subject: WIP QT Clipboard --- ui/qt/clipboard/capi.hpp | 11 +++++++++++ ui/qt/clipboard/clipboard.cpp | 20 ++++++++++++++++++++ ui/qt/clipboard/clipboard.go | 15 +++++++++++++++ ui/qt/clipboard/clipboard.hpp | 23 +++++++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 ui/qt/clipboard/capi.hpp create mode 100644 ui/qt/clipboard/clipboard.cpp create mode 100644 ui/qt/clipboard/clipboard.go create mode 100644 ui/qt/clipboard/clipboard.hpp (limited to 'ui/qt') diff --git a/ui/qt/clipboard/capi.hpp b/ui/qt/clipboard/capi.hpp new file mode 100644 index 000000000..202613469 --- /dev/null +++ b/ui/qt/clipboard/capi.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include "clipboard.hpp" + +typedef void Clipboard_; + +Clipboard_ *initClipboard() +{ + Clipboard *clipboard = new(Clipboard); + return static_cast(clipboard); +} diff --git a/ui/qt/clipboard/clipboard.cpp b/ui/qt/clipboard/clipboard.cpp new file mode 100644 index 000000000..192aa7a2b --- /dev/null +++ b/ui/qt/clipboard/clipboard.cpp @@ -0,0 +1,20 @@ +#include "clipboard.h" + +#include + +Clipboard::Clipboard() +{ + connect(QApplication::clipboard(), &QClipboard::dataChanged, [this] { emit clipboardChanged();}); +} + +QString Clipboard::get() const +{ + QClipboard *clipboard = QApplication::clipboard(); + return clipboard->text(); +} + +void Clipboard::toClipboard(QString _text) +{ + QClipboard *clipboard = QApplicationion::clipboard(); + clipboard->setText(_text); +} diff --git a/ui/qt/clipboard/clipboard.go b/ui/qt/clipboard/clipboard.go new file mode 100644 index 000000000..064ee954d --- /dev/null +++ b/ui/qt/clipboard/clipboard.go @@ -0,0 +1,15 @@ +package clipboard + +// #cgo CPPFLAGS: -I./ +// #cgo CXXFLAGS: -std=c++0x -pedantic-errors -Wall -fno-strict-aliasing +// #cgo LDFLAGS: -lstdc++ +// #cgo pkg-config: Qt5Quick +// +// #include "capi.hpp" +import "C" + +import "github.com/obscuren/qml" + +func SetQMLClipboard(context *qml.Context) { + context.SetVar("clipboard", (unsafe.Pointer)(C.initClipboard())) +} diff --git a/ui/qt/clipboard/clipboard.hpp b/ui/qt/clipboard/clipboard.hpp new file mode 100644 index 000000000..1aa213ceb --- /dev/null +++ b/ui/qt/clipboard/clipboard.hpp @@ -0,0 +1,23 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +class Clipboard : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString get READ get WRITE toClipboard NOTIFY clipboardChanged) +public: + Clipboard(); + virtual ~Clipboard(){} + + Q_INVOKABLE void toClipboard(QString _text); + +signals: + void clipboardChanged(); +}; + +#ifdef __cplusplus +} // extern "C" +#endif -- cgit v1.2.3 From 982f73fa6d6f12874729faacd0db14fc78d518dd Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 20 Feb 2015 12:59:54 +0100 Subject: Added timeout for filter & removed clipboard. Closes #350 --- ui/qt/clipboard/capi.hpp | 11 ----------- ui/qt/clipboard/clipboard.cpp | 20 -------------------- ui/qt/clipboard/clipboard.go | 15 --------------- ui/qt/clipboard/clipboard.hpp | 23 ----------------------- 4 files changed, 69 deletions(-) delete mode 100644 ui/qt/clipboard/capi.hpp delete mode 100644 ui/qt/clipboard/clipboard.cpp delete mode 100644 ui/qt/clipboard/clipboard.go delete mode 100644 ui/qt/clipboard/clipboard.hpp (limited to 'ui/qt') diff --git a/ui/qt/clipboard/capi.hpp b/ui/qt/clipboard/capi.hpp deleted file mode 100644 index 202613469..000000000 --- a/ui/qt/clipboard/capi.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "clipboard.hpp" - -typedef void Clipboard_; - -Clipboard_ *initClipboard() -{ - Clipboard *clipboard = new(Clipboard); - return static_cast(clipboard); -} diff --git a/ui/qt/clipboard/clipboard.cpp b/ui/qt/clipboard/clipboard.cpp deleted file mode 100644 index 192aa7a2b..000000000 --- a/ui/qt/clipboard/clipboard.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "clipboard.h" - -#include - -Clipboard::Clipboard() -{ - connect(QApplication::clipboard(), &QClipboard::dataChanged, [this] { emit clipboardChanged();}); -} - -QString Clipboard::get() const -{ - QClipboard *clipboard = QApplication::clipboard(); - return clipboard->text(); -} - -void Clipboard::toClipboard(QString _text) -{ - QClipboard *clipboard = QApplicationion::clipboard(); - clipboard->setText(_text); -} diff --git a/ui/qt/clipboard/clipboard.go b/ui/qt/clipboard/clipboard.go deleted file mode 100644 index 064ee954d..000000000 --- a/ui/qt/clipboard/clipboard.go +++ /dev/null @@ -1,15 +0,0 @@ -package clipboard - -// #cgo CPPFLAGS: -I./ -// #cgo CXXFLAGS: -std=c++0x -pedantic-errors -Wall -fno-strict-aliasing -// #cgo LDFLAGS: -lstdc++ -// #cgo pkg-config: Qt5Quick -// -// #include "capi.hpp" -import "C" - -import "github.com/obscuren/qml" - -func SetQMLClipboard(context *qml.Context) { - context.SetVar("clipboard", (unsafe.Pointer)(C.initClipboard())) -} diff --git a/ui/qt/clipboard/clipboard.hpp b/ui/qt/clipboard/clipboard.hpp deleted file mode 100644 index 1aa213ceb..000000000 --- a/ui/qt/clipboard/clipboard.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -class Clipboard : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString get READ get WRITE toClipboard NOTIFY clipboardChanged) -public: - Clipboard(); - virtual ~Clipboard(){} - - Q_INVOKABLE void toClipboard(QString _text); - -signals: - void clipboardChanged(); -}; - -#ifdef __cplusplus -} // extern "C" -#endif -- cgit v1.2.3