Skip to content

Developer Guide

Rithvik Vibhu edited this page Feb 28, 2022 · 1 revision

Getting started with Bob Wallet development is pretty easy.

Setup

Install node.js v16+. Then:

# Clone the repo
git clone https://github.com/kyokan/bob-wallet   # or with ssh

# Install dependencies
npm i --legacy-peer-deps

# Start dev
npm run dev

This opens up Bob in dev mode, along with DevTools (which you can manually open with Inspect element). You may want to switch to regtest network, which is a local chain that does not connect to any peers (by default), and can mine blocks as needed - more on that later.

Most files* are watched and will reload it when changed.

* - changing files in background/* will not reload, will need to close and run npm run dev again.

HSD Client

Since Bob runs a hsd node, it's possible to interact with it with hs{d,w}-{cli,rpc}.

# install hsd (even only hs-client will do)
npm i -g hsd

# set network and apikey (api key from Bob's settings)
export HSD_NETWORK=regtest
export HSD_API_KEY=apikey

# use client
hsd-cli info

More info on cli/rpc: https://hsd-dev.org/api-docs/

Play around

In regtest, you control whent to mine blocks: Bob shows 3 buttons +1, +10, +50 to mine that many blocks at once. Also, the network parameters for regtest are adjusted for development, so auction times, etc. are shorter:

regtest.names = {
  auctionStart: 0,
  rolloutInterval: 2,
  lockupPeriod: 2,
  renewalWindow: 5000,
  renewalPeriod: 2500,
  renewalMaturity: 50,
  claimPeriod: 250000,
  biddingPeriod: 5,
  revealPeriod: 10,
  treeInterval: 5,
  transferLockup: 10,
  revocationDelay: 50,
  auctionMaturity: 5 + 10 + 50,
  noRollout: false,
  noReserved: false,
};

You might want to use a simple wallet passphrase since it'll be needed a lot. For the lazy: set the passphrase in AccountLogin/index.js so there's no need to type in the passphrase every time to unlock. Just don't commit that line 😉.

Files

Bob user data

Bob settings and user preferences are stored in:

  • Windows: %AppData%\Electron\ in dev (%AppData%\Bob\ when packaged)
  • Linux: ~/.config/Electron/ in dev (~/.config/Bob/ when packaged)
  • Macos: ~/Library/Application\ Support/Electron/ in dev (~/Library/Application\ Support/Bob/ when packaged)

Blockchain data

By default, blockchain data (hsd_data) is stored along with user data (append hsd_data to the path above). This also includes wallets.

If running in any other network other than mainnet, then the data is a network-specific directory. Ex: regtest hsd logs in Linux, when run in dev mode, is at ~/.config/Electron/hsd_data/regtest/debug.log.

However, Bob can be set to use blockchain data other directories / disks too - so it's best to always confirm the path from the settings page.

Code Structure

Just the important bits:

  • app - source files
    • pages - each page gets a folder with its own scss
    • components - reusable components
    • utils - common helper code
    • background - code that runs in the main process
    • ducks - redux code, runs in renderer process
    • db - persists data
    • constants - constants, duh.
    • assets - binary files like images and fonts
  • locale - strings for i18n
  • release - where binaries are exported to

The background directory consists of services with each having a service.js and client.js. These are run in the main process and do not block the UI thread - any expensive processing should happen here, not in pages, components, or ducks.


This page steals a lot of content from @pinheadmz's gist.

Clone this wiki locally