当前位置: 首页>>代码示例>>Java>>正文


Java TransactionOutput.isMine方法代码示例

本文整理汇总了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;
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:16,代码来源:WalletUtils.java

示例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;
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:31,代码来源:Wallet.java

示例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;
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:26,代码来源:SendRequest.java

示例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;
}
 
开发者ID:soapboxsys,项目名称:ombuds-android,代码行数:22,代码来源:WalletUtils.java

示例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;
}
 
开发者ID:soapboxsys,项目名称:ombuds-android,代码行数:22,代码来源:WalletUtils.java

示例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;
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:16,代码来源:WalletUtils.java

示例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;
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:15,代码来源:WalletUtils.java

示例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;
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:45,代码来源:Wallet.java

示例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;
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:11,代码来源:RaiseFeeDialogFragment.java

示例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;
}
 
开发者ID:soapboxsys,项目名称:ombuds-android,代码行数:11,代码来源:RaiseFeeDialogFragment.java

示例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;
}
 
开发者ID:yopeio,项目名称:payment-api,代码行数:10,代码来源:WalletEventListener.java

示例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;
}
 
开发者ID:yopeio,项目名称:payment-api,代码行数:14,代码来源:WalletEventListener.java

示例13: isTransactionOutputMine

import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
public boolean isTransactionOutputMine(TransactionOutput out)
{
	return out.isMine(trackedWallet);
}
 
开发者ID:BitcoinAuthenticator,项目名称:Wallet,代码行数:5,代码来源:WalletWrapper.java


注:本文中的org.bitcoinj.core.TransactionOutput.isMine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。