Skip to content

Rust bindings#67

Closed
sneurlax wants to merge 60 commits intoMrCyjaneK:developfrom
sneurlax:rust
Closed

Rust bindings#67
sneurlax wants to merge 60 commits intoMrCyjaneK:developfrom
sneurlax:rust

Conversation

@sneurlax
Copy link
Copy Markdown
Collaborator

@sneurlax sneurlax commented Oct 10, 2024

Proof of concept Rust bindings. TODO:

  • Prove actual wallet usage (gen. seed or similar)
  • Rust wrapper structure(s) around the C FFI (eg. a struct to store a wallet with the C pointer)
  • Convert example from a bin to a lib
  • Add unit tests
  • Add docs tests
  • Add integration tests
  • Improve error handling: add get_status
  • Finish wrapping bindings
    • At minimum wrap all functions listed by binarybaron here:
      • get_address(&self, account_index: u32) -> GetAddress;
      • get_balance(&self, account_index: u32) -> GetBalance;
      • create_account(&self, label: String) -> CreateAccount;
      • get_accounts(&self, tag: String) -> GetAccounts;
      • open_wallet(&self, filename: String) -> WalletOpened;
      • close_wallet(&self) -> WalletClosed;
      • create_wallet(&self, filename: String, language: String) -> WalletCreated;
      • transfer(&self, account_index: u32, destinations: Vec, get_tx_key: bool) -> Transfer;
      • get_height(&self) -> BlockHeight;
      • check_tx_key(&self, txid: String, tx_key: String, address: String) -> CheckTxKey;
      • generate_from_keys(&self, filename: String, address: String, spendkey: String, viewkey: String, restore_height: u32, password: String, autosave_current: bool) -> GenerateFromKeys;
      • refresh(&self) -> Refreshed;
      • sweep_all(&self, address: String) -> SweepAll;
      • check_tx_key(&self) -> Version;
  • Test wrappers
    • transfer
    • sweep_all
    • check_tx_key
  • Fix example for subsequent runs (fails when wallet file already exists)
  • Address clippy warnings (format, etc.)

Ensure cross-platform compatibility:

  • Linux
  • Android
  • Windows
  • macOS
  • iOS

