Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 57 additions & 12 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,50 @@ jobs:
toolchain: stable
- name: Install wasm-pack
run: curl https://raw.githubusercontent.com/rustwasm/wasm-pack/a3a48401795cd4b3afe1d74568c93675a04f3970/installer/init.sh -sSf | sh -s -- -f
- name: Install jq
run: apt-get update -y && apt-get install -y jq
- name: Rust Cache
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3
- name: Build
run: wasm-pack build --scope bitcoindevkit --features "esplora"
run: |
wasm-pack build --target bundler --out-dir pkg-web --features "esplora"
cd pkg-web
jq '.name = "bdk-wallet-web"' package.json > temp.json && mv temp.json package.json
cd ..
wasm-pack build --target nodejs --out-dir pkg-node --all-features
cd pkg-node
jq '.name = "bdk-wallet-node"' package.json > temp.json && mv temp.json package.json
cd ..
- uses: actions/cache@v4
with:
path: ./pkg-web
key: ${{ github.sha }}-web
- uses: actions/cache@v4
with:
path: ./pkg-node
key: ${{ github.sha }}-node

publish-npm-dry-run-web:
runs-on: ubuntu-latest
needs: publish-release
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- uses: actions/setup-node@v4
with:
node-version: "lts/*"
- uses: actions/cache@v4
with:
path: |
./pkg
key: ${{ github.sha }}
./pkg-web
key: ${{ github.sha }}-web
fail-on-cache-miss: true
- name: Dry Run Publish
working-directory: pkg-web
run: npm publish --dry-run

publish-npm-dry-run:
publish-npm-dry-run-node:
runs-on: ubuntu-latest
needs: publish-release
steps:
Expand All @@ -44,17 +77,17 @@ jobs:
- uses: actions/cache@v4
with:
path: |
./pkg
key: ${{ github.sha }}
./pkg-node
key: ${{ github.sha }}-node
fail-on-cache-miss: true
- name: Dry Run Publish
working-directory: pkg
working-directory: pkg-node
run: npm publish --dry-run

publish-npm:
environment: npm-publish
runs-on: ubuntu-latest
needs: publish-npm-dry-run
needs: [publish-npm-dry-run-web, publish-npm-dry-run-node]
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -66,11 +99,23 @@ jobs:
- uses: actions/cache@v4
with:
path: |
./pkg
key: ${{ github.sha }}
./pkg-web
key: ${{ github.sha }}-web
fail-on-cache-miss: true
- uses: actions/cache@v4
with:
path: |
./pkg-node
key: ${{ github.sha }}-node
fail-on-cache-miss: true
- name: Publish
working-directory: pkg
- name: Publish web
working-directory: pkg-web
run: npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
SKIP_PREPACK: true
- name: Publish node
working-directory: pkg-node
run: npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
78 changes: 10 additions & 68 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 2 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
[package]
name = "bitcoindevkit"
version = "0.1.13"
version = "0.2.0"
repository = "https://github.com/bitcoindevkit/bdk-wasm"
description = "A modern, lightweight, descriptor-based wallet library in WebAssembly for browsers and Node"
keywords = [
"bitcoin",
"descriptor",
"wasm",
"browser",
"node",
]
keywords = ["bitcoin", "descriptor", "wasm", "browser", "node"]
readme = "README.md"
license = "MIT OR Apache-2.0"
authors = ["Bitcoin Developers"]
Expand Down Expand Up @@ -51,7 +45,6 @@ console_error_panic_hook = { version = "0.1.7", optional = true }

[dev-dependencies]
wasm-bindgen-test = "0.3.50"
bdk_wallet = { version = "2.0.0", features = ["keys-bip39"] }

[profile.release]
# Tell `rustc` to optimize for small code size.
Expand Down
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
</p>

<p>
<a href="https://www.npmjs.com/package/@bitcoindevkit/bitcoindevkit"><img alt="NPM Package" src="https://img.shields.io/npm/v/@bitcoindevkit/bitcoindevkit.svg"/></a>
<a href="https://www.npmjs.com/package/bdk-wallet-web"><img alt="NPM Package (Web)" src="https://img.shields.io/npm/v/bdk-wallet-web.svg"/></a>
<a href="https://www.npmjs.com/package/bdk-wallet-node"><img alt="NPM Package (Node)" src="https://img.shields.io/npm/v/bdk-wallet-node.svg"/></a>
<a href="https://github.com/bitcoindevkit/bdk-wasm/blob/master/LICENSE"><img alt="MIT or Apache-2.0 Licensed" src="https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg"/></a>
<a href="https://blog.rust-lang.org/2023/10/05/Rust-1.73.0.html"><img alt="Rustc Version 1.73.0+" src="https://img.shields.io/badge/rustc-1.73.0%2B-lightgrey.svg"/></a>
<a href="https://discord.gg/d7NkDKm"><img alt="Chat on Discord" src="https://img.shields.io/discord/753336465005608961?logo=discord"></a>
Expand All @@ -21,7 +22,7 @@
The `bdk-wasm` library aims at providing access to the excellent [BitcoinDevKit](https://github.com/bitcoindevkit/bdk) to JS and Node environments (and eventually any device supporting WebAssembly).
It specializes in compiling BDK on the `wasm32-unknown-unknown` target and use [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) to create TypeScript bindings.

This repo handles the packaging and publishing of the `bitcoindevkit` NPM package, using `wasm-pack`.
This repo handles the packaging and publishing of the `bdk-wallet-web` (for browsers) and `bdk-wallet-node` (for Node.js) NPM packages, using `wasm-pack`.

This library offers all the desired functionality to build a Bitcoin wallet out of the box:

Expand All @@ -36,10 +37,18 @@ This library offers all the desired functionality to build a Bitcoin wallet out

For a lightweight library providing stateless utility functions, see [`bitcoinjs`](https://github.com/bitcoinjs/bitcoinjs-lib).

## Browser Usage
## Installation

### Browser/Web

```sh
yarn add bdk-wallet-web
```

### Node.js

```sh
yarn add bitcoindevkit
yarn add bdk-wallet-node
```

## Notes on WASM Specific Considerations
Expand Down Expand Up @@ -80,11 +89,17 @@ Refers to [this section](./DEVELOPMENT.md#build-on-macos).
> rustup target add wasm32-unknown-unknown
> ```

To build for browser/web:

```sh
wasm-pack build
wasm-pack build --target bundler --features "esplora"
```

> Choose your desired features when building: `--features "esplora"`
To build for Node.js:

```sh
wasm-pack build --target nodejs --all-features
```

### Test in Headless Browsers with `wasm-pack test`

Expand Down