GithubHelp home page GithubHelp logo

consenlabs / token-core Goto Github PK

View Code? Open in Web Editor NEW
287.0 36.0 115.0 97.52 MB

Next generation core inside imToken Wallet.

License: Apache License 2.0

Shell 1.77% Rust 97.38% Makefile 0.29% JavaScript 0.56%
blockchain imtoken cross-platform cryptocurrency bitcoin-cash litecoin

token-core's Introduction

TokenCoreX

Build status Gitter chat

Next generation core inside imToken Wallet.

A cross-platform library that implements crypto wallet functions for blockchains, exporting c interfaces in Protobuf protocol. This library totally wrote in Rust, and now provides friendly interfaces for the mobile platform including ReactNative, iOS, and Android.

TokenCoreX welcomes contribution from everyone. See CONTRIBUTING.md for help getting started. In all communications and contributions, this project follows the Code of Conduct

Goals

  • Abstration interfaces that provide crypto wallet common logic with multi blockchain support
  • Cross platform, on mobile, desktop, server side
  • Multi keystore support, with file, HSM, KMS, hardware-wallet

Packages

  • tcx wallet interface wrapper
  • tcx-bch | tcx-btc-fork | tcx-tron | tcx-ckb packages contain particular chain operations
  • tcx-chain keystore and signer interface
  • tcx-proto protobuf datastructure definition
  • tcx-constants blockchain spec definition
  • [tcx-primitive | tcx-crypto] low level component

Examples

We provide three example applications,

Test Coverage

We can use tarpaulin to know the coverage rate.

The easy way to run coverage test is using docker,

docker run --security-opt seccomp=unconfined -v "${PWD}:/volume" xd009642/tarpaulin sh -c "cargo tarpaulin --out Html"

After couple minutes, it will generate html report of project root directory named tarpaulin-report.html.

Code Styles

This project is using pre-commit. Please run cargo clean && cargo test to install the git pre-commit hooks on you clone.

Every time you will try to commit, pre-commit will run checks on your files to make sure they follow our style standards and they aren't affected by some simple issues. If the checks fail, pre-commit won't let you commit.

Read More

License

Apache Licence v2.0

token-core's People

Contributors

dependabot[bot] avatar kaichen avatar linrz avatar tyrone98 avatar urugang avatar xiaoguang1010 avatar xuneal avatar xwartz avatar zys20080808 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

token-core's Issues

执行./tools/ios-framework-build.sh时编译报错

执行./tools/ios-framework-build.sh时编译,依然出现i386和armv7的报错。如下信息:

error: The linked library 'libtcx.a' is missing one or more architectures required by this target: i386. (in target 'TokenCoreX' from project 'TokenCoreX')

** BUILD FAILED **

Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -target TokenCoreX ONLY_ACTIVE_ARCH=NO -configuration Release -sdk iphoneos BUILD_DIR=./Products BUILD_ROOT=./Products build

Build settings from command line:
BUILD_DIR = ./Products
BUILD_ROOT = ./Products
ONLY_ACTIVE_ARCH = NO
SDKROOT = iphoneos14.2

note: Using new build system
note: Planning build
note: Constructing build description
error: No signing certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID "8Z7NF6BL8X" with a private key was found. (in target 'TokenCoreX' from project 'TokenCoreX')
error: The linked library 'libtcx.a' is missing one or more architectures required by this target: armv7. (in target 'TokenCoreX' from project 'TokenCoreX')

** BUILD FAILED **

期待可以正常编译

framework缺少头文件

framework编译完成后,UserData.swift文件编辑报错,Cannot find 'init_token_core_x' in scopeCannot find 'Buffer' in scopeCannot find 'free_buf' in scope, Cannot find 'get_last_err' in scope

Android例子中调用的call_tcx_api传入的hex编码,我转换成string为什么会有乱码?

在Android例子中调用的call_tcx_api,传入的hex编码:
0a0f68645f73746f72655f63726561746512230a07696d746f6b656e12180a11496e7365637572652050613535773072641a03616161
转换成string是:

�hd_store_create�#
�imtoken��
�Insecure Pa55w0rd��aaa

程序没有问题,但是这个格式为什么是这样的?而且我自己写的转为hex编码格式函数程序会闪退,我要用什么方法才能转为例子的格式?希望得到一个回复。

编译环境:ubuntu18

IOS release 到自己的cocoapods

将token-core编译后,怎么发布到自己的cocoapods上。
我看到tool下有个ios-pod-release.sh 但是里面内容是空的。

Add XinFin-XDC Network support

Hello Team,

It will be great if Would you consider to Add ETH compatible DPOS chain XinFin(XDC) Network support.

XinFin Digital Contract or XDC — the XinFin network’s native crypto — is a one-stop solution that combines speed, scalability, and sustainability into an immaculate package. XDC is built on XinFin’s exclusive consensus mechanism — the XinFin Delegated Proof-of-Stake or XDPoS protocol that was specially developed to overcome the shortcomings of the technology that came before it.

