|
|
|
@ -41,13 +41,16 @@ func (self *Whisper) Post(payload []string, to, from string, topics []string, pr |
|
|
|
|
data = append(data, fromHex(d)...) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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: crypto.ToECDSA(fromHex(from)), |
|
|
|
|
From: key, |
|
|
|
|
Topics: whisper.TopicsFromString(topics...), |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
qlogger.Infoln(err) |
|
|
|
|
// handle error
|
|
|
|
@ -59,14 +62,20 @@ func (self *Whisper) Post(payload []string, to, from string, topics []string, pr |
|
|
|
|
// 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 { |
|
|
|
|