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
10 changes: 8 additions & 2 deletions tools/src/main/java/org/bitcoinj/tools/BuildCheckpoints.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.bitcoinj.store.MemoryBlockStore;
import org.bitcoinj.utils.BriefLogFormatter;
import org.bitcoinj.utils.Threading;
import org.jspecify.annotations.Nullable;
import picocli.CommandLine;

import java.io.File;
Expand All @@ -50,6 +51,7 @@
import java.time.temporal.ChronoUnit;
import java.util.Base64;
import java.util.List;
import java.util.Objects;
import java.util.TreeMap;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
Expand All @@ -66,15 +68,15 @@ public class BuildCheckpoints implements Callable<Integer> {
@CommandLine.Option(names = "--net", description = "Which network to connect to. Valid values: ${COMPLETION-CANDIDATES}. Default: ${DEFAULT-VALUE}")
private BitcoinNetwork net = BitcoinNetwork.MAINNET;
@CommandLine.Option(names = "--peer", description = "IP address/domain name for connection instead of localhost.")
private String peer = null;
@Nullable private String peer = null;
@CommandLine.Option(names = "--days", description = "How many days to keep as a safety margin. Checkpointing will be done up to this many days ago.")
private int days = 7;
@CommandLine.Option(names = "--verbose", description = "Enables logging.")
private boolean verbose = false;
@CommandLine.Option(names = "--help", usageHelp = true, description = "Displays program options.")
private boolean help;

private static NetworkParameters params;
private static @Nullable NetworkParameters params;

public static void main(String[] args) throws Exception {
int exitCode = new CommandLine(new BuildCheckpoints()).execute(args);
Expand All @@ -90,6 +92,7 @@ public Integer call() throws Exception {

final String suffix;
params = NetworkParameters.of(net);
Objects.requireNonNull(params);
Context.propagate(new Context());

switch (net) {
Expand Down Expand Up @@ -156,6 +159,7 @@ public Integer call() throws Exception {
System.out.println("Checkpointing up to " + TimeUtils.dateTimeFormat(timeAgo));

chain.addNewBestBlockListener(Threading.SAME_THREAD, block -> {
Objects.requireNonNull(params);
int height = block.getHeight();
if (height % params.getInterval() == 0 && timeAgo.isAfter(block.getHeader().time())) {
System.out.println(String.format("Checkpointing block %s at height %d, time %s",
Expand Down Expand Up @@ -210,6 +214,7 @@ private static void writeTextualCheckpoints(TreeMap<Integer, StoredBlock> checkp
}

private static void sanityCheck(File file, int expectedSize) throws IOException {
Objects.requireNonNull(params);
FileInputStream fis = new FileInputStream(file);
CheckpointManager manager;
try {
Expand Down Expand Up @@ -239,6 +244,7 @@ private static void sanityCheck(File file, int expectedSize) throws IOException
}

private static void startPeerGroup(PeerGroup peerGroup, InetAddress ipAddress) {
Objects.requireNonNull(params);
final PeerAddress peerAddress = PeerAddress.simple(ipAddress, params.getPort());
System.out.println("Connecting to " + peerAddress + "...");
peerGroup.addAddress(peerAddress);
Expand Down
5 changes: 4 additions & 1 deletion tools/src/main/java/org/bitcoinj/tools/TestFeeLevel.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
import org.bitcoinj.wallet.KeyChainGroupStructure;
import org.bitcoinj.wallet.SendRequest;
import org.bitcoinj.wallet.Wallet;
import org.jspecify.annotations.Nullable;

import java.io.File;
import java.util.Objects;
import java.util.concurrent.ExecutionException;

/**
Expand All @@ -36,7 +38,7 @@
public class TestFeeLevel {

private static final int NUM_OUTPUTS = 2;
private static WalletAppKit kit;
private static @Nullable WalletAppKit kit;

public static void main(String[] args) throws Exception {
BriefLogFormatter.initWithSilentBitcoinJ();
Expand All @@ -60,6 +62,7 @@ public static void main(String[] args) throws Exception {
}

private static void go(Coin feeRateToTest, int numOutputs) throws InterruptedException, ExecutionException, InsufficientMoneyException {
Objects.requireNonNull(kit);
System.out.println("Wallet has " + kit.wallet().getBalance().toFriendlyString()
+ "; current receive address is " + kit.wallet().currentReceiveAddress());

Expand Down
23 changes: 23 additions & 0 deletions tools/src/main/java/org/bitcoinj/tools/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright by the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* <b>bitcoinj<b> tool utility applications.
*/
@NullMarked
package org.bitcoinj.tools;

import org.jspecify.annotations.NullMarked;
Loading