XinFin Network: https://xdc.network/home
XDC Wallet (Android App): https://play.google.com/store/apps/details?id=com.xdcwallet&hl=en&gl=US
Github: https://github.com/XinFinOrg/XDPoSChain
Integration Code example: https://xinfin.org/exchange-listing-resource

Technical Community Support available at:

Telegram Community: https://t.me/XinFinDevelopers
Slack Community: https://xinfin-public.slack.com/messages/CELR2M831/
Slack Invitation Link: https://launchpass.com/xinfin-public
Technical help Resource: http://howto.xinfin.org/

It is a pleasure to talk about commercials and ready to support with large XinFin community to increase the adoption rate of your team.

Hope you will revert soon.

mac m1 run ios-framework-build.sh error

使用mac m1 执行 cargo install cargo-lipo 失败,查看文档使用下面的命令重新安装了rustup.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
重装的版本是 1.68.2.
然后执行到 Run tools/ios-framework-build.sh 的时候,提示:

[ERROR cargo_lipo] cargo_metadata failed: error during execution of cargo metadata: error: failed to load manifest for workspace member xxx/token-core/tcx-substrate

Caused by:
failed to parse manifest at xxx/token-core/tcx-substrate/Cargo.toml

Caused by:
key branch is ignored for dependency (codec).

请问怎么解决呢?

sh ios-example-build.sh 编译报错 rust库编译失败

Compiling tcx-substrate v0.1.0 (/Users/hehuiqi/Desktop/token-core/tcx-substrate)
Compiling tcx-ckb v0.1.0 (/Users/hehuiqi/Desktop/token-core/tcx-ckb)
error[E0603]: module export is private
--> tcx-substrate/src/keystore.rs:11:12
|
11 | use serde::export::{fmt, PhantomData};
| ^^^^^^ private module
|
note: the module export is defined here
--> /Users/hehuiqi/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.119/src/lib.rs:275:5
|
275 | use self::__private as export;
| ^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

how to use this signature interface

the interface is "pub(crate) fn sign_tezos_tx_raw(param: &SignParam, keystore: &mut Keystore) -> Result<Vec>".
I do not know the usage of "TezosRawTxIn" structure.
in fact there is no declaration of this structure is its field "raw_data"
how to convert my data to the string.
the interface is in "token-core-dev/tcx/src/handler.rs"
the define of the structure is in "token-core-dev/tcx-tezos/src/transaction.rs"

find_wallet_by_mnemonic看上去是个只读函数,实际做了derive_account的修改动作

