Skip to content

Hive wallet application for Nano S and X

Notifications You must be signed in to change notification settings

qbLedger/app-hive

 
 

Repository files navigation

Hive Application for Ledger Nano S/X

License

What is Hive

Hive is an innovative and forward-looking decentralized blockchain and ecosystem, designed to scale with widespread adoption of the currency and platforms in mind. By combining the lightning-fast processing times and fee-less transactions, Hive is positioned to become one of the leading Web3 blockchains used by people around the world.

Fast - Transactions take less than 3 seconds

Scalable - Future proof resource-bandwidth & storage system

Powerful - Battle-tested for 5 years by hundreds of apps, communities & projects around the world.

Learn more: https://hive.io


Operations supported by Hive Ledger application:

  • vote
  • comment
  • transfer
  • transfer_to_vesting
  • withdraw_vesting
  • limit_order_create
  • limit_order_cancel
  • feed_publish
  • convert
  • account_create
  • account_update
  • witness_update
  • account_witness_vote
  • account_witness_proxy
  • delete_comment
  • custom_json
  • comment_options
  • set_withdraw_vesting_route
  • claim_account
  • create_claimed_account
  • request_account_recovery
  • recover_account
  • change_recovery_account
  • transfer_to_savings
  • transfer_from_savings
  • cancel_transfer_from_savings
  • decline_voting_rights
  • reset_account
  • set_reset_account
  • claim_reward_balance
  • delegate_vesting_shares
  • create_proposal
  • update_proposal_votes
  • remove_proposal
  • update_proposal
  • collateralized_convert
  • recurrent_transfer

Prerequisite

Be sure to have your environment correctly set up (see Getting Started) and ledgerblue and installed.

Local development

Download ledger-app-builder:

docker pull ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
docker image tag ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest ledger-app-builder

Compile app in the container:

docker run --rm -ti -v "$(realpath .):/app" ledger-app-builder:latest make

You can compile the app in debug mode (should print additional information in speculos) with:

docker run --rm -ti -v "$(realpath .):/app" ledger-app-builder:latest make DEBUG=1

If you want to compile the app for Nano X model, enter the container:

docker run --rm -ti -v "$(realpath .):/app" ledger-app-builder:latest

And then run

BOLOS_SDK=$NANOX_SDK make

Simulate with Speculos

Download speculos

docker pull ghcr.io/ledgerhq/speculos:latest
docker image tag ghcr.io/ledgerhq/speculos speculos

Run the app in speculos simulator

docker run --rm -it -v $(realpath .)/bin:/speculos/apps -p 1234:1234 -p 5000:5000 -p 40000:40000 -p 41000:41000 speculos --display headless --vnc-port 41000 --apdu-port 40000 apps/app.elf

Open http://localhost:5000/ in your browser to see the simulator.

Debug with Speculos

You can also debug this app with GDB thanks to speculos. First, make sure you have gdb-multiarch installed:

sudo apt install gdb-multiarch

Then, install Native debug extension in your vscode.

Run application in debug mode:

docker run --rm -it -v $(realpath .)/bin:/speculos/apps -p 1234:1234 -p 5000:5000 -p 40000:40000 -p 41000:41000 speculos --display headless --vnc-port 41000 --apdu-port 40000 --debug apps/app.elf

Connect your debugger with vscode by starting Attach to gdbserver configuration.

Load the app to your physical Nano S

You need to have ledgerblue installed (should be handled in "Prerequisite" part of this Readme).

Load it with:

python3 -m ledgerblue.loadApp --curve secp256k1 --appFlags 0x240 --path "48'/13'" --tlv --targetId 0x31100004 --targetVersion="2.0.0" --delete --fileName bin/app.hex --appName "Hive" --appVersion "1.0.0" --dataSize $((0x`cat debug/app.map |grep _envram_data | tr -s ' ' | cut -f2 -d' '|cut -f2 -d'x'` - 0x`cat debug/app.map |grep _nvram_data | tr -s ' ' | cut -f2 -d' '|cut -f2 -d'x'`)) `ICONHEX=\`python3 ./dev-env/SDK/nanos-secure-sdk/icon3.py --hexbitmaponly icons/nanos_app_hive.gif  2>/dev/null\` ; [ ! -z "$ICONHEX" ] && echo "--icon $ICONHEX"`

Tests

Big part of source code is covered by unit tests, written in cmocka framework.

Unit testing

docker run --rm -ti -v "$(realpath .):/app" ledger-app-builder:latest sh -c "cd unit-tests && cmake -Bbuild -H. && make -C build && CTEST_OUTPUT_ON_FAILURE=1 make -C build test"

Documentation

High level documentation such as APDU, commands are included in developer documentation which can be generated with doxygen

doxygen .doxygen/Doxyfile

the process outputs HTML and LaTeX documentations in doc/html and doc/latex folders.

Tests & Continuous Integration

The flow processed in Gitlab CI/CD is the following:

It outputs 4 artifacts:

  • hive-app within output files of the compilation process
  • speculos-log within APDU command/response when executing end-to-end tests
  • code-coverage within HTML details of code coverage
  • documentation within HTML auto-generated documentation

About

Hive wallet application for Nano S and X

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 89.7%
  • TypeScript 5.9%
  • CMake 2.9%
  • Makefile 1.3%
  • Shell 0.2%