woodser / monero-ts

TypeScript library for using Monero
http://woodser.github.io/monero-ts/typedocs
MIT License
210 stars 71 forks source link

Can't open wallet by keys #179

Closed tothstevee closed 7 months ago

tothstevee commented 8 months ago

I have a wallet with all the keys view, spender, primary but when i try to open any wallet i got this error:

MoneroRpcError: Failed to open wallet

`const walletRPC = await moneroTs.connectToWalletRpc( "http://127.0.0.1:18083" );

await walletRPC.openWallet({
    path: "wallet_" + Date.now(),
    password: "monero",
    primaryAddress:
        "xxxx",
    privateViewKey:
        "xxxx",
    privateSpendKey:
        "xxx",
});

console.log(await walletRPC.getBalance());` 
woodser commented 8 months ago

openWallet needs to be called with a path to a previously created wallet, so this fails because "wallet_" + Date.now() is always unique. First call createWallet.

tothstevee commented 8 months ago

Thank! Now i understand how is it work. My other issue now is i'm getting back 0 balance but the account had some. Is that a daemon rpc issue?

woodser commented 8 months ago

The wallet needs to be synced from the wallet's restore height which requires a connection to daemon RPC.