and so we don't overload our upstream:

  • Rework PR as the addition of a git subtree of a standalone repo with a build script (preferably the upstream's)

We may also want to: (optional)

  • Allow the wallet files storage path to be configured
  • Add coin control
  • Add hardware wallets

Optionally, improve the build script:
- [x] Don't clone a brand new repo, build in place (unless passed -c|--clean)
Build script removed

courtesy of cypherstack/flutter_libmonero and MrCyjaneK & julian-CStack's work there

remove wownero

update docs and script

add gitignore
and document the required placement
just to match the style in impls

and sneurlax/monero_c -> MrCyjaneK/monero_c
Copy link
Copy Markdown
Owner

@MrCyjaneK MrCyjaneK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice PR!

@sneurlax

This comment was marked as resolved.

@binarybaron
Copy link
Copy Markdown
Collaborator

Again, this is a really cool proof of concept. I'm currently compiling this branch and testing it out. I'll try to leave some feedback on this PR over the next few days.

I'd love to use this for our atomic swaps implementation to replace monero-wallet-rpc. I'll just throw all the api calls we'd need to replace with your wrapper in here. You don't have to implement all this but perhaps it's interesting to you.

#[jsonrpc_client::api(version = "2.0")]
pub trait MoneroWalletRpc {
    async fn get_address(&self, account_index: u32) -> GetAddress;
    async fn get_balance(&self, account_index: u32) -> GetBalance;
    async fn create_account(&self, label: String) -> CreateAccount;
    async fn get_accounts(&self, tag: String) -> GetAccounts;
    async fn open_wallet(&self, filename: String) -> WalletOpened;
    async fn close_wallet(&self) -> WalletClosed;
    async fn create_wallet(&self, filename: String, language: String) -> WalletCreated;
    async fn transfer(
        &self,
        account_index: u32,
        destinations: Vec<Destination>,
        get_tx_key: bool,
    ) -> Transfer;
    async fn get_height(&self) -> BlockHeight;
    async fn check_tx_key(&self, txid: String, tx_key: String, address: String) -> CheckTxKey;
    #[allow(clippy::too_many_arguments)]
    async fn generate_from_keys(
        &self,
        filename: String,
        address: String,
        spendkey: String,
        viewkey: String,
        restore_height: u32,
        password: String,
        autosave_current: bool,
    ) -> GenerateFromKeys;
    async fn refresh(&self) -> Refreshed;
    async fn sweep_all(&self, address: String) -> SweepAll;
    async fn get_version(&self) -> Version;
}

@sneurlax
Copy link
Copy Markdown
Collaborator Author

Thanks @binarybaron, that's a good initial list of methods to wrap, I appreciate the targets.

Do note that I've been pushing changes before and after your comment so things may be changing. You can get a lib from https://github.com/MrCyjaneK/monero_c/releases rather than building it with the script, which has now been removed IAW MrCyjaneK's requested changes

@sneurlax

This comment was marked as resolved.

@sneurlax sneurlax closed this Oct 12, 2024
@MrCyjaneK

This comment was marked as resolved.

@MrCyjaneK MrCyjaneK reopened this Oct 12, 2024
@binarybaron
Copy link
Copy Markdown
Collaborator

binarybaron commented Oct 13, 2024

Running create_wallet wallet on an already existing wallet causes this behaviour. It seems that address_ptr.is_null() does not correctly detect the null pointer. The pointer returned by the wallet in my case is 0x12ff4e610.

$ cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.16s
     Running `target/debug/monero_example`
Wallet created successfully.
Seed: tavern dwindling dialect warped different bite moat assorted claim session pouch eagle antics yellow hinder cause losing smuggled tobacco vulture react poetry army aztec tobacco
Primary address: 48P1nxBe9zKLbcR7whtJ73W9sEqhCysThGwXArmvnmKGagZmXHwyVryKpUNZqvQ5GJ8JiwJVz2tDWTmL2v5Etnr8Kmpyajb
$ cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
     Running `target/debug/monero_example`
Wallet created successfully.
Failed to get seed: FfiError("Received empty seed")
Primary address: 41d7FXjswpK1111111111111111111111111111111111111111111111111111111111111111111111111111112KhNi4

Edit: This is a known issue

@sneurlax
Copy link
Copy Markdown
Collaborator Author

Thanks for that, I'll update the bindings etc after a rebuild. I'm working on getting the example app working now in order to complete the testing tasks, then will work on macos, windows, etc

@sneurlax
Copy link
Copy Markdown
Collaborator Author

sneurlax commented Oct 29, 2024

As of now, check_tx_key doesn't work as expected. I was expecting it to work without being synced (I think it should be able to tell if a txid & tx key pair are related without being able to tell if the tx is in the pool, etc., but I'm not sure about this). I just pushed failing tests, I think it's an FFI error and will have to dig in deeper another time.

The example app in monero_c/impls/monero.rs/example runs almost as expected, it generates the expected address but fails to ever connect to a node or sync. I'll be looking into this eventually but if anyone reading this can get it fixed you're more than welcome to the change in that wallet as pushed :) swiper no swiping if you're not going to fix it (on your honor)

@sneurlax
Copy link
Copy Markdown
Collaborator Author

binarybaron mentioned on Matrix that the monero-harness crate and testcontainers-rs will be helpful for testing on private nets: https://github.com/UnstoppableSwap/core/tree/master/monero-harness

@binarybaron
Copy link
Copy Markdown
Collaborator

@sneurlax FYI: We haven't forgotten this, we had a lot on our plate with our 1.0 release. We are still very eager to use this :) I'll get to this hopefully soon.

@binarybaron
Copy link
Copy Markdown
Collaborator

I haven't been able to compile monero_c yet on my apple silicone machine. Anyone know what the issue might be here?

