1

I would like to use the Wallet RPC API to determine if the wallet I am connecting to is view-only.

I'm thinking about using the query_key command with key_type=mnemonic. Is it safe to assume that if the command fails to return a mnemonic, the wallet is view-only? Or is there a better way?

I'm guessing this is not the best way, because the documentation mentions that older wallets do not have a mnemonic.

2

I'm thinking about using query_key command with key_type=mnemonic. Is it safe to assume that if the command fails to return a mnemonic, the wallet is view-only?

Yes.

I'm guessing this is not the best way, because the documentation mentions that older wallets do not have a mnemonic.

It's the only way if you need to check though. The likelihood of such an old wallet I would guess is low due to the fact people actually using monero will have been upgrading.

With all this said, I find it difficult to understand the need to check if a wallet is view-only. The moment you try to spend from a view-only wallet you'll get an error and know then.

  • I simply wish to display in my UI whether the wallet is view-only, preferably without having to attempt a transfer. I think you are correct in that I can assume wallets are sufficiently upgraded. Thank you for your answer! – alexg Sep 8 '18 at 13:18
1

If you query the spend key using that same RPC, watch only wallets will have it as 0000000000000000000000000000000000000000000000000000000000000000.

Of course, querying secret keys over RPC (or any other sensitive RPC calls) should be done with caution, since in this case, you're sending secret keys over a network connection, but there does not seem to be any other way. You should use stunnel or similar if calling remotely.

  • 1
    With the wallet RPC, you cannot specifically ask for the spend key (albeit mnemonic is essentially the spend key for newer wallets) . From the docs on query_key: "Return the spend or view private key.", "key_type - string; Which key to retrieve: "mnemonic" - the mnemonic seed (older wallets do not have one) OR "view_key" - the view key". Also, I wouldn't say querying keys over RPC is "dangerous", rather it needs using with caution. – jtgrassie Sep 8 '18 at 12:32
  • You can AFAIK. Why do you think you can't ? And why would you need caution if there's no danger ? But edit the wording if you feel really strongly about it. – user36303 Sep 8 '18 at 14:07
  • Just in case you might have been right, I just tried. (of course, it worked). – user36303 Sep 8 '18 at 20:55
  • I just think that many of the RPC calls need using with caution so as to not leak private information. Dangerous implies do not use whereas caution implies think about how you wish to use. But yes, danger also implies use with caution ;) – jtgrassie Sep 9 '18 at 17:43
  • I just changed it to say caution then :) – user36303 Sep 9 '18 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.