mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
whisper bug fix for encrypted messages
This commit is contained in:
parent
bad3f49d24
commit
78e6c38a58
2 changed files with 7 additions and 2 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue