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


Java Transaction.getValue方法代码示例

本文整理汇总了Java中org.bitcoinj.core.Transaction.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Transaction.getValue方法的具体用法?Java Transaction.getValue怎么用?Java Transaction.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bitcoinj.core.Transaction的用法示例。


在下文中一共展示了Transaction.getValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCoinsReceived

import org.bitcoinj.core.Transaction; //导入方法依赖的package包/类
/**
     *
     * @param wallet
     * @param tx
     * @param prevBalance
     * @param newBalance
     */
    @Override
    public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
        final Address address = WalletUtils.getWalletAddressOfReceived(tx, wallet);
        final Coin amount = tx.getValue(wallet);

        //final TransactionConfidence.ConfidenceType confidenceType = tx.getConfidence().getConfidenceType();

//        String addressStr = WalletUtils.formatAddress(address, Constants.ADDRESS_FORMAT_GROUP_SIZE, Constants.ADDRESS_FORMAT_LINE_SIZE).toString();
//        long value = amount.getValue();

//        for (CoinAction.CoinActionCallback<CurrencyCoin> callback : _callbacks) {
//            callback.onCoinsReceived(addressStr, value, _bitcoin);
//        }

        // meaning that we are receiving amount, not sending
        if (amount.isPositive()) {
          //  wallet.freshReceiveAddress();
        }
    }
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:27,代码来源:BitcoinManager.java

示例2: onCoinsReceived

import org.bitcoinj.core.Transaction; //导入方法依赖的package包/类
@Override
public void onCoinsReceived(final Wallet wallet, final Transaction tx, final Coin prevBalance,
        final Coin newBalance) {
    transactionsReceived.incrementAndGet();

    final int bestChainHeight = blockChain.getBestChainHeight();

    final Address address = WalletUtils.getWalletAddressOfReceived(tx, wallet);
    final Coin amount = tx.getValue(wallet);
    final ConfidenceType confidenceType = tx.getConfidence().getConfidenceType();
    final Sha256Hash hash = tx.getHash();

    handler.post(new Runnable() {
        @Override
        public void run() {
            final boolean isReceived = amount.signum() > 0;
            final boolean replaying = bestChainHeight < config.getBestChainHeightEver();
            final boolean isReplayedTx = confidenceType == ConfidenceType.BUILDING && replaying;

            if (isReceived && !isReplayedTx)
                notifyCoinsReceived(address, amount, hash);
        }
    });
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:25,代码来源:BlockchainServiceImpl.java

示例3: getTransactionList

import org.bitcoinj.core.Transaction; //导入方法依赖的package包/类
/**
 *
 */
@Override
public List<CoinTransaction> getTransactionList() {
    List<CoinTransaction> transactions = new ArrayList<>();

    Set<Transaction> txs = _coin.getWalletManager().wallet().getTransactions(true);
    for (Transaction tx : txs) {
        Coin amount = tx.getValue(_coin.getWalletManager().wallet());

        String hash = tx.getHash().toString();
        String amountStr = amount.toPlainString();
        String fee = "";
        String confirmationStr = "CONFIRMED";

        if (tx.getFee() != null) {
            fee = tx.getFee().toPlainString();
        }

        TransactionConfidence confidence = tx.getConfidence();
        if (confidence.getDepthInBlocks() < 6) {
            confirmationStr = confidence.getDepthInBlocks() + " CONFIRMATIONS";
        }

        TransactionConfidence.ConfidenceType cType = confidence.getConfidenceType();

        CoinTransaction coinTransaction = new CoinTransaction(fee, hash, amountStr, confirmationStr, tx.getUpdateTime());
        transactions.add(coinTransaction);
    }

    return transactions;
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:34,代码来源:BitcoinManager.java

示例4: bindView

import org.bitcoinj.core.Transaction; //导入方法依赖的package包/类
public void bindView(final View row, final Transaction tx) {
    final boolean isCoinBase = tx.isCoinBase();
    final boolean isInternal = tx.getPurpose() == Purpose.KEY_ROTATION;

    final Coin value = tx.getValue(wallet);
    final boolean sent = value.signum() < 0;
    final boolean self = WalletUtils.isEntirelySelf(tx, wallet);
    final Address address;
    if (sent)
        address = WalletUtils.getToAddressOfSent(tx, wallet);
    else
        address = WalletUtils.getWalletAddressOfReceived(tx, wallet);

    // receiving or sending
    final TextView rowFromTo = (TextView) row.findViewById(R.id.block_row_transaction_fromto);
    if (isInternal || self)
        rowFromTo.setText(R.string.symbol_internal);
    else if (sent)
        rowFromTo.setText(R.string.symbol_to);
    else
        rowFromTo.setText(R.string.symbol_from);

    // address
    final TextView rowAddress = (TextView) row.findViewById(R.id.block_row_transaction_address);
    final String label;
    if (isCoinBase)
        label = textCoinBase;
    else if (isInternal || self)
        label = textInternal;
    else if (address != null)
        label = AddressBookProvider.resolveLabel(context, address.toBase58());
    else
        label = "?";
    rowAddress.setText(label != null ? label : address.toBase58());
    rowAddress.setTypeface(label != null ? Typeface.DEFAULT : Typeface.MONOSPACE);

    // value
    final CurrencyTextView rowValue = (CurrencyTextView) row.findViewById(R.id.block_row_transaction_value);
    rowValue.setAlwaysSigned(true);
    rowValue.setFormat(format);
    rowValue.setAmount(value);
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:43,代码来源:BlockListAdapter.java


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