24 releases

0.10.2 Mar 20, 2024
0.10.0 Apr 26, 2023
0.10.0-alpha.1 Mar 24, 2023
0.9.0-rc.1 Dec 25, 2022
0.5.0 Nov 23, 2021

#19 in #bip-32

Download history 45/week @ 2024-07-22 62/week @ 2024-07-29 76/week @ 2024-08-05 48/week @ 2024-08-12 42/week @ 2024-08-19 69/week @ 2024-08-26 41/week @ 2024-09-02 52/week @ 2024-09-09 46/week @ 2024-09-16 104/week @ 2024-09-23 50/week @ 2024-09-30 1/week @ 2024-10-07 47/week @ 2024-10-14 31/week @ 2024-10-21 27/week @ 2024-10-28 74/week @ 2024-11-04

179 downloads per month
Used in 28 crates (4 directly)

Apache-2.0

205KB
4K SLoC

Descriptor wallet library

Build Tests Lints codecov

crates.io Docs unsafe forbidden Apache2 licensed

Library for building descriptor-based bitcoin wallets. Everything a modern cold and hot bitcoin wallet needs, but which is not (yet) a part of rust-bitcoin library.

The library clearly separates parts requiring access to private keys from those which should operate never touching them. It is advised that wallets should be designed in a way assuming zero private key access for all of their operations aside from transaction signing; this part must be separated into other repository/library and be strictly controlled. One may look after command-line btc-hot and btc-cold wallets in bin directory for an example of how this can be done.

Library provides

  • efficient manipulations with BIP-32 derivation paths, separating derivations requiring private key access from those, which will always operate without;
  • miniscript & classical bitcoin descriptors;
  • PSBT constructor using input descriptors, which allow to specify custom information about RBFs, previous public key P2C tweaks and custom hash types on a per-input basis;
  • PSBT signer, supporting RBFs, relative and absolute timelocks, all sighash types, complex scripts, including witness- and taproot-based;
  • script templates allowing embedding extended pubkeys into bitcoin script assembly;
  • lexicographic ordering of transaction & PSBT inputs & oututs;
  • script type system;
  • helper types for working with hash-lock contracts;
  • PSBT utility functions (retrieving previous output, computing fee);
  • transaction resolver API on top of Electrum Server API for convenience computation of already-mined transaction fees etc;
  • support for SLIP-32/132 extended pubkey types (ypub, zprv etc).

Wallet comparison diagram

Command-line wallets

One may install command-line wallets with the following command (requires rust compiler and rustup tools to be already installed on a system):

$ rustup default stable
$ rustup update
$ git clone https://github.com/BP-WG/descriptor-wallet
$ cd descriptor-wallet
$ cargo install --path . --locked --all-features

This will add btc-hot and btc-cold commands to the system.

Install with Docker

Build

Clone the repository and checkout to the desired version (here v0.8.0):

$ git clone https://github.com/BP-WG/descriptor-wallet
$ cd descriptor-wallet
$ git checkout v0.8.0

Build and tag the Docker image:

$ docker build -t descriptor-wallet:v0.8.0 .

Usage

$ docker run descriptor-wallet:v0.8.0 btc-hot --help
$ docker run descriptor-wallet:v0.8.0 btc-cold --help

Examples with files

$ docker run -v $PWD/data:/data descriptor-wallet:v0.8.0 btc-hot seed /data/testnet.seed
$ docker run -v $PWD/data:/data descriptor-wallet:v0.8.0 btc-hot derive --testnet /data/testnet.seed /data/testnet

Dependencies

~11MB
~165K SLoC