Sample C++ Application for Wallet-Core
This repository contains a simple but complete C++ sample application, for demostrating usage of the Wallet Core library (part of Trust Wallet).
This is a sample application with demonstration purpose only, do not use it with real addresses, real transactions, or real funds. Use it at your own risk.
See the official Trust Wallet developer documentation here.
See especially Wallet Core Integration Guide, and Build Instructions.
You need to download and build WalletCore yourself (there is no official binary distribution). The dependencies TrezorCrypto and protobuf are also needed, these are also come with WalletCore. You need to build the library.
Go to the samples/cpp folder within wallet core repo:
git clone https://github.com/trustwallet/wallet-core.git
cd wallet-core/samples/cppConfigure and build -- path to the top-level Wallet Core library folder is needed:
cmake . -DWALLET_CORE=../../
makeRun it:
./sampleThe relavant sample code is in the file cpp/sample.cpp.
An overview of the operations done in the sample app is as follows.
- Import a wallet
- Create a wallet by importing an existing recovery phrase (mnemonic), using HDWallet.
- Derive address
- Address is derived from the HD wallet.
- Create send transaction
- put together a send transaction (contains sender and receiver address, amount, etc.)
- sign this transaction (using the private key)
See the Integration Guide.