-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
906 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 7 additions & 3 deletions
10
sigma-tree-c/Cargo.toml → bindings/ergo-wallet-c/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
[package] | ||
name = "sigma-tree-c" | ||
name = "ergo-wallet-c" | ||
version = "0.1.0" | ||
authors = ["Denys Zadorozhnyi <denys@zadorozhnyi.com>"] | ||
edition = "2018" | ||
description = "C bindings for sigma-tree" | ||
description = "Ergo wallet C bindings" | ||
build = "build.rs" | ||
|
||
[lib] | ||
crate-type = ["staticlib"] | ||
|
||
[dependencies] | ||
sigma-tree = { path = "../sigma-tree", version = "0.1.0" } | ||
ffi_helpers = "0.2" | ||
sigma-tree = { path = "../../sigma-tree"} | ||
ergo-wallet = { path = "../../ergo-wallet"} | ||
|
||
[build-dependencies] | ||
cbindgen = "0.14" | ||
|
||
[profile.release] | ||
# Tell `rustc` to optimize for small code size. | ||
opt-level = "s" | ||
lto = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
extern crate cbindgen; | ||
|
||
use std::env; | ||
|
||
fn main() { | ||
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); | ||
let config = cbindgen::Config::from_file("cbindgen.toml").expect("No cbindgen.toml found"); | ||
|
||
cbindgen::Builder::new() | ||
.with_crate(crate_dir) | ||
.with_config(config) | ||
.generate() | ||
.expect("Unable to generate bindings") | ||
.write_to_file("h/ergo_wallet.h"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
# This is a template cbindgen.toml file with all of the default values. | ||
# Some values are commented out because their absence is the real default. | ||
# | ||
# See https://github.com/eqrion/cbindgen/blob/master/docs.md#cbindgentoml | ||
# for detailed documentation of every option here. | ||
|
||
|
||
language = "C" | ||
|
||
|
||
|
||
############## Options for Wrapping the Contents of the Header ################# | ||
|
||
# header = "/* Text to put at the beginning of the generated file. Probably a license. */" | ||
# trailer = "/* Text to put at the end of the generated file */" | ||
# include_guard = "my_bindings_h" | ||
# pragma_once = true | ||
autogen_warning = "/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */" | ||
include_version = false | ||
# namespace = "my_namespace" | ||
namespaces = [] | ||
using_namespaces = [] | ||
sys_includes = [] | ||
includes = [] | ||
no_includes = false | ||
after_includes = "" | ||
|
||
|
||
|
||
|
||
############################ Code Style Options ################################ | ||
|
||
braces = "SameLine" | ||
line_length = 100 | ||
tab_width = 2 | ||
documentation_style = "auto" | ||
|
||
|
||
|
||
|
||
|
||
############################# Codegen Options ################################## | ||
|
||
style = "both" | ||
|
||
|
||
|
||
[defines] | ||
# "target_os = freebsd" = "DEFINE_FREEBSD" | ||
# "feature = serde" = "DEFINE_SERDE" | ||
|
||
|
||
|
||
[export] | ||
include = [] | ||
exclude = [] | ||
# prefix = "CAPI_" | ||
item_types = [] | ||
renaming_overrides_prefixing = false | ||
|
||
|
||
|
||
[export.rename] | ||
|
||
|
||
|
||
[export.body] | ||
|
||
|
||
|
||
|
||
[fn] | ||
rename_args = "None" | ||
# must_use = "MUST_USE_FUNC" | ||
# prefix = "START_FUNC" | ||
# postfix = "END_FUNC" | ||
args = "auto" | ||
sort_by = "Name" | ||
|
||
|
||
|
||
|
||
[struct] | ||
rename_fields = "None" | ||
# must_use = "MUST_USE_STRUCT" | ||
derive_constructor = false | ||
derive_eq = false | ||
derive_neq = false | ||
derive_lt = false | ||
derive_lte = false | ||
derive_gt = false | ||
derive_gte = false | ||
|
||
|
||
|
||
|
||
[enum] | ||
rename_variants = "None" | ||
# must_use = "MUST_USE_ENUM" | ||
add_sentinel = false | ||
prefix_with_name = false | ||
derive_helper_methods = false | ||
derive_const_casts = false | ||
derive_mut_casts = false | ||
# cast_assert_name = "ASSERT" | ||
derive_tagged_enum_destructor = false | ||
derive_tagged_enum_copy_constructor = false | ||
enum_class = true | ||
private_default_tagged_enum_constructor = false | ||
|
||
|
||
|
||
|
||
[const] | ||
allow_static_const = true | ||
allow_constexpr = false | ||
|
||
|
||
|
||
|
||
[macro_expansion] | ||
bitflags = false | ||
|
||
|
||
|
||
|
||
|
||
|
||
############## Options for How Your Rust library Should Be Parsed ############## | ||
|
||
[parse] | ||
parse_deps = false | ||
# include = [] | ||
exclude = [] | ||
clean = false | ||
extra_bindings = [] | ||
|
||
|
||
|
||
[parse.expand] | ||
crates = [] | ||
all_features = false | ||
default_features = true | ||
features = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */ | ||
|
||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
|
||
typedef struct Address Address; | ||
|
||
typedef struct DataInputBoxes DataInputBoxes; | ||
|
||
typedef struct ErgoBoxCandidate ErgoBoxCandidate; | ||
|
||
typedef struct ErgoStateContext ErgoStateContext; | ||
|
||
typedef struct Error Error; | ||
|
||
typedef struct OutputBoxes OutputBoxes; | ||
|
||
typedef struct Transaction Transaction; | ||
|
||
typedef struct UnspentBoxes UnspentBoxes; | ||
|
||
typedef struct Wallet Wallet; | ||
|
||
typedef Error *ErrorPtr; | ||
|
||
typedef Address *AddressPtr; | ||
|
||
typedef Transaction *TransactionPtr; | ||
|
||
typedef ErgoBoxCandidate *ErgoBoxCandidatePtr; | ||
|
||
typedef ErgoStateContext *ErgoStateContextPtr; | ||
|
||
typedef OutputBoxes *OutputBoxesPtr; | ||
|
||
typedef UnspentBoxes *UnspentBoxesPtr; | ||
|
||
typedef Wallet *WalletPtr; | ||
|
||
typedef DataInputBoxes *DataInputBoxesPtr; | ||
|
||
ErrorPtr ergo_wallet_address_delete(AddressPtr _address); | ||
|
||
ErrorPtr ergo_wallet_address_from_testnet(const char *_address_str, AddressPtr *_address_out); | ||
|
||
void ergo_wallet_delete_error(ErrorPtr error); | ||
|
||
ErrorPtr ergo_wallet_delete_signed_tx(TransactionPtr _transaction); | ||
|
||
void ergo_wallet_delete_string(char *ptr); | ||
|
||
ErrorPtr ergo_wallet_ergo_box_candidate_delete(ErgoBoxCandidatePtr _ergo_box_candidate); | ||
|
||
ErrorPtr ergo_wallet_ergo_box_candidate_new_pay_to_address(AddressPtr _recipient, | ||
uint64_t _value, | ||
uint32_t _creation_height, | ||
ErgoBoxCandidatePtr *_ergo_box_candidate_out); | ||
|
||
ErrorPtr ergo_wallet_ergo_state_context_delete(ErgoStateContextPtr _ergo_state_context); | ||
|
||
ErrorPtr ergo_wallet_ergo_state_context_from_json(const char *_json_str, | ||
ErgoStateContextPtr *_ergo_state_context_out); | ||
|
||
char *ergo_wallet_error_to_string(ErrorPtr error); | ||
|
||
ErrorPtr ergo_wallet_output_boxes_delete(OutputBoxesPtr _output_boxes); | ||
|
||
ErrorPtr ergo_wallet_output_boxes_new(ErgoBoxCandidatePtr _ergo_box_candidate, | ||
OutputBoxesPtr *_output_boxes_out); | ||
|
||
ErrorPtr ergo_wallet_signed_tx_to_json(TransactionPtr _transaction, const char **_json_str_out); | ||
|
||
ErrorPtr ergo_wallet_unspent_boxes_delete(UnspentBoxesPtr _unspent_boxes); | ||
|
||
ErrorPtr ergo_wallet_unspent_boxes_from_json(const char *_json_str, | ||
UnspentBoxesPtr *_unspent_boxes_out); | ||
|
||
ErrorPtr ergo_wallet_wallet_delete(WalletPtr _wallet); | ||
|
||
ErrorPtr ergo_wallet_wallet_from_mnemonic(const char *_mnemonic_phrase, | ||
const uint8_t *_mnemonic_password, | ||
uintptr_t _mnemonic_password_length, | ||
WalletPtr *_wallet_out); | ||
|
||
ErrorPtr ergo_wallet_wallet_new_signed_tx(WalletPtr _wallet, | ||
ErgoStateContextPtr _state_context, | ||
UnspentBoxesPtr _unspent_boxes, | ||
DataInputBoxesPtr _data_input_boxes, | ||
OutputBoxesPtr _output_boxes, | ||
AddressPtr _send_change_to, | ||
uint64_t _min_change_value, | ||
uint64_t _tx_fee_amount, | ||
TransactionPtr *_transaction_out); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use std::{error, fmt, result}; | ||
|
||
pub type Result<T> = result::Result<T, Box<dyn error::Error + 'static>>; | ||
|
||
#[derive(Debug)] | ||
pub struct Error { | ||
details: Box<dyn error::Error + 'static>, | ||
} | ||
|
||
pub type ErrorPtr = *mut Error; | ||
|
||
impl fmt::Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
fmt::Display::fmt(self.details.as_ref(), f) | ||
} | ||
} | ||
|
Oops, something went wrong.