npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@swan-bitcoin/bdk-node

v0.2.2

Published

This package is a wrapper around the [Bitcoin Dev Kit](https://bitcoindevkit.org/getting-started/) made with [Napi-RS](https://napi.rs/docs/).

Downloads

92

Readme

bdk-node

This package is a wrapper around the Bitcoin Dev Kit made with Napi-RS.

Installation

npm install @swan-bitcoin/bdk-node
# or
yarn add @swan-bitcoin/bdk-node
# or
pnpm install @swan-bitcoin/bdk-node

Usage

import { ... } from '@swan-bitcoin/bdk-node';

TODO: Add usage examples

Contributing

The Rust code that gets build is inside src/lib.rs. When you run pnpm build this file gets compiled and NAPI spit out the Typescript file and JS with the biddings.

Publishing

Napi comes out of the box with a release process that is documented here: https://napi.rs/docs/introduction/simple-package

To publish a new version of the package you need to:

# Make sure you start on the main branch and main is up-to-date
git checkout main
git pull

# check out a new branch and give it a good name using <initials>/<branch-name>, such as:
git checkout -b jdf/publish-new-package-version

# Patch version and push to github, 'major' and 'minor' can also be used in place of 'patch' (if appropriate)
npm version patch
git push --follow-tags

then, open and merge a pull request. The version bump must be the most recent commit on this branch when merging for publishing to occur.

Manual Testing

yes, we need a better testing system.

check out: https://github.com/turkycat/fulcrum-regtest

from fulcrum-regtest/

docker compose up -d  
./prepare_btc1.sh  
./send_to_address.sh   bcrt1q8vw3juyk7gm7elt8rut87mghe50sxc32njs7zn9fqv6ynsxr52xq4h2uu0 10  
./mine_blocks.sh 1  

the above commands will:

  • set up two bitcoin nodes in regtest and a fulcrum server that connects to them.
  • create a bitcoin wallet with the first node and mine 101 blocks to it (making 50 bitcoin available)
  • send 10 bitcoin to the address bcrt1q8vw3juyk7gm7elt8rut87mghe50sxc32njs7zn9fqv6ynsxr52xq4h2uu0 -- this address was obtained with the BDK instructions below
  • mine 1 block to confirm the transaction

for some extra fun:

docker logs -f fulcrum - watch fulcrum as it processes new blocks, receives transactions, and other stuff

docker exec -it btc1 /bin/bash - execute commands with bitcoin-cli

BDK instructions:
to interact with this wallet in BDK use the following command:

bdk-cli --network regtest repl --server localhost:50001 --descriptor "wsh(multi(2,[5708531c/84h/1h/0h/2h]tpubDFE8F7LxXBEQEMPxed7QxhUJn6HMZg9keYLiXTCFbAkP3bRAneGZjNW44gwWcVj8yzwE9F7i55m78ZqdVsrmdJXXsh2iZCHjoon7LRAjXcu/0/*,[946d4c49/84h/1h/0h/2h]tpubDFXJS31fJep45UaMw4EUUqNhL6qUYL3BUW5TuHyXn4A4yCkXcJMy7ba6uT9cqX6KjMBgeVRqb56TuQ5oRxW5QUQ3ffhMqEy44ECvyxhwUFk/0/*,[4c69896e/84h/1h/0h/2h]tpubDE159ZNvnVj5Dv7Eo8EmnTjUdvJZYQ8fNp7R3K29a5FjZkmd4priKbdePGWU7XJMERG7LPQnh3Fi7Hjv1JrmXUrxuNaWXfULj8hDG7biXqh/0/*))" --change_descriptor "wsh(multi(2,[5708531c/84h/1h/0h/2h]tpubDFE8F7LxXBEQEMPxed7QxhUJn6HMZg9keYLiXTCFbAkP3bRAneGZjNW44gwWcVj8yzwE9F7i55m78ZqdVsrmdJXXsh2iZCHjoon7LRAjXcu/1/*,[946d4c49/84h/1h/0h/2h]tpubDFXJS31fJep45UaMw4EUUqNhL6qUYL3BUW5TuHyXn4A4yCkXcJMy7ba6uT9cqX6KjMBgeVRqb56TuQ5oRxW5QUQ3ffhMqEy44ECvyxhwUFk/1/*,[4c69896e/84h/1h/0h/2h]tpubDE159ZNvnVj5Dv7Eo8EmnTjUdvJZYQ8fNp7R3K29a5FjZkmd4priKbdePGWU7XJMERG7LPQnh3Fi7Hjv1JrmXUrxuNaWXfULj8hDG7biXqh/1/*))"

then, in the REPL you can do the following interesting things

wallet get_new_address- returns the next unused address ( which will be bcrt1q8vw3juyk7gm7elt8rut87mghe50sxc32njs7zn9fqv6ynsxr52xq4h2uu0 [index 0] if used before wallet sync or before spending)

wallet sync

wallet get_balance - need to sync first to get accurate info

help

wallet help

bdk-cli will create a local database in ~/.bdk-bitcoin by default, so you may need to clean those up if you need to restart.