From ddccea75e8f4931689fdf6b57ec7159b65c0d3c5 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 10 Feb 2015 13:20:06 +0100 Subject: [PATCH] Fixed "to" field --- whisper/message.go | 2 ++ whisper/whisper.go | 2 ++ xeth/whisper.go | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/whisper/message.go b/whisper/message.go index 23b5cfb0e..5d9e5b5c1 100644 --- a/whisper/message.go +++ b/whisper/message.go @@ -12,6 +12,8 @@ type Message struct { Signature []byte Payload []byte Sent int64 + + To *ecdsa.PublicKey } func NewMessage(payload []byte) *Message { diff --git a/whisper/whisper.go b/whisper/whisper.go index 57c898303..066f2c4ea 100644 --- a/whisper/whisper.go +++ b/whisper/whisper.go @@ -256,6 +256,8 @@ func (self *Whisper) postEvent(envelope *Envelope) { func (self *Whisper) open(envelope *Envelope) (*Message, *ecdsa.PrivateKey) { for _, key := range self.keys { if message, err := envelope.Open(key); err == nil || (err != nil && err == ecies.ErrInvalidPublicKey) { + message.To = &key.PublicKey + return message, key } } diff --git a/xeth/whisper.go b/xeth/whisper.go index 8e3bcefd0..d9c7e1614 100644 --- a/xeth/whisper.go +++ b/xeth/whisper.go @@ -99,8 +99,9 @@ type Options struct { type WhisperMessage struct { ref *whisper.Message Payload string `json:"payload"` + To string `json:"to"` From string `json:"from"` - Sent int64 `json:"time"` + Sent int64 `json:"sent"` } func NewWhisperMessage(msg *whisper.Message) WhisperMessage { @@ -108,6 +109,7 @@ func NewWhisperMessage(msg *whisper.Message) WhisperMessage { ref: msg, Payload: toHex(msg.Payload), From: toHex(crypto.FromECDSAPub(msg.Recover())), + To: toHex(crypto.FromECDSAPub(msg.To)), Sent: msg.Sent, } }