示例#1
0
// BroadcastRead creates a Bitmessage object from an unencrypted
// wire.MsgBroadcast.
func BroadcastRead(msg *cipher.Broadcast) (*Bmail, error) {
	header := msg.Object().Header()
	data := msg.Bitmessage()

	sign, _ := data.SigningKey.ToBtcec()
	encr, _ := data.EncryptionKey.ToBtcec()
	from := identity.NewPublic(sign, encr, data.Pow, data.FromAddressVersion, data.FromStreamNumber)
	fromAddress, err := from.Address.Encode()
	if err != nil {
		return nil, err
	}

	return &Bmail{
		From:       "*****@*****.**",
		To:         bmToEmail(fromAddress),
		Expiration: header.Expiration(),
		Content:    data.Content,
	}, nil
}