WalletAppKit: make Closeable

This commit is contained in:
Sean Gilligan 2023-03-26 10:20:33 -07:00 committed by Andreas Schildbach
parent 84c8a2887a
commit 884072c9e3
2 changed files with 8 additions and 2 deletions

View file

@ -46,6 +46,7 @@ import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@ -84,7 +85,7 @@ import static org.bitcoinj.base.internal.Preconditions.checkState;
* if anything goes wrong during startup - you should probably handle it and use {@link Exception#getCause()} to figure
* out what went wrong more precisely. Same thing if you just use the {@link #startAsync()} method.</p>
*/
public class WalletAppKit extends AbstractIdleService {
public class WalletAppKit extends AbstractIdleService implements Closeable {
protected static final Logger log = LoggerFactory.getLogger(WalletAppKit.class);
protected final BitcoinNetwork network;
@ -504,6 +505,11 @@ public class WalletAppKit extends AbstractIdleService {
}
}
@Override
public void close() {
stopAsync();
}
public BitcoinNetwork network() {
return network;
}

View file

@ -156,7 +156,7 @@ public class ForwardingService implements Closeable {
if (kit.isRunning()) {
kit.wallet().removeCoinsReceivedEventListener(listener);
}
kit.stopAsync();
kit.close();
}
/**