forked from cerc-io/plugeth
Fixed "to" field
This commit is contained in:
parent
58ba290a9f
commit
ddccea75e8
@ -12,6 +12,8 @@ type Message struct {
|
||||
Signature []byte
|
||||
Payload []byte
|
||||
Sent int64
|
||||
|
||||
To *ecdsa.PublicKey
|
||||
}
|
||||
|
||||
func NewMessage(payload []byte) *Message {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user