mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-09-17 19:13:56 +02:00
more fixes and tweaks to keyer, 17, 44 and 59.
This commit is contained in:
@@ -37,23 +37,30 @@ func PrepareMessage(
|
||||
kr keyer.Keyer,
|
||||
recipientPubKey string,
|
||||
modify func(*nostr.Event),
|
||||
) (nostr.Event, error) {
|
||||
) (toUs nostr.Event, toThem nostr.Event, err error) {
|
||||
ourPubkey := kr.GetPublicKey(ctx)
|
||||
|
||||
rumor := nostr.Event{
|
||||
Kind: 14,
|
||||
Content: content,
|
||||
Tags: tags,
|
||||
CreatedAt: nostr.Now(),
|
||||
PubKey: kr.GetPublicKey(ctx),
|
||||
PubKey: ourPubkey,
|
||||
}
|
||||
rumor.ID = rumor.GetID()
|
||||
|
||||
return nip59.GiftWrap(
|
||||
wraps, err := nip59.GiftWrap(
|
||||
rumor,
|
||||
recipientPubKey,
|
||||
[]string{ourPubkey, recipientPubKey},
|
||||
func(s string) (string, error) { return kr.Encrypt(ctx, s, recipientPubKey) },
|
||||
func(e *nostr.Event) error { return kr.SignEvent(ctx, e) },
|
||||
modify,
|
||||
)
|
||||
if err != nil {
|
||||
return nostr.Event{}, nostr.Event{}, err
|
||||
}
|
||||
|
||||
return wraps[0], wraps[1], nil
|
||||
}
|
||||
|
||||
// ListenForMessages returns a channel with the rumors already decrypted and checked
|
||||
|
Reference in New Issue
Block a user