fn _find_wallet_by_mnemonic(v: &Value) -> Result<String> {
    let mnemonic = v["mnemonic"].as_str().unwrap();
    let _path = v["path"].as_str().unwrap();
    let _network = v["network"].as_str().unwrap();
    let chain_type = v["chainType"].as_str().unwrap();
    let _password = "InsecurePassword";
    let _meta: Metadata = serde_json::from_value(v.clone())?;
    let acc = match chain_type {
        "BCH" => {
            let coin_info = _coin_info_from_symbol("BCH")?;
            HdKeystore::mnemonic_to_account::<BchAddress, ExtendedPubKeyExtra>(&coin_info, mnemonic)
        }
        _ => Err(format_err!("{}", "chain_type_not_support")),
    }?;
    pub fn mnemonic_to_account<A: Address, E: Extra>(
        coin_info: &CoinInfo,
        mnemonic: &str,
    ) -> Result<Account> {
        let mnemonic = Mnemonic::from_phrase(mnemonic, Language::English)
            .map_err(|_| format_err!("invalid_mnemonic"))?;
        let seed = bip39::Seed::new(&mnemonic, &"");
        Self::derive_account_from_coin::<A, E>(coin_info, &seed)
    }

suggestion for replacing `&Vec<&T>` with `&[T]`

It's more common to pass slice as arg rather than vector when you just want to provide read only access, for example, CkbTxSigner#sign_witnesses, can we change witnesses / input_cells to slice?

编译完成,但是遇到了 java.lang.UnsatisfiedLinkError

在Android的示例中,MainActivity中,
调用TokenCore.INSTANCE.init_token_core_x(jsonObject.toString());
报以下错误:
java.lang.UnsatisfiedLinkError: Error looking up function 'init_token_core_x': undefined symbol: init_token_core_x

注释此行代码,app能正常运行,点击按钮无报错,说明TokenCore.INSTANCE.call_tcx_api和TokenCore.INSTANCE.get_last_err_message都能找到对应方法。就唯独TokenCore.INSTANCE.init_token_core_x会报错。

编译环境:Mac OS 11.1
NDK: 21.0.6113669

hdStoreDerive 返回错误error

walletAPI.hdStoreCreate创建成功之后拿到参数 调用 walletAPI.hdStoreDerive后 返回 error:1211756e737570706f727465645f636861696e

Implicit declaration of function 'clear_err' is invalid in C99

The following error appears when running RN Example IOS

/Users/sky/Desktop/token-core/examples/RN/ios/RN/TcxApi.m:18:3: error: implicit declaration of function 'clear_err' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
clear_err();
^
/Users/sky/Desktop/token-core/examples/RN/ios/RN/TcxApi.m:18:3: note: did you mean 'clearerr'?
In module 'Darwin' imported from /Users/sky/Desktop/token-core/examples/RN/ios/RN/TcxApi.m:8:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/usr/include/stdio.h:142:7: note: 'clearerr' declared here
void clearerr(FILE *);
^
/Users/sky/Desktop/token-core/examples/RN/ios/RN/TcxApi.m:20:24: error: implicit declaration of function 'call_tcx_api' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
const char *result = call_tcx_api([hex UTF8String]);
^
/Users/sky/Desktop/token-core/examples/RN/ios/RN/TcxApi.m:20:15: warning: incompatible integer to pointer conversion initializing 'const char *' with an expression of type 'int' [-Wint-conversion]
const char *result = call_tcx_api([hex UTF8String]);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/sky/Desktop/token-core/examples/RN/ios/RN/TcxApi.m:21:23: error: implicit declaration of function 'get_last_err_message' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
const char *error = get_last_err_message();
^
/Users/sky/Desktop/token-core/examples/RN/ios/RN/TcxApi.m:21:15: warning: incompatible integer to pointer conversion initializing 'const char *' with an expression of type 'int' [-Wint-conversion]
const char *error = get_last_err_message();
^ ~~~~~~~~~~~~~~~~~~~~~~
/Users/sky/Desktop/token-core/examples/RN/ios/RN/TcxApi.m:26:3: error: implicit declaration of function 'free_const_string' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
free_const_string(error);

I forgot my password

I forgot my password and didn't save the mnemonic and private key. Can I extract the encrypted information from my phone and crack it. thank you

make build-android-rn-example failed

I tried this :
"make build-android-rn-example", it failed.

error[E0463]: can't find crate for `core`

note: the aarch64-linux-android target may not be installed
error: Could not compile byte-tools.
error: Could not compile scopeguard.
error[E0463]: can't find crate for std
note: the armv7-linux-androideabi target may not be installed
Could not compile rand_core.

rustc --version --verbose:
rustc 1.38.0 (625451e37 2019-09-23)
binary: rustc
commit-hash: 625451e376bb2e5283fc4741caa0a3e8a2ca4d54
commit-date: 2019-09-23
host: x86_64-unknown-linux-gnu
release: 1.38.0
LLVM version: 9.0

In the android-rn-example-build.sh, i check the bash script. It is written for MacOS only. The script cannot work on Linux.

export ANDROID_NDK_TOOLCHAINS=$HOME/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin

iOS Framework Build Error

fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: archive member /Users/andrew/token-core/target/x86_64-apple-ios/release/libtcx.a(aesni-x86_64-macosx.o) cputype (16777228) and cpusubtype (0) does not match previous archive members cputype (16777223) and cpusubtype (3) (all members must match)
[ERROR cargo_lipo] Executing "lipo" "-create" "-output" "/Users/andrew/token-core/target/universal/release/libtcx.a" "/Users/andrew/token-core/target/aarch64-apple-ios/release/libtcx.a" "/Users/andrew/token-core/target/x86_64-apple-ios/release/libtcx.a" finished with error status: exit status: 1

stable-aarch64-apple-darwin
Apple M1 Pro
Xcode Version 13.2.1 (13C100)

Who can help me?

安装基础组件报错

我在执行这条命令后:
token-core git:(dev) rustup target add aarch64-apple-ios armv7-apple-ios armv7s-apple-ios i386-apple-ios x86_64-apple-ios
出现以下信息,无法正常安装组件
info: component 'rust-std' for target 'aarch64-apple-ios' is up to date
error: component 'rust-std' for target 'armv7-apple-ios' is unavailable for download for channel 1.44.0

iOS example build 不成功

"How to build"里面没有更新

Run tools/ios-token-v2-build.sh. Set the right DIR in tools/ios-token-v2-build.sh. After running this shell, the lib files will be compiled and copied to the directory you set before.

已经没有这个脚本了

现在是: ios-framework-build.sh ios-example-build.sh 这两个,请问应该怎么编译?

error[E0463]: can't find crate for `core`
  |
  = note: the `aarch64-apple-ios` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error[E0463]: can't find crate for `core`
  |
  = note: the `aarch64-apple-ios` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error[E0463]: can't find crate for `std`
  |
  = note: the `aarch64-apple-ios` target may not be installed

error: aborting due to previous error

产品崩溃时会暴露用户端输入信息

只允许debug模式下导出调试信息,因为backtrace的参数信息会携带密码信息。

pub unsafe extern "C" fn scan_wallets(json_str: *const c_char) {
    let json_c_str = unsafe { CStr::from_ptr(json_str) };
    let json_str = json_c_str.to_str().unwrap();
    let v: Value = serde_json::from_str(json_str).unwrap();
    set_panic_hook();
    _scan_wallets(v);
    ()
}

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.