SparkWallet extends EventEmitter, so it inherits the following methods for handling events.
Available Events
| Event | Callback Signature | Description |
|---|---|---|
"transfer:claimed" | (transferId: string, updatedBalance: bigint) => void | Emitted when an incoming transfer is claimed. Does NOT fire for outgoing Lightning payments. |
"deposit:confirmed" | (depositId: string, updatedBalance: bigint) => void | Emitted when a pending L1 deposit becomes spendable (after 3 confirmations). Only fires if you claimed before confirmation. |
"stream:connected" | () => void | Emitted when the event stream connects |
"stream:disconnected" | (reason: string) => void | Emitted when the stream disconnects after max retries |
"stream:reconnecting" | (attempt: number, maxAttempts: number, delayMs: number, error: string) => void | Emitted when attempting to reconnect |
The
updatedBalance parameter is a bigint representing the wallet’s new total balance in satoshis after the event.on(event: string, listener: Function)
Adds a listener for the specified event.Parameters
The event name to listen for
The callback function to execute when the event is emitted
Returns
The SparkWallet instance for chaining
Example
once(event: string, listener: Function)
Adds a one-time listener for the specified event.Parameters
The event name to listen for
The callback function to execute when the event is emitted
Returns
The SparkWallet instance for chaining
Example
off(event: string, listener: Function)
Removes the specified listener from the specified event.Parameters
The event name
The callback function to remove
Returns
The SparkWallet instance for chaining