bitmask-core
bitmask-core copied to clipboard
Core functionality for the BitMask wallet
BitMask Core
Core functionality for the BitMask wallet - https://bitmask.app
BitMask is a Bitcoin-only web wallet and browser extension for accessing decentralized web applications on the Bitcoin timechain. It is designed to support UTXO-based smart contracting protocols such as RGB, in addition to Lightning payments.
Uses
- bdk - Bitcoin Dev Kit
- rgb-wallet - RGB Wallet
- wasm-pack - WebAssembly
- lndhubx - Custodial Lightning
- nostr-sdk - Nostr SDK
- carbonado - Carbonado e2ee decentralized storage
Build
This should work with either wasm-pack, trunk, or x86-64.
Some environment variables may be needed in order to compile on macos-aarch64, for more, see this.
If there are issues compiling, be sure to check you're compiling with the latest Rust version.
To build this as a NodeJS module, use: wasm-pack build --release --target bundler
Test
- Lint against wasm32:
cargo clippy --target wasm32-unknown-unknown - Run tests in browser:
TEST_WALLET_SEED="replace with a 12 word mnemonic for a wallet containing testnet sats" wasm-pack test --headless --chrome
Run
To run the bitmaskd node with REST server, either for testing the web wallet, or simply for increased privacy:
cargo install --features=server --path .
Then run bitmaskd.
Development
Parts of this application are built with conditional compilation statements for wasm32 support. This is a helpful command for checking linting and correctness while also developing on desktop platforms:
cargo clippy --target wasm32-unknown-unknown --no-default-features --release
Release
Upon a new release, follow these steps:
- Run
cargo updateto update to latest deps. - Run
cargo +nightly udepsto see if there are any unused dependencies.
Docker
For running bitmask-core tests in Regtest Mode, please follow the steps below:
Initial Setup
- Build bitcoin node + electrum:
docker-compose build. - Up and running Docker containers:
docker-compose up -d node1 bitmaskd. - Load the command line:
source .commands - Download and install BDK cli:
cargo install bdk-cli. We will use BDK to generate the mnemonic. - Generate a new mnemonic:
bdk-cli generate. - Create an environment variable called TEST_WALLET_SEED with mnemonic generated in the step 5 (only wasm32).
- Run the test to get main address for bitcoin and rgb:
cargo test --test wallet -- create_wallet --exact. - Load your wallet in the bitcoin node:
node1 loadwallet default. - Generate new first 500 blocks:
node1 -generate 500. - Send some coins to the main wallet address:
node1 sendtoaddress {MAIN_VAULT_ADDRESS} 10. Change{MAIN_VAULT_ADDRESS}with the address generated in the step 7. - Send some coins to the rgb wallet address:
node1 sendtoaddress {RGB_VAULT_ADDRESS} 10. Change{RGB_VAULT_ADDRESS}with the address generated in the step 7. - Mine a new block:
node1 -generate 1 - Run the test to check the balance:
cargo test --test wallet -- get_wallet_balance --exact.
Running the tests
Running the tests: cargo test --test-threads 1
Troubleshooting
1. After restarting the container
A.The bitcoin node does not work?
Check if your wallet is loaded. For that, run the command node1 loadwallet default.
B.The electrs node does not work?
To stop the electrs freeze, run node1 -generate.