Skip to content

Commit f079fc1

Browse files
committed
GetInfo call impl.
1 parent c41c530 commit f079fc1

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>com.nitinsurana</groupId>
55
<artifactId>Litecoin-Bitcoin-RPC-Java-Connector</artifactId>
6-
<version>2.0.0</version>
6+
<version>2.0.1</version>
77
<packaging>jar</packaging>
88

99
<name>Litecoin-Bitcoin-RPC-Java-Connector</name>

src/main/java/com/nitinsurana/bitcoinlitecoin/rpcconnector/APICalls.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public enum APICalls {
2828
GET_RECEIVED_BY_ADDRESS("getreceivedbyaddress"),
2929
GET_BALANCE("getbalance"),
3030
GET_TRANSACTION("gettransaction"),
31+
GET_INFO("getinfo"),
3132
GET_CONNECTION_COUNT("getconnectioncount"),
3233
BACKUP_WALLET("backupwallet"),
3334
DECODE_RAW_TRANSACTION("decoderawtransaction"),

src/main/java/com/nitinsurana/bitcoinlitecoin/rpcconnector/CryptoCurrencyRPC.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,19 @@ public String getNewAddress() throws CryptoCurrencyRpcException {
190190
return jsonObj.get("result").getAsString();
191191
}
192192

193+
194+
/**
195+
* Returns an object containing various state info.
196+
*
197+
* @return
198+
* @throws com.nitinsurana.bitcoinlitecoin.rpcconnector.exception.CryptoCurrencyRpcException
199+
*/
200+
public String getInfo() throws CryptoCurrencyRpcException {
201+
JsonObject jsonObj = callAPIMethod(APICalls.GET_INFO);
202+
cryptoCurrencyRpcExceptionHandler.checkException(jsonObj);
203+
return jsonObj.get("result").getAsString();
204+
}
205+
193206
/**
194207
* Returns a new address for receiving payments.
195208
*
@@ -468,9 +481,9 @@ private JsonObject callAPIMethod(APICalls callMethod, Object... params) throws C
468481
WebResponse resp = client.getPage(req).getWebResponse();
469482
jsonObj = new JsonParser().parse(resp.getContentAsString()).getAsJsonObject();
470483

471-
StringBuffer buffer = new StringBuffer("");
484+
StringBuilder buffer = new StringBuilder("");
472485
for (Object item : params) {
473-
buffer.append(item.toString() + " | ");
486+
buffer.append(item).append(" | ");
474487
}
475488
LOG.info("Bitcoin RPC Request: Method: " + callMethod + " Params: " + buffer.toString() +
476489
"\nBitcoin RPC Response : " + jsonObj);

0 commit comments

Comments
 (0)