summaryrefslogtreecommitdiff
path: root/impls/monero.rs
diff options
context:
space:
mode:
authorIm-Beast <franik.mateusz@gmail.com>2025-01-05 16:21:03 +0100
committerIm-Beast <franik.mateusz@gmail.com>2025-01-05 16:21:03 +0100
commit962647f31842f4ba9b1108a0e07857c2c49d5869 (patch)
tree3e5b79ee6bf7caf1d0392a1bae1f354f2c47e143 /impls/monero.rs
parent64d5d9b6f8d8bfc9b6b7781860bd2f7d042e247a (diff)
fix: set the WalletManager daemon address
Diffstat (limited to 'impls/monero.rs')
-rw-r--r--impls/monero.rs/example/src/main.rs10
-rw-r--r--impls/monero.rs/src/lib.rs14
2 files changed, 21 insertions, 3 deletions
diff --git a/impls/monero.rs/example/src/main.rs b/impls/monero.rs/example/src/main.rs
index dbc309c..39163dc 100644
--- a/impls/monero.rs/example/src/main.rs
+++ b/impls/monero.rs/example/src/main.rs
@@ -35,6 +35,9 @@ fn main() -> Result<(), WalletError> {
proxy_address: "".to_string(),
};
+ // Set WalletManager's daemon address
+ manager.set_daemon_address(&config.daemon_address);
+
// Perform the initialization.
wallet.init(config)?;
wallet.throw_if_error()?;
@@ -46,10 +49,11 @@ fn main() -> Result<(), WalletError> {
// Wait for the refresh to complete.
loop {
- let height = manager.get_height().expect("Failed to get blockchain height");
+ let height = manager.get_height()?;
println!("Current blockchain height: {}", height);
- if height > 3263501 { // After this height we can get_balance.
- break ();
+ if height > 3263501 {
+ // After this height we can get_balance.
+ break;
}
// Wait one second.
std::thread::sleep(std::time::Duration::from_secs(1));
diff --git a/impls/monero.rs/src/lib.rs b/impls/monero.rs/src/lib.rs
index b40cb94..1334b7a 100644
--- a/impls/monero.rs/src/lib.rs
+++ b/impls/monero.rs/src/lib.rs
@@ -628,6 +628,20 @@ impl WalletManager {
Ok(height)
}
}
+
+ /// Sets the daemon address of WalletManager
+ pub fn set_daemon_address(&self, daemon_address: &str) -> WalletResult<()> {
+ let c_daemon_address = CString::new(daemon_address)
+ .map_err(|_| WalletError::FfiError("Invalid daemon address".to_string()))?;
+
+ unsafe {
+ bindings::MONERO_WalletManager_setDaemonAddress(
+ self.ptr.as_ptr(),
+ c_daemon_address.as_ptr(),
+ );
+ Ok(())
+ }
+ }
}
impl Wallet {