[ 66%] Building CXX object CMakeFiles/wallet2_api_c.dir/src/main/cpp/helpers.cpp.o
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:83:34: error: no member named 'commitUR' in 'Monero::PendingTransaction'
   83 |     std::string str = pendingTx->commitUR(max_fragment_length);
      |                       ~~~~~~~~~  ^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:140:48: error: no member named 'hex' in 'Monero::PendingTransaction'
  140 |     std::vector<std::string> txid = pendingTx->hex();
      |                                     ~~~~~~~~~  ^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:146:48: error: no member named 'txKey' in 'Monero::PendingTransaction'
  146 |     std::vector<std::string> txid = pendingTx->txKey();
      |                                     ~~~~~~~~~  ^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:206:35: error: no member named 'signUR' in 'Monero::UnsignedTransaction'
  206 |     std::string str = unsignedTx->signUR(max_fragment_length);
      |                       ~~~~~~~~~~  ^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:436:13: error: no type named 'CoinsInfo' in namespace 'Monero'
  436 |     Monero::CoinsInfo *coinsInfo = reinterpret_cast<Monero::CoinsInfo*>(coinsInfo_ptr);
      |     ~~~~~~~~^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:436:61: error: no type named 'CoinsInfo' in namespace 'Monero'
  436 |     Monero::CoinsInfo *coinsInfo = reinterpret_cast<Monero::CoinsInfo*>(coinsInfo_ptr);
      |                                                     ~~~~~~~~^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:441:13: error: no type named 'CoinsInfo' in namespace 'Monero'
  441 |     Monero::CoinsInfo *coinsInfo = reinterpret_cast<Monero::CoinsInfo*>(coinsInfo_ptr);
      |     ~~~~~~~~^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:441:61: error: no type named 'CoinsInfo' in namespace 'Monero'
  441 |     Monero::CoinsInfo *coinsInfo = reinterpret_cast<Monero::CoinsInfo*>(coinsInfo_ptr);
      |                                                     ~~~~~~~~^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:450:13: error: no type named 'CoinsInfo' in namespace 'Monero'
  450 |     Monero::CoinsInfo *coinsInfo = reinterpret_cast<Monero::CoinsInfo*>(coinsInfo_ptr);
      |     ~~~~~~~~^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:450:61: error: no type named 'CoinsInfo' in namespace 'Monero'
  450 |     Monero::CoinsInfo *coinsInfo = reinterpret_cast<Monero::CoinsInfo*>(coinsInfo_ptr);
      |                                                     ~~~~~~~~^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:455:13: error: no type named 'CoinsInfo' in namespace 'Monero'
  455 |     Monero::CoinsInfo *coinsInfo = reinterpret_cast<Monero::CoinsInfo*>(coinsInfo_ptr);
      |     ~~~~~~~~^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:455:61: error: no type named 'CoinsInfo' in namespace 'Monero'
  455 |     Monero::CoinsInfo *coinsInfo = reinterpret_cast<Monero::CoinsInfo*>(coinsInfo_ptr);
      |                                                     ~~~~~~~~^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:460:13: error: no type named 'CoinsInfo' in namespace 'Monero'
  460 |     Monero::CoinsInfo *coinsInfo = reinterpret_cast<Monero::CoinsInfo*>(coinsInfo_ptr);
      |     ~~~~~~~~^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:460:61: error: no type named 'CoinsInfo' in namespace 'Monero'
  460 |     Monero::CoinsInfo *coinsInfo = reinterpret_cast<Monero::CoinsInfo*>(coinsInfo_ptr);
      |                                                     ~~~~~~~~^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:465:13: error: no type named 'CoinsInfo' in namespace 'Monero'
  465 |     Monero::CoinsInfo *coinsInfo = reinterpret_cast<Monero::CoinsInfo*>(coinsInfo_ptr);
      |     ~~~~~~~~^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:465:61: error: no type named 'CoinsInfo' in namespace 'Monero'
  465 |     Monero::CoinsInfo *coinsInfo = reinterpret_cast<Monero::CoinsInfo*>(coinsInfo_ptr);
      |                                                     ~~~~~~~~^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:470:13: error: no type named 'CoinsInfo' in namespace 'Monero'
  470 |     Monero::CoinsInfo *coinsInfo = reinterpret_cast<Monero::CoinsInfo*>(coinsInfo_ptr);
      |     ~~~~~~~~^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:470:61: error: no type named 'CoinsInfo' in namespace 'Monero'
  470 |     Monero::CoinsInfo *coinsInfo = reinterpret_cast<Monero::CoinsInfo*>(coinsInfo_ptr);
      |                                                     ~~~~~~~~^
