Skip to content

Files

go

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Dec 13, 2023
Dec 5, 2022
Dec 5, 2022
Dec 13, 2023
Dec 5, 2022
Sep 22, 2023
Dec 22, 2021
Mar 15, 2024
Mar 15, 2024
Sep 22, 2023

Sample Go Integration for Wallet-Core

🔖 Overview

This folder contains a small Go sample integration with Wallet Core library (part of Trust Wallet), using cgo.

⚠️ DISCLAIMER

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.

📜 Documentation

See the official Trust Wallet developer documentation here.

See especially Wallet Core Integration Guide, and Build Instructions.

🛠 Prerequisites

macOS or Docker

⚙️ Building and Running

 macOS

Prerequisites on macOS

  • 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

Full Build

  1. Clone the wallet-core repo and go inside:
git clone https://github.com/trustwallet/wallet-core.git

cd wallet-core
  1. The full build can be triggered with one top-level script:
./bootstrap.sh

🐳 Docker

  1. Run docker run -it trustwallet/wallet-core The library is already built in this image (Build instructions here) Note: may not be the most recent version.

  2. Install go: apt-get update && apt-get install golang (or download from here go1.16.12, configure GOROOT and append GOROOT/bin to PATH).

🏃🏽‍♂️ Run (macOS & Docker)

  1. Go to the samples/go folder within wallet core repo:
cd wallet-core/samples/go
  1. Compile it by go build -o main. Relevant source file is main.go.

  2. Run ./main and you will see the output below:

==> calling wallet core from go
==> mnemonic is valid:  true
==> Bitcoin...
  1. (optional) You might want to copy and run main outside of the docker container, make sure you have libc++1 and libc++abi1 installed in your host Ubuntu.

  2. (optional) If you want to make transaction on other networks you need to compile src/proto proto files and to do that, just run the ./compile.sh . you can also modify it based on your project.