Skip to content
This repository was archived by the owner on Mar 1, 2019. It is now read-only.

Testing Yoroi and Cardano wallet

Matthias Benkort edited this page Jan 16, 2019 · 2 revisions

(These notes used as starting point a document by Alfredo di Napoli)

Testing environments

Local cluster

Runs 3 core nodes and 1 wallet and generates a fresh blockchain all the time.

It's handy as it comes with a wallet called the "Genesis wallet" which can be used to test the various features without worrying about money.

Staging cluster

On the other hand, the staging cluster has the advantage of targeting a "semi-realistic" blockchain (especially in size) but stake cannot be created out of thin air.

In order to test transactions on this blockchain, IOHK developers share a bunch of staging wallets for testing on this chain. For that, see the test wallet worksheet to claim and use wallets:

https://docs.google.com/spreadsheets/d/1CN69eb48Ww9jciBE4ZKE0y7JyLQi7lP4nxY5-FHz6k0/edit#gid=0

(if you create new wallets and transfer funds to them, add the wallet details to this sheet so that other devs can test with those funds in future since ADA on staging is a limited resource)

This guide will focus on testing using the staging cluster.

Using cardano-cli

The Yoroi wallet is packaged as a Chrome Browser plugin. This does not give us an easy handle to test cardano wallets against Yoroi wallets. Instead of using Yoroi directly, we can rely on the underlying command-line for Cardano - cardano-cli.

To use this command line, you'll need to install Rust lang. Then install cardano-cli:

git clone https://github.com/input-output-hk/cardano-cli.git --recursive

cd cardano-cli
cargo install

(There are cardano-cli tutorials here: https://cardanorust.iohkdev.io/cli-wallet/)

Setup up a local blockchain

Use one of staging/mainnet/testnet:

cardano-cli blockchain new staging --template=staging

cardano-cli blockchain pull staging

There is also a fast fetch, but this is still experimental code, try with caution:

cardano-cli blockchain remote-fetch staging hermes # to kill when 1s remain

You can check the status of the blockchain with

cardano-cli blockchain status staging

Recover a Daedelus wallet

Note the 12 word mnemonic and random_index_2levels for Daedelus wallets. We need to name the new wallet (TestWallet in this case).

cardano-cli wallet recover --daedalus-seed --derivation-scheme=v1 --mnemonics-length=12 --wallet-scheme=random_index_2levels TestWallet

You will need to enter the wallet's 12-word mnemonic along with a spending password.

Next we attach the wallet to our staging blockchain and then catch the wallet up with the chain using sync:

cardano-cli wallet attach TestWallet staging

cardano-cli wallet sync TestWallet

You can check the status (including balance) of the wallet with

cardano-cli wallet status TestWallet

We can now also see a statement of all transactions for this wallet:

cardano-cli wallet statement TestWallet

and to see the wallet utxo:

cardano-cli wallet utxos TestWallet

Generate BIP-44 Addresses

  • Follow the steps above to install and setup the cardano-cli
  • Run $ cardano-cli wallet create myWallet
  • Run $ cardano-cli wallet attach myWallet mainnet (provided there's a blockchain created named mainnet)
  • Run $ cardano-cli wallet address 0 0 to generate an address with account index 0' and address index 0
  • Note that, addresses are by default, generated on the external chain and addresses can be generated on the internal chain by passing --internal to the command above.

Running a cardano node (TODO use nix)

Compiling the node

stack build cardano-node --ghc-options=-optl-Wl,-dead_strip_dylibs

If you are not an a Mac, you can ignore the --ghc-options being passed here.

Generating TLS certs

Before running the node we need to generate some TLS certs. This is important so that Daedalus and the node agrees on the https certs and can communicate securely. Daedalus doesn't support querying the node from plain "http", so this is required, moreover if you want to enable "client side authentication", but we are not going to enable client-side auth, so that you can also query the node easily via the web browser. We can do this with the cardano-x509-certificates tool:

stack build cardano-sl-tools --ghc-options=-optl-Wl,-dead_strip_dylibs         

stack exec cardano-x509-certificates -- --server-out-dir ../tls-certs --clients-out-dir ../tls-certs -k default -c lib/configuration.yaml

Running the node against staging

The --no-client-auth option is very important to disable client-side TLS verification.

 stack exec cardano-node -- --topology=docs/network/example-topologies/mainnet-staging.yaml \
    --configuration-key mainnet_dryrun_full \
    --db-path ../staging-db \
    --tlscert ../tls-certs/server.crt \
    --tlskey ../tls-certs/server.key \
    --tlsca ../tls-certs/ca.crt \
    --no-client-auth

Note: Here I'm using an explicit --db-path at a directory of choice so that I will go through the pain of syncing with the blockchain only once. It's important you use the same RocksDB name across multiple runs, unless you want to test other things like syncing or wallet restoration on a partially-synced node.

Note that you cannot operate Daedalus if you are more than 6 blocks behind the BlockChain.

If all is well, now you should be able to query successfully from the browser these two endpoints:

  • GET https://localhost:8090/api/v1/node-info
  • GET https://localhost:8090/docs/v1/index/

Running Daedalus (TODO use nix)

Now that you have a node running talking to staging it's time for Daedalus.

A note on the platform

These instructions works out of the box on a Mac, but for Linux things are more complicated. Talk to devops on how to run Daedalus on Linux.

In order to run Daedalus, you have to:

  • Clone the Daedalus repo

  • (Optional) Install the Node Version Manager. This is a simple bash script which allows you to install and manage multiple versions of node, both globally and (important), locally. I usually use Node 8.2.1 in the Daedalus repo. You can have a .nvmrc in the Daedalus repo with content:

    8.2.1
    

    And then simply typing nvm use will drop you in a shell with the right version.

  • Run npm install inside the Daedalus repo.If this steps fails due to python2 not being present, you can solve it with a tool like pyenv, which is basically like nvm. Google for it!

  • Finally run:

    CARDANO_TLS_PATH=/Users/.../tls-certs yarn run dev
    

    Note that obviously the filepath to the tls-certs is what I (Alfredo) use, but you will have to specify the tls-certs folder you created using the cardano-x509-certificates tool.

If all is well, Daedalus should appear and you should see the white screen of syncing. If it stays on the blue one, something is not working as it should. Check out the cardano-node logs or the "Developer Tools" in the Electron app.

Clone this wiki locally