PersistentWalletTransactionLogger

class PersistentWalletTransactionLogger(context: Context, fileName: String = DEFAULT_FILE_NAME) : WalletTransactionLogger

File-backed WalletTransactionLogger that persists events as JSON Lines.

The log file lives under context.noBackupFilesDir/walletsdk/<fileName> — it is not included in Android auto-backup, matching how the wallet DB itself is stored.

Each call to log appends a single JSON-encoded event to the file on the calling thread (guarded by a Java monitor lock). This is intentional: the EUDI transaction decorator can fire logs from Dispatchers.Main.immediate, and the consuming app may call list immediately afterwards — an asynchronous write here would race the next read and silently drop events.

Appends are very small (single JSON line) so the synchronous cost is negligible in practice. list, delete and deleteAll still hop to Dispatchers.IO because they can read or rewrite the whole file.

The consuming app can:

  • call list to fetch the full history (newest-first),

  • call delete to remove a single event by id,

  • call deleteAll to wipe the entire log.

Apps that need a different persistence strategy (encrypted DB, remote shipping, etc.) should implement WalletTransactionLogger directly instead.

Constructors

Link copied to clipboard
constructor(context: Context, fileName: String = DEFAULT_FILE_NAME)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
suspend fun delete(id: String): Boolean

Remove the event with the given WalletTransactionEvent.id.

Link copied to clipboard
suspend fun deleteAll()

Remove all persisted events.

Link copied to clipboard

Read all persisted events, newest-first.

Link copied to clipboard
open override fun log(event: WalletTransactionEvent)

Append an event to the log file synchronously.