Files
hash-wallet/cw_bitcoin
Konstantin UllrichandGitHub e7b8229429 Handle network errors, improve Lightning setup, and add deposit events (#3127)
* fix: send all for lightning

* fix: adjust crypto amount parsing logic for send page outputs

* feat: add event handling for deposit transactions in Bitcoin and Lightning wallets

- Introduced `onCreateDepositTransactionEvent` and `onUpdateDepositTransactionEvent` callbacks to manage deposit transaction updates.
- Updated event listener logic to handle unclaimed and claimed deposit events.
- Added support for processing deposit transaction info with `ElectrumTransactionInfo`.

* fix: handle network errors on username validation and improve Lightning address setup

- Added network error handling for username validation with a fallback error.
- Enhanced Lightning address setup logic with error handling and a fail-safe mechanism to disable Lightning usage if the setup fails.

* fix: enhance error handling for Lightning and update validation patterns

* fix: remove redundant raw string mark from amount validation pattern

* fix: normalize crypto amount input by replacing commas with dots
2026-03-25 20:45:23 +01:00
..
2026-03-11 04:26:57 +02:00
2026-03-17 15:19:06 +01:00
2026-03-17 15:19:06 +01:00

cw_bitcoin

Bitcoin-family Electrum wallet implementation used by Cake Wallet (BTC, LTC and derivatives).

Features

  • Electrum client and wallet with address/UTXO management and snapshots.
  • Derivation via BIP‑39; receive/change chains with per-coin configs.
  • Create/sign/broadcast transactions; PSBT helpers and payjoin support.
  • Transaction history, priorities, and size-based fee calculations.
  • Hardware wallet support for BTC/LTC.

Getting started

Use the module via app services (see bitcoin_wallet_service.dart, litecoin_wallet_service.dart). Ensure Electrum nodes are configured for the target coin.

final wallet = await BitcoinWallet.create(
  mnemonic: '...',
  password: 'secret',
  walletInfo: walletInfo,
  unspentCoinsInfo: unspentCoinsBox,
  encryptionFileUtils: encryption,
);

Usage

Send BTC with medium priority:

final feeRate = wallet.feeRate(BitcoinTransactionPriority.medium);
final pending = await wallet.createTransaction(
  outputs: [BitcoinTransactionOutput(address: 'bc1...', amount: 50000)],
  feeRate: feeRate,
);
final txHash = await pending.commit();

See lib/ for wallet/services, PSBT, and payjoin utilities.