Skip to content

Missing error handling for EventSigner methods #450

@nogringo

Description

@nogringo

Describe the bug

NDK assumes signing operations always succeed fast. EventSigner methods (sign,
encrypt, decrypt, encryptNip44, decryptNip44) have no error handling
throughout the codebase.

Signing can fail for multiple reasons:

  • External signers (NIP-46, Amber, NIP-07): user refuses, bunker disconnected,
    timeout
  • BIP340: invalid input data

When a signer fails, internal state (streams, BroadcastState, RequestState) is
not properly cleaned up.

Expected behavior

  • Signer errors should be caught internally
  • Streams and state properly closed on signing failure
  • Exception re-thrown to caller after cleanup

Additional context

Exceptions that can be thrown:

  • SignerRequestRejectedException - user explicitly rejects the request
  • SignerRequestCancelledException - request cancelled by user
  • Generic Exception - e.g., "Private key is required for signing"

Discovered while working on #398.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtoTriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions