3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-07 14:54:15 +00:00

Move AllowUnconfirmedCoinSelector out into wallet package.

This commit is contained in:
Mike Hearn 2013-09-20 17:38:41 +02:00
parent 628aba15f8
commit 1f52b75ad9
3 changed files with 26 additions and 22 deletions

View File

@ -153,26 +153,6 @@ public class Wallet implements Serializable, BlockChainListener, PeerFilterProvi
private volatile long vKeyRotationTimestamp;
private volatile boolean vKeyRotationEnabled;
/**
* This coin selector will select any transaction at all, regardless of where it came from or whether it was
* confirmed yet. However immature coinbases will not be included (would be a protocol violation).
*/
public static class AllowUnconfirmedCoinSelector extends DefaultCoinSelector {
@Override protected boolean shouldSelect(Transaction tx) {
return true;
}
private static AllowUnconfirmedCoinSelector instance;
/** Returns a global static instance of the selector. */
public static AllowUnconfirmedCoinSelector get() {
// This doesn't have to be thread safe as the object has no state, so discarded duplicates are harmless.
if (instance == null)
instance = new AllowUnconfirmedCoinSelector();
return instance;
}
}
private transient CoinSelector coinSelector = new DefaultCoinSelector();
// The keyCrypter for the wallet. This specifies the algorithm used for encrypting and decrypting the private keys.
@ -2836,7 +2816,7 @@ public class Wallet implements Serializable, BlockChainListener, PeerFilterProvi
* be dangerous - only use this if you absolutely know what you're doing!
*/
public void allowSpendingUnconfirmedTransactions() {
setCoinSelector(Wallet.AllowUnconfirmedCoinSelector.get());
setCoinSelector(AllowUnconfirmedCoinSelector.get());
}
private static class BalanceFutureRequest {

View File

@ -20,6 +20,7 @@ import com.google.bitcoin.core.*;
import com.google.bitcoin.crypto.TransactionSignature;
import com.google.bitcoin.script.Script;
import com.google.bitcoin.script.ScriptBuilder;
import com.google.bitcoin.wallet.AllowUnconfirmedCoinSelector;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
@ -176,7 +177,7 @@ public class PaymentChannelClientState {
if (multisigOutput.getMinNonDustValue().compareTo(totalValue) > 0)
throw new ValueOutOfRangeException("totalValue too small to use");
Wallet.SendRequest req = Wallet.SendRequest.forTx(template);
req.coinSelector = Wallet.AllowUnconfirmedCoinSelector.get();
req.coinSelector = AllowUnconfirmedCoinSelector.get();
editContractSendRequest(req);
if (!wallet.completeTx(req))
throw new ValueOutOfRangeException("Cannot afford this channel");

View File

@ -0,0 +1,23 @@
package com.google.bitcoin.wallet;
import com.google.bitcoin.core.Transaction;
/**
* This coin selector will select any transaction at all, regardless of where it came from or whether it was
* confirmed yet. However immature coinbases will not be included (would be a protocol violation).
*/
public class AllowUnconfirmedCoinSelector extends DefaultCoinSelector {
@Override protected boolean shouldSelect(Transaction tx) {
return true;
}
private static AllowUnconfirmedCoinSelector instance;
/** Returns a global static instance of the selector. */
public static AllowUnconfirmedCoinSelector get() {
// This doesn't have to be thread safe as the object has no state, so discarded duplicates are harmless.
if (instance == null)
instance = new AllowUnconfirmedCoinSelector();
return instance;
}
}