CFD library for C/C++.
This library is development kit for crypto finance application. Useful when developing applications for cryptocurrencies.
- Bitcoin
- Liquid Network
- Estimate Fee
- Coin Selection (FundRawTransaction)
- Simple pubkey-hash sign / verify
- C language API (for reference from other languages)
- from cfd-core function:
- Bitcoin
- Bitcoin Script (builder, viewer)
- Transaction
- PSBT (v0)
- ECDSA Pubkey/Privkey (TweakAdd/Mul, Negate, Sign, Verify)
- BIP32, BIP39
- Output Descriptor (contains miniscript parser)
- Schnorr/Taproot
- Bitcoin Address (Segwit-v0, Segwit-v1, P2PKH/P2SH)
- Liquid Network
- Confidential Transaction
- Blind, Unblind
- Issuance, Reissuance
- PegIn, PegOut
- Confidential Address
- Confidential Transaction
- Bitcoin
- C++ : cfd-core
- Core library. Definition base class.
- C/C++ : cfd
- Extend the cfd-core library. Defines the C language API and extension classes.
- Libraries to link cfd library:
- JavaScript : cfd-js
- WebAssembly : cfd-js-wasm
- Python : cfd-python
- C# : cfd-csharp
- Go : cfd-go
- Rust : cfd-rust
- C/C++ Compiler - can compile c++11 or upper (default is c++11. use STD_CPP_VERSION option)
- CMake (3.14.3 or higher)
- When using npm scripts and cmake-js
- node.js (stable version)
- Python 3.x
- for building libwally-core js wrapper
download and install files:
- CMake (3.14.3 or higher)
- Compiler or development environment (One of the following)
- MSVC
- Visual Studio (Verified version is 2017 or higher)
- Build Tools for Visual Studio (2017 or higher)
- (Using only) msvc redistribution package
- Clang
- LLVM (Requires MSVC or MinGW)
- MinGW w64
- MSYS2
- Use MinGW
- other
- I have not confirmed it, but I think that it can be built if it supports c++11 and cmake.
- MSVC
# xcode cli tools
xcode-select --install
# install dependencies using Homebrew
brew install cmake python node
# install dependencies using APT package Manager
apt-get install -y build-essential cmake python nodejs
cmake version 3.14.2 or lower, download from website and install cmake. (https://cmake.org/download/)
# build image, dependencies and run tests
sudo docker build -t cfd .
# run container and invoke shell
sudo docker run -it cfd bash
(If you want to install, see the installation. Introduces build and install command.)
When using the cmake-js package and npm script, the options for compilation are already set.
npm install
npm run cmake_all
# recommend out of source build
mkdir build && cd $_
# configure & build
cmake .. (CMake options)
make
cmake -S . -B build -G "Visual Studio 16 2019"
cmake -D ENABLE_SHARED=1 -DCMAKE_BUILD_TYPE=Release --build build
cmake --build build
CMake options
-DENABLE_ELEMENTS
: Enable functionalies for elements sidechain. [ON/OFF] (default:ON)-DENABLE_SHARED
: Enable building a shared library. [ON/OFF] (default:OFF)-DENABLE_TESTS
: Enable building a testing codes. If enables this option, builds testing framework submodules(google test) automatically. [ON/OFF] (default:ON)-DTARGET_RPATH=xxxxx;yyyyy
: Set rpath (Linux, MacOS). Separator is ';'.-DCMAKE_BUILD_TYPE=Release
: Enable release build.-DCMAKE_BUILD_TYPE=Debug
: Enable debug build.-DSTD_CPP_VERSION=xx
: Set the C++ version. [11,14,17,20] (default:11)-DCFDCORE_DEBUG=on
: Enable cfd debug mode and loggings log files. [ON/OFF] (default:OFF)- Enable debug mode is need
STD_CPP_VERSION
upper 14.
- Enable debug mode is need
-DCFDCORE_LOG_LEVEL=xxxx
: Set log level. [trace/debug/info/warn] (default:info)-DCFDCORE_LOG_CONSOLE=on
: Enable cfd loggings console output mode. [ON/OFF] (default:OFF)
On Linux or MacOS, can use install / uninstall.
install for /usr/local/lib
.
When using the cmake-js package and npm script, the options for compilation are already set.
npm cmake_make_install
(Enter the password when prompted to use the sudo command.)
cmake version is 3.15 or higher:
npm cmake_install
(Enter the password when prompted to use the sudo command.)
cd build && sudo make install
(Using ninja)
cd build && sudo ninja install
cmake version is 3.15 or higher: cmake --install build
- Ubuntu / MacOS
(cleanup)
./tools/cmake_cleanup.sh
sudo ./tools/cleanup_install_files.sh
(download)
wget https://github.com/p2pderivatives/cfd/releases/download/v0.3.2/cfd-v0.3.2-ubuntu2004-gcc-x86_64.zip
(unzip)
sudo unzip -q cfd-v0.3.2-ubuntu2004-gcc-x86_64.zip -d /
- Windows
- get releases asset. (ex. https://github.com/p2pderivatives/cfd/releases/download/v0.3.2/cfd-v0.3.2-win-vs2019-x86_64.zip )
- Expand to PATH
(uninstall by using makefile)
cd build && sudo make uninstall
(uninstall by using ninja)
cd build && sudo ninja uninstall
(uninstall by using script)
sudo ./tools/cleanup_install_files.sh
npm run ctest
- Not Implemented yet
- cfd-core
- libwally-core (forked from ElementsProject/libwally-core)
- secp256k1-zkp (forked from ElementsProject/secp256k1-zkp)
- univalue (for JSON encoding and decoding)
- libwally-core (forked from ElementsProject/libwally-core)
- clang-format (using v10.0.0)
- cpplint (customize from google/styleguide/cpplint)
- doxygen & graphviz
- Visual Studio (2017 or higher)
- Clang (7.x or higher)
- GCC (contains MinGW) (5.x or higher)
- lcov
- Collecting coverage only on Linux.
- It is generated unnecessary constructors and destructors on MacOS. So it is not suitable for collecting function coverage.
- It may be possible to run it on windows, but I have not tried it.
- Collecting coverage only on Linux.
Git repository connections default to HTTPS.
However, depending on the connection settings of GitHub, you may only be able to connect via SSH.
As a countermeasure, forcibly establish SSH connection by setting CFD_CMAKE_GIT_SSH=1
in the environment variable.
- Windows: (On the command line. Or set from the system setting screen.)
set CFD_CMAKE_GIT_SSH=1
- MacOS & Linux(Ubuntu):
export CFD_CMAKE_GIT_SSH=1
Depending on your git environment, you may get the following error when checking out external:
Performing update step for 'libwally-core-download'
Current branch cmake_build is up to date.
No stash entries found.
No stash entries found.
No stash entries found.
CMake Error at /workspace/cfd-core/build/external/libwally-core/download/libwally-core-download-prefix/tmp/libwally-core-download-gitupdate.cmake:133 (message):
Failed to unstash changes in:
'/workspace/cfd-core/external/libwally-core/'.
You will have to resolve the conflicts manually
This phenomenon is due to the git update
related command.
Please set an environment variable that skips update processing.
- Windows: (On the command line. Or set from the system setting screen.)
set CFD_CMAKE_GIT_SKIP_UPDATE=1
- MacOS & Linux(Ubuntu):
export CFD_CMAKE_GIT_SKIP_UPDATE=1
When debugging build with Visual C++, std::map related may not work properly.