Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cj-btc-json/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
import net.ltgt.gradle.errorprone.CheckSeverity

plugins {
id 'java-library'
}
apply plugin: 'net.ltgt.errorprone'

ext.moduleName = 'org.consensusj.bitcoin.json'

dependencies {
api libs.jspecify
api libs.bitcoinj.core
api libs.jackson.core
api libs.jackson.databind

errorprone libs.errorprone.core
}

tasks.withType(JavaCompile) {
options.errorprone {
check("NullAway", CheckSeverity.ERROR)
option("NullAway:OnlyNullMarked")
}
}

jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.bitcoinj.crypto.ECKey;
import org.bitcoinj.base.Sha256Hash;
import org.bitcoinj.core.Transaction;
import org.jspecify.annotations.Nullable;

import java.util.Objects;

Expand All @@ -43,7 +44,7 @@ public RpcClientModule() {
* @param network Which network we are going to be a client for (may be null if {@code strictAddressParsing} is false)
* @param strictAddressParsing set to {@code true} to throw exceptions when deserializing addresses that don't match {@code network}
*/
protected RpcClientModule(Network network, boolean strictAddressParsing) {
protected RpcClientModule(@Nullable Network network, boolean strictAddressParsing) {
super("BitcoinJMappingClient", new Version(1, 0, 0, null, null, null));

this.addDeserializer(Address.class, strictAddressParsing ? new AddressDeserializer(Objects.requireNonNull(network)) : new AddressDeserializer())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@
/**
* Jackson JSON serializers, deserializers, modules, and utilities.
*/
package org.consensusj.bitcoin.json.conversion;
@NullMarked
package org.consensusj.bitcoin.json.conversion;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.bitcoinj.base.Address;
import org.bitcoinj.base.AddressParser;
import org.bitcoinj.base.Coin;
import org.jspecify.annotations.Nullable;

import java.util.List;

Expand All @@ -30,7 +31,7 @@ public class AddressGroupingItem {
private static final AddressParser addressParser = AddressParser.getDefault();
private final Address address;
private final Coin balance;
private final String account;
@Nullable private final String account;

public AddressGroupingItem(Address address, Coin balance, String account) {
this.address = address;
Expand All @@ -57,6 +58,7 @@ public Coin getBalance() {
return balance;
}

@Nullable
public String getAccount() {
return account;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import org.bitcoinj.base.Address;
import org.jspecify.annotations.Nullable;

public class AddressInfo {
private final Address address;
Expand All @@ -35,15 +36,16 @@
private final boolean iscompressed;
private final String label;
private final boolean ischange;
@Nullable
private final Instant timestamp;
private final List<Object> labels;

/**
*
* @param address

Check warning on line 45 in cj-btc-json/src/main/java/org/consensusj/bitcoin/json/pojo/AddressInfo.java

View workflow job for this annotation

GitHub Actions / JavadocAll ubuntu-24.04 JDK 25

[EmptyBlockTag] A block tag (@param, @return, @throws, @deprecated) has an empty description. Block tags without descriptions don't add much value for future readers of the code; consider removing the tag entirely or adding a description.
* @param ischange

Check warning on line 46 in cj-btc-json/src/main/java/org/consensusj/bitcoin/json/pojo/AddressInfo.java

View workflow job for this annotation

GitHub Actions / JavadocAll ubuntu-24.04 JDK 25

[EmptyBlockTag] A block tag (@param, @return, @throws, @deprecated) has an empty description. Block tags without descriptions don't add much value for future readers of the code; consider removing the tag entirely or adding a description.
* @param ismine

Check warning on line 47 in cj-btc-json/src/main/java/org/consensusj/bitcoin/json/pojo/AddressInfo.java

View workflow job for this annotation

GitHub Actions / JavadocAll ubuntu-24.04 JDK 25

[EmptyBlockTag] A block tag (@param, @return, @throws, @deprecated) has an empty description. Block tags without descriptions don't add much value for future readers of the code; consider removing the tag entirely or adding a description.
* @param label

Check warning on line 48 in cj-btc-json/src/main/java/org/consensusj/bitcoin/json/pojo/AddressInfo.java

View workflow job for this annotation

GitHub Actions / JavadocAll ubuntu-24.04 JDK 25

[EmptyBlockTag] A block tag (@param, @return, @throws, @deprecated) has an empty description. Block tags without descriptions don't add much value for future readers of the code; consider removing the tag entirely or adding a description.
* @param iswatchonly
* @param iswitness
* @param labels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.bitcoinj.base.Coin;
import org.bitcoinj.base.Sha256Hash;
import org.bitcoinj.core.Transaction;
import org.jspecify.annotations.Nullable;

import java.time.Instant;
import java.util.ArrayList;
Expand All @@ -33,14 +34,14 @@
/**
* RawTransaction POJO
*/
// "hash" property added (present in Bitcoin 0.13)
public class RawTransactionInfo {
private final String hex;
private final Sha256Hash txid;
private final long version;
private final LockTime lockTime;
private final List<Vin> vin;
private final List<Vout> vout;
@Nullable
private final Sha256Hash blockhash;
private final int confirmations;
private final Instant time;
Expand All @@ -50,7 +51,7 @@
public RawTransactionInfo(@JsonProperty("hex") String hex,
@JsonProperty("txid") Sha256Hash txid,
@JsonProperty("version") long version,
@JsonProperty("locktime") long locktime,

Check warning on line 54 in cj-btc-json/src/main/java/org/consensusj/bitcoin/json/pojo/RawTransactionInfo.java

View workflow job for this annotation

GitHub Actions / JavadocAll ubuntu-24.04 JDK 25

[InconsistentCapitalization] Found the field 'lockTime' with the same name as the parameter 'locktime' but with different capitalization.
@JsonProperty("vin") VinList vin,
@JsonProperty("vout") VoutList vout,
@JsonProperty("blockhash") Sha256Hash blockhash,
Expand Down Expand Up @@ -118,7 +119,7 @@
* @deprecated Use {@link #getLockTime()}
*/
@Deprecated
public long getLocktime() {

Check warning on line 122 in cj-btc-json/src/main/java/org/consensusj/bitcoin/json/pojo/RawTransactionInfo.java

View workflow job for this annotation

GitHub Actions / JavadocAll ubuntu-24.04 JDK 25

[InlineMeSuggester] This deprecated API looks inlineable. If you'd like the body of the API to be automatically inlined to its callers, please annotate it with @InlineMe. NOTE: the suggested fix makes the method final if it was not already.
return getLockTime().rawValue();
}

Expand All @@ -130,6 +131,7 @@
return vout;
}

@Nullable
public Sha256Hash getBlockhash() {
return blockhash;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
* <p>
* <a href="https://github.com/OmniLayer/omnicore/pull/1180">OmniCore PR #1180</a>
*/
package org.consensusj.bitcoin.json.pojo.bitcore;
package org.consensusj.bitcoin.json.pojo.bitcore;
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
/**
* POJOs definitions for JSON objects
*/
package org.consensusj.bitcoin.json.pojo;
package org.consensusj.bitcoin.json.pojo;
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -86,14 +87,14 @@ public interface TransportFactory {
private final JavaType defaultType;
private final JsonRpcTransport<JavaType> transport;

public DefaultRpcClient(URI server, final String rpcUser, final String rpcPassword) {
public DefaultRpcClient(URI server, @Nullable String rpcUser, @Nullable String rpcPassword) {
this(JsonRpcTransport.getDefaultSSLContext(), DEFAULT_JSON_RPC_VERSION, server, rpcUser, rpcPassword);
}

public DefaultRpcClient(JsonRpcMessage.Version jsonRpcVersion, URI server, final String rpcUser, final String rpcPassword) {
public DefaultRpcClient(JsonRpcMessage.Version jsonRpcVersion, URI server, @Nullable String rpcUser, @Nullable String rpcPassword) {
this(JsonRpcTransport.getDefaultSSLContext(), jsonRpcVersion, server, rpcUser, rpcPassword);
}
public DefaultRpcClient(SSLContext sslContext, JsonRpcMessage.Version jsonRpcVersion, URI server, final String rpcUser, final String rpcPassword) {
public DefaultRpcClient(SSLContext sslContext, JsonRpcMessage.Version jsonRpcVersion, URI server, @Nullable String rpcUser, @Nullable String rpcPassword) {
this((m) -> new JsonRpcClientJavaNet(m, sslContext, server, rpcUser, rpcPassword), jsonRpcVersion);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.consensusj.jsonrpc;

import org.jspecify.annotations.Nullable;

import java.io.IOException;
import java.lang.reflect.Type;
import java.util.Arrays;
Expand Down Expand Up @@ -84,15 +86,15 @@ default <R> CompletableFuture<R> sendAsync(String method, List<Object> params)
* @throws IOException network error
* @throws JsonRpcStatusException JSON RPC status error
*/
default Object send(String method, Object... params) throws IOException, JsonRpcStatusException {
default Object send(String method, @Nullable Object... params) throws IOException, JsonRpcStatusException {
return send(method, Arrays.asList(params));
}

default <R> R send(String method, Class<R> resultType, Object... params) throws IOException, JsonRpcStatusException {
default <R> R send(String method, Class<R> resultType, @Nullable Object... params) throws IOException, JsonRpcStatusException {
return send(method, resultType, Arrays.asList(params));
}

default <R> CompletableFuture<R> sendAsync(String method, Class<R> resultType, Object... params) {
default <R> CompletableFuture<R> sendAsync(String method, Class<R> resultType, @Nullable Object... params) {
return sendAsync(method, resultType, Arrays.asList(params));
}

Expand Down Expand Up @@ -132,11 +134,11 @@ default Object send(String method, T resultType, List<Object> params) throws IOE
/**
* Varargs version
*/
default Object send(String method, T resultType, Object... params) throws IOException, JsonRpcStatusException {
default Object send(String method, T resultType, @Nullable Object... params) throws IOException, JsonRpcStatusException {
return syncGet(sendRequestForResultAsync(buildJsonRequest(method, params), resultType));
}

default <R> CompletableFuture<R> sendAsync(String method, T resultType, Object... params) {
default <R> CompletableFuture<R> sendAsync(String method, T resultType, @Nullable Object... params) {
return sendRequestForResultAsync(buildJsonRequest(method, params), resultType);
}

Expand Down Expand Up @@ -167,7 +169,7 @@ default JsonRpcRequest buildJsonRequest(String method, List<Object> params) {
return new JsonRpcRequest(getJsonRpcVersion(), method, params);
}

default JsonRpcRequest buildJsonRequest(String method, Object... params) {
default JsonRpcRequest buildJsonRequest(String method, @Nullable Object... params) {
return new JsonRpcRequest(getJsonRpcVersion(), method, Arrays.asList(params));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -42,7 +43,9 @@ public class JsonRpcClientJavaNet implements JsonRpcTransport<JavaType> {

private final ObjectMapper mapper;
private final URI serverURI;
@Nullable
private final String username;
@Nullable
private final String password;
private final HttpClient client;
private static final String UTF8 = StandardCharsets.UTF_8.name();
Expand All @@ -52,7 +55,7 @@ public JsonRpcClientJavaNet(ObjectMapper mapper, URI server, final String rpcUse
this(mapper, JsonRpcTransport.getDefaultSSLContext(), server, rpcUser, rpcPassword);
}

public JsonRpcClientJavaNet(ObjectMapper mapper, SSLContext sslContext, URI server, final String rpcUser, final String rpcPassword) {
public JsonRpcClientJavaNet(ObjectMapper mapper, SSLContext sslContext, URI server, @Nullable String rpcUser, @Nullable String rpcPassword) {
log.debug("Constructing JSON-RPC client for: {}", server);
this.mapper = mapper;
this.serverURI = server;
Expand Down
Loading