/Users/***/Development/monero_c/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp:475:13: error: no type named 'CoinsInfo' in namespace 'Monero'
  475 |     Monero::CoinsInfo *coinsInfo = reinterpret_cast<Monero::CoinsInfo*>(coinsInfo_ptr);
      |     ~~~~~~~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [CMakeFiles/wallet2_api_c.dir/src/main/cpp/wallet2_api_c.cpp.o] Error 1
make[1]: *** [CMakeFiles/wallet2_api_c.dir/all] Error 2
make: *** [all] Error 2

@MrCyjaneK
Copy link
Copy Markdown
Owner

MrCyjaneK commented Dec 3, 2024

@binarybaron you need to run ./apply_patches.sh monero

docs: https://moneroc.mrcyjanek.net/latest/macos.html

@binarybaron
Copy link
Copy Markdown
Collaborator

@binarybaron you need to run ./apply_patches.sh monero

docs: https://moneroc.mrcyjanek.net/latest/macos.html

I get this error when building:

[100%] Linking CXX shared library libwallet2_api_c.dylib
Undefined symbols for architecture arm64:
  "_hid_close", referenced from:
      hw::io::device_io_hid::disconnect() in libdevice.a[7](device_io_hid.cpp.o)
  "_hid_enumerate", referenced from:
      hw::io::device_io_hid::connect(unsigned int, unsigned int, boost::optional<int>, boost::optional<unsigned short>) in libdevice.a[7](device_io_hid.cpp.o)
  "_hid_error", referenced from:
      hw::io::safe_hid_error(hid_device_*) in libdevice.a[7](device_io_hid.cpp.o)
  "_hid_free_enumeration", referenced from:
      hw::io::device_io_hid::connect(unsigned int, unsigned int, boost::optional<int>, boost::optional<unsigned short>) in libdevice.a[7](device_io_hid.cpp.o)
  "_hid_init", referenced from:
      hw::io::device_io_hid::init() in libdevice.a[7](device_io_hid.cpp.o)
  "_hid_open_path", referenced from:
      hw::io::device_io_hid::connect(unsigned int, unsigned int, boost::optional<int>, boost::optional<unsigned short>) in libdevice.a[7](device_io_hid.cpp.o)
  "_hid_read", referenced from:
      hw::io::device_io_hid::exchange(unsigned char*, unsigned int, unsigned char*, unsigned int, bool) in libdevice.a[7](device_io_hid.cpp.o)
  "_hid_read_timeout", referenced from:
      hw::io::device_io_hid::exchange(unsigned char*, unsigned int, unsigned char*, unsigned int, bool) in libdevice.a[7](device_io_hid.cpp.o)
      hw::io::device_io_hid::exchange(unsigned char*, unsigned int, unsigned char*, unsigned int, bool) in libdevice.a[7](device_io_hid.cpp.o)
  "_hid_write", referenced from:
      hw::io::device_io_hid::exchange(unsigned char*, unsigned int, unsigned char*, unsigned int, bool) in libdevice.a[7](device_io_hid.cpp.o)
ld: symbol(s) not found for architecture arm64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libwallet2_api_c.dylib] Error 1
make[1]: *** [CMakeFiles/wallet2_api_c.dir/all] Error 2

Any idea how to fix? :/

