Lendasat LogoLendasat Docs
Setup & Initialization

Wallet & Mnemonic

Self-custodial wallet setup and key management

Self-Custody Model

Your mnemonic seed phrase is the master key to all your swap operations. LendaSwap never has access to your private keys - all cryptographic operations happen locally.

Key principles:

  • Your keys, your coins - Private keys never leave your device
  • Deterministic derivation - All swap parameters derived from your seed
  • Recoverable - Restore pending swaps anytime with your mnemonic
  • Automatic storage - The SDK stores your mnemonic securely via the configured storage provider

Generate New Mnemonic

Generate a new 12-word BIP39 mnemonic using the Signer class:

import { Signer } from "@lendasat/lendaswap-sdk-pure";

// Generate a new 12-word mnemonic
const signer = Signer.generate();
console.log("Mnemonic:", signer.mnemonic);
// Store this securely — it's the only way to recover your wallet

Import Existing Mnemonic

To restore from an existing mnemonic, pass it to the client builder:

import { Client, IdbWalletStorage, IdbSwapStorage } from "@lendasat/lendaswap-sdk-pure";

const client = await Client.builder()
  .withSignerStorage(new IdbWalletStorage())
  .withSwapStorage(new IdbSwapStorage())
  .withMnemonic("your twelve word mnemonic phrase goes here ...")
  .build();

Get Xpub

Retrieve the user ID xpub from the initialized client. Note: This is an identifier, not a wallet.

const xpub = client.getUserIdXpub();
console.log("User ID xpub:", xpub);

// Retrieve stored mnemonic (for backup)
const mnemonic = client.getMnemonic();

Key Derivation

The SDK uses BIP32/BIP39 standards for deterministic key derivation. Each swap gets unique cryptographic parameters derived from your mnemonic:

  • Preimage - Random secret for HTLC
  • Preimage Hash - SHA256 hash used as hash lock
  • Own Public Key - For VHTLC scripts
  • User ID - Derived identifier for swap recovery

All derivation happens locally - your mnemonic never leaves your device.

Critical: Your mnemonic is the only way to recover pending swaps. If you lose it, you cannot recover funds locked in HTLCs.