Skip to content

Commit

Permalink
Code polishing to make Codacy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarguindzberg committed Sep 9, 2020
1 parent b8fcb53 commit 47c011a
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 37 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ configure(project(':pricenode')) {

test {
useJUnitPlatform()

// Disabled by default, since spot provider tests include connections to external API endpoints
// Can be enabled by adding -Dtest.pricenode.includeSpotProviderTests=true to the gradle command:
// ./gradlew test -Dtest.pricenode.includeSpotProviderTests=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ public BisqKeyChainFactory(boolean isBsqWallet) {

@Override
public DeterministicKeyChain makeKeyChain(Protos.Key key, Protos.Key firstSubKey, DeterministicSeed seed, KeyCrypter crypter, boolean isMarried, Script.ScriptType outputScriptType, ImmutableList<ChildNumber> accountPath) {
ImmutableList<ChildNumber> maybeUpdatedAccountPath = accountPath;
if (DeterministicKeyChain.ACCOUNT_ZERO_PATH.equals(accountPath)) {
// This is a bitcoinj 0.14 wallet that has no account path in the serialized mnemonic
KeyChainGroupStructure structure = new BisqKeyChainGroupStructure(isBsqWallet);
accountPath = structure.accountPathFor(outputScriptType);
maybeUpdatedAccountPath = structure.accountPathFor(outputScriptType);
}

return super.makeKeyChain(key, firstSubKey, seed, crypter, isMarried, outputScriptType, accountPath);
return super.makeKeyChain(key, firstSubKey, seed, crypter, isMarried, outputScriptType, maybeUpdatedAccountPath);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import org.bitcoinj.crypto.ChildNumber;
import org.bitcoinj.script.Script;
import org.bitcoinj.wallet.DeterministicKeyChain;
import org.bitcoinj.wallet.KeyChainGroupStructure;

import com.google.common.collect.ImmutableList;
Expand Down
22 changes: 11 additions & 11 deletions core/src/main/java/bisq/core/btc/setup/WalletConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ protected List<WalletExtension> provideWalletExtensions() throws Exception {
* This method is invoked on a background thread after all objects are initialised, but before the peer group
* or block chain download is started. You can tweak the objects configuration here.
*/
protected void onSetupCompleted() { }
protected void onSetupCompleted() {
// Meant to be overridden by subclasses
}

/**
* Tests to see if the spvchain file has an operating system file lock on it. Useful for checking if your app
Expand Down Expand Up @@ -314,13 +316,13 @@ public boolean isChainFileLocked() throws IOException {
protected void startUp() throws Exception {
// Runs in a separate thread.
Context.propagate(context);
// bitcoinj's WalletAppKit creates the wallet directory if it was not created already,
// but WalletConfig should not do that.
// if (!directory.exists()) {
// if (!directory.mkdirs()) {
// throw new IOException("Could not create directory " + directory.getAbsolutePath());
// }
// }
// bitcoinj's WalletAppKit creates the wallet directory if it was not created already,
// but WalletConfig should not do that.
// if (!directory.exists()) {
// if (!directory.mkdirs()) {
// throw new IOException("Could not create directory " + directory.getAbsolutePath());
// }
// }
log.info("Starting up with directory = {}", directory);
try {
File chainFile = new File(directory, filePrefix + ".spvchain");
Expand Down Expand Up @@ -359,9 +361,7 @@ protected void startUp() throws Exception {
log.info("Clearing the chain file in preparation for restore.");
vStore.clear();
}
}
else
{
} else {
time = vBtcWallet.getEarliestKeyCreationTime();
}
if (time > 0)
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/bisq/core/btc/wallet/BisqRiskAnalysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ private Result analyzeIsFinal() {
if (tx.getConfidence().getSource() == TransactionConfidence.Source.SELF)
return Result.OK;

// Commented out to accept replace-by-fee txs.
// // We consider transactions that opt into replace-by-fee at risk of double spending.
// if (tx.isOptInFullRBF()) {
// nonFinal = tx;
// return Result.NON_FINAL;
// }
// Commented out to accept replace-by-fee txs.
// // We consider transactions that opt into replace-by-fee at risk of double spending.
// if (tx.isOptInFullRBF()) {
// nonFinal = tx;
// return Result.NON_FINAL;
// }

// Relative time-locked transactions are risky too. We can't check the locks because usually we don't know the
// spent outputs (to know when they were created).
Expand Down
10 changes: 0 additions & 10 deletions core/src/main/java/bisq/core/btc/wallet/BsqWalletService.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,19 @@
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.BlockChain;
import org.bitcoinj.core.Coin;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.InsufficientMoneyException;
import org.bitcoinj.core.LegacyAddress;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.Sha256Hash;
import org.bitcoinj.core.listeners.TransactionConfidenceEventListener;
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.Script;
import org.bitcoinj.wallet.CoinSelection;
import org.bitcoinj.wallet.CoinSelector;
import org.bitcoinj.wallet.SendRequest;
import org.bitcoinj.wallet.Wallet;
import org.bitcoinj.wallet.listeners.KeyChainEventListener;
import org.bitcoinj.wallet.listeners.ScriptsChangeEventListener;
import org.bitcoinj.wallet.listeners.WalletChangeEventListener;
import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
import org.bitcoinj.wallet.listeners.WalletCoinsSentEventListener;
import org.bitcoinj.wallet.listeners.WalletReorganizeEventListener;

import javax.inject.Inject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,8 @@

import bisq.common.util.Utilities;

import org.bitcoinj.core.Coin;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.core.TransactionConfidence;
import org.bitcoinj.core.listeners.TransactionConfidenceEventListener;
import org.bitcoinj.script.Script;
import org.bitcoinj.utils.Threading;
import org.bitcoinj.wallet.Wallet;
import org.bitcoinj.wallet.listeners.KeyChainEventListener;
import org.bitcoinj.wallet.listeners.ScriptsChangeEventListener;
import org.bitcoinj.wallet.listeners.WalletChangeEventListener;
Expand Down

0 comments on commit 47c011a

Please sign in to comment.