@MrCyjaneK
Copy link
Copy Markdown
Owner

Could you try building the binaries from develop branch? There has been couple improvements made and this PR is out of date, I'll merge develop to this branch in a bit.

@binarybaron
Copy link
Copy Markdown
Collaborator

Could you try building the binaries from develop branch? There has been couple improvements made and this PR is out of date, I'll merge develop to this branch in a bit.

develop does compile for me.

@binarybaron
Copy link
Copy Markdown
Collaborator

Could I get write access to the branch? @MrCyjaneK @sneurlax

@binarybaron
Copy link
Copy Markdown
Collaborator

I got this compiling on my machine. The example is not syncing the wallet properly for me. I'm using a stagenet wallet and a local node.

use monero_c_rust::{NetworkType, WalletConfig, WalletError, WalletManager};
use tempfile::TempDir;

fn main() -> Result<(), WalletError> {
    let manager = WalletManager::new()?;

    let temp_dir = TempDir::new().expect("Failed to create temporary directory");
    let wallet_path = temp_dir.path().join("test_wallet");
    let wallet_str = wallet_path.to_str().unwrap();

    let wallet = manager.restore_polyseed(
        wallet_str.to_string(),
        "password".to_string(),
        "capital chief route liar question fix clutch water outside pave hamster occur always learn license knife".to_string(),
        NetworkType::Stagenet,
        1767926, // Restore from the beginning of the blockchain.
        1, // Default KDF rounds.
        "".to_string(), // No seed offset.
        true, // Create a new wallet.
    )?;

    println!("Wallet created successfully.");

    // Print the primary address.
    println!("Primary address: {}", wallet.get_address(0, 0)?);

    // Initialize the wallet.
    let config = WalletConfig {
        daemon_address: " localhost:38081".to_string(),
        upper_transaction_size_limit: 10000, // TODO: use sane value.
        daemon_username: "".to_string(),
        daemon_password: "".to_string(),
        use_ssl: false,
        light_wallet: false,
        proxy_address: "".to_string(),
    };

    // Perform the initialization.
    wallet.init(config)?;
    wallet.throw_if_error()?;

    let target_block = manager.get_height_target()?;
    println!("Target block: {}", target_block);

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

    // Wait for the refresh to complete.
    loop {
        let height = manager
            .get_height()
            .expect("Failed to get blockchain height");
        println!("Current blockchain height: {}", height);
        if height > 3263501 {
            // After this height we can get_balance.
            break ();
        }
        // Wait one second.
        std::thread::sleep(std::time::Duration::from_secs(1));
    }

    // Get the balance.
    let balance_result = wallet.get_balance(0); // Account index 0.
    let balance = balance_result.unwrap();
    println!("Balance: {:?}", balance);

    // Clean up the wallet.
    std::fs::remove_file(wallet_str).expect("Failed to delete test wallet");
    std::fs::remove_file(format!("{}.keys", wallet_str))
        .expect("Failed to delete test wallet keys");

    Ok(())
}
Wallet created successfully.
Primary address: 56HeZM3u6xYCV8oVVh7CuWWHs7yeB1oxhNPrsEM5FKSqadTXmobLqsNEtRnyGsbN1rbDuBtWdtxtXhTJda1Lm9vcH73iSWn
Target block: 0
Current blockchain height: 0
Current blockchain height: 0
Current blockchain height: 0
Current blockchain height: 0
Current blockchain height: 0
Current blockchain height: 0
Current blockchain height: 0
Current blockchain height: 0
.....
Current blockchain height: 0
Current blockchain height: 0
Current blockchain height: 0

@MrCyjaneK MrCyjaneK changed the base branch from master to develop January 5, 2025 12:06
@MrCyjaneK
Copy link
Copy Markdown
Owner

#103

@binarybaron
Copy link
Copy Markdown
Collaborator

Perhaps the issue is that in lib.rs::init(...) we pass the pointer to the daemon_address string to the FFI function. Once init(...) returns the string will be dropped (and freed). This will prevent the C code from accessing the underlying value.

