mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-14 19:25:51 +00:00
Wallet: Split CoinSelector out into a top level interface in the wallet package.
This commit is contained in:
parent
efb6349a50
commit
c4405d3ee7
@ -423,7 +423,7 @@ public class TransactionConfidence implements Serializable {
|
||||
/**
|
||||
* The source of a transaction tries to identify where it came from originally. For instance, did we download it
|
||||
* from the peer to peer network, or make it ourselves, or receive it via Bluetooth, or import it from another app,
|
||||
* and so on. This information is useful for {@link Wallet.CoinSelector} implementations to risk analyze
|
||||
* and so on. This information is useful for {@link com.google.bitcoin.wallet.CoinSelector} implementations to risk analyze
|
||||
* transactions and decide when to spend them.
|
||||
*/
|
||||
public synchronized Source getSource() {
|
||||
@ -433,7 +433,7 @@ public class TransactionConfidence implements Serializable {
|
||||
/**
|
||||
* The source of a transaction tries to identify where it came from originally. For instance, did we download it
|
||||
* from the peer to peer network, or make it ourselves, or receive it via Bluetooth, or import it from another app,
|
||||
* and so on. This information is useful for {@link Wallet.CoinSelector} implementations to risk analyze
|
||||
* and so on. This information is useful for {@link com.google.bitcoin.wallet.CoinSelector} implementations to risk analyze
|
||||
* transactions and decide when to spend them.
|
||||
*/
|
||||
public synchronized void setSource(Source source) {
|
||||
|
@ -25,6 +25,7 @@ import com.google.bitcoin.store.UnreadableWalletException;
|
||||
import com.google.bitcoin.store.WalletProtobufSerializer;
|
||||
import com.google.bitcoin.utils.ListenerRegistration;
|
||||
import com.google.bitcoin.utils.Threading;
|
||||
import com.google.bitcoin.wallet.CoinSelector;
|
||||
import com.google.bitcoin.wallet.KeyTimeCoinSelector;
|
||||
import com.google.bitcoin.wallet.WalletFiles;
|
||||
import com.google.common.base.Preconditions;
|
||||
@ -164,16 +165,6 @@ public class Wallet implements Serializable, BlockChainListener, PeerFilterProvi
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A CoinSelector is responsible for picking some outputs to spend, from the list of all spendable outputs. It
|
||||
* allows you to customize the policies for creation of transactions to suit your needs. The select operation
|
||||
* may return a {@link CoinSelection} that has a valueGathered lower than the requested target, if there's not
|
||||
* enough money in the wallet.
|
||||
*/
|
||||
public interface CoinSelector {
|
||||
public CoinSelection select(BigInteger target, LinkedList<TransactionOutput> candidates);
|
||||
}
|
||||
|
||||
/**
|
||||
* This class implements a {@link CoinSelector} which attempts to get the highest priority possible. This means that
|
||||
* the transaction is the most likely to get confirmed
|
||||
@ -1636,7 +1627,7 @@ public class Wallet implements Serializable, BlockChainListener, PeerFilterProvi
|
||||
public KeyParameter aesKey = null;
|
||||
|
||||
/**
|
||||
* If not null, the {@link Wallet.CoinSelector} to use instead of the wallets default. Coin selectors are
|
||||
* If not null, the {@link com.google.bitcoin.wallet.CoinSelector} to use instead of the wallets default. Coin selectors are
|
||||
* responsible for choosing which transaction outputs (coins) in a wallet to use given the desired send value
|
||||
* amount.
|
||||
*/
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.google.bitcoin.wallet;
|
||||
|
||||
import com.google.bitcoin.core.TransactionOutput;
|
||||
import com.google.bitcoin.core.Wallet;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* A CoinSelector is responsible for picking some outputs to spend, from the list of all spendable outputs. It
|
||||
* allows you to customize the policies for creation of transactions to suit your needs. The select operation
|
||||
* may return a {@link com.google.bitcoin.core.Wallet.CoinSelection} that has a valueGathered lower than the requested target, if there's not
|
||||
* enough money in the wallet.
|
||||
*/
|
||||
public interface CoinSelector {
|
||||
public Wallet.CoinSelection select(BigInteger target, LinkedList<TransactionOutput> candidates);
|
||||
}
|
@ -29,7 +29,7 @@ import java.util.LinkedList;
|
||||
* A coin selector that takes all coins assigned to keys created before the given timestamp.
|
||||
* Used as part of the implementation of {@link Wallet#setKeyRotationTime(java.util.Date)}.
|
||||
*/
|
||||
public class KeyTimeCoinSelector implements Wallet.CoinSelector {
|
||||
public class KeyTimeCoinSelector implements CoinSelector {
|
||||
private static final Logger log = LoggerFactory.getLogger(KeyTimeCoinSelector.class);
|
||||
|
||||
/** A number of inputs chosen to avoid hitting {@link com.google.bitcoin.core.Transaction.MAX_STANDARD_TX_SIZE} */
|
||||
|
Loading…
x
Reference in New Issue
Block a user