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

A minor issue with using "-h" option to run the wallet in current directory #728

Open
aglkm opened this issue Dec 3, 2024 · 4 comments
Open

Comments

@aglkm
Copy link

aglkm commented Dec 3, 2024

When you are creating a wallet in the current directory using grin-wallet init -h command, you will end up with errors saying that wallet can't contact a node.
The reason is that wallet creates API secrets paths in grin-wallet.toml file pointing to the current directory, not the actual/correct paths of node's api secrets location.

It would be nice if wallet could auto-detect the correct paths, if not possible then just print a simple message, saying that you need to correct API secrets paths, e.g.:

20241203 22:44:37.332 ERROR grin_wallet_impls::node_clients::http - Error calling get_version: ResponseError error: Cannot parse response
20241203 22:44:37.332 ERROR grin_wallet_impls::node_clients::http - Unable to contact Node to get version info: Client Callback Error: Error calling get_version: ResponseError error: Cannot parse response
**WARNING: YOU NEED TO CORRECT API SECRET PATHS IN GRIN-WALLET.TOML FILE.**
Please enter a password for your new wallet
Password: 
Confirm Password: 
@Anynomouss
Copy link

Anynomouss commented Jan 16, 2025

I just want to mention that this issue of not correctly detecting (or creating) the API secret when using -h or -t is quite a high priority bug in my opinion, since it blocks anyone from testing using multiple wallets on a single machine - unless they would run a docker instance for each wallet.

I am not sure even what exactly the root issue is here.
For example copying the .api_secret secret from my default wallet directory to my custom top level directory does not make the wallet able to connect to the node API. Also the grin-wallet.toml contains lines for .foreign_api_secret and .owner_api_secret but none for .api_secret. Which secret is exactly needed by grin-wallet to connect to the node?

@aglkm
Copy link
Author

aglkm commented Jan 16, 2025

This issue should not block from using multiple wallets.

The secrets inside wallet directory are for wallet API.
The secrets inside node directory are for node API.

Don't copy the secrets, but instead correct node_api_secret_path inside grin-wallet.toml file for each wallet you are using.

node_api_secret_path should point to node's Foreign API secret.

Node API secrets:
.api_secret - Node Full API access. ( ? )
.owner_api_secret - Node Owner API.
.foreign_api_secret - Node Foreign API.

Wallet API secrets:
.owner_api_secret - Wallet Owner API.
.foreign_api_secret - Wallet Foreign API.

Btw, I don't have .api_secret inside wallet directory. You copied it from node's directory?

If you already messed up the secrets, just delete them, restart node & wallet and correct node_api_secret_path in grin-wallet.toml file for each wallet.

I hope this helps.

@Anynomouss
Copy link

Thanks, that was useful 👍 .
You lifted my brain-fog, the secrets were getting me confused and I somehow missed that the path was just there in the grin-wallet.toml file. Now I also know better where to look in the wallet code although I am uncertain if I will be able to fix it in the code.

@Anynomouss
Copy link

Anynomouss commented Jan 24, 2025

I am working on a fix to this issue, and I have some questions.
I added a warning message Warning: You might need to correct 'node_api_secret_path' in your 'grin-wallet.toml' file to the wallet, so far so good.

The next step is changing the default behavior in setting the directory for .foreign_api_secret.
Question 1: why is grin-wallet expecting the node API secret .foreign_api_secret to be in the custom wallet directory provide by the user via -h or -t ? What confuses me even more is that the wallet creates a .foreign_api_secret if it does not exist in the specified wallet path. @yeastplume is the .foreign_api_secret that is being created by grin wallet a) for the node API , b) for the wallet API, or c) is it a shared secret that both node and wallet use for their API's?
I know that it cannot be changed easily without breaking backwards compatibility but for me it would have been more logical if the secrets would be explicit, e.g. .node_foreign_api_secret, .wallet_foreign_api_secret, unless it is a shared secret.

Question 2: Should I change the default behavior to let the wallet look for the nodes .foreign_api_secret in the home directory? I assume most people run the node in the default directory and only use grin-wallet with custom directories using -h or -t .
If it does not exist, I can let the wallet create the directory, just like it does now, only ignoring the user specified path.
I can make the changes myself, but I do need to know that I am not breaking anything in the process. Maybe there are good reasons for this default behavior that I just failed to see.

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

2 participants