Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GA_get_receive_address address reuse with single-sig accounts #169

Closed
pavel-kokolemin opened this issue Jul 15, 2022 · 2 comments
Closed

Comments

@pavel-kokolemin
Copy link

When I call GA_get_receive_address with single-sig liquid account it returns old addresses after some period.
I think that's a bug.

get_next_address function looks correct:

    pub fn get_next_address(&self) -> Result<AddressPointer, Error> {
        let pointer = {
            let store = &mut self.store.write()?;
            let acc_store = store.account_cache_mut(self.account_num)?;
            acc_store.indexes.external += 1;
            acc_store.indexes.external
        };
        ...

but the counter is probably rewritten from the Syncer thread:

impl Syncer {
    pub fn sync(&self, client: &Client) -> Result<HashSet<u32>, Error> {
        ...
                    if let Some(max) = max {
                        if i == 0 {
                            last_used.external = max + batch_count * BATCH_SIZE;
        ...

I'm attaching example program to reproduce the issue.
new_address.py.txt

@pavel-kokolemin
Copy link
Author

With this change it works correctly:

                 let mut acc_store = store_write.account_cache_mut(account.num())?;
-                acc_store.indexes = last_used;
+                acc_store.indexes.external =
+                    u32::max(acc_store.indexes.external, last_used.external);
+                acc_store.indexes.internal = last_used.internal;

@pavel-kokolemin
Copy link
Author

With this change it works correctly:

                 let mut acc_store = store_write.account_cache_mut(account.num())?;
-                acc_store.indexes = last_used;
+                acc_store.indexes.external =
+                    u32::max(acc_store.indexes.external, last_used.external);
+                acc_store.indexes.internal = last_used.internal;

Found a problem with that change. acc_store.scripts and acc_store.scripts are not properly filled.

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

No branches or pull requests

1 participant