Giter Club home page Giter Club logo

cfd-js's Introduction

Crypto Finance Development Kit for JavaScript (CFD-JS)

JavaScript wrapper of cfd libraries

Overview

This library is development kit for crypto finance application. Useful when developing applications for cryptocurrencies.

Target Network

  • Bitcoin
  • Liquid Network

Support function by cfd

  • Bitcoin
    • Bitcoin Script (builder, viewer)
    • Transaction
      • Create, Parse, Decode
      • Simple pubkey-hash sign / verify
      • Estimate Fee
      • Coin Selection (FundRawTransaction)
    • PSBT (v0. v2 & taproot is not yet.)
      • Create, Parse, Decode
      • Simple pubkey-hash sign / verify
      • Estimate Fee
      • Coin Selection (FundRawTransaction)
    • 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
      • Reissuance
    • Confidential Address

Libraries for each language

  • JavaScript : cfd-js
    • C/C++ : cfd
      • Extend the cfd-core library. Defines the C language API and extension classes.
    • C++ : cfd-core
      • Core library. Definition base class.
  • other language:
    • WebAssembly : cfd-js-wasm
    • Python : cfd-python
    • C# : cfd-csharp
    • Go : cfd-go
    • Rust : cfd-rust

Dependencies

  • C/C++ Compiler ย  - can compile c++11
  • CMake (3.14.3 or higher)
  • node.js (stable version)
  • Python 3.x
    • for building libwally-core js wrapper

Windows

download and install files.

MacOS

# xcode cli tools
xcode-select --install

# install dependencies using Homebrew
brew install cmake python node

Linux(Ubuntu)

# 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/)


Use case

add dependencies on package.json (nodejs or Electron)

Add cfd-js github on caller app's package.json.

ex)

  "cfd-js": "cryptogarageinc/cfd-js#semver:^0.1.3",

If you use old npm or yarn, describe as follows.

ex)

  "cfd-js": "git+https://github.com/cryptogarageinc/cfd-js#semver:^0.1.3",

When npm is installed, the cfd-js build is executed.

N-API

cfd-js uses the N-API. Therefore, the same binary can be used for both node.js and electron.


Test and Example

Build

Using cmake-js

When using the cmake-js package and npm script, the options for compilation are already set.

npm install
npm run cmake_release_parallel

Test

npm run test

Example

Bitcoin

npm run example

Elements

npm run elements_example

Information for developers

using library

formatter

  • clang-format (using v10.0.0)
  • eslint

linter

  • cpplint
  • eslint

document tool

  • Not Implemented yet

support compilers

  • Visual Studio (2017 or higher)
  • Clang (7.x or higher)
  • GCC (contains MinGW) (5.x or higher)

Note

Git connection

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

For installed fail

If the shared library you downloaded cannot be referenced and the build fails, do a full build without downloading the shared library. Prevents the download of the shared library by setting CFDJS_UNUSE_ASSET=1 in the environment variable.

  • Windows: (On the command line. Or set from the system setting screen.)

    set CFDJS_UNUSE_ASSET=1
  • MacOS & Linux(Ubuntu):

    export CFDJS_UNUSE_ASSET=1

Ignore git update for CMake External Project

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

Build error on windows

Errors may occur during processing of CMake External project on Windows. This is a problem with the Windows environment, but you can work around it by using npm v7. If npm is less than v7, please try to cleanup&build after running the following command:

npm i -g npm@7

Error loading shared library libcfdjs.so

This error may occur on the Alpine Linux. The cause is that the related library can not referenced. Please add the installation location to LD_LIBRARY_PATH.

export LD_LIBRARY_PATH="./node_modules/cfd-js/build/Release:$LD_LIBRARY_PATH"

For source build

The cfd-js is using prebuild-install & own downloading asset. If you want to build directly from source code, you can do so by setting environment variables as follows:

  • Windows: (On the command line. Or set from the system setting screen.)

    set npm_config_build_from_source=true
    set CFDJS_UNUSE_ASSET=1
  • MacOS & Linux(Ubuntu):

    export npm_config_build_from_source=true
    export CFDJS_UNUSE_ASSET=1

see: https://www.npmjs.com/package/prebuild-install

cfd-js's People

Contributors

k-matsuzawa avatar ko-matsu avatar fujita-cg avatar tibo-lg avatar dependabot[bot] avatar dillionverma avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.