Skip to content

Commit

Permalink
chore: removed commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
HashEngineering committed Feb 2, 2023
1 parent 057d260 commit 2583b05
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 238 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -588,13 +588,9 @@ private boolean joinExistingQueue(Coin balanceNeedsAnonymized) {
timeLastSuccessfulStep.set(Utils.currentTimeSeconds());
log.info("coinjoin: pending connection (from queue): sessionDenom: {} ({}), addr={}",
sessionDenom, CoinJoin.denominationToString(sessionDenom), dmn.getService());
//strAutoDenomResult = "Trying to connect...";
//status.set(PoolStatus.CONNECTING);
setStatus(PoolStatus.CONNECTING);
return true;
}
//strAutoDenomResult = "Failed to find mixing queue to join";
//status.set(PoolStatus.WARN_NO_MIXING_QUEUES);
setStatus(PoolStatus.WARN_NO_MIXING_QUEUES);
return false;
}
Expand All @@ -613,9 +609,6 @@ private boolean startNewQueue(Coin balanceNeedsAnonymized) {
HashSet<Coin> setAmounts = new HashSet<>();
if (!mixingWallet.selectDenominatedAmounts(balanceNeedsAnonymized, setAmounts)) {
// this should never happen
//strAutoDenomResult = "Can't mix: no compatible inputs found!";
//log.error("coinjoin: error: {}", strAutoDenomResult);
//status.set(PoolStatus.ERR_NO_INPUTS);
setStatus(PoolStatus.ERR_NO_INPUTS);
return false;
}
Expand All @@ -625,9 +618,6 @@ private boolean startNewQueue(Coin balanceNeedsAnonymized) {
Masternode dmn = context.coinJoinManager.coinJoinClientManagers.get(mixingWallet.getDescription()).getRandomNotUsedMasternode();

if (dmn == null) {
//strAutoDenomResult = "Can't find random Masternode.";
//status.set(PoolStatus.ERR_MASTERNODE_NOT_FOUND);
//log.info("coinjoin: error: {}", strAutoDenomResult);
setStatus(PoolStatus.ERR_MASTERNODE_NOT_FOUND);
return false;
}
Expand Down Expand Up @@ -671,8 +661,6 @@ private boolean startNewQueue(Coin balanceNeedsAnonymized) {
timeLastSuccessfulStep.set(Utils.currentTimeSeconds());
log.info("coinjoin: start new queue -> pending connection, nSessionDenom: {} ({}), addr={}",
sessionDenom, CoinJoin.denominationToString(sessionDenom), dmn.getService());
//strAutoDenomResult = "Trying to connect...";
//status.set(PoolStatus.CONNECTING);
context.coinJoinManager.startAsync();
setStatus(PoolStatus.CONNECTING);
return true;
Expand Down Expand Up @@ -1232,9 +1220,6 @@ public boolean doAutomaticDenominating(boolean fDryRun) {
Coin balanceNeedsAnonymized;

if (!fDryRun && mixingWallet.isEncrypted()) {
//strAutoDenomResult = "Wallet is locked.";
//status.set(PoolStatus.ERR_WALLET_LOCKED);
//hasNothingToDo.set(true);
setStatus(PoolStatus.ERR_WALLET_LOCKED);
return false;
}
Expand Down Expand Up @@ -1290,10 +1275,6 @@ public boolean doAutomaticDenominating(boolean fDryRun) {

// mixable balance is way too small
if (nBalanceAnonymizable.isLessThan(nValueMin)) {
//strAutoDenomResult = "Not enough funds to mix.";
//log.info("coinjoin: {}", strAutoDenomResult);
//status.set(PoolStatus.ERR_NOT_ENOUGH_FUNDS);
//hasNothingToDo.set(true);
setStatus(PoolStatus.ERR_NOT_ENOUGH_FUNDS);
queueSessionCompleteListeners(ERR_SESSION);
return false;
Expand Down Expand Up @@ -1361,8 +1342,6 @@ public boolean doAutomaticDenominating(boolean fDryRun) {
}

if (sessionID.get() != 0) {
//strAutoDenomResult = "Mixing in progress...";
//status.set(PoolStatus.MIXING);
setStatus(PoolStatus.MIXING);
return false;
}
Expand Down Expand Up @@ -1414,9 +1393,7 @@ public boolean doAutomaticDenominating(boolean fDryRun) {
if (startNewQueue(balanceNeedsAnonymized)) {
return true;
}

//strAutoDenomResult = "No compatible Masternode found.";
//status.set(PoolStatus.WARN_NO_COMPATIBLE_MASTERNODE);

setStatus(PoolStatus.WARN_NO_COMPATIBLE_MASTERNODE);
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ protected UnmixedZeroConfCoinSelector() {
super();
}

/*public UnmixedZeroConfCoinSelector(Wallet wallet) {
super();
this.wallet = wallet;
this.onlyConfirmed = false;
}
public UnmixedZeroConfCoinSelector(Wallet wallet, boolean onlyConfirmed) {
this(wallet);
this.onlyConfirmed = onlyConfirmed;
}*/

@Override
public CoinSelection select(Coin target, List<TransactionOutput> candidates) {
CoinSelection selection = super.select(target, candidates);
Expand Down
200 changes: 1 addition & 199 deletions core/src/main/java/org/bitcoinj/wallet/WalletEx.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
public class WalletEx extends Wallet {
private static final Logger log = LoggerFactory.getLogger(WalletEx.class);

//protected KeyChainGroup coinJoinKeyChainGroup;
protected CoinJoinExtension coinjoin;

/**
Expand Down Expand Up @@ -218,8 +217,6 @@ public Coin getBalance(BalanceType balanceType) {
value = value.add(out.getValue());
}
return value;
//CoinSelection selection = new CoinJoinCoinSelector(this).select(NetworkParameters.MAX_MONEY, candidates);
//return selection.valueGathered;
} else if (balanceType == BalanceType.DENOMINATED || balanceType == BalanceType.DENOMINATED_SPENDABLE) {
List<TransactionOutput> candidates = calculateAllSpendCandidates(false, balanceType == BalanceType.DENOMINATED_SPENDABLE);
CoinSelection selection = DenominatedCoinSelector.get().select(MAX_MONEY, candidates);
Expand Down Expand Up @@ -620,7 +617,6 @@ public int countInputsWithAmount(Coin inputValue) {
return count;
}

// TODO: Do we need these lock functions
public boolean lockCoin(TransactionOutPoint outPoint) {
lockedCoinsSet.add(outPoint);
clearAnonymizableCaches();
Expand All @@ -632,7 +628,6 @@ public void unlockCoin(TransactionOutPoint outPoint) {
clearAnonymizableCaches();
}

//TODO: need to implement these methods
public Coin getAnonymizableBalance() {
return getAnonymizableBalance(false, true);
}
Expand Down Expand Up @@ -798,14 +793,7 @@ public void availableCoins(ArrayList<TransactionOutput> vCoins,
if (!allowUsedAddresses && isUsedDestination(wtxid, i)) {
continue;
}

// our TransactionOutput doesn't have a place to put these fields, add them?
//const SigningProvider * provider = GetSigningProvider();

//boolean solvable = provider ? IsSolvable( * provider, pcoin->tx -> vout[i].scriptPubKey) :false;
//boolean spendable = (mine || (((mine & ISMINE_WATCH_ONLY) != ISMINE_NO) && (coinControl && coinControl -> fAllowWatchOnly && solvable));

vCoins.add(coin.getOutput(i));//new TransactionOutput(params, coin, coin.getOutput(i).getValue(), coin.getOutput(i).getScriptBytes()));
vCoins.add(coin.getOutput(i));

// Checks the sum amount of all UTXO's.
if (nMinimumSumAmount != MAX_MONEY) {
Expand Down Expand Up @@ -936,192 +924,6 @@ public void reorganize(StoredBlock splitPoint, List<StoredBlock> oldBlocks, List
clearAnonymizableCaches();
}

/**
* Returns a list of all outputs that are being tracked by this wallet either from the {@link UTXOProvider}
* (in this case the existence or not of private keys is ignored), or the wallets internal storage (the default)
* taking into account the flags.
*
* @param excludeImmatureCoinbases Whether to ignore coinbase outputs that we will be able to spend in future once they mature.
* @param excludeUnsignable Whether to ignore outputs that we are tracking but don't have the keys to sign for.
*/
// public List<TransactionOutput> calculateAllSpendCandidates(boolean excludeImmatureCoinbases, boolean excludeUnsignable, boolean isCoinJoinOnly) {
// lock.lock();
// try {
// List<TransactionOutput> candidates;
// if (getUTXOProvider() == null) {
// candidates = new ArrayList<>(myUnspents.size());
// for (TransactionOutput output : myUnspents) {
// if (excludeUnsignable && !canSignFor(output.getScriptPubKey())) continue;
//
// // exclude non coinjoin outputs if isCoinJoinOnly is true
// // exclude coinjoin outputs when isCoinJoinOnly is false
// boolean isCoinJoin = output.isCoinJoin(this) && isFullyMixed(output);
//
// if (isCoinJoin != isCoinJoinOnly)
// continue;
//
// Transaction transaction = checkNotNull(output.getParentTransaction());
// if (excludeImmatureCoinbases && !transaction.isMature())
// continue;
//
// candidates.add(output);
// }
// } else {
// candidates = calculateAllSpendCandidatesFromUTXOProvider(excludeImmatureCoinbases);
// }
// return candidates;
// } finally {
// lock.unlock();
// }
// }

/**
* Returns the spendable coinjoin candidates from the {@link UTXOProvider} based on keys that the wallet contains.
* @return The list of candidates.
*/
// protected LinkedList<TransactionOutput> calculateAllCoinJoinSpendCandidatesFromUTXOProvider(boolean mixed) {
// checkState(lock.isHeldByCurrentThread());
// UTXOProvider utxoProvider = checkNotNull(getUTXOProvider(), "No UTXO provider has been set");
// LinkedList<TransactionOutput> candidates = Lists.newLinkedList();
// try {
// int chainHeight = utxoProvider.getChainHeadHeight();
// for (UTXO output : getStoredOutputsFromUTXOProvider()) {
// boolean coinbase = output.isCoinbase();
// // Do not try and spend coinbases, they cannot be coinjoin transactions.
// if (!coinbase) {
// // TODO deterimine if this item is a coinjoin transaction
// byte [] p2pkh = ScriptPattern.extractHashFromP2PKH(output.getScript());
// if (mixed && coinjoin.findKeyFromPubKey(p2pkh) != null) {
// candidates.add(new FreeStandingTransactionOutput(params, output, chainHeight));
// } else if (!mixed && CoinJoin.isDenominatedAmount(output.getValue())) {
// candidates.add(new FreeStandingTransactionOutput(params, output, chainHeight));
// }
// }
// }
// } catch (UTXOProviderException e) {
// throw new RuntimeException("UTXO provider error", e);
// }
// // We need to handle the pending transactions that we know about.
// for (Transaction tx : pending.values()) {
// // Remove the spent outputs.
// for (TransactionInput input : tx.getInputs()) {
// if (input.getConnectedOutput().isMine(this)) {
// candidates.remove(input.getConnectedOutput());
// }
// }
// // Add change outputs. Do not try and spend coinbases that were mined too recently, the protocol forbids it.
// if (tx.isMature()) {
// for (TransactionOutput output : tx.getOutputs()) {
// if (output.isAvailableForSpending() && output.isMine(this)) {
// candidates.add(output);
// }
// }
// }
// }
// return candidates;
// }

/**
* Returns a list of the outputs that can potentially be spent, i.e. that we have the keys for and are unspent
* according to our knowledge of the block chain.
*/
// public List<TransactionOutput> calculateAllSpendCandidates() {
// return calculateAllSpendCandidates(true, true, false);
// }

/**
* Returns a list of all outputs that are being tracked by this wallet either from the {@link UTXOProvider}
* (in this case the existence or not of private keys is ignored), or the wallets internal storage (the default)
* taking into account the flags.
*
* @param excludeImmatureCoinbases Whether to ignore coinbase outputs that we will be able to spend in future once they mature.
* @param excludeUnsignable Whether to ignore outputs that we are tracking but don't have the keys to sign for.
*/
// public List<TransactionOutput> calculateAllSpendCandidates(boolean excludeImmatureCoinbases, boolean excludeUnsignable, boolean isCoinJoin) {
// lock.lock();
// try {
// List<TransactionOutput> candidates;
// if (vUTXOProvider == null) {
// candidates = new ArrayList<>(myUnspents.size());
// for (TransactionOutput output : myUnspents) {
// if (excludeUnsignable && !canSignFor(output.getScriptPubKey())) continue;
// Transaction transaction = checkNotNull(output.getParentTransaction());
// if (excludeImmatureCoinbases && !transaction.isMature())
// continue;
//
// // exclude non coinjoin outputs if isCoinJoinOnly is true
// // exclude coinjoin outputs when isCoinJoinOnly is false
// boolean isOutputCoinJoin = output.isCoinJoin(this) && isFullyMixed(output);
//
// if (isCoinJoin != isOutputCoinJoin)
// continue;
//
// candidates.add(output);
// }
// } else {
// candidates = calculateAllSpendCandidatesFromUTXOProvider(excludeImmatureCoinbases, isCoinJoin);
// }
// return candidates;
// } finally {
// lock.unlock();
// }
// }
//
// @Override
// protected LinkedList<TransactionOutput> calculateAllSpendCandidatesFromUTXOProvider(boolean excludeImmatureCoinbases) {
// return calculateAllSpendCandidatesFromUTXOProvider(excludeImmatureCoinbases, false);
// }
/**
* Returns the spendable candidates from the {@link UTXOProvider} based on keys that the wallet contains.
* @return The list of candidates.
*/
// protected LinkedList<TransactionOutput> calculateAllSpendCandidatesFromUTXOProvider(boolean excludeImmatureCoinbases, boolean isCoinJoinOnly) {
// checkState(lock.isHeldByCurrentThread());
// UTXOProvider utxoProvider = checkNotNull(vUTXOProvider, "No UTXO provider has been set");
// LinkedList<TransactionOutput> candidates = Lists.newLinkedList();
// try {
// int chainHeight = utxoProvider.getChainHeadHeight();
// for (UTXO output : getStoredOutputsFromUTXOProvider()) {
// boolean coinjoin = false;
// if (ScriptPattern.isP2PKH(output.getScript()))
// coinjoin = isCoinJoinPubKeyHashMine(ScriptPattern.extractHashFromP2PKH(output.getScript()), Script.ScriptType.P2PKH);
// else if (ScriptPattern.isP2PK(output.getScript()))
// coinjoin = isCoinJoinPubKeyMine(ScriptPattern.extractKeyFromP2PK(output.getScript()));
// else if (ScriptPattern.isP2SH(output.getScript()))
// coinjoin = isCoinJoinPayToScriptHashMine(ScriptPattern.extractHashFromP2SH(output.getScript()));
//
// if (coinjoin != isCoinJoinOnly)
// continue;
// boolean coinbase = output.isCoinbase();
// int depth = chainHeight - output.getHeight() + 1; // the current depth of the output (1 = same as head).
// // Do not try and spend coinbases that were mined too recently, the protocol forbids it.
// if (!excludeImmatureCoinbases || !coinbase || depth >= params.getSpendableCoinbaseDepth()) {
// candidates.add(new FreeStandingTransactionOutput(params, output, chainHeight));
// }
// }
// } catch (UTXOProviderException e) {
// throw new RuntimeException("UTXO provider error", e);
// }
// // We need to handle the pending transactions that we know about.
// for (Transaction tx : pending.values()) {
// // Remove the spent outputs.
// for (TransactionInput input : tx.getInputs()) {
// if (input.getConnectedOutput().isMine(this)) {
// candidates.remove(input.getConnectedOutput());
// }
// }
// // Add change outputs. Do not try and spend coinbases that were mined too recently, the protocol forbids it.
// if (!excludeImmatureCoinbases || tx.isMature()) {
// for (TransactionOutput output : tx.getOutputs()) {
// if (output.isAvailableForSpending() && output.isMine(this) && output.isCoinJoin(this) == isCoinJoinOnly) {
// candidates.add(output);
// }
// }
// }
// }
// return candidates;
// }

public CoinJoinExtension getCoinJoin() {
return coinjoin;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ public void setUp() throws UnreadableWalletException {
.seed(seed)
.accountPath(DerivationPathFactory.get(TESTNET).bip44DerivationPath(0))
.build();
//coinJoin.getKeys(KeyChain.KeyPurpose.RECEIVE_FUNDS, 500);

wallet.addAndActivateHDChain(bip44);
wallet.initializeCoinJoin();
((WalletEx)wallet).coinjoin.getActiveKeyChain().getKeys(KeyChain.KeyPurpose.RECEIVE_FUNDS, 3000);
wallet.coinjoin.getActiveKeyChain().getKeys(KeyChain.KeyPurpose.RECEIVE_FUNDS, 3000);
wallet.addWalletTransaction(new WalletTransaction(WalletTransaction.Pool.SPENT, new Transaction(TESTNET, inputTx)));
ArrayList<Transaction> unspentTxList = Lists.newArrayList();

Expand Down
3 changes: 0 additions & 3 deletions tools/src/main/java/org/bitcoinj/tools/WalletTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -687,9 +687,6 @@ private static void addAddr() {

private static void send(List<String> outputs, Coin feePerKb, String lockTimeStr, boolean allowUnconfirmed, boolean isCoinJoin) throws VerificationException {
try {
//if (options.has(roundsFlag)) {
// CoinJoinClientOptions.setRounds(options.valueOf(roundsFlag));
//}
// Convert the input strings to outputs.
Transaction t = new Transaction(params);
for (String spec : outputs) {
Expand Down

0 comments on commit 2583b05

Please sign in to comment.