This commit is contained in:
Jarrad 2016-08-06 17:57:26 +00:00 committed by GitHub
commit 180a00d66f
2 changed files with 6 additions and 2 deletions

View file

@ -178,6 +178,9 @@ func (s *PublicWhisperAPI) Post(args PostArgs) (bool, error) {
// construct whisper message with transmission options
message := NewMessage(common.FromHex(args.Payload))
if len(message.Payload) == 0 && len(args.Payload) > 0 {
message.Payload = []byte(args.Payload)
}
options := Options{
To: crypto.ToECDSAPub(common.FromHex(args.To)),
TTL: time.Duration(args.TTL) * time.Second,

View file

@ -302,10 +302,11 @@ func (self *Whisper) open(envelope *Envelope) *Message {
// Iterate over the keys and try to decrypt the message
for _, key := range self.keys {
message, err := envelope.Open(key)
if err == nil {
switch err {
case nil:
message.To = &key.PublicKey
return message
} else if err == ecies.ErrInvalidPublicKey {
case ecies.ErrInvalidPublicKey:
return message
}
}