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.

user36303
  • 34,928
  • 2
  • 58
  • 123
alexg
  • 207
  • 1
  • 2
  • 6

2 Answers2

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.

jtgrassie
  • 19,601
  • 4
  • 17
  • 54
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.

jtgrassie
  • 19,601
  • 4
  • 17
  • 54
user36303
  • 34,928
  • 2
  • 58
  • 123