Sample Go Integration for Wallet-Core
This folder contains a small Go sample integration with Wallet Core library (part of Trust Wallet), using cgo.
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.
macOS or Docker
- CMake
brew install cmake - Boost
brew install boost - Xcode
- Xcode command line tools:
xcode-select --install - Other tools:
brew install git ninja autoconf automake libtool xcodegen clang-format - GoLang: download
- Protobuf:
brew install protobuf protoc-gen-go
- Clone the wallet-core repo and go inside:
git clone https://github.com/trustwallet/wallet-core.git
cd wallet-core- The full build can be triggered with one top-level script:
./bootstrap.sh-
Run
docker run -it trustwallet/wallet-coreThe library is already built in this image (Build instructions here) Note: may not be the most recent version. -
Install go:
apt-get update && apt-get install golang(or download from here go1.16.12, configureGOROOTand appendGOROOT/bintoPATH).
- Go to the samples/go folder within wallet core repo:
cd wallet-core/samples/go-
Compile it by
go build -o main. Relevant source file ismain.go. -
Run
./mainand you will see the output below:
==> calling wallet core from go
==> mnemonic is valid: true
==> Bitcoin...-
(optional) You might want to copy and run
mainoutside of the docker container, make sure you havelibc++1andlibc++abi1installed in your host Ubuntu. -
(optional) If you want to make transaction on other networks you need to compile
src/protoproto files and to do that, just run the./compile.sh. you can also modify it based on your project.