Trust Developer
Search…
WalletConsole utility
The Wallet Core library comes with an interactive command-line utility, for accessing key- and address management functionality of the library.

Quick Start

1
$ ./build/walletconsole/walletconsole
2
Wallet-Core Console (c) TrustWallet
3
Type 'help' for list of commands.
4
> help
5
Commands:
6
. . .
7
newKey Create new pseudo-random 32-byte key (secret!)
8
. . .
9
> coin btc
10
Set active coin to: bitcoin
11
> addrDefault
12
Result: bc1q2kecrqfvzj7l6phet956whxkvathsvsgn7twav
Copied!

Starting

The utility builds together with the library and can be started from: build/walletconsole/walletconsole . See build instructions.
Walletconsole can be also executed 'off the shelf' using the Docker image:
1
docker run -i -t trustwallet/wallet-core /wallet-core/build/walletconsole/walletconsole
Copied!

Commands

Here is a snapshot of the commands:
1
Commands:
2
exit Exit
3
quit Exit
4
help This help
5
Inputs, buffer:
6
# Take last result
7
#<n> Take nth previous result
8
buffer Take buffer values
9
Coins:
10
coins List known coins
11
coin <coin> Set active coin, selected by its ID or symbol or name
12
Keys:
13
newKey Create new pseudo-random 32-byte key (secret!)
14
pubPri <priKey> Derive public key from a secret private key (type is coin-dependent)
15
priPub <pubKey> Derive private key from public key :)
16
setMnemonic <word1> ... Set current mnemonic, several words (secret!)
17
newMnemonic <strength> Create and store a new mnemonic, of strength (128 -- 256) (secret!)
18
dumpSeed Dump the seed of the current mnemonic (secret!)
19
dumpMnemonic Dump the current mnemonic (secret!)
20
dumpDP Dump the default derivation path of the current coin (ex.: m/84'/0'/0'/0/0)
21
priDP [<derivPath>] Derive a new private key for the coin, from the current mnemonic and given derivation path.
22
If derivation path is missing, the default one is used (see dumpDP).
23
Addresses:
24
addrPub <pubKey> Create <coin> address from public key
25
addrPri <priKey> Create <coin> address from private key
26
addr <addr> Check string <coin> address
27
addrDefault Derive default address, for current coin, fom current mnemonic; see dumpDP
28
addrDP <derivPath> Derive a new address with the given derivation path (using current coin and mnemonic)
29
Coin-specific methods:
30
tonInitMsg <priKey> Build TON account initialization message.
31
Transformations:
32
hex <inp> Encode given string to hex
33
base64Encode <inp> Encode given hex data to Base64
34
base64Decode <inp> Decode given Base64 string to hex data
35
File methods:
36
fileW <fileName> <data> Write data to a (new) binary file.
37
fileR <fileName> Read data from a binary file.
Copied!

Examples

Here are various sample usages.
Create a new private key, derive a BTC address from it, write it to a file:
1
> coin bitcoin
2
Set active coin to: bitcoin Use 'coin' to change. (name: 'bitcoin' symbol: btc numericalid: 0)
3
> newKey
4
Result: 4e8c1773ce1ca447594fa23a445d9952236c7a15e96802b880aab4d918bdcfd9
5
> addrPri #
6
Result: bc1qvjf93nc80f3fu7j2ehqv6xw6zqa5cny32hl90y
7
> fileW btcaddr.txt #
8
Written to file 'btcaddr.txt', 21 bytes.
Copied!
Create a new private key, derive the public key from it, derive a BTC address from it:
1
> newKey
2
Result: ef8f76035c4d4dd29ed4bbe3fc7c0db45d81cd616f2ac8b038cb982bec2a63ad
3
> pubPri #
4
Result: 0381277ec943a6cd4033171da547bbe93585a8905fb3dad108e8e51e88a4e136ea
5
> addrPub #
6
Result: bc1qvf6gzfhcelpugw84ks677x5zuke46jm946dtpx
Copied!
Check an ALGO address for validity:
1
> coin algo
2
Set active coin to: algorand Use 'coin' to change. (name: 'algorand' symbol: algo numericalid: 283)
3
> addr LCSUSBOLNVT6BND6DWWGM4DLVUYJN3PGBT4T7LTCMDMKS7TR7FZAOHOVPE
4
Address is a valid algorand address: LCSUSBOLNVT6BND6DWWGM4DLVUYJN3PGBT4T7LTCMDMKS7TR7FZAOHOVPE
Copied!
Derive private keys using different BIP39 derivation paths, and create address from it:
1
> coin btc
2
Set active coin to: bitcoin Use 'coin' to change. (name: 'bitcoin' symbol: btc numericalid: 0)
3
> dumpDP
4
Result: m/84'/0'/0'/0/0
5
> priDP
6
Using derivation path "m/84'/0'/0'/0/0" for coin bitcoin
7
Result: df6a78d65fe3c82f020c25be12debd46e58f5f4366381102485ce26c52416a96
8
> priDP m/84'/0'/0'/0/1
9
Using derivation path "m/84'/0'/0'/0/1" for coin bitcoin
10
Result: 19c44359b4953bb3084dd73ba2854f6822de3b6f8f358055a16a1b19e533e37c
11
> pubPri #
12
Result: 02222d3889870d36e0c9e788c69a6509eddfb2105309e7733cfa669bb52ba996d1
13
> addrPub #
14
Result: bc1q7ghe6xyx38vdkzs9ryv3gz47mgvpa747z2mcvy
15
> addr #
16
Address is a valid bitcoin address: bc1q7ghe6xyx38vdkzs9ryv3gz47mgvpa747z2mcvy
Copied!
Derive several NANO addresses (BIP39):
1
> coin nano
2
Set active coin to: nano Use 'coin' to change. (name: 'nano' symbol: nano numericalid: 165)
3
> dumpDP
4
Result: m/44'/165'/0'
5
> setMnemonic edge defense waste choose enrich upon flee junk siren film clown finish luggage leader kid quick brick print evidence swap drill paddle truly occur
6
Mnemonic set (24 words).
7
> addrDefault
8
Result: nano_3yyipbgtnd7183k61nkh5mxnt9wpsfhto95mksdqj6s7p45mwj9osai7asad
9
> addrDP m/44'/165'/0'
10
Result: nano_3yyipbgtnd7183k61nkh5mxnt9wpsfhto95mksdqj6s7p45mwj9osai7asad
11
> addrDP m/44'/165'/1'
12
Result: nano_3zni7o8m4dq1aphffnaq5pwseh7rrzhkrz5mpr8bcm68n6u775pbk7csedam
Copied!
Hex and Base64 encoding example:
1
> hex Hello
2
Result: 48656c6c6f
3
> base64Encode #
4
Result: SGVsbG8=
5
> base64Decode #
6
Result: 48656c6c6f
7
> buffer
8
Last value: 48656c6c6f
9
3 previous values:
10
#1 48656c6c6f
11
#2 SGVsbG8=
12
#3 48656c6c6f
Copied!
Last modified 1yr ago