FlutterFever Studio
Back to packages

Coconut Lib Flutter package guide

A Dart-native development library for building secure, air-gapped Bitcoin wallet applications and cold storage signers.

Install command
Copy and run in your Flutter project
flutter pub add coconut_lib

When to use Coconut Lib

In the modern landscape of digital asset security, isolating sensitive cryptographic keys from internet-connected environments is crucial. Coconut Lib (coconut_lib) is a specialized Dart library engineered specifically for developing air-gapped Bitcoin wallet applications and cold-storage vaults. By keeping cryptographic key generation, seed management, and transaction signing isolated on hardware without active network interfaces, developers can build solutions that effectively resist remote attack vectors, network sniffing, and malicious data exfiltration.

At its technical core, Coconut Lib equips developers with robust abstractions for core Bitcoin wallet operations. The package handles key derivation standards across standard Hierarchical Deterministic (HD) structures, including support for BIP32, BIP39 seed phrases, BIP44, BIP84, and BIP86 paths. It simplifies the handling of Partially Signed Bitcoin Transactions (PSBTs), allowing offline mobile devices to ingest unsigned transaction payloads, review address output parameters safely, and generate valid signatures without ever needing direct contact with the Bitcoin blockchain network.

Architecturally, Coconut Lib fits neatly into the data and cryptographic service layers of a clean Flutter architecture. In an air-gapped workflow, the app relies heavily on optical data transmission—such as animated high-density QR codes—to pass data back and forth between an online watching device and an offline signing vault. By decoupling network logic entirely from the signing logic, developers can create modular state management pipelines using Bloc or Riverpod, where Coconut Lib acts purely as a deterministic offline signing engine.

To integrate Coconut Lib into your Flutter project, begin by adding the package using the standard Flutter dependency tooling. Because the package focuses on pure Dart cryptographic logic, it integrates smoothly into cross-platform target builds including iOS and Android. However, since production air-gapped applications rely on hardware features like high-resolution cameras for QR scanning or secure hardware enclaves for local storage, developers should pair Coconut Lib with appropriate hardware access packages and native security plugins.

When deploying apps built with Coconut Lib to production, software teams must follow strict security precautions. High-quality entropy is vital during initial seed creation, so applications must ensure the operating system's cryptographically secure pseudo-random number generator (CSPRNG) is properly seeded. Furthermore, sensitive memory containing private keys or mnemonic seed phrases should be scrubbed immediately after signing operations, and native platform flags should be set to prevent screenshot captures or background task memory leaks.

Coconut Lib is the ideal foundation for developers aiming to build specialized vault applications, offline multisig co-signers, or custom enterprise cold-storage solutions in Flutter. Whether constructing a complete cold-wallet system or building companion software for existing air-gapped signing routines, this library provides a tailored Dart toolkit for secure Bitcoin transaction processing.

Air-gapped Bitcoin cold storage vault applications
Offline PSBT (Partially Signed Bitcoin Transaction) signers
Multi-signature co-signer hardware/software interfaces
Secure key management and address derivation utilities

Pros

  • Enables completely offline, air-gapped wallet architectures in Dart
  • Powers production air-gapped tools like Coconut Vault and Coconut Wallet
  • Provides robust handling for modern Bitcoin standards like PSBT and BIPs
  • Reduces supply-chain risk by implementing core wallet logic directly in Dart

Watch outs

  • Requires specialized knowledge of Bitcoin cryptography and air-gap protocols
  • Niche package target specific to Bitcoin vault architectures
  • Requires manual integration with optical camera/NFC components for data transport

Setup notes

Install the package in your Flutter project by running: flutter pub add coconut_lib Ensure your target device supports secure local storage (such as iOS Keychain or Android Keystore) to store encrypted seed material securely. If building an air-gapped vault UI that transfers PSBTs via QR codes, configure platform camera permissions in Info.plist (iOS) and AndroidManifest.xml (Android).

Requires Dart SDK 3.0 or higher. Compatible with Flutter target platforms including iOS, Android, macOS, Linux, and Windows.

import 'package:coconut_lib/coconut_lib.dart';

void main() async {
  // Generate a secure 12-word mnemonic phrase
  final mnemonic = CoconutWallet.generateMnemonic();
  print('Generated Mnemonic: $mnemonic');

  // Initialize an offline vault instance on mainnet
  final wallet = CoconutWallet.fromMnemonic(
    mnemonic: mnemonic,
    network: BitcoinNetwork.mainnet,
  );

  // Derive a SegWit receiving address (BIP84)
  final receiveAddress = await wallet.getReceiveAddress(index: 0);
  print('Derived Public Address: $receiveAddress');

  // Parse an incoming PSBT string captured via offline QR code
  const incomingPsbtBase64 = 'cHNidAC...';
  final parsedPsbt = wallet.parsePsbt(incomingPsbtBase64);

  // Sign the PSBT completely offline
  final signedPsbt = wallet.signPsbt(parsedPsbt);
  print('Signed PSBT ready for transmission: ${signedPsbt.toBase64()}');
}

Official package resources