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?

1 Answer 1

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.

7
  • But I haven't asked about monero-wallet-rpc. I've asked about RPC, and making requests to an RPC node
    – Kum
    Commented Dec 2, 2022 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
    Commented Dec 2, 2022 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
    Commented Dec 2, 2022 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
    Commented Dec 3, 2022 at 0: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
    Commented Dec 3, 2022 at 5:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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