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

MoneroWalletFull.createSubaddress(0).getAddress() returns same address until its used #262

Open
Hackerokuz opened this issue Jan 15, 2025 · 1 comment

Comments

@Hackerokuz
Copy link

I want to create a unique sub address per transaction for my web app this code returns same sub address until its used

async function createSubaddress() {
    // Note: I have tried both viewOnly and full wallet!
    let viewOnlyWallet  = await openMoneroWallet();
    await viewOnlyWallet.sync();
    return (await viewOnlyWallet.createSubaddress(0)).getAddress();
}


function openMoneroWallet() {
    return moneroTs.openWalletFull({
        path: getWalletPath(),
        password: "****",
        networkType: moneroTs.MoneroNetworkType.STAGENET,
        server: {
            uri: "****"
        }
    })
    
}

In Monero GUI wallet going to receive and clicking create new address creates a new one every time you click it.
image

I have looked through docs and code of the library and also Monero docs but I dont see why I cant create a sub address.

Am I doing something wrong or is this a bug with the library?

@woodser
Copy link
Owner

woodser commented Jan 26, 2025

Currently you're opening the wallet and creating a new subaddress in the same function, but I don't see the wallet being saved before re-opening the wallet.

You'll need to save the wallet in order for the newly created subaddresses to exist when the wallet is re-opened.

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

3 participants
@woodser @Hackerokuz and others