Skip to main content
Bark never stores the mnemonic for an SDK app. Your wallet app stores it and passes it to Wallet.open() every time it opens the wallet, at launch or on a background wake. Barkd and the Bark CLI store the mnemonic as a file in their data directory.

Store the mnemonic in secure storage on the Bark SDK

Cross-platform recommendations

  • One entry in secure storage: Store the mnemonic as a single entry in the platform’s secure storage, which encrypts it with a key the operating system holds. The browser has no such storage, so for web deployments, encrypt the mnemonic yourself, preferably with a key derived from a user password.
  • Bound to the device: Choose the settings that leave the entry out of cloud sync and out of backups restored on another device.
  • Readable without a prompt: If your wallet app refreshes in the background, choose the setting that lets a background task read the entry once the user has unlocked the device after a restart, with no biometric prompt or password on each read (background refresh).
  • Record the mnemonic externally: Your app should ensure that the user records the mnemonic outside the app, for example by writing it down, because it will be required in the event of an app failure or a lost device.
  • No logs or telemetry: Never log the mnemonic or send it in crash reports or analytics.

Platform-specific recommendations

Use the keyring crate, version 4.1 or later, with its default features. It stores the entry in Keychain Services on macOS, Credential Manager on Windows, and the Secret Service on Linux.
  • Version 3: Enable the feature for each platform you build for. Without one, the crate falls back to a mock store that persists nothing.
  • Windows: To restrict the entry to one computer, create it through keyring-core and windows-native-keyring-store with the persistence modifier set to Local. By default, keyring writes Enterprise entries, which follow a roaming profile to other computers.
  • Linux: The crate needs a Secret Service provider, such as GNOME Keyring or KWallet, running in the user’s session. On a machine without one, write the mnemonic to an unencrypted file readable only by the user account that runs your app, as Barkd does.

Protect the mnemonic file on Barkd and the Bark CLI

The mnemonic file sits unencrypted next to the wallet database, and file permissions are its only protection.
The data directory defaults to ~/.bark and holds one wallet, so give each network its own, such as ~/.bark-mainnet. Set it with --datadir or BARKD_DATADIR.
  • One user, one directory: Run barkd as a dedicated system user and make the data directory readable by that user only. With Docker, mount the data directory from a volume that only the barkd container uses.
  • Backups copy the file: Anything that backs up the data directory copies the mnemonic in plain text. Encrypt those backups or exclude the file from them, and back up the wallet database separately (continuous backups).
  • Record it once, offline: When you create the wallet, read the mnemonic once and record it offline. Do not store it in the repository, in CI variables, or in a password manager that syncs it in plain text.
  • Leave the endpoint off: Start barkd without --expose-mnemonic unless your product reveals the mnemonic. If you enable it, the bearer token is the endpoint’s only protection, so never expose barkd to the public internet.
Restoring a wallet balance with the mnemonic alone requires the Ark server’s cooperation and does not include payment history. It resumes an in-progress exit only once the VTXO’s own transaction is on-chain or in the mempool. For a full, trustless restore, make sure your app also makes continuous backups of the wallet database.

Reopen the wallet from the stored mnemonic

Each time your wallet app starts or wakes, it reads the stored mnemonic to open the wallet. Sometimes the read returns nothing or fails even though the wallet is still on the device, causing the app to create a new wallet in its place. To avoid this:
  • Generate a mnemonic in your create flow only: Never generate one because a read came back empty. On Android, expo-secure-store returns null after it deletes an entry whose Keystore key is missing. A new mnemonic never opens the user’s existing wallet.
  • Check for an existing entry before you create one: On iOS, a keychain entry can survive an uninstall. If your create flow finds one, offer to restore that wallet. Delete the entry only once the user confirms they no longer need that wallet.
  • Retry on the next wake: Skip the pass and read again on the next wake or foreground open. Never delete or overwrite the entry because a read failed. On iOS, a read before the first unlock after a restart fails with errSecInteractionNotAllowed.
  • Reopen with createIfNotExists: false: Use it everywhere except your create and restore flows (create_if_not_exists in Rust, CreateIfNotExists in Go). With true, the default everywhere except Go, Wallet.open() creates a new wallet when it finds no stored wallet to open. With a wrong mnemonic, that new wallet is empty.
The web version runs the SDK in the browser, so the mnemonic stays there:
  • Default: AES-GCM under a non-extractable key stored in IndexedDB, with the ciphertext in localStorage. The wallet unlocks on reload without a prompt. A copy of localStorage alone can’t reveal the mnemonic. A script running on the page or a copy of the whole browser profile can.
  • With a password: Once the user sets one under Password protection in Settings, the key comes from PBKDF2 (600,000 iterations) instead, and the wallet asks for the password on every load.
  • Reopen: createIfNotExists: false, so a wrong mnemonic fails instead of opening an empty wallet.
A self-hosted install (Umbrel, Start9, or Docker) runs on Barkd, so the browser never stores the mnemonic:
  • Storage: Barkd stores the mnemonic in its data directory, as on any Barkd deployment.
  • Reveal: Bark Wallet runs barkd with --expose-mnemonic. Its API server fetches GET /api/v1/wallet/mnemonic from an endpoint that requires a session when UI_AUTH is on, and its barkd proxy blocks that route from the browser.