woodser / monero-java

Java library for using Monero
https://woodser.github.io/monero-java/javadocs/
MIT License
105 stars 39 forks source link

Exception in example #58

Closed bigBonSlime closed 1 year ago

bigBonSlime commented 1 year ago

I tried to run the following code:

        MoneroWalletRpc walletRpc = new MoneroWalletRpc("xmr-node.cakewallet.com:18081");
        walletRpc.openWallet("name", "pass");
        String primaryAddress = walletRpc.getPrimaryAddress(); 
        BigInteger balance = walletRpc.getBalance();           
        List<MoneroTxWallet> txs = walletRpc.getTxs();         

,And get the following error:

Exception in thread "main" -32601: Method not found
RPC request: 'open_wallet' with params: {"password":"pass","filename":"name"}
    at monero.common.MoneroRpcConnection.validateRpcResponse(MoneroRpcConnection.java:603)
    at monero.common.MoneroRpcConnection.sendJsonRequest(MoneroRpcConnection.java:363)
    at monero.common.MoneroRpcConnection.sendJsonRequest(MoneroRpcConnection.java:305)
    at monero.wallet.MoneroWalletRpc.openWallet(MoneroWalletRpc.java:299)
    at monero.wallet.MoneroWalletRpc.openWallet(MoneroWalletRpc.java:258)
    at org.example.Main.main(Main.java:23)
woodser commented 1 year ago

MoneroWalletRpc should be initialized with a connection to a monero-wallet-rpc server, not monerod. Then you can create a wallet with a connection to monerod.

bigBonSlime commented 1 year ago

Thanks