fromSeed

fun fromSeed(seed: ByteArray, clearSeed: Boolean = false): HDWallet

Creates an HD wallet from a BIP-39 seed.

CRITICAL SECURITY WARNING: This function does NOT clear the provided seed array. The caller MUST wipe the seed from memory after calling this function:

val seed = BIP39.mnemonicToSeed(mnemonic)
try {
val wallet = HDWallet.fromSeed(seed)
// Use wallet...
wallet.clear()
} finally {
// CRITICAL: Wipe seed from memory
Arrays.fill(seed, 0.toByte())
}

The seed is the master secret that can derive ALL keys in this wallet. Failing to wipe it is a critical security vulnerability.

Compatibility:

  • BIP-39 mnemonicToSeed() produces 64-byte seeds (most common)

  • Midnight SDK supports seeds from 16 to 64 bytes

  • This implementation accepts 16-64 bytes for full compatibility

Return

HDWallet instance

Parameters

seed

Seed bytes (16-64 bytes). BIP-39 mnemonicToSeed() produces 64 bytes.

clearSeed

If true, automatically clears the seed after use (default: false for backward compatibility)

Throws

if seed is not between 16 and 64 bytes