Giter Club home page Giter Club logo

lwk's Introduction

Liquid Wallet Kit

WARNING: LWK is still early stage software, use it at your own risk.

Liquid Wallet Kit is a collection of Rust crates for Liquid Wallets.

Main Features

  • Watch-Only wallet support: using Liquid descriptors, better known as CT descriptors.
  • PSET based: transactions are shared and processed using the Partially Signed Elements Transaction format.
  • Electrum and Esplora backends: no need to run and sync a full Liquid node or rely on closed source servers.
  • Asset issuance, reissuance and burn support: manage the lifecycle of your Issued Assets with a lightweight client.
  • Generic multisig wallets: create a wallet controlled by any combination of hardware or software signers, with a user specified quorum.
  • Hardware signer support: receive, issue, reissue and burn L-BTC and Issued Assets with your hardware signer, using singlesig or multisig wallets (currently Jade only, with more coming soon).
  • Native bindings PoC support for Python, Kotlin and Swift, with many other language available soon using uniffi
  • WASM preliminary support with lwk_wasm crate, see it live.
  • JSON-RPC Server support: all functions are exposed via JSON-RPC Server, making it easier to build your own frontend, GUI, or integration.

Building from source

First you need rust, our MSRV is 1.75.0 then you can build from source:

$ git clone [email protected]:Blockstream/lwk.git
$ cd lwk
$ cargo install --path ./lwk_cli/ 

Or

$ cargo install --path ./lwk_cli/ --features serial

To enable connection with Jade over serial.

CLI Usage

Start the rpc server (default in Liquid Testnet) and put it in background

$ lwk_cli server start &

Create a software signer named sw from a given BIP39 mnemonic

$ lwk_cli signer load-software -s sw --persist false --mnemonic "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"

Create a p2wpkh wallet named ss (install jq or extract the descriptor manually)

$ DESC=$(lwk_cli signer singlesig-desc -s sw --descriptor-blinding-key slip77 --kind wpkh | jq -r .descriptor)
$ lwk_cli wallet load -w ss -d $DESC

Get the wallet balance

$ lwk_cli wallet balance -w ss

When you're done, stop the rpc server.

$ lwk_cli server stop

Jade

If you have a Jade, you can plug it in and use it to create a wallet and sign its transactions.

Workspace Structure

The projects are split into different component crates that might be useful independently.

Internal crate dependencies are shown in this diagram, where an arrow indicates "depends on":

  graph TD;
      cli-->app;
      cli-->rpc_model;

      app-->common;
      app-->wollet;
      app-->signer;
      app-->tiny_jrpc;
      app-->rpc_model;

      jade-->common;

      signer-->common;
      signer-->jade;

      wollet-->common;
      
      bindings-->signer;
      bindings-->wollet;
      bindings-->test_util;

      wasm-->signer;
      wasm-->wollet;

      test_util-->containers

For instance, mobile app devs might be interested mainly in lwk_bindings, lwk_wollet and lwk_signer. While backend developers might want to directly use lwk_cli in their systems.

Tests

Run unit tests:

cargo test --lib

End-to-end tests need some local servers:

./context/download_bins.sh # needed once unless server binaries changes
. .envrc  # not needed if you use direnv and you executed `direnv allow`

And also the following docker images:

docker pull xenoky/local-jade-emulator:1.0.27
docker pull tulipan81/blind_pin_server:v0.0.7

Note: Failed test executions can leave docker containers running. To stop all running containers run:

docker stop $(docker ps -a -q)

To run end-to-end tests:

cargo test

To see log outputs use RUST_LOG for example

RUST_LOG=info cargo test -- test_name
RUST_LOG=jade=debug cargo test -- test_name  # filter only on specific module

Test with a physical Jade

Tests using Jade over serial (via USB cable) need an additional dependency:

apt install -y libudev-dev

These serial tests cannot be executed in parallel, so we need the --test-threads 1 flag.

cargo test -p lwk_jade --features serial -- serial --include-ignored --test-threads 1
cargo test -p lwk_wollet --features serial -- serial --include-ignored --test-threads 1

Docs

To generate documentation you can use

RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features --no-deps --open

Nix

We provide a flake for a dev environment and for running the lwk_cli. If you use direnv and allow the .envrc the dev environment is automatically loaded as soon as you enter the directory, otherwise you can run:

nix develop

To run lwk_cli on nix-enabled system:

nix run github:blockstream/lwk

History

BEWallet was originally an Elements/Liquid wallet library written in Rust to develop prototypes and experiments.

BEWallet was based on Blockstream's GDK. Essentially some GDK Rust pieces were moved to this project.

This was used as the starting point for the Liquid Wallet Kit project. Parts that were not necessary have been dropped, many things have been polished, and new features have been added.

The codebase has been entirely re-written, and now it has almost no similarity with the original code.

lwk's People

Contributors

rcasatta avatar leocomandini avatar delta1 avatar angelix avatar domegabri avatar lvaccaro avatar i5hi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.