Skip to content

Commit

Permalink
enable logging
Browse files Browse the repository at this point in the history
fix build
  • Loading branch information
MrCyjaneK committed Jan 5, 2025
1 parent 085d74b commit 64d5d9b
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 28 deletions.
4 changes: 2 additions & 2 deletions impls/monero.dart/lib/src/checksum_monero.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore_for_file: constant_identifier_names
const String wallet2_api_c_h_sha256 = "9e80c4b59a0509aa02fbf01e8df2881b89f82225d1765bfa7856cbdbaf7af116";
const String wallet2_api_c_cpp_sha256 = "d229507db508e574bd2badf4819a38dbead8c16a84311ad32c22c887a6003439-b089f9ee69924882c5d14dd1a6991deb05d9d1cd";
const String wallet2_api_c_h_sha256 = "6c1ba9b57cb185c6dad030b15bcffe8a4772f33930e7f1d62d23b33514ba6f62";
const String wallet2_api_c_cpp_sha256 = "1d1deff340408541f5755b4838d06345f63dcdfffe26b14dbdce32a5de839c55-b089f9ee69924882c5d14dd1a6991deb05d9d1cd";
const String wallet2_api_c_exp_sha256 = "d0f95f1f3bc49f1f59fe4eb0b61826128d7d3bb75405d5a01a252d02db03097d";
3 changes: 1 addition & 2 deletions impls/monero.rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ fn main() {

println!("cargo:rustc-link-search=native={}", lib_path.display());
println!("cargo:rustc-link-lib=dylib=monero_libwallet2_api_c");
println!("cargo:rustc-link-lib=dylib=stdc++");
println!("cargo:rustc-link-lib=dylib=hidapi-hidraw");
// println!("cargo:rustc-link-lib=dylib=libc++");
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", lib_path.display());

// Generate bindings using bindgen.
Expand Down
7 changes: 4 additions & 3 deletions impls/monero.rs/example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn main() -> Result<(), WalletError> {
"password".to_string(),
"capital chief route liar question fix clutch water outside pave hamster occur always learn license knife".to_string(),
NetworkType::Mainnet,
0, // Restore from the beginning of the blockchain.
3, // Restore from the beginning of the blockchain.
1, // Default KDF rounds.
"".to_string(), // No seed offset.
true, // Create a new wallet.
Expand All @@ -26,11 +26,11 @@ fn main() -> Result<(), WalletError> {

// Initialize the wallet.
let config = WalletConfig {
daemon_address: "https://monero.stackwallet.com:18081".to_string(),
daemon_address: "xmr-node.cakewallet.com:18081".to_string(),
upper_transaction_size_limit: 10000, // TODO: use sane value.
daemon_username: "".to_string(),
daemon_password: "".to_string(),
use_ssl: true,
use_ssl: false,
light_wallet: false,
proxy_address: "".to_string(),
};
Expand All @@ -41,6 +41,7 @@ fn main() -> Result<(), WalletError> {

// Refresh the wallet.
wallet.refresh()?;
// wallet.refresh_async()?;
wallet.throw_if_error()?;

// Wait for the refresh to complete.
Expand Down
21 changes: 5 additions & 16 deletions impls/monero.rs/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* automatically generated by rust-bindgen 0.70.1 */

pub const MONERO_wallet2_api_c_h_sha256: &[u8; 65] =
b"e8db0ef0324a153f5e3ecca4c0db23c54f4576e84988f04bd4f11c1142f9d7ad\0";
pub const MONERO_wallet2_api_c_cpp_sha256 : & [u8 ; 106] = b"dca52ac9ee009fda9fb5726543a454885e61d8eb74fb33112288029ed625bec5-b089f9ee69924882c5d14dd1a6991deb05d9d1cd\0" ;
b"6c1ba9b57cb185c6dad030b15bcffe8a4772f33930e7f1d62d23b33514ba6f62\0";
pub const MONERO_wallet2_api_c_cpp_sha256 : & [u8 ; 106] = b"1d1deff340408541f5755b4838d06345f63dcdfffe26b14dbdce32a5de839c55-b089f9ee69924882c5d14dd1a6991deb05d9d1cd\0" ;
pub const MONERO_wallet2_api_c_exp_sha256: &[u8; 65] =
b"c8913ac41068f67b57c9b0a3c7dd8973e3c1273b66c2ff0aadb0003931da748c\0";
b"d0f95f1f3bc49f1f59fe4eb0b61826128d7d3bb75405d5a01a252d02db03097d\0";
pub const NetworkType_MAINNET: ::std::os::raw::c_int = 0;
pub const NetworkType_TESTNET: ::std::os::raw::c_int = 1;
pub const NetworkType_STAGENET: ::std::os::raw::c_int = 2;
Expand Down Expand Up @@ -843,17 +843,6 @@ extern "C" {
extern "C" {
pub fn MONERO_Wallet_daemonBlockChainHeight(wallet_ptr: *mut ::std::os::raw::c_void) -> u64;
}
extern "C" {
pub fn MONERO_Wallet_daemonBlockChainHeight_cached(
wallet_ptr: *mut ::std::os::raw::c_void,
) -> u64;
}
extern "C" {
pub fn MONERO_Wallet_daemonBlockChainHeight_runThread(
wallet_ptr: *mut ::std::os::raw::c_void,
seconds: ::std::os::raw::c_int,
);
}
extern "C" {
pub fn MONERO_Wallet_daemonBlockChainTargetHeight(
wallet_ptr: *mut ::std::os::raw::c_void,
Expand Down Expand Up @@ -1477,11 +1466,11 @@ extern "C" {
}
extern "C" {
pub fn MONERO_WalletManager_queryWalletDevice(
device_type: ::std::os::raw::c_int,
wm_ptr: *mut ::std::os::raw::c_void,
keys_file_name: *const ::std::os::raw::c_char,
password: *const ::std::os::raw::c_char,
kdf_rounds: u64,
) -> bool;
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn MONERO_WalletManager_findWallets(
Expand Down
20 changes: 19 additions & 1 deletion impls/monero.rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ impl WalletManager {
/// ```
pub fn new() -> WalletResult<Arc<Self>> {
unsafe {
bindings::MONERO_WalletManagerFactory_setLogLevel(4);
let ptr = bindings::MONERO_WalletManagerFactory_getWalletManager();
let ptr = NonNull::new(ptr).ok_or(WalletError::NullPointer)?;
Ok(Arc::new(WalletManager { ptr }))
Expand Down Expand Up @@ -1032,6 +1033,16 @@ impl Wallet {
.map_err(|_| WalletError::FfiError("Invalid proxy address".to_string()))?;

unsafe {
let c_empty = CString::new("").unwrap();
let c_log_tag = CString::new("moneroc").unwrap();
bindings::MONERO_Wallet_init3(
self.ptr.as_ptr(),
c_empty.as_ptr(),
c_log_tag.as_ptr(),
c_empty.as_ptr(),
true,
);

let result = bindings::MONERO_Wallet_init(
self.ptr.as_ptr(),
c_daemon_address.as_ptr(),
Expand All @@ -1042,7 +1053,7 @@ impl Wallet {
config.light_wallet,
c_proxy_address.as_ptr(),
);

if result {
Ok(())
} else {
Expand Down Expand Up @@ -1117,6 +1128,13 @@ impl Wallet {
}
}

pub fn refresh_async(&self) -> WalletResult<Refreshed> {
unsafe {
bindings::MONERO_Wallet_refreshAsync(self.ptr.as_ptr());
return Ok(Refreshed)
}
}

/// Initiates a transfer from the wallet to the specified destinations.
///
/// # Returns
Expand Down
4 changes: 2 additions & 2 deletions impls/monero.ts/checksum_monero.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const moneroChecksum = {
wallet2_api_c_h_sha256: "9e80c4b59a0509aa02fbf01e8df2881b89f82225d1765bfa7856cbdbaf7af116",
wallet2_api_c_cpp_sha256: "d229507db508e574bd2badf4819a38dbead8c16a84311ad32c22c887a6003439-b089f9ee69924882c5d14dd1a6991deb05d9d1cd",
wallet2_api_c_h_sha256: "6c1ba9b57cb185c6dad030b15bcffe8a4772f33930e7f1d62d23b33514ba6f62",
wallet2_api_c_cpp_sha256: "1d1deff340408541f5755b4838d06345f63dcdfffe26b14dbdce32a5de839c55-b089f9ee69924882c5d14dd1a6991deb05d9d1cd",
wallet2_api_c_exp_sha256: "d0f95f1f3bc49f1f59fe4eb0b61826128d7d3bb75405d5a01a252d02db03097d",
}
4 changes: 2 additions & 2 deletions monero_libwallet2_api_c/src/main/cpp/monero_checksum.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef MONEROC_CHECKSUMS
#define MONEROC_CHECKSUMS
const char * MONERO_wallet2_api_c_h_sha256 = "9e80c4b59a0509aa02fbf01e8df2881b89f82225d1765bfa7856cbdbaf7af116";
const char * MONERO_wallet2_api_c_cpp_sha256 = "d229507db508e574bd2badf4819a38dbead8c16a84311ad32c22c887a6003439-b089f9ee69924882c5d14dd1a6991deb05d9d1cd";
const char * MONERO_wallet2_api_c_h_sha256 = "6c1ba9b57cb185c6dad030b15bcffe8a4772f33930e7f1d62d23b33514ba6f62";
const char * MONERO_wallet2_api_c_cpp_sha256 = "1d1deff340408541f5755b4838d06345f63dcdfffe26b14dbdce32a5de839c55-b089f9ee69924882c5d14dd1a6991deb05d9d1cd";
const char * MONERO_wallet2_api_c_exp_sha256 = "d0f95f1f3bc49f1f59fe4eb0b61826128d7d3bb75405d5a01a252d02db03097d";
#endif

0 comments on commit 64d5d9b

Please sign in to comment.