kernl API
    Preparing search index...

    Function createLegacyMessagesBackend

    • A MessagingBackend for the legacy direct-message format (NIP-04) over the active account's signer.

      Sending encrypts the text to the one recipient with signer().nip04, signs the kind 4 event with the account and publishes it to the recipient's inbox relays and the user's own, so the user's other devices see it too. Receiving subscribes to kind 4 events addressed to or written by the user and decrypts them with the same signer. Conversation ids and message shapes match createPrivateMessagesBackend; groups are refused with invalid:groups-unsupported because the format has none.

      Parameters

      Returns MessagingBackend

      A backend for the legacy provider; available while the signer has nip04.

      const backend = createLegacyMessagesBackend({
      store: kernl.eventStore,
      pool: kernl.pool,
      tiers: kernl.relays,
      signer: () => kernl.accounts.active,
      selfPubkey: () => kernl.accounts.active?.pubkey,
      });
      backend.subscribe({}, (message) => console.log(message.content));