本文整理汇总了Java中org.bitcoinj.core.TransactionOutput.isMine方法的典型用法代码示例。如果您正苦于以下问题:Java TransactionOutput.isMine方法的具体用法?Java TransactionOutput.isMine怎么用?Java TransactionOutput.isMine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bitcoinj.core.TransactionOutput
的用法示例。
在下文中一共展示了TransactionOutput.isMine方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getWalletAddressOfReceived
import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
@Nullable
public static Address getWalletAddressOfReceived(final Transaction tx, final Wallet wallet) {
for (final TransactionOutput output : tx.getOutputs()) {
try {
if (output.isMine(wallet)) {
final Script script = output.getScriptPubKey();
return script.getToAddress(Constants.NETWORK_PARAMETERS, true);
}
} catch (final ScriptException x) {
// swallow
}
}
return null;
}
示例2: getTotalReceived
import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
/**
* Returns the amount of bitcoin ever received via output. <b>This is not the balance!</b> If an output spends from a
* transaction whose inputs are also to our wallet, the input amounts are deducted from the outputs contribution, with a minimum of zero
* contribution. The idea behind this is we avoid double counting money sent to us.
* @return the total amount of satoshis received, regardless of whether it was spent or not.
*/
public Coin getTotalReceived() {
Coin total = Coin.ZERO;
// Include outputs to us if they were not just change outputs, ie the inputs to us summed to less
// than the outputs to us.
for (Transaction tx: transactions.values()) {
Coin txTotal = Coin.ZERO;
for (TransactionOutput output : tx.getOutputs()) {
if (output.isMine(this)) {
txTotal = txTotal.add(output.getValue());
}
}
for (TransactionInput in : tx.getInputs()) {
TransactionOutput prevOut = in.getConnectedOutput();
if (prevOut != null && prevOut.isMine(this)) {
txTotal = txTotal.subtract(prevOut.getValue());
}
}
if (txTotal.isPositive()) {
total = total.add(txTotal);
}
}
return total;
}
示例3: childPaysForParent
import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
/**
* Construct a SendRequest for a CPFP (child-pays-for-parent) transaction. The resulting transaction is already
* completed, so you should directly proceed to signing and broadcasting/committing the transaction. CPFP is
* currently only supported by a few miners, so use with care.
*/
public static SendRequest childPaysForParent(Wallet wallet, Transaction parentTransaction, Coin feeRaise) {
TransactionOutput outputToSpend = null;
for (final TransactionOutput output : parentTransaction.getOutputs()) {
if (output.isMine(wallet) && output.isAvailableForSpending()
&& output.getValue().isGreaterThan(feeRaise)) {
outputToSpend = output;
break;
}
}
// TODO spend another confirmed output of own wallet if needed
checkNotNull(outputToSpend, "Can't find adequately sized output that spends to us");
final Transaction tx = new Transaction(parentTransaction.getParams());
tx.addInput(outputToSpend);
tx.addOutput(outputToSpend.getValue().subtract(feeRaise), wallet.freshAddress(KeyPurpose.CHANGE));
tx.setPurpose(Transaction.Purpose.RAISE_FEE);
final SendRequest req = forTx(tx);
req.completed = true;
return req;
}
示例4: getToAddressOfSent
import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
@Nullable
public static Address getToAddressOfSent(final Transaction tx, final Wallet wallet)
{
for (final TransactionOutput output : tx.getOutputs())
{
try
{
if (!output.isMine(wallet))
{
final Script script = output.getScriptPubKey();
return script.getToAddress(Constants.NETWORK_PARAMETERS, true);
}
}
catch (final ScriptException x)
{
// swallow
}
}
return null;
}
示例5: getWalletAddressOfReceived
import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
@Nullable
public static Address getWalletAddressOfReceived(final Transaction tx, final Wallet wallet)
{
for (final TransactionOutput output : tx.getOutputs())
{
try
{
if (output.isMine(wallet))
{
final Script script = output.getScriptPubKey();
return script.getToAddress(Constants.NETWORK_PARAMETERS, true);
}
}
catch (final ScriptException x)
{
// swallow
}
}
return null;
}
示例6: getToAddressOfSent
import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
@Nullable
public static Address getToAddressOfSent(final Transaction tx, final Wallet wallet) {
for (final TransactionOutput output : tx.getOutputs()) {
try {
if (!output.isMine(wallet)) {
final Script script = output.getScriptPubKey();
return script.getToAddress(Constants.NETWORK_PARAMETERS, true);
}
} catch (final ScriptException x) {
// swallow
}
}
return null;
}
示例7: isEntirelySelf
import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
public static boolean isEntirelySelf(final Transaction tx, final Wallet wallet) {
for (final TransactionInput input : tx.getInputs()) {
final TransactionOutput connectedOutput = input.getConnectedOutput();
if (connectedOutput == null || !connectedOutput.isMine(wallet))
return false;
}
for (final TransactionOutput output : tx.getOutputs()) {
if (!output.isMine(wallet))
return false;
}
return true;
}
示例8: getTotalSent
import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
/**
* Returns the amount of bitcoin ever sent via output. If an output is sent to our own wallet, because of change or
* rotating keys or whatever, we do not count it. If the wallet was
* involved in a shared transaction, i.e. there is some input to the transaction that we don't have the key for, then
* we multiply the sum of the output values by the proportion of satoshi coming in to our inputs. Essentially we treat
* inputs as pooling into the transaction, becoming fungible and being equally distributed to all outputs.
* @return the total amount of satoshis sent by us
*/
public Coin getTotalSent() {
Coin total = Coin.ZERO;
for (Transaction tx: transactions.values()) {
// Count spent outputs to only if they were not to us. This means we don't count change outputs.
Coin txOutputTotal = Coin.ZERO;
for (TransactionOutput out : tx.getOutputs()) {
if (out.isMine(this) == false) {
txOutputTotal = txOutputTotal.add(out.getValue());
}
}
// Count the input values to us
Coin txOwnedInputsTotal = Coin.ZERO;
for (TransactionInput in : tx.getInputs()) {
TransactionOutput prevOut = in.getConnectedOutput();
if (prevOut != null && prevOut.isMine(this)) {
txOwnedInputsTotal = txOwnedInputsTotal.add(prevOut.getValue());
}
}
// If there is an input that isn't from us, i.e. this is a shared transaction
Coin txInputsTotal = tx.getInputSum();
if (txOwnedInputsTotal != txInputsTotal) {
// multiply our output total by the appropriate proportion to account for the inputs that we don't own
BigInteger txOutputTotalNum = new BigInteger(txOutputTotal.toString());
txOutputTotalNum = txOutputTotalNum.multiply(new BigInteger(txOwnedInputsTotal.toString()));
txOutputTotalNum = txOutputTotalNum.divide(new BigInteger(txInputsTotal.toString()));
txOutputTotal = Coin.valueOf(txOutputTotalNum.longValue());
}
total = total.add(txOutputTotal);
}
return total;
}
示例9: findSpendableOutput
import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
private static @Nullable TransactionOutput findSpendableOutput(final Wallet wallet, final Transaction transaction,
final Coin minimumOutputValue) {
for (final TransactionOutput output : transaction.getOutputs()) {
if (output.isMine(wallet) && output.isAvailableForSpending()
&& output.getValue().isGreaterThan(minimumOutputValue))
return output;
}
return null;
}
示例10: findSpendableOutput
import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
private static @Nullable TransactionOutput findSpendableOutput(final Wallet wallet, final Transaction transaction)
{
for (final TransactionOutput output : transaction.getOutputs())
{
if (output.isMine(wallet) && output.isAvailableForSpending() && output.getValue().isGreaterThan(FEE_RAISE))
return output;
}
return null;
}
示例11: getSenderHash
import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
private String getSenderHash(final List<TransactionOutput> outputs, final org.bitcoinj.core.Wallet wallet) {
for (final TransactionOutput o : outputs) {
if (o.isMine(wallet)) {
continue;
}
return o.getScriptPubKey().getToAddress(this.params).toString();
}
return null;
}
示例12: getTransaction
import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
private Transaction getTransaction(final List<TransactionOutput> outputs, final org.bitcoinj.core.Wallet wallet) {
for (final TransactionOutput o : outputs) {
if (!o.isMine(wallet)) {
continue;
}
final String hash = o.getScriptPubKey().getToAddress(this.params).toString();
final Transaction transaction = this.transactionService.getByReceiverHash(hash);
if (transaction != null) {
return transaction;
}
}
return null;
}
示例13: isTransactionOutputMine
import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
public boolean isTransactionOutputMine(TransactionOutput out)
{
return out.isMine(trackedWallet);
}