Skip to content

Conversation

andycreed0x
Copy link

@andycreed0x andycreed0x commented Aug 16, 2025

Description

This example demonstrates how to implement a fee service that allows users to send assets on the Liquid Network without needing LBTC in their wallet to pay transaction fees. The fee service pays the network fees on behalf of users by providing its LBTC UTXO in a collaborative transaction (similar to a payjoin).

What this example includes

  • lwk_wollet/examples/fee_service.rs - A complete working example with three different implementation approaches

Key Features

  1. Fee Service Pattern: Third-party service pays transaction fees on behalf of users
  2. External UTXO Handling: Shows how to use UTXOs from one wallet (fee service) in another wallet's transaction
  3. Multiple Approaches: Three different implementations to suit different use cases

How it Works

  1. The fee service provides an LBTC UTXO to pay for transaction fees
  2. The user wallet creates a transaction to send their asset
  3. The fee service's UTXO is added as an external input
  4. The fee service calculates and adds explicit LBTC change output
  5. Both parties sign their respective inputs
  6. The transaction is broadcast with the user sending assets and the fee service paying fees

Three Implementation Approaches

1. Basic Approach (Default)

cargo run -p lwk_wollet --features electrum --example fee_service
  • User creates transaction from their perspective
  • Fee service LBTC UTXO added as external input
  • Manual fee calculation and explicit change handling

2. Unified PSET Approach

cargo run -p lwk_wollet --features electrum --example fee_service -- unified [FEE_AMOUNT]
  • Single PSET created from user wallet
  • Optional: User can pay fee service with asset units
  • Automatic change handling using drain_lbtc_to()

3. Split App/Server Approach

cargo run -p lwk_wollet --features electrum --example fee_service -- splited_server [FEE_AMOUNT]
  • Separation between app-side and server-side logic
  • Server constructs PSET and handles all outputs including asset change

Requirements

  • Two wallets: one for the fee service (with LBTC) and one for the user (with assets)
  • An issued asset to send
  • Configuration via lwk_wollet/examples/keys.env file

Screenshot

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant