• Stars
    star
    244
  • Rank 165,493 (Top 4 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created about 6 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The BitBoxApp for desktop and mobile.

BitBoxApp

BitBoxApp Screenshot

This repo contains the source code for the BitBoxApp and related tools.

Contributions are very welcome. Please see the contribution guidelines.

Tech stack

The wallet UI is a React single page webapp. It sources its data from the backend written in Go.

The Desktop app is a C++ Qt5 program containing only a WebEngineView, displaying the UI.

Static assets are sourced from a Qt rcc file, and the dynamic data is bridged from Go with WebChannels.

The Go library is compiled as a C library which exposes two functions only: one to set up the bridge, and one to invoke calls in the backend.

Similarly to the Desktop variant, the Go library can be compiled and added to an Android Studio / XCode project.

Directories (subject to change)

  • cmd/: Go projects which generate binaries are here.
  • cmd/servewallet/: a development aid which serves the static web ui and the http api it talks to. See below.
  • vendor/: Go dependencies, created by make go-vendor based on Go modules.
  • backend/coins/btc/electrum/: A json rpc client library, talking to Electrum servers.
  • backend/devices/{bitbox,bitbox02}/: Library to detect and talk to BitBoxes. High level API access.
  • backend/coins/btc/: Local HD wallet, sourcing blockchain index from an arbitrary backend. Manages addresses, outputs, tx creation, and everything else that a wallet needs to do.
  • backend/: The library that ties it all together. Uses the above packages to create a wallet talking Electrum using the BitBox for signing, and serve a high level HTTP API to control it.
  • frontends/qt/: the C++/Qt5 app which builds the wallet app for the desktop.
  • frontends/android/: Android target
  • frontends/web/: home of the React UI.

Set up the development environment

The below instructions assume a unix environment.

Requirements

To build the app or run the development workflow, the following dependencies need to be installed:

  • Go version 1.20
  • Node.js version 18.x
  • NPM version 9.x or newer
  • Qt5 version 5.15.2
    • install Qt for your platform, including the WebEngine component

Environment variables

Make sure the environment variables for qt, go and node are set, see also docs/BUILD.md for platform specific instructions

To initialize the build environment and install the required go utilities (linters, ...), call

  • make envinit, or
  • on MacOS make osx-init

Build the BitBoxApp

Clone this repository using git clone --recursive.

Please consult docs/BUILD.md for platform specific instructions and further information.

I18N translation workflow

Please consult docs/i18n.md.

Electrum server backend

The servers used are configurable in the app settings. Currently, when running the app in devmode (make servewallet), the config is ignored and servers on Shift's devserver are used. The hosts/ports/certs of those are currently hardcoded.

Currently, Electrs and ElectrumX are the recommended ways to connect your own full node.

Development workflow

Local development

Run make servewallet and make webdev in seperate terminals.

Before the first use of make webdev, you also need to run make buildweb, to install the dev dependencies.

Watch and build the UI

Run make webdev to develop the UI inside a web browser (for quick development, automatic rebuilds and devtools). This serves the UI on localhost:8080. Changes to the web code in frontends/web/src are automatically detected and rebuilt.

UI testing

The tests are run using jest and ts-jest preprocessor.

Because the app is based on preact, we use preact-render-spy package instead of enzyme to test app components rendering and their state.

To run all test suites, execute make webtest. If you plan on spending a lot of time in frontends/web/src space or just keen on doing TDD, use jest's tests watcher:

cd frontends/web/
make jstest-watch

To generate coverage report, execute make jstest-cover from frontends/web dir and open coverage/lcov-report/index.html in a browser.

Run the HTTP API

Run make servewallet to compile the code and run servewallet. servewallet is a devtool which serves the HTTP API. Changes to the backend code are not automatically detected, so you need to restart the server after changes.

Go dependencies

Go dependencies are managed by go mod, and vendored using make go-vendor. The deps are vendored so that

  • offline builds work
  • dependency diffs are easier to inspect
  • less reliance on remote systems
  • because gomobile bind does not support Go modules yet

NPM dependencies

All dependencies are locked in package-lock.json so that subsequent installs and different installations get the exact same dependency tree. To run any of the following npm commands run cd frontends/web first.

Note: Some devDependencies in package.json are specified with a semver range operator i.e. "typescript": "^4.4.2". The main reason is that those dependencies can be updated anytime within the range by running npm update.

Check outdated dependencies: npm outdated.

Update a specific dependency with a fixed semver npm install modulename@specificversion --save-exact, and with --save-dev for devDependencies.

Qt WebEngine Debugging

Set the following environment variable to debug the Qt WebEngine with Chrome developer tools, use a port_number of your choice, launch the following command and go to http://localhost:<port_number>.

QTWEBENGINE_REMOTE_DEBUGGING=<port_number> ./frontends/qt/build/osx/BitBox.app/Contents/MacOS/BitBox

see also https://doc.qt.io/qt-5/qtwebengine-debugging.html

CI

Run make ci to run all static analysis tools and tests.

Build the UI

To statically compile the UI, run make buildweb again, which compiles the web ui into a compact bundle.

Develop using Docker

The Dockerfile provides a Ubuntu container with the whole environment preconfigured. To set it up, run make dockerinit, which builds the Docker image (this takes a while).

After that, make dockerdev enters the container (a shell inside an Ubuntu virtual machine), where you can perform the same steps as in the previous section (make servewallet and make webdev).

Before the first use of make webdev, you also need to run make buildweb, to install the dev dependencies.

Running make dockerdev multiple times shares the same container. You can edit the code in your usual editor in the host and compile inside the container.

To execute make servewallet and make webdev insider the container, but from the host, use this:

$ ./scripts/docker_exec.sh servewallet/webdev

Testnet coins

In development mode, any password entered derives a unique testnet wallet.

Get Bitcoin Testnet coins here: https://coinfaucet.eu/en/btc-testnet/

Get Litecoin Testnet coins here: https://tltc.bitaps.com/

Get Ethereum Goerli coins here: https://goerlifaucet.com/

More Repositories

1

bitbox02-firmware

Firmware code of the BitBox02 hardware wallet
C
208
star
2

bitbox-base

Personal Bitcoin & Lightning full node appliance
Go
83
star
3

mcu

MCU code for the BitBox01 hardware wallet
C
63
star
4

bitbox02-backup-recovery

Website for offline recovery of BitBox02 backups
JavaScript
21
star
5

bitbox-bridge

A bridge that connects web wallets like MyEtherWallet to BitBox02
Rust
18
star
6

bitbox02-api-js

BitBox02 JavaScript library
JavaScript
11
star
7

2FA-app

Smartphone app for Digital Bitbox QR-code verification (2FA)
JavaScript
10
star
8

open-source-everything

Get the free open-source design files for the infamous BitBox "Open Source Everything" baseball cap
8
star
9

html_backup

JavaScript
7
star
10

rust-bip32-ed25519

This crate implements BIP32 for Ed25519 according to the paper *BIP32-Ed25519 Hierarchical Deterministic Keys over a Non-linear Keyspace*.
Rust
6
star
11

bitbox02-api-go

BitBox02 Go library
Go
5
star
12

ElectronDemo

JavaScript
4
star
13

bitbox-api-rs

BitBox02 client library for Rust and TypeScript
Rust
4
star
14

block-client-go

Electrum client library with failover capabilities
Go
3
star
15

bitpaywalletclient

C++ library to access Bitpays Wallet Service (Copay) https://github.com/bitpay/bitcore-wallet-service
C
3
star
16

digitalbitbox-chrome-commander

Chrome extension debug and command window
JavaScript
2
star
17

smart-verification-server

PHP
1
star
18

bitbox-base-deps

Binaries for the BitBox Base.
1
star
19

FatFs

Copy of http://elm-chan.org/fsw/ff/00index_e.html with custom patches
C
1
star
20

electrumx-containers

A collection of scripts to run electrumx servers in containers
Shell
1
star
21

libdbb

[UNMAINTAINED] C++(11) library for the DigitalBitbox device family.
C++
1
star