2

I'm aware of the get_balance function - https://www.getmonero.org/resources/developer-guides/wallet-rpc.html#get_balance

$ curl http://127.0.0.1:18082/json_rpc -d 
'{"jsonrpc":"2.0","id":"0","method":"get_balance",
"params":{"account_index":0,"address_indices":[0,1]}}'
-H 'Content-Type: application/json'

===> {.............}

However, it doesn't show how, at what point use the private view key, nor any keys at all.

How?

Kum
  • 25
  • 4

1 Answers1

0

The monero-wallet-rpc program operates on a wallet, not just key(s). Create1 yourself a view-only wallet and open that with the monero-wallet-rpc (either using the --wallet-file=<file> option or open_wallet RPC method).

Additionally, you need to understand that to get the balance, a view-only wallet is not sufficient alone, as you need to also track the spent status of outputs to know the wallet balance. See this answer for import/export of outputs and key-images, which you'll also need to perform.

1There are multiple ways to create your view-only wallet, one example is via monero-wallet-cli --generate-from-view-key arg.

jtgrassie
  • 19,111
  • 4
  • 14
  • 51
  • But I haven't asked about monero-wallet-rpc. I've asked about RPC, and making requests to an RPC node – Kum Dec 02 '22 at 16:48
  • monero-wallet-rpc is the thing RPC you'd use. There are two different RPC interfaces with Monero: wallet and daemon. As you're asking about wallet functionality (balance), you use the wallet RPC. – jtgrassie Dec 02 '22 at 20:06
  • "But I haven't asked about monero-wallet-rpc" <- You have though. You used a link to the monero-wallet-rpc documentation in your question. – jtgrassie Dec 02 '22 at 20:16
  • Even if I asked about, now I'm saying: I'm not asking about wallet RPC. I'm asking about RPC on a remote node. – Kum Dec 03 '22 at 00:32
  • "remote node"s have no wallet level functionality. Your question specifically asks about the get_balance wallet RPC method. There is no daemon (remote or local) RPC method to get a wallets balance. – jtgrassie Dec 03 '22 at 05:33
  • I'm asking about get_balance. Whether it require or involve wallet or not -- I have no idea. What I do know is that I want to get a balance of a certain address. And preferably without having to get a wallet and wallet-cli into this in any way. That is, via remote RPC node. What will this be? – Kum Dec 04 '22 at 01:21
  • "I'm asking about get_balance."<- yes, I know, which as I've answered and commented, is a monero-wallet-rpc method. And monero-wallet-rpc operates on a wallet. There is no RPC method (wallet or domain) that has a method to get a balance with your private view key alone. – jtgrassie Dec 04 '22 at 03:01