mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-14 19:25:51 +00:00
Move AllowUnconfirmedCoinSelector out into wallet package.
This commit is contained in:
parent
628aba15f8
commit
1f52b75ad9
@ -153,26 +153,6 @@ public class Wallet implements Serializable, BlockChainListener, PeerFilterProvi
|
|||||||
private volatile long vKeyRotationTimestamp;
|
private volatile long vKeyRotationTimestamp;
|
||||||
private volatile boolean vKeyRotationEnabled;
|
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();
|
private transient CoinSelector coinSelector = new DefaultCoinSelector();
|
||||||
|
|
||||||
// The keyCrypter for the wallet. This specifies the algorithm used for encrypting and decrypting the private keys.
|
// 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!
|
* be dangerous - only use this if you absolutely know what you're doing!
|
||||||
*/
|
*/
|
||||||
public void allowSpendingUnconfirmedTransactions() {
|
public void allowSpendingUnconfirmedTransactions() {
|
||||||
setCoinSelector(Wallet.AllowUnconfirmedCoinSelector.get());
|
setCoinSelector(AllowUnconfirmedCoinSelector.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class BalanceFutureRequest {
|
private static class BalanceFutureRequest {
|
||||||
|
@ -20,6 +20,7 @@ import com.google.bitcoin.core.*;
|
|||||||
import com.google.bitcoin.crypto.TransactionSignature;
|
import com.google.bitcoin.crypto.TransactionSignature;
|
||||||
import com.google.bitcoin.script.Script;
|
import com.google.bitcoin.script.Script;
|
||||||
import com.google.bitcoin.script.ScriptBuilder;
|
import com.google.bitcoin.script.ScriptBuilder;
|
||||||
|
import com.google.bitcoin.wallet.AllowUnconfirmedCoinSelector;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
@ -176,7 +177,7 @@ public class PaymentChannelClientState {
|
|||||||
if (multisigOutput.getMinNonDustValue().compareTo(totalValue) > 0)
|
if (multisigOutput.getMinNonDustValue().compareTo(totalValue) > 0)
|
||||||
throw new ValueOutOfRangeException("totalValue too small to use");
|
throw new ValueOutOfRangeException("totalValue too small to use");
|
||||||
Wallet.SendRequest req = Wallet.SendRequest.forTx(template);
|
Wallet.SendRequest req = Wallet.SendRequest.forTx(template);
|
||||||
req.coinSelector = Wallet.AllowUnconfirmedCoinSelector.get();
|
req.coinSelector = AllowUnconfirmedCoinSelector.get();
|
||||||
editContractSendRequest(req);
|
editContractSendRequest(req);
|
||||||
if (!wallet.completeTx(req))
|
if (!wallet.completeTx(req))
|
||||||
throw new ValueOutOfRangeException("Cannot afford this channel");
|
throw new ValueOutOfRangeException("Cannot afford this channel");
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user