Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path). BitcoinJSONRPCClient异常、及其他异常

1、异常信息 Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path)

Exception in thread "main" wf.bitcoin.javabitcoindrpcclient.BitcoinRPCException: RPC Query Failed (method: getbalance, params: [], response code: 500 responseMessage Internal Server Error, response: {"result":null,"error":{"code":-19,"message":"Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path)."},"id":"1"}

    at wf.bitcoin.javabitcoindrpcclient.BitcoinJSONRPCClient.query(BitcoinJSONRPCClient.java:236)
    at wf.bitcoin.javabitcoindrpcclient.BitcoinJSONRPCClient.getBalance(BitcoinJSONRPCClient.java:294)
    at com.lpz.exchange.biz.TestBitcoinCore.javaBitcoin(TestBitcoinCore.java:46)
    at com.lpz.exchange.biz.TestBitcoinCore.main(TestBitcoinCore.java:74)

Process finished with exit code 1

原因:由于bitcoin core 客户端里面创建了多个钱包,java连接的时候未指明使用某个钱包而产生的

解决: URL url = new URL("http://user:password@127.0.0.1:18332");  在连接后面加上钱包名称

Eq: 我有个钱包名叫:lpz

那么连接就因该是: URL url = new URL("http://user:password@127.0.0.1:18332/wallet/lpz"); 在连接后面加上钱包名称

钱包里面有个默认的钱包,连接是就不加名称 URL url = new URL("http://user:password@127.0.0.1:18332/wallet/");

2、异常信息 Error: Please enter the wallet passphrase with walletpassphrase first.

Exception in thread "main" wf.bitcoin.javabitcoindrpcclient.BitcoinRPCException: RPC Query Failed (method: dumpprivkey, params: [2N1y1DGtXUbajM5SWyo9yRgiWAqQcPUyVEA], response code: 500 responseMessage Internal Server Error, response: {"result":null,"error":{"code":-13,"message":"Error: Please enter the wallet passphrase with walletpassphrase first."},"id":"1"}

    at wf.bitcoin.javabitcoindrpcclient.BitcoinJSONRPCClient.query(BitcoinJSONRPCClient.java:236)
    at com.lpz.exchange.biz.TestBitcoinCore.javaBitcoin(TestBitcoinCore.java:56)
    at com.lpz.exchange.biz.TestBitcoinCore.main(TestBitcoinCore.java:74)

Process finished with exit code 1

原因:调用dumppivkey (获取私钥) 的时候需要先输入钱包密码,没有输入密码就调用此方法抛出的异常

解决:在调用获取私钥方法之前输入钱包密码:bitcoinClient.walletPassPhrase("你的钱包密码",超时时间);

Eq:

 bitcoinClient.walletPassPhrase("lpz",60);
 String addressPrivateKey=bitcoinClient.query("dumpprivkey","2N1y1DGtXUbajM5SWyo9yRgiWAqQcPUyVEA").toString();
 logger.info("获取地址私钥:"+ addressPrivateKey);

还有其它的方法也是需要输入密码的,主要是看它提示什么,或者你在bitcoin core控制台线调用一下方法

posted @ 2019-05-22 13:07  iviv  阅读(2094)  评论(0编辑  收藏  举报