clear

fun clear()

Clears all keys from memory using hierarchical cleanup.

CRITICAL SECURITY: This method performs the following:

  1. Clears all derived account wallets (and their role wallets recursively)

  2. Attempts to wipe the root key from memory

  3. Marks this wallet as cleared to prevent use-after-clear

IMPORTANT:

  • Always call this method when done using the wallet

  • After calling clear, this wallet instance cannot be used again

  • This method is idempotent - safe to call multiple times

  • Cleanup is best-effort - some keys may remain in BitcoinJ internals

Limitations: BitcoinJ's DeterministicKey uses immutable BigInteger for private keys, which cannot be reliably wiped from memory. This method does its best to minimize key exposure, but hardware wallets are recommended for maximum security.