whisper bug fix for encrypted messages

This commit is contained in:
Daniel Whitenack 2016-06-10 18:14:17 -05:00
parent bad3f49d24
commit 78e6c38a58
2 changed files with 7 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

@ -23,6 +23,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/ecies"
"github.com/ethereum/go-ethereum/event/filter"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
@ -301,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 {
case ecies.ErrInvalidPublicKey:
origMessage, err := envelope.Open(nil)
if err != nil {
return nil