public class SendRequest extends Object
Modifier and Type | Field and Description |
---|---|
org.spongycastle.crypto.params.KeyParameter |
aesKey
The AES key to use to decrypt the private keys before signing.
|
Address |
changeAddress
"Change" means the difference between the value gathered by a transactions inputs (the size of which you
don't really control as it depends on who sent you money), and the value being sent somewhere else.
|
CoinSelector |
coinSelector
If not null, the
CoinSelector to use instead of the wallets default. |
boolean |
emptyWallet
When emptyWallet is set, all coins selected by the coin selector are sent to the first output in tx
(its value is ignored and set to
Wallet.getBalance() - the fees required
for the transaction). |
boolean |
ensureMinRequiredFee
Requires that there be enough fee for a default Bitcoin Core to at least relay the transaction.
|
ExchangeRate |
exchangeRate
If not null, this exchange rate is recorded with the transaction during completion.
|
Coin |
feePerKb
A transaction can have a fee attached, which is defined as the difference between the input values
and output values.
|
String |
memo
If not null, this memo is recorded with the transaction during completion.
|
Wallet.MissingSigsMode |
missingSigsMode
Specifies what to do with missing signatures left after completing this request.
|
boolean |
shuffleOutputs
If true (the default), the outputs will be shuffled during completion to randomize the location of the change
output, if any.
|
boolean |
signInputs
If true (the default), the inputs will be signed.
|
Transaction |
tx
A transaction, probably incomplete, that describes the outline of what you want to do.
|
Modifier and Type | Method and Description |
---|---|
static SendRequest |
childPaysForParent(Wallet wallet,
Transaction parentTransaction,
Coin feeRaise)
Construct a SendRequest for a CPFP (child-pays-for-parent) transaction.
|
static SendRequest |
emptyWallet(Address destination) |
static SendRequest |
forTx(Transaction tx)
Simply wraps a pre-built incomplete transaction provided by you.
|
SendRequest |
fromPaymentDetails(Protos.PaymentDetails paymentDetails)
Copy data from payment request.
|
static SendRequest |
to(Address destination,
Coin value)
Creates a new SendRequest to the given address for the given value.
|
static SendRequest |
to(NetworkParameters params,
ECKey destination,
Coin value)
Creates a new SendRequest to the given pubkey for the given value.
|
static SendRequest |
toCLTVPaymentChannel(NetworkParameters params,
BigInteger time,
ECKey from,
ECKey to,
Coin value) |
static SendRequest |
toCLTVPaymentChannel(NetworkParameters params,
Date releaseTime,
ECKey from,
ECKey to,
Coin value) |
static SendRequest |
toCLTVPaymentChannel(NetworkParameters params,
int releaseBlock,
ECKey from,
ECKey to,
Coin value) |
String |
toString() |
public Transaction tx
A transaction, probably incomplete, that describes the outline of what you want to do. This typically will mean it has some outputs to the intended destinations, but no inputs or change address (and therefore no fees) - the wallet will calculate all that for you and update tx later.
Be careful when adding outputs that you check the min output value
(TransactionOutput.getMinNonDustValue(Coin)
) to avoid the whole transaction being rejected
because one output is dust.
If there are already inputs to the transaction, make sure their out point has a connected output,
otherwise their value will be added to fee. Also ensure they are either signed or are spendable by a wallet
key, otherwise the behavior of Wallet#completeTx(Wallet.SendRequest)
is undefined (likely
RuntimeException).
public boolean emptyWallet
Wallet.getBalance()
- the fees required
for the transaction). Any additional outputs are removed.public Address changeAddress
public Coin feePerKb
A transaction can have a fee attached, which is defined as the difference between the input values and output values. Any value taken in that is not provided to an output can be claimed by a miner. This is how mining is incentivized in later years of the Bitcoin system when inflation drops. It also provides a way for people to prioritize their transactions over others and is used as a way to make denial of service attacks expensive.
This is a dynamic fee (in satoshis) which will be added to the transaction for each kilobyte in size including the first. This is useful as as miners usually sort pending transactions by their fee per unit size when choosing which transactions to add to a block. Note that, to keep this equivalent to Bitcoin Core definition, a kilobyte is defined as 1000 bytes, not 1024.
public boolean ensureMinRequiredFee
Requires that there be enough fee for a default Bitcoin Core to at least relay the transaction. (ie ensure the transaction will not be outright rejected by the network). Defaults to true, you should only set this to false if you know what you're doing.
Note that this does not enforce certain fee rules that only apply to transactions which are larger than
26,000 bytes. If you get a transaction which is that large, you should set a feePerKb of at least
Transaction.REFERENCE_DEFAULT_MIN_TX_FEE
.
public boolean signInputs
public org.spongycastle.crypto.params.KeyParameter aesKey
public CoinSelector coinSelector
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.public boolean shuffleOutputs
public Wallet.MissingSigsMode missingSigsMode
Wallet.MissingSigsMode.THROW
).Wallet.MissingSigsMode
public ExchangeRate exchangeRate
public String memo
public static SendRequest to(Address destination, Coin value)
Creates a new SendRequest to the given address for the given value.
Be very careful when value is smaller than Transaction.MIN_NONDUST_OUTPUT
as the transaction will
likely be rejected by the network in this case.
public static SendRequest to(NetworkParameters params, ECKey destination, Coin value)
Creates a new SendRequest to the given pubkey for the given value.
Be careful to check the output's value is reasonable using
TransactionOutput.getMinNonDustValue(Coin)
afterwards or you risk having the transaction
rejected by the network. Note that using to(Address, Coin)
will result
in a smaller output, and thus the ability to use a smaller output value without rejection.
public static SendRequest forTx(Transaction tx)
public static SendRequest emptyWallet(Address destination)
public static SendRequest childPaysForParent(Wallet wallet, Transaction parentTransaction, Coin feeRaise)
public static SendRequest toCLTVPaymentChannel(NetworkParameters params, Date releaseTime, ECKey from, ECKey to, Coin value)
public static SendRequest toCLTVPaymentChannel(NetworkParameters params, int releaseBlock, ECKey from, ECKey to, Coin value)
public static SendRequest toCLTVPaymentChannel(NetworkParameters params, BigInteger time, ECKey from, ECKey to, Coin value)
public SendRequest fromPaymentDetails(Protos.PaymentDetails paymentDetails)
Copyright © 2016. All rights reserved.