### Install Dependencies Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/wasm/examples/node/README.md Install the necessary Node.js dependencies for the example. ```bash npm i ``` -------------------------------- ### Start Regtest Environment Source: https://github.com/breez/breez-sdk-liquid/blob/main/regtest/README.md Execute this script to initiate the regtest setup. Monitor for any unhealthy containers after startup. ```bash ./start.sh ``` -------------------------------- ### Install Protobuf Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/bindings/DEVELOPMENT.md Install Protobuf using Homebrew. This is a prerequisite for building UniFFI bindings. ```bash brew install protobuf ``` -------------------------------- ### Run the CLI Example Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/wasm/examples/node/README.md Execute the command-line interface for the Breez SDK Wasm Node.js example. ```bash npm run cli ``` -------------------------------- ### Install Breez SDK - Liquid with npm Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/wasm/README.md Use npm to install the Breez SDK - Liquid package. ```bash npm install @breeztech/breez-sdk-liquid ``` -------------------------------- ### Initialize Project Environment Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/wasm/DEVELOPMENT.md Runs the initial setup for the project. This command should be executed on first usage. ```bash make init ``` -------------------------------- ### Install Dependencies and Build Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/flutter_breez_liquid/DEVELOPMENT.md Run this command to install all necessary dependencies, build Rust bindings, generate Flutter/Dart bindings, and set up the development environment for iOS and Android. ```bash just setup build ``` -------------------------------- ### Install Breez SDK - Liquid with yarn Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/wasm/README.md Use yarn to install the Breez SDK - Liquid package. ```bash yarn add @breeztech/breez-sdk-liquid ``` -------------------------------- ### Install Build Dependencies Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/wasm/DEVELOPMENT.md Installs Protobuf and Emscripten, which are required for building Wasm dependencies. Ensure these are installed before proceeding. ```bash brew install protobuf emscripten ``` -------------------------------- ### Node.js CLI Example for Breez SDK - Liquid Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/wasm/README.md This example demonstrates how to set up and use the Breez SDK - Liquid in a Node.js environment, including event listening and basic command-line operations. ```javascript const { connect, defaultConfig, setLogger } = require('@breeztech/breez-sdk-liquid/node') const { Command } = require('commander') require('dotenv').config() class JsEventListener { onEvent = (event) => { console.log(`EVENT RECEIVED: ${JSON.stringify(event)}`) } } class JsLogger { log = (logEntry) => { console.log(`[${logEntry.level}]: ${logEntry.line}`) } } const program = new Command() const eventListener = new JsEventListener() const logger = new JsLogger() const initSdk = async () => { // Set the logger to trace setLogger(logger) // Get the mnemonic const breezApiKey = process.env.BREEZ_API_KEY const mnemonic = process.env.MNEMONIC // Connect using the config let config = defaultConfig('mainnet', breezApiKey) config.workingDir = "./.data" console.log(`defaultConfig: ${JSON.stringify(config)}`) const sdk = await connect({ config, mnemonic }) console.log(`connect`) const listenerId = await sdk.addEventListener(eventListener) console.log(`addEventListener: ${listenerId}`) return sdk } program.name('nodeless-wasm-cli').description('CLI for Breez SDK - Nodeless Wasm') program.command('get-info').action(async () => { let sdk = await initSdk() let getInfoRes = await sdk.getInfo() console.log(`getInfo: ${JSON.stringify(getInfoRes)}`) }) program.parse() ``` -------------------------------- ### Install Dependencies Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/wasm/examples/web-vite/README.md Install project dependencies using yarn. ```bash yarn ``` -------------------------------- ### Install Development Tools Source: https://github.com/breez/breez-sdk-liquid/blob/main/DEVELOPMENT.md Install necessary tools for cross-platform development, including Flutter, WASM pack, and UniFFI bindings generator. ```bash # For Flutter development flutter pub get # For WASM development cargo install wasm-pack # For bindings generation cargo install uniffi-bindgen ``` -------------------------------- ### Fetch Fiat Rates, List Currencies, and Get Recommended Fees Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Use `fetch_fiat_rates` to get live exchange rates, `list_fiat_currencies` to see supported currencies, and `recommended_fees` to get Bitcoin on-chain fee tiers. ```rust // Live fiat rates sorted by name let rates = sdk.fetch_fiat_rates().await?; for r in &rates { println!("{}: {:.2}", r.coin, r.value); } // Supported fiat currencies let currencies = sdk.list_fiat_currencies().await?; println!("Supported currencies: {}", currencies.len()); // Recommended BTC fees let fees = sdk.recommended_fees().await?; println!("Fast: {} sat/vbyte", fees.fastest_fee); println!("Medium: {} sat/vbyte", fees.half_hour_fee); println!("Slow: {} sat/vbyte", fees.hour_fee); ``` -------------------------------- ### Start Regtest Environment Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/core/DEVELOPMENT.md Initializes and starts the regtest environment required for end-to-end tests. Refer to the regtest README for prerequisites. ```bash make regtest-start ``` -------------------------------- ### Install Breez Liquid SDK for Python Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/bindings/langs/python/README.md Install the Breez Liquid SDK package using pip. This is the standard method for adding the SDK to your Python environment. ```bash pip install breez-sdk-liquid ``` -------------------------------- ### Install Rust with rustup Source: https://github.com/breez/breez-sdk-liquid/blob/main/DEVELOPMENT.md Ensure Rust is installed using rustup. This is a prerequisite for most development tasks. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` -------------------------------- ### Run Breez SDK Liquid CLI Source: https://github.com/breez/breez-sdk-liquid/blob/main/cli/README.md Start the Breez SDK Liquid CLI tool. Ensure the BREEZ_API_KEY environment variable is set. ```bash cargo run ``` -------------------------------- ### Install Breez SDK Liquid React Native Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/react-native/README.md Install the Breez SDK for React Native using npm or yarn. ```bash npm install @breeztech/breez-sdk-liquid-react-native ``` ```bash yarn add @breeztech/breez-sdk-liquid-react-native ``` -------------------------------- ### Prepare and Buy Bitcoin via Moonpay (Mainnet Only) Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Use `prepare_buy_bitcoin` to get a Moonpay URL for purchasing Bitcoin. Amounts must be multiples of 1000 sats. Then use `buy_bitcoin` to generate the URL. ```rust let prepare_res = sdk.prepare_buy_bitcoin(&PrepareBuyBitcoinRequest { provider: BuyBitcoinProvider::Moonpay, amount_sat: 50_000, // must be a multiple of 1000 }).await?; println!("Fees: {} sats", prepare_res.fees_sat); let url = sdk.buy_bitcoin(&BuyBitcoinRequest { prepare_response: prepare_res, redirect_url: Some("https://myapp.com/purchase-complete".into()), }).await?; println!("Open this URL: {}", url); ``` -------------------------------- ### Receive Payment with Breez SDK Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Use `prepare_receive_payment` to set up a receive request, then `receive_payment` to get a destination string. Supports BOLT11, BOLT12 Offer, Bitcoin on-chain, and Liquid addresses. ```rust // --- Receive via BOLT11 --- let prepare_res = sdk.prepare_receive_payment(&PrepareReceiveRequest { payment_method: PaymentMethod::Bolt11Invoice, amount: Some(ReceiveAmount::Bitcoin { payer_amount_sat: 50_000 }), }).await?; println!("Fees: {} sats", prepare_res.fees_sat); let receive_res = sdk.receive_payment(&ReceivePaymentRequest { prepare_response: prepare_res, description: Some("Invoice for order #42".into()), description_hash: None, payer_note: None, }).await?; println!("Give this invoice to the payer: {}", receive_res.destination); ``` ```rust // --- Receive via Bitcoin on-chain address --- let prepare_res = sdk.prepare_receive_payment(&PrepareReceiveRequest { payment_method: PaymentMethod::BitcoinAddress, amount: Some(ReceiveAmount::Bitcoin { payer_amount_sat: 100_000 }), }).await?; let receive_res = sdk.receive_payment(&ReceivePaymentRequest { prepare_response: prepare_res, description: None, description_hash: None, payer_note: None, }).await?; // receive_res.destination is a BIP21 Bitcoin URI println!("Send Bitcoin to: {}", receive_res.destination); ``` -------------------------------- ### LiquidSdk::connect Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Initializes the SDK with a mnemonic, creates or opens the persistent database, and starts background tasks. This must be called before any other SDK method. ```APIDOC ## LiquidSdk::connect — Initialize and connect the SDK ### Description Initializes the SDK with a mnemonic (or seed), creates or opens the persistent database, and starts background tasks for block-tracking and swap monitoring. Must be called before any other SDK method. ### Method ```rust LiquidSdk::connect ``` ### Parameters #### Request Body - **config** (LiquidConfig) - Required - The SDK configuration. - **mnemonic** (Option) - Optional - The mnemonic phrase for wallet recovery. - **passphrase** (Option) - Optional - The passphrase for the mnemonic. - **seed** (Option>) - Optional - The seed for wallet recovery. ### Request Example ```rust use breez_sdk_liquid::prelude::*; #[tokio::main] async fn main() -> anyhow::Result<()> { // Set up logging (call once at startup, before connect) LiquidSdk::init_logging(".data", None)?; let mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"; let config = LiquidSdk::default_config(LiquidNetwork::Mainnet, Some("YOUR_BREEZ_API_KEY".into()))?; let sdk = LiquidSdk::connect(ConnectRequest { config, mnemonic: Some(mnemonic.to_string()), passphrase: None, seed: None, }) .await?; println!("Connected! SDK is ready."); // sdk is Arc — keep it alive for the session Ok(()) } ``` ### Response #### Success Response (LiquidSdk) - Returns an `Arc` instance upon successful connection. ``` -------------------------------- ### Import Flutter Breez Liquid Package Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/flutter_breez_liquid/README.md Import the package into your Dart file to start using its functionalities. ```dart import 'package:flutter_breez_liquid/flutter_breez_liquid.dart'; ``` -------------------------------- ### Get Blockchain Info (Elements) Source: https://github.com/breez/breez-sdk-liquid/blob/main/regtest/README.md Interact with the Elements regtest node to retrieve blockchain information. ```bash elements-cli-sim-client getblockchaininfo ``` -------------------------------- ### Get Node Info (Lightning) Source: https://github.com/breez/breez-sdk-liquid/blob/main/regtest/README.md Retrieve information about a specific Lightning node in the regtest environment. ```bash lightning-cli-sim 1 getinfo ``` -------------------------------- ### Get Blockchain Info (Bitcoin) Source: https://github.com/breez/breez-sdk-liquid/blob/main/regtest/README.md Interact with the Bitcoin regtest node to retrieve blockchain information. ```bash bitcoin-cli-sim-client getblockchaininfo ``` -------------------------------- ### Update npm Dependencies for Local Package Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/wasm/DEVELOPMENT.md Configures npm to use the locally built Breez Liquid SDK package by specifying a file path. This is essential for testing local changes in examples. ```json "@breeztech/breez-sdk-liquid": "file:../../", ``` -------------------------------- ### Project Configuration and CargoKit Integration Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/flutter_breez_liquid/linux/CMakeLists.txt Configures the project name and integrates Rust code using CargoKit. This setup is essential for building the Flutter plugin with its Rust components. ```cmake set(PROJECT_NAME "flutter_breez_liquid") project(${PROJECT_NAME} LANGUAGES CXX) ``` ```cmake include("../cargokit/cmake/cargokit.cmake") apply_cargokit(${PROJECT_NAME} ../rust flutter_breez_liquid "") ``` -------------------------------- ### Initialize and Connect SDK (Rust) Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Initializes the SDK with a mnemonic, sets up logging, and connects to the network. Must be called before any other SDK method. Ensure to replace 'YOUR_BREEZ_API_KEY' with your actual API key. ```rust use breez_sdk_liquid::prelude::*; #[tokio::main] async fn main() -> anyhow::Result<()> { // Set up logging (call once at startup, before connect) LiquidSdk::init_logging(".data", None)?; let mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"; let config = LiquidSdk::default_config(LiquidNetwork::Mainnet, Some("YOUR_BREEZ_API_KEY".into()))?; let sdk = LiquidSdk::connect(ConnectRequest { config, mnemonic: Some(mnemonic.to_string()), passphrase: None, seed: None, }) .await?; println!("Connected! SDK is ready."); // sdk is Arc — keep it alive for the session Ok(()) } ``` -------------------------------- ### Run Vite Preview Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/wasm/examples/web-vite/README.md Serve the built Vite application for preview. ```bash yarn preview ``` -------------------------------- ### Build All Bindings Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/bindings/DEVELOPMENT.md Run 'make all' to build all UniFFI bindings. For language-specific builds, refer to the Makefile tasks. ```bash make all ``` -------------------------------- ### Initialize and Connect Breez SDK Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/react-native/README.md Initialize the Breez SDK with a default configuration for the Liquid mainnet and connect using a mnemonic. An event handler is also set up to log SDK events. ```typescript import React, { useEffect } from "react" import { addEventListener, connect, defaultConfig, LiquidNetwork, NodeConfigVariant, prepareSendPayment, SdkEvent, sendPayment } from "@breeztech/breez-sdk-liquid" import BuildConfig from "react-native-build-config" const App = () => ( ... const eventHandler = (sdkEvent: SdkEvent) => { console.log(`${JSON.stringify(sdkEvent)}`) } const payInvoice = async (bolt11: string) => { // Pay invoice let prepareSendRes = await prepareSendPayment({ destination: bolt11 }) let sendPaymentRes = await sendPayment({ prepareResponse: prepareSendRes }) } useEffect(() => { const asyncFn = async () => { // Construct the sdk default config const config = await defaultConfig(LiquidNetwork.MAINNET, BuildConfig.BREEZ_API_KEY) // Connect to the Breez SDK make it ready to use await connect({ config, mnemonic }) // Add event handler await addEventListener(eventHandler) } asyncFn() }, []) ... ) ``` -------------------------------- ### Run Vite Build Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/wasm/examples/web-vite/README.md Build the Vite application for production. ```bash yarn build ``` -------------------------------- ### Get Node Info (lncli) Source: https://github.com/breez/breez-sdk-liquid/blob/main/regtest/README.md Retrieve information about a specific Lightning node using lncli. ```bash lncli-sim 1 getinfo ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/breez/breez-sdk-liquid/blob/main/DEVELOPMENT.md Clone the project repository and change the directory to your target package. ```bash git clone cd ``` -------------------------------- ### Available 'just' Commands Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/flutter_breez_liquid/DEVELOPMENT.md A list of individual 'just' commands for managing dependencies, building, code generation, versioning, and cleaning build artifacts. ```bash just setup # Install required dependencies just check-deps # Check system dependencies just build # Build UniFFI library and generate bindings just build-uniffi # Build UniFFI library for all platforms just build-uniffi-android # Build UniFFI library for Android only just build-uniffi-swift # Build UniFFI library for iOS/macOS only just gen # Generate Dart bindings and iOS frameworks just codegen # Generate Dart bindings only just version # Update version across all platform files just clean # Clean all build artifacts ``` -------------------------------- ### Get New Liquid Address Source: https://github.com/breez/breez-sdk-liquid/blob/main/regtest/README.md Generate a new Liquid address using the Elements regtest node. ```bash elements-cli-sim-client getnewaddress ``` -------------------------------- ### Get New Bitcoin Address Source: https://github.com/breez/breez-sdk-liquid/blob/main/regtest/README.md Generate a new Bitcoin address using the Bitcoin regtest node. ```bash bitcoin-cli-sim-client getnewaddress ``` -------------------------------- ### Initialize WebAssembly module for Web Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/wasm/README.md When developing a browser application, it's crucial to initialize the WebAssembly module using `await init()` before making any other calls to the Breez SDK - Liquid. ```typescript import init, connect, defaultConfig, SdkEvent } from '@breeztech/breez-sdk-liquid/web' // Initialise the WebAssembly module await init() ``` -------------------------------- ### Publish Breez Liquid SDK Package Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/bindings/langs/csharp/README.md Command to push the Breez Liquid SDK NuGet package to a source. Replace PUT-API-KEY-HERE with your actual API key. ```bash dotnet nuget push ./bin/Debug/Breez.Sdk.Liquid.{version}.nupkg --api-key PUT-API-KEY-HERE --source https://api.nuget.org/v3/index.json ``` -------------------------------- ### Build Breez Liquid SDK for Linux Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/bindings/langs/python/README.md Manually build the Breez Liquid SDK package for Linux using the provided Makefile. This command is useful for development or when pre-built wheels are not suitable. ```shell make linux # builds the package for linux ``` -------------------------------- ### Add Breez Liquid SDK Package Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/bindings/langs/csharp/README.md Use this command to add the Breez Liquid SDK package to your C# project. ```bash dotnet add package Breez.Sdk.Liquid ``` -------------------------------- ### List Available 'just' Commands Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/flutter_breez_liquid/DEVELOPMENT.md Execute 'just' without arguments to view all available build and development recipes for the Breez Liquid Flutter package. ```bash just ``` -------------------------------- ### Initialize Breez SDK Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/flutter_breez_liquid/README.md Initialize the Breez SDK - Nodeless (Liquid Implementation) by calling `FlutterBreezLiquid.init()`. This should preferably be done in your `main.dart` file before other operations. ```dart import 'package:flutter_breez_liquid/flutter_breez_liquid.dart'; Future main() async { await FlutterBreezLiquid.init(); ... } ``` -------------------------------- ### Import Breez Liquid SDK in Python Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/bindings/langs/python/README.md Import the breez_sdk_liquid library into your Python script. This is necessary to use the SDK's functionalities. ```python import breez_sdk_liquid ``` -------------------------------- ### Build Breez Liquid SDK for macOS Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/bindings/langs/python/README.md Manually build the Breez Liquid SDK package for macOS using the provided Makefile. This command is useful for development or when pre-built wheels are not suitable. ```shell make darwin # builds the package for macos ``` -------------------------------- ### Login to npm Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/wasm/PUBLISHING.md Authenticate with npm using your scope before publishing. ```bash npm login --@scope=@breeztech ``` -------------------------------- ### Format and Lint Source Code Source: https://github.com/breez/breez-sdk-liquid/blob/main/CONTRIBUTING.md Run this command to format and lint the source code according to project standards. ```bash make fmt clippy ``` -------------------------------- ### Run Breez SDK Liquid CLI with Custom Data Directory Source: https://github.com/breez/breez-sdk-liquid/blob/main/cli/README.md Run the Breez SDK Liquid CLI and specify a custom directory for storing data. ```bash cargo run -- --data-dir temp-dir ``` -------------------------------- ### Fetch Fiat Rates, List Fiat Currencies, and Recommended Fees Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Fetches live fiat exchange rates, lists all supported fiat currencies, and retrieves recommended Bitcoin on-chain fee tiers from the configured mempool.space instance. ```APIDOC ## `LiquidSdk::fetch_fiat_rates` / `list_fiat_currencies` / `recommended_fees` — Utility queries Fetches live fiat exchange rates, lists supported fiat currencies, and retrieves recommended Bitcoin on-chain fee tiers from the configured mempool.space instance. ```rust // Live fiat rates sorted by name let rates = sdk.fetch_fiat_rates().await?; for r in &rates { println!("{}: {:.2}", r.coin, r.value); } // Supported fiat currencies let currencies = sdk.list_fiat_currencies().await?; println!("Supported currencies: {}", currencies.len()); // Recommended BTC fees let fees = sdk.recommended_fees().await?; println!("Fast: {} sat/vbyte", fees.fastest_fee); println!("Medium: {} sat/vbyte", fees.half_hour_fee); println!("Slow: {} sat/vbyte", fees.hour_fee); ``` ``` -------------------------------- ### Import Breez SDK - Liquid for Deno Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/wasm/README.md When developing a Deno application, import the Breez SDK - Liquid using its explicit submodule path. ```typescript import '@breeztech/breez-sdk-liquid/deno' ``` -------------------------------- ### Set Breez API Key (Linux/macOS) Source: https://github.com/breez/breez-sdk-liquid/blob/main/cli/README.md Set your Breez API key as an environment variable for Linux or macOS. ```bash export BREEZ_API_KEY="your-api-key-here" ``` -------------------------------- ### Handle Fee Negotiation for Zero-Amount Chain Swaps Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Use these methods when a zero-amount incoming chain swap's on-chain fees exceed the initial estimate. Fetch the updated proposal and then accept or reject it. This is typically triggered by the SdkEvent::PaymentWaitingFeeAcceptance event. ```rust // Triggered by SdkEvent::PaymentWaitingFeeAcceptance let proposal = sdk.fetch_payment_proposed_fees(&FetchPaymentProposedFeesRequest { swap_id: "abc123swap".to_string(), }).await?; println!("Payer amount: {} sats", proposal.payer_amount_sat); println!("Fees: {} sats", proposal.fees_sat); println!("You receive: {} sats", proposal.receiver_amount_sat); // Accept if fees are acceptable sdk.accept_payment_proposed_fees(&AcceptPaymentProposedFeesRequest { response: proposal, }).await?; ``` -------------------------------- ### Pay to Bitcoin On-Chain Address with Breez SDK Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Send L-BTC to a native Bitcoin address via chain swap. Use `prepare_pay_onchain` for fee estimates and `pay_onchain` to execute. ```rust let prepare_res = sdk.prepare_pay_onchain(&PreparePayOnchainRequest { amount: PayAmount::Bitcoin { receiver_amount_sat: 200_000 }, fee_rate_sat_per_vbyte: None, // use swapper default }).await?; println!("Receiver gets: {} sats", prepare_res.receiver_amount_sat); println!("Total fees: {} sats", prepare_res.total_fees_sat); let send_res = sdk.pay_onchain(&PayOnchainRequest { address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh".to_string(), prepare_response: prepare_res, }).await?; println!("Chain swap state: {:?}", send_res.payment.status); ``` -------------------------------- ### Build Wasm Package Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/wasm/examples/node/README.md Build the Wasm package from the local directory. Ensure you are in the Wasm package directory before running. ```bash cd .. make build ``` -------------------------------- ### Faster Iteration for Android Development Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/flutter_breez_liquid/DEVELOPMENT.md Use this command sequence to rebuild only the Android UniFFI library and regenerate Dart bindings for faster iteration during Android development. ```bash just build-uniffi-android && just codegen ``` -------------------------------- ### Query Payment Limits with Breez SDK Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Fetches the current minimum and maximum amounts (in sats) for Lightning and on-chain send/receive operations. Includes zero-conf limits for receive operations. ```rust let lightning_limits = sdk.fetch_lightning_limits().await?; println!("Lightning send: {} - {} sats", lightning_limits.send.min_sat, lightning_limits.send.max_sat); println!("Lightning receive: {} - {} sats", lightning_limits.receive.min_sat, lightning_limits.receive.max_sat); println!("Zero-conf receive up to: {} sats", lightning_limits.receive.max_zero_conf_sat); let onchain_limits = sdk.fetch_onchain_limits().await?; println!("Onchain send: {} - {} sats", onchain_limits.send.min_sat, onchain_limits.send.max_sat); println!("Onchain receive: {} - {} sats", onchain_limits.receive.min_sat, onchain_limits.receive.max_sat); ``` -------------------------------- ### Faster Iteration for iOS/macOS Development Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/flutter_breez_liquid/DEVELOPMENT.md Use this command sequence to rebuild only the iOS/macOS UniFFI library and regenerate Dart bindings for faster iteration during iOS/macOS development. ```bash just build-uniffi-swift && just gen ``` -------------------------------- ### Backup and Restore Local Wallet State Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Use `backup` to export the local SQLite database to a file, and `restore` to import it. The SDK must not be connected when calling `restore`. ```rust // Backup to default path (Config::working_dir) sdk.backup(BackupRequest { backup_path: None })?; // Backup to a custom path sdk.backup(BackupRequest { backup_path: Some("/path/to/my/backup.db".to_string()), })?; // Restore from backup (SDK must NOT be connected yet) sdk.restore(RestoreRequest { backup_path: Some("/path/to/my/backup.db".to_string()), })?; ``` -------------------------------- ### Run Breez SDK Liquid CLI on Specific Network Source: https://github.com/breez/breez-sdk-liquid/blob/main/cli/README.md Execute the Breez SDK Liquid CLI and specify the network to connect to (e.g., mainnet or regtest). Testnet is not supported. ```bash cargo run -- --network mainnet ``` ```bash cargo run -- --network regtest ``` -------------------------------- ### Receive Payment (Two-Step Flow) Source: https://context7.com/breez/breez-sdk-liquid/llms.txt This section details the two-step process for receiving payments using `prepare_receive_payment` and `receive_payment`. It supports various methods including BOLT11, BOLT12, and on-chain addresses. ```APIDOC ## `LiquidSdk::prepare_receive_payment` + `receive_payment` — Receive a payment Two-step receive flow. Supports BOLT11 (Lightning), BOLT12 Offer, Bitcoin on-chain address, and direct Liquid address. Returns a destination string (invoice, offer, BIP21 URI, or address) that the payer sends to. ### Example: Receive via BOLT11 ```rust let prepare_res = sdk.prepare_receive_payment(&PrepareReceiveRequest { payment_method: PaymentMethod::Bolt11Invoice, amount: Some(ReceiveAmount::Bitcoin { payer_amount_sat: 50_000 }), }).await?; println!("Fees: {} sats", prepare_res.fees_sat); let receive_res = sdk.receive_payment(&ReceivePaymentRequest { prepare_response: prepare_res, description: Some("Invoice for order #42".into()), description_hash: None, payer_note: None, }).await?; println!("Give this invoice to the payer: {}", receive_res.destination); ``` ### Example: Receive via Bitcoin on-chain address ```rust let prepare_res = sdk.prepare_receive_payment(&PrepareReceiveRequest { payment_method: PaymentMethod::BitcoinAddress, amount: Some(ReceiveAmount::Bitcoin { payer_amount_sat: 100_000 }), }).await?; let receive_res = sdk.receive_payment(&ReceivePaymentRequest { prepare_response: prepare_res, description: None, description_hash: None, payer_note: None, }).await?; // receive_res.destination is a BIP21 Bitcoin URI println!("Send Bitcoin to: {}", receive_res.destination); ``` ``` -------------------------------- ### Send Lightning or Liquid Payment with Breez SDK Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Use `prepare_send_payment` to validate and estimate fees, then `send_payment` to execute. Supports BOLT11, BOLT12, Liquid addresses, Lightning addresses, pay codes, and LNURL-Pay. ```rust // --- Send via BOLT11 invoice --- let prepare_res = sdk.prepare_send_payment(&PrepareSendRequest { destination: "lnbc10u1p...".to_string(), // BOLT11 invoice amount: None, // use invoice amount disable_mrh: None, payment_timeout_sec: None, }).await?; println!("Estimated fees: {:?} sats", prepare_res.fees_sat); let send_res = sdk.send_payment(&SendPaymentRequest { prepare_response: prepare_res, use_asset_fees: None, payer_note: None, }).await?; println!("Payment state: {:?}", send_res.payment.status); ``` ```rust // --- Send directly to a Liquid address --- let prepare_res = sdk.prepare_send_payment(&PrepareSendRequest { destination: "liquidnetwork:VJL...?amount=0.0001".to_string(), // BIP21 URI amount: Some(PayAmount::Bitcoin { receiver_amount_sat: 10_000 }), disable_mrh: None, payment_timeout_sec: None, }).await?; let send_res = sdk.send_payment(&SendPaymentRequest { prepare_response: prepare_res, use_asset_fees: Some(false), payer_note: Some("Thanks!".into()), }).await?; ``` -------------------------------- ### Authenticate with LNURL-Auth using Breez SDK Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Authenticates with an LNURL-auth endpoint by signing the `k1` challenge with the wallet's linking key. Requires parsing the input string to extract authentication data. ```rust let parsed = sdk.parse("LNURL1DP68GURN8...AUTH...").await?; if let InputType::LnUrlAuth { data } = parsed { let status = sdk.lnurl_auth(data).await?; match status { LnUrlCallbackStatus::Ok => println!("Authenticated!"), LnUrlCallbackStatus::ErrorStatus { data } => eprintln!("Auth failed: {}", data.reason), } } ``` -------------------------------- ### Build Specific Wasm Artifacts Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/wasm/DEVELOPMENT.md Builds individual artifacts for specific environments like Bundle, Deno, Node, or Web. Use these if you only need a subset of the generated files. ```bash make build-bundle ``` ```bash make build-deno ``` ```bash make build-node ``` ```bash make build-web ``` -------------------------------- ### Run Browser Wasm End-to-End Tests (Not Headless) Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/core/DEVELOPMENT.md Executes end-to-end tests in a browser environment with the UI visible. Set NO_HEADLESS=1 to enable. ```bash make wasm-regtest-test-browser NO_HEADLESS=1 ``` -------------------------------- ### Prepare and Buy Bitcoin via Moonpay Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Prepares and generates a Moonpay URL for purchasing Bitcoin that flows into the wallet. This feature is only available on Mainnet, and amounts must be multiples of 1000 sats. ```APIDOC ## `LiquidSdk::prepare_buy_bitcoin` + `buy_bitcoin` — Fiat on-ramp via Moonpay Prepares and generates a Moonpay URL for purchasing Bitcoin that flows into the wallet via a reverse chain swap. Only available on Mainnet; amounts must be multiples of 1000 sats. ```rust let prepare_res = sdk.prepare_buy_bitcoin(&PrepareBuyBitcoinRequest { provider: BuyBitcoinProvider::Moonpay, amount_sat: 50_000, // must be a multiple of 1000 }).await?; println!("Fees: {} sats", prepare_res.fees_sat); let url = sdk.buy_bitcoin(&BuyBitcoinRequest { prepare_response: prepare_res, redirect_url: Some("https://myapp.com/purchase-complete".into()), }).await?; println!("Open this URL: {}", url); ``` ``` -------------------------------- ### Query Payment History with Breez SDK Source: https://context7.com/breez/breez-sdk-liquid/llms.txt List all payments (Lightning, Liquid, on-chain) using `list_payments` or retrieve a specific payment with `get_payment`. Supports filtering by type, state, and date range. ```rust // List all payments let payments = sdk.list_payments(&ListPaymentsRequest { filters: Some(vec![PaymentType::Send, PaymentType::Receive]), states: None, from_timestamp: None, to_timestamp: None, offset: None, limit: Some(20), details: None, sort_ascending: None, metadata_filters: None, }).await?; for p in &payments { println!("{:?} | {} sats | {:?}", p.payment_type, p.amount_sat, p.status); } ``` ```rust // Retrieve a specific payment by lightning payment hash let payment = sdk.get_payment(&GetPaymentRequest::Lightning { payment_hash: "abc123...".to_string(), }).await?; println!("{:?}", payment); ``` -------------------------------- ### Generate Code for Bindings Source: https://github.com/breez/breez-sdk-liquid/blob/main/CONTRIBUTING.md Execute this command to generate code for Flutter and React Native bindings. ```bash make codegen ``` -------------------------------- ### LiquidSdk::fetch_payment_proposed_fees & LiquidSdk::accept_payment_proposed_fees Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Handles fee negotiation for zero-amount chain swaps. When estimated on-chain fees exceed the initial estimate, these methods allow fetching and accepting or rejecting the updated fee proposal. ```APIDOC ## fetch_payment_proposed_fees & accept_payment_proposed_fees ### Description Handle fee negotiation for zero-amount chain swaps. When a zero-amount incoming chain swap's actual on-chain fees exceed the initial estimate (plus the configured leeway), the payment enters `WaitingFeeAcceptance` state. Use these methods to fetch the updated proposal and accept or reject it. ### Methods - `fetch_payment_proposed_fees(request: FetchPaymentProposedFeesRequest) -> Result` - `accept_payment_proposed_fees(request: AcceptPaymentProposedFeesRequest) -> Result<()>` ### Parameters #### `fetch_payment_proposed_fees` Request Body - **swap_id** (string) - Required - The ID of the swap for which to fetch proposed fees. #### `accept_payment_proposed_fees` Request Body - **response** (PaymentProposedFeesResponse) - Required - The fee proposal response object obtained from `fetch_payment_proposed_fees`. - **payer_amount_sat** (integer) - The amount the payer will pay in sats. - **fees_sat** (integer) - The estimated fees in sats. - **receiver_amount_sat** (integer) - The amount the receiver will get in sats. ### Request Example ```rust // Triggered by SdkEvent::PaymentWaitingFeeAcceptance let proposal = sdk.fetch_payment_proposed_fees(&FetchPaymentProposedFeesRequest { swap_id: "abc123swap".to_string(), }).await?; println!("Payer amount: {} sats", proposal.payer_amount_sat); println!("Fees: {} sats", proposal.fees_sat); println!("You receive: {} sats", proposal.receiver_amount_sat); // Accept if fees are acceptable if proposal.fees_sat < MAX_ALLOWED_FEES { // Example condition sdk.accept_payment_proposed_fees(&AcceptPaymentProposedFeesRequest { response: proposal, }).await?; } ``` ### Response #### `fetch_payment_proposed_fees` Success Response (200) - **PaymentProposedFeesResponse** - An object containing the proposed fee details. - **payer_amount_sat** (integer) - The amount the payer will pay in sats. - **fees_sat** (integer) - The estimated fees in sats. - **receiver_amount_sat** (integer) - The amount the receiver will get in sats. #### `accept_payment_proposed_fees` Success Response (200) - Indicates successful acceptance of the proposed fees. ``` -------------------------------- ### Publish to npm Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/wasm/PUBLISHING.md Publish the package to npm with public access. ```bash npm publish --access public ``` -------------------------------- ### Pay On-Chain (Chain Swap) Source: https://context7.com/breez/breez-sdk-liquid/llms.txt This section covers paying to a Bitcoin on-chain address using a chain swap, involving `prepare_pay_onchain` for fee estimation and `pay_onchain` for execution. ```APIDOC ## `LiquidSdk::prepare_pay_onchain` + `pay_onchain` — Pay to a Bitcoin on-chain address Sends L-BTC to a native Bitcoin address using a chain swap. Call `prepare_pay_onchain` to get fee estimates, then `pay_onchain` to execute. ### Example ```rust let prepare_res = sdk.prepare_pay_onchain(&PreparePayOnchainRequest { amount: PayAmount::Bitcoin { receiver_amount_sat: 200_000 }, fee_rate_sat_per_vbyte: None, // use swapper default }).await?; println!("Receiver gets: {} sats", prepare_res.receiver_amount_sat); println!("Total fees: {} sats", prepare_res.total_fees_sat); let send_res = sdk.pay_onchain(&PayOnchainRequest { address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh".to_string(), prepare_response: prepare_res, }).await?; println!("Chain swap state: {:?}", send_res.payment.status); ``` ``` -------------------------------- ### Run Memory Usage Test Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/wasm/examples/node-mem-usage-bench/README.md Execute the memory usage benchmark. Optionally specify the number of rounds and instances to test. ```bash npm run memory-test [rounds] [instances] ``` -------------------------------- ### Send Payment (Two-Step Flow) Source: https://context7.com/breez/breez-sdk-liquid/llms.txt This section describes the two-step process for sending payments using `prepare_send_payment` and `send_payment`. It supports various payment methods including BOLT11, Liquid addresses, and more. ```APIDOC ## `LiquidSdk::prepare_send_payment` + `send_payment` — Send a Lightning or Liquid payment Two-step payment flow: first call `prepare_send_payment` to validate the destination and get fee estimates, then call `send_payment` to execute. Supports BOLT11, BOLT12, Liquid addresses (BIP21 or plain), Lightning addresses, BIP353 pay codes, and LNURL-Pay. ### Example: Send via BOLT11 invoice ```rust let prepare_res = sdk.prepare_send_payment(&PrepareSendRequest { destination: "lnbc10u1p...".to_string(), // BOLT11 invoice amount: None, // use invoice amount disable_mrh: None, payment_timeout_sec: None, }).await?; println!("Estimated fees: {:?} sats", prepare_res.fees_sat); let send_res = sdk.send_payment(&SendPaymentRequest { prepare_response: prepare_res, use_asset_fees: None, payer_note: None, }).await?; println!("Payment state: {:?}", send_res.payment.status); ``` ### Example: Send directly to a Liquid address ```rust let prepare_res = sdk.prepare_send_payment(&PrepareSendRequest { destination: "liquidnetwork:VJL...?amount=0.0001".to_string(), // BIP21 URI amount: Some(PayAmount::Bitcoin { receiver_amount_sat: 10_000 }), disable_mrh: None, payment_timeout_sec: None, }).await?; let send_res = sdk.send_payment(&SendPaymentRequest { prepare_response: prepare_res, use_asset_fees: Some(false), payer_note: Some("Thanks!".into()), }).await?; ``` ``` -------------------------------- ### Run Wasm Tests Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/wasm/DEVELOPMENT.md Executes the test suite for the Wasm crate. Ensure all prerequisites are met before running tests. ```bash make test ``` -------------------------------- ### Query Payment Limits Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Returns the current minimum and maximum amounts (in sats) for Lightning and on-chain send/receive, including zero-conf limits, based on the swapper's live pair data. ```APIDOC ## `LiquidSdk::fetch_lightning_limits` / `fetch_onchain_limits` — Query payment limits Returns the current minimum and maximum amounts (in sats) for Lightning and on-chain send/receive, including zero-conf limits, based on the swapper's live pair data. ### Method `fetch_lightning_limits`: GET (implied) `fetch_onchain_limits`: GET (implied) ### Description - `fetch_lightning_limits`: Retrieves the payment limits for Lightning transactions. - `fetch_onchain_limits`: Retrieves the payment limits for on-chain transactions. ### Response #### `fetch_lightning_limits` Success Response - **send.min_sat** (number) - Minimum amount in satoshis for sending via Lightning. - **send.max_sat** (number) - Maximum amount in satoshis for sending via Lightning. - **receive.min_sat** (number) - Minimum amount in satoshis for receiving via Lightning. - **receive.max_sat** (number) - Maximum amount in satoshis for receiving via Lightning. - **receive.max_zero_conf_sat** (number) - Maximum amount in satoshis for zero-conf receiving via Lightning. #### `fetch_onchain_limits` Success Response - **send.min_sat** (number) - Minimum amount in satoshis for sending on-chain. - **send.max_sat** (number) - Maximum amount in satoshis for sending on-chain. - **receive.min_sat** (number) - Minimum amount in satoshis for receiving on-chain. - **receive.max_sat** (number) - Maximum amount in satoshis for receiving on-chain. ``` -------------------------------- ### Configure Git Hooks for Code Formatting Source: https://github.com/breez/breez-sdk-liquid/blob/main/DEVELOPMENT.md Configure Git hooks to automatically format code and run linting checks before commits. ```bash git config --local core.hooksPath .githooks/ ``` -------------------------------- ### Set Breez API Key (Windows PowerShell) Source: https://github.com/breez/breez-sdk-liquid/blob/main/cli/README.md Set your Breez API key as an environment variable for Windows using PowerShell. ```powershell $env:BREEZ_API_KEY="your-api-key-here" ``` -------------------------------- ### Run Native End-to-End Tests Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/core/DEVELOPMENT.md Executes end-to-end tests specifically on the native platform using Cargo. ```bash make cargo-regtest-test ``` -------------------------------- ### Define Bundled Libraries Source: https://github.com/breez/breez-sdk-liquid/blob/main/packages/flutter_breez_liquid/linux/CMakeLists.txt Lists absolute paths to libraries that will be bundled with the plugin. This includes prebuilt libraries or those generated by an external build process. ```cmake set(flutter_breez_liquid_bundled_libraries "${${PROJECT_NAME}_cargokit_lib}" PARENT_SCOPE ) ``` -------------------------------- ### Build Wasm Artifacts Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/wasm/DEVELOPMENT.md Compiles the Wasm crate and generates various artifacts for different environments (Bundle, Deno, Node, Web). ```bash make build ``` -------------------------------- ### Run Browser Wasm End-to-End Tests (Headless) Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/core/DEVELOPMENT.md Executes end-to-end tests in a headless browser environment. This is useful for automated testing. ```bash make wasm-regtest-test-browser ``` -------------------------------- ### Perform LNURL-Withdraw with Breez SDK Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Executes an LNURL-withdraw flow by generating a BOLT11 invoice and submitting it to the LNURL endpoint. The remote party then initiates a payment to this wallet. Ensure the input string is a valid LNURL. ```rust let parsed = sdk.parse("LNURL1DP68GURN8...").await?; if let InputType::LnUrlWithdraw { data } = parsed { let result = sdk.lnurl_withdraw(LnUrlWithdrawRequest { data: data.clone(), amount_msat: data.max_withdrawable, // withdraw max description: Some("Withdrawal from faucet".into()), }).await?; match result { LnUrlWithdrawResult::Ok { data } => { println!("Withdraw initiated, invoice: {}", data.invoice.bolt11); } LnUrlWithdrawResult::Timeout { .. } => println!("Withdraw timed out"), LnUrlWithdrawResult::ErrorStatus { data } => eprintln!("Error: {}", data.reason), } } ``` -------------------------------- ### LiquidSdk::get_info Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Fetches current wallet balance (L-BTC and other Liquid assets), pending send/receive amounts, public key, fingerprint, and the latest known block heights for both Liquid and Bitcoin chains. ```APIDOC ## LiquidSdk::get_info — Fetch wallet and blockchain info ### Description Returns the current wallet balance (L-BTC and other Liquid assets), pending send/receive amounts, public key, fingerprint, and the latest known block heights for both Liquid and Bitcoin chains. ### Method ```rust LiquidSdk::get_info ``` ### Parameters None ### Response #### Success Response (GetInfoResponse) - **wallet_info**: WalletInfo - Contains wallet-specific information. - **balance_sat**: u64 - The total balance in satoshis. - **pending_receive_sat**: u64 - The amount of pending received satoshis. - **pending_send_sat**: u64 - The amount of pending sent satoshis. - **asset_balances**: Vec - A list of balances for different assets. - **ticker**: Option - The ticker symbol of the asset. - **balance**: Option - The balance of the asset in satoshis. - **blockchain_info**: BlockchainInfo - Contains blockchain-specific information. - **liquid_tip**: u64 - The height of the latest Liquid block. - **bitcoin_tip**: u64 - The height of the latest Bitcoin block. ### Request Example ```rust let info = sdk.get_info().await?; println!("Balance: {} sats", info.wallet_info.balance_sat); println!("Pending receive: {} sats", info.wallet_info.pending_receive_sat); println!("Pending send: {} sats", info.wallet_info.pending_send_sat); println!("Liquid tip: {}", info.blockchain_info.liquid_tip); println!("Bitcoin tip: {}", info.blockchain_info.bitcoin_tip); for asset in &info.wallet_info.asset_balances { if let (Some(ticker), Some(balance)) = (&asset.ticker, asset.balance) { println!(ירת ticker} balance: {balance}); } } ``` ``` -------------------------------- ### Fetch Wallet and Blockchain Info (Rust) Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Retrieves current wallet balance, pending amounts, public key, fingerprint, and the latest block heights for Liquid and Bitcoin chains. Iterates through asset balances to print ticker and balance if available. ```rust let info = sdk.get_info().await?; println!("Balance: {} sats", info.wallet_info.balance_sat); println!("Pending receive: {} sats", info.wallet_info.pending_receive_sat); println!("Pending send: {} sats", info.wallet_info.pending_send_sat); println!("Liquid tip: {}", info.blockchain_info.liquid_tip); println!("Bitcoin tip: {}", info.blockchain_info.bitcoin_tip); for asset in &info.wallet_info.asset_balances { if let (Some(ticker), Some(balance)) = (&asset.ticker, asset.balance) { println!(ירת{ticker} balance: {balance}); } } ``` -------------------------------- ### LNURL-Auth Source: https://context7.com/breez/breez-sdk-liquid/llms.txt Authenticates with an LNURL-auth endpoint by signing the `k1` challenge with the wallet's linking key. ```APIDOC ## `LiquidSdk::lnurl_auth` — LNURL-Auth Authenticates with an LNURL-auth endpoint by signing the `k1` challenge with the wallet's linking key. ### Method `lnurl_auth`: POST (implied) ### Description Authenticates the user with an LNURL service using a signed challenge. ### Parameters #### `lnurl_auth` Request Body - **data** (object) - Required - The parsed LNURL-auth data, including the `k1` challenge. ### Request Example (Conceptual) ```rust let parsed = sdk.parse("LNURL1DP68GURN8...AUTH...").await?; if let InputType::LnUrlAuth { data } = parsed { let status = sdk.lnurl_auth(data).await?; } ``` ### Response #### `lnurl_auth` Success Response - **Ok**: Authentication successful. - **ErrorStatus**: Authentication failed. - **data.reason** (string) - The reason for the failure. ``` -------------------------------- ### Run All End-to-End Tests Source: https://github.com/breez/breez-sdk-liquid/blob/main/lib/core/DEVELOPMENT.md Executes all end-to-end tests across all available targets. Ensure the regtest environment is running. ```bash make regtest-test ```