aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt
diff options
context:
space:
mode:
Diffstat (limited to 'ui/qt')
-rw-r--r--ui/qt/qwhisper/message.go4
-rw-r--r--ui/qt/qwhisper/whisper.go45
2 files changed, 29 insertions, 20 deletions
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 {