Skip to content

Commit

Permalink
Merge pull request #4910 from chimp1984/remove-log-entry
Browse files Browse the repository at this point in the history
Improve logs
  • Loading branch information
ripcurlx authored Dec 8, 2020
2 parents 2a2f05f + d0005e4 commit 89e5577
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 107 deletions.
1 change: 0 additions & 1 deletion common/src/main/java/bisq/common/setup/CommonSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public static void setupUncaughtExceptionHandler(UncaughtExceptionHandler uncaug
private static void setupLog(Config config) {
String logPath = Paths.get(config.appDataDir.getPath(), "bisq").toString();
Log.setup(logPath);
log.info("Log files under: {}", logPath);
Utilities.printSysInfo();
Log.setLevel(Level.toLevel(config.logLevel));
}
Expand Down
6 changes: 5 additions & 1 deletion core/src/main/java/bisq/core/btc/model/AddressEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,12 @@ public String getAddressString() {

@Nullable
public Address getAddress() {
if (address == null && keyPair != null)
if (address == null && keyPair != null) {
address = Address.fromKey(Config.baseCurrencyNetworkParameters(), keyPair, segwit ? Script.ScriptType.P2WPKH : Script.ScriptType.P2PKH);
}
if (address == null) {
log.warn("Address is null at getAddress(). keyPair={}", keyPair);
}
return address;
}

Expand Down
12 changes: 9 additions & 3 deletions core/src/main/java/bisq/core/btc/model/AddressEntryList.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,13 @@ public void onWalletReady(Wallet wallet) {
wallet.getIssuedReceiveAddresses().stream()
.filter(this::isAddressNotInEntries)
.forEach(address -> {
log.info("Create AddressEntry for IssuedReceiveAddress. address={}", address.toString());
DeterministicKey key = (DeterministicKey) wallet.findKeyFromAddress(address);
DeterministicKey key = (DeterministicKey) wallet.findKeyFromAddress(address);
if (key != null) {
// Address will be derived from key in getAddress method
log.info("Create AddressEntry for IssuedReceiveAddress. address={}", address.toString());
entrySet.add(new AddressEntry(key, AddressEntry.Context.AVAILABLE, address instanceof SegwitAddress));
} else {
log.warn("DeterministicKey for address {} is null", address);
}
});
}
Expand Down Expand Up @@ -190,6 +192,7 @@ public void addAddressEntry(AddressEntry addressEntry) {
return;
}

log.info("addAddressEntry: add new AddressEntry {}", addressEntry);
boolean setChangedByAdd = entrySet.add(addressEntry);
if (setChangedByAdd)
requestPersistence();
Expand All @@ -205,6 +208,7 @@ public void swapToAvailable(AddressEntry addressEntry) {
return;
}

log.info("swapToAvailable addressEntry to swap={}", addressEntry);
boolean setChangedByRemove = entrySet.remove(addressEntry);
boolean setChangedByAdd = entrySet.add(new AddressEntry(addressEntry.getKeyPair(),
AddressEntry.Context.AVAILABLE,
Expand All @@ -218,7 +222,8 @@ public AddressEntry swapAvailableToAddressEntryWithOfferId(AddressEntry addressE
AddressEntry.Context context,
String offerId) {
boolean setChangedByRemove = entrySet.remove(addressEntry);
final AddressEntry newAddressEntry = new AddressEntry(addressEntry.getKeyPair(), context, offerId, addressEntry.isSegwit());
AddressEntry newAddressEntry = new AddressEntry(addressEntry.getKeyPair(), context, offerId, addressEntry.isSegwit());
log.info("swapAvailableToAddressEntryWithOfferId newAddressEntry={}", newAddressEntry);
boolean setChangedByAdd = entrySet.add(newAddressEntry);
if (setChangedByRemove || setChangedByAdd)
requestPersistence();
Expand All @@ -232,6 +237,7 @@ public void setCoinLockedInMultiSigAddressEntry(AddressEntry addressEntry, long
return;
}

log.info("setCoinLockedInMultiSigAddressEntry addressEntry={}, value={}", addressEntry, value);
boolean setChangedByRemove = entrySet.remove(addressEntry);
AddressEntry entry = new AddressEntry(addressEntry.getKeyPair(),
addressEntry.getContext(),
Expand Down
57 changes: 43 additions & 14 deletions core/src/main/java/bisq/core/btc/setup/WalletConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,66 @@
import bisq.common.config.Config;
import bisq.common.file.FileUtil;

import com.google.common.io.Closeables;
import com.google.common.util.concurrent.*;
import org.bitcoinj.core.listeners.*;
import org.bitcoinj.core.*;
import org.bitcoinj.core.BlockChain;
import org.bitcoinj.core.CheckpointManager;
import org.bitcoinj.core.Context;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.PeerAddress;
import org.bitcoinj.core.PeerGroup;
import org.bitcoinj.core.listeners.DownloadProgressTracker;
import org.bitcoinj.crypto.KeyCrypter;
import org.bitcoinj.net.BlockingClientManager;
import org.bitcoinj.net.discovery.*;
import org.bitcoinj.net.discovery.DnsDiscovery;
import org.bitcoinj.net.discovery.PeerDiscovery;
import org.bitcoinj.script.Script;
import org.bitcoinj.store.*;
import org.bitcoinj.wallet.*;
import org.bitcoinj.store.BlockStore;
import org.bitcoinj.store.BlockStoreException;
import org.bitcoinj.store.SPVBlockStore;
import org.bitcoinj.wallet.DeterministicKeyChain;
import org.bitcoinj.wallet.DeterministicSeed;
import org.bitcoinj.wallet.KeyChainGroup;
import org.bitcoinj.wallet.KeyChainGroupStructure;
import org.bitcoinj.wallet.Protos;
import org.bitcoinj.wallet.Wallet;
import org.bitcoinj.wallet.WalletExtension;
import org.bitcoinj.wallet.WalletProtobufSerializer;

import com.runjva.sourceforge.jsocks.protocol.Socks5Proxy;

import com.google.common.io.Closeables;
import com.google.common.util.concurrent.AbstractIdleService;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;

import org.bouncycastle.crypto.params.KeyParameter;

import org.slf4j.*;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Proxy;

import javax.annotation.*;
import java.io.*;
import java.net.*;
import java.util.concurrent.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import java.util.concurrent.TimeUnit;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import lombok.Getter;
import lombok.Setter;

import javax.annotation.Nullable;

import static bisq.common.util.Preconditions.checkDir;
import static com.google.common.base.Preconditions.*;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;

/**
* <p>Utility class that wraps the boilerplate needed to set up a new SPV bitcoinj app. Instantiate it with a directory
Expand Down Expand Up @@ -233,7 +263,6 @@ protected void onSetupCompleted() {
protected void startUp() throws Exception {
// Runs in a separate thread.
Context.propagate(context);
log.info("Starting up with directory = {}", directory);
try {
File chainFile = new File(directory, filePrefix + ".spvchain");
boolean chainFileExists = chainFile.exists();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@
import org.bitcoinj.core.LegacyAddress;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.Sha256Hash;
import org.bitcoinj.script.ScriptException;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.core.TransactionConfidence;
import org.bitcoinj.core.TransactionInput;
import org.bitcoinj.core.TransactionOutPoint;
import org.bitcoinj.core.TransactionOutput;
import org.bitcoinj.script.ScriptException;
import org.bitcoinj.wallet.CoinSelection;
import org.bitcoinj.wallet.CoinSelector;
import org.bitcoinj.wallet.SendRequest;
Expand Down Expand Up @@ -565,6 +565,7 @@ private Transaction getPreparedSendTx(String receiverAddress, Coin receiverAmoun

return tx;
} catch (InsufficientMoneyException e) {
log.error("getPreparedSendTx: tx={}", tx.toString());
log.error(e.toString());
throw new InsufficientBsqException(e.missing);
}
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/bisq/core/btc/wallet/BtcWalletService.java
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ public AddressEntry getOrCreateAddressEntry(String offerId, AddressEntry.Context
} else {
DeterministicKey key = (DeterministicKey) wallet.findKeyFromAddress(wallet.freshReceiveAddress(Script.ScriptType.P2WPKH));
AddressEntry entry = new AddressEntry(key, context, offerId, true);
log.info("getOrCreateAddressEntry: new AddressEntry={}", entry);
addressEntryList.addAddressEntry(entry);
return entry;
}
Expand Down Expand Up @@ -689,6 +690,7 @@ private AddressEntry getOrCreateAddressEntry(AddressEntry.Context context,
key = (DeterministicKey) wallet.findKeyFromAddress(wallet.freshReceiveAddress(Script.ScriptType.P2PKH));
}
AddressEntry entry = new AddressEntry(key, context, segwit);
log.info("getOrCreateAddressEntry: add new AddressEntry {}", entry);
addressEntryList.addAddressEntry(entry);
return entry;
}
Expand Down
Loading

0 comments on commit 89e5577

Please sign in to comment.