ForwardingService: improve JavaDoc

This commit is contained in:
Sean Gilligan 2023-03-27 12:26:05 -07:00 committed by Andreas Schildbach
parent 7cd8f80e44
commit a0c5501b4b

View file

@ -40,8 +40,8 @@ import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
/** /**
* ForwardingService demonstrates basic usage of the library. It sits on the network and when it receives coins, simply * ForwardingService demonstrates basic usage of bitcoinj. It creates an SPV Wallet, listens on the network
* sends them onwards to an address given on the command line. * and when it receives coins, simply sends them onwards to the address given on the command line.
*/ */
public class ForwardingService implements Closeable { public class ForwardingService implements Closeable {
static final String USAGE = "Usage: address-to-forward-to [mainnet|testnet|signet|regtest]"; static final String USAGE = "Usage: address-to-forward-to [mainnet|testnet|signet|regtest]";
@ -52,6 +52,10 @@ public class ForwardingService implements Closeable {
private final WalletAppKit kit; private final WalletAppKit kit;
private final WalletCoinsReceivedEventListener listener; private final WalletCoinsReceivedEventListener listener;
/**
* Run the forwarding service as a command line tool
* @param args See {@link #USAGE}
*/
public static void main(String[] args) { public static void main(String[] args) {
// This line makes the log output more compact and easily read, especially when using the JDK log adapter. // This line makes the log output more compact and easily read, especially when using the JDK log adapter.
BriefLogFormatter.init(); BriefLogFormatter.init();
@ -139,9 +143,8 @@ public class ForwardingService implements Closeable {
} }
/** /**
* Implement the {@link WalletCoinsReceivedEventListener} functional interface. We could have {@link ForwardingService} * A listener to receive coins and forward them to the configured address.
* implement {@link WalletCoinsReceivedEventListener} with the {@code implements} keyword, but with JDK 8+ this method * Implements the {@link WalletCoinsReceivedEventListener} functional interface.
* can be private with any name and be referenced with a method reference.
* @param wallet The active wallet * @param wallet The active wallet
* @param incomingTx the received transaction * @param incomingTx the received transaction
* @param prevBalance wallet balance before this transaction (unused) * @param prevBalance wallet balance before this transaction (unused)