let c_daemon_address = CString::new(config.daemon_address)
            .map_err(|_| WalletError::FfiError("Invalid daemon address".to_string()))?;
       ....

        unsafe {
            ...

            let result = bindings::MONERO_Wallet_init(
                self.ptr.as_ptr(),
                c_daemon_address.as_ptr(),
                config.upper_transaction_size_limit,
                c_daemon_username.as_ptr(),
                c_daemon_password.as_ptr(),
                config.use_ssl,
                config.light_wallet,
                c_proxy_address.as_ptr(),
            );

            if result {
                 // After returning c_daemon_address will be freed
                Ok(())
            } else {
                // Retrieve the last error from the wallet
                Err(self.get_last_error())
            }
        }

I tried using .into_raw() instead of as_ptr() which should "Consume[...] the CString and transfer[...] ownership of the string to [the] C caller" but the issue hasn't resolved itself.


// Wait for the refresh to complete.
loop {
let height = manager.get_height().expect("Failed to get blockchain height");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are checking WalletManager's height, but you forgot to set MONERO_WalletManager_setDaemonAddress before that, Wallet_init doesn't do that for you

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's odd. Why are we passing on the daemon address if it is not used?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@binarybaron right, we shouldn't be checking manager's height but wallet's height instead

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe the wallet is synced properly. I sent funds to the wallet but they are not detected (balance is zero).

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's correct, because that function is asking the node about the height, and not the wallet

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would I check how far the sync is?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

monero.Wallet_blockchainHeight()
and

extern ADDAPI uint64_t MONERO_Wallet_daemonBlockChainHeight(void* wallet_ptr);

if the difference is zero - you are synced

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also current example uses refresh, instead I would recommend using

extern ADDAPI void MONERO_Wallet_startRefresh(void* wallet_ptr);

@binarybaron
Copy link
Copy Markdown
Collaborator

binarybaron commented Jan 6, 2025

Is there a difference between monero_libwallet2_api_c.dylib, libwallet2_api_c.dylib, libmonero_libwallet2_api_c.dylib?

@MrCyjaneK
Copy link
Copy Markdown
Owner

No, it is the same file - I'm not sure why rust needs all of them. The general convention is to use {prefix}monero_libwallet2_api_c.{suffix}

where suffix is so/dll/dylib and prefix is lib on android

@MrCyjaneK
Copy link
Copy Markdown
Owner

also please move onto #103 (unless @sneurlax is up to do a force push to sync this branch)

@MrCyjaneK
Copy link
Copy Markdown
Owner

@binarybaron maybe polyseed doesn't know how to handle that for stagenet? I'm not sure, can you try using

extern ADDAPI void MONERO_Wallet_setRefreshFromBlockHeight(void* wallet_ptr, uint64_t refresh_from_block_height);
extern ADDAPI uint64_t MONERO_Wallet_getRefreshFromBlockHeight(void* wallet_ptr);

to verify that it contains correct restore height?

@binarybaron
Copy link
Copy Markdown
Collaborator

binarybaron commented Jan 7, 2025

@binarybaron maybe polyseed doesn't know how to handle that for stagenet? I'm not sure, can you try using

extern ADDAPI void MONERO_Wallet_setRefreshFromBlockHeight(void* wallet_ptr, uint64_t refresh_from_block_height); extern ADDAPI uint64_t MONERO_Wallet_getRefreshFromBlockHeight(void* wallet_ptr);

to verify that it contains correct restore height?

Yes, calling MONERO_Wallet_setRefreshFromBlockHeight before syncing fixes the issue! Thank you.

@sneurlax
Copy link
Copy Markdown
Collaborator Author

Sorry to be only just now seeing this, this PR can be closed, then, right?

also please move onto #103 (unless @sneurlax is up to do a force push to sync this branch)

@sneurlax sneurlax mentioned this pull request Apr 29, 2025
@MrCyjaneK MrCyjaneK closed this May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants