crypto-com / thaler

Thaler Experimental Network; For Crypto.org Chain: github.com/crypto-org-chain/chain-main
https://thaler-testnet.crypto.com
Other
158 stars 80 forks source link

Problem: no C bindings for client libraries #819

Closed tomtau closed 4 years ago

tomtau commented 4 years ago

This will be very important for wallet integrations in different programming languages.

Create another client crate, e.g. called “client-c-binding”, that will expose client functionality in a C-friendly way.

Here’s an example how this can be done in Rust (in Cardano/Ada): https://github.com/input-output-hk/rust-cardano/blob/master/cardano-c/src/bip39.rs#L34

the C code: https://github.com/input-output-hk/rust-cardano/blob/master/cardano-c/examples/signed_transaction.c#L32

yihuang commented 4 years ago

I find it hard to find the boundary of abstraction for this c-api. The Cardano's c-APIs are only stateless stuff, address derivation, transaction building, stuff like that. That is simple and useful for some users. But if the user wants to build a full-featured wallet node based on that, or build an interactive shell as mentioned in another issue, there are still significant works to do (block syncing, wallet state storage, etc.). Another approach would be export APIs like client-rpc itself, full-featured stuff, including storage, RPC client inside. In this way, the APIs might not embeddable, and it would probably be easier for user to simply run a client-rpc process at the background and calls the json-rpc apis. I guess going with the first option would make more sense?

tomtau commented 4 years ago

I find it hard to find the boundary of abstraction for this c-api.

The initial bindings (focus of this issue) will first begin with stateless stuff -- the goal would be to support building something like https://github.com/crypto-com/cro-nodelib/ (or elsewhere bitcoin.js, BitcoinJ).

Later (as cro-nodelib) -- either this issue or other, it can add "stateful" stuff -- light client would be good... AFAIK (and what @calvinaco mentioned), it'll be desirable to decouple that from storage implementation, so syncing may take some function pointer / callback that the user provides.

So, the C binding needs to be agnostic in this way. For example, for key storage, one will want to use a KeyStore on Android, Keychain on iOS and some KMS (like Hashicorp Vault) in some cloud infra...

The bindings can also be exposed with some "default" implementations, so it could be used say for the interactive shell.

leejw51crypto commented 4 years ago

started

leejw51crypto commented 4 years ago

hdwallet and basic api is done