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


Java Coin.signum方法代码示例

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


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

示例1: getAmount

import org.bitcoinj.core.Coin; //导入方法依赖的package包/类
public Coin getAmount() {
    Coin amount = Coin.ZERO;

    if (hasOutputs())
        for (final Output output : outputs)
            if (output.hasAmount())
                amount = amount.add(output.amount);

    if (amount.signum() != 0)
        return amount;
    else
        return null;
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:14,代码来源:PaymentIntent.java

示例2: convertToBitcoinURI

import org.bitcoinj.core.Coin; //导入方法依赖的package包/类
/**
 * Simple Bitcoin URI builder using known good fields.
 *
 * @param params The network parameters that determine which network the URI
 * is for.
 * @param address The Bitcoin address
 * @param amount The amount
 * @param label A label
 * @param message A message
 * @return A String containing the Bitcoin URI
 */
public static String convertToBitcoinURI(NetworkParameters params,
                                         String address, @Nullable Coin amount,
                                         @Nullable String label, @Nullable String message) {
    checkNotNull(params);
    checkNotNull(address);
    if (amount != null && amount.signum() < 0) {
        throw new IllegalArgumentException("Coin must be positive");
    }
    
    StringBuilder builder = new StringBuilder();
    String scheme = params.getUriScheme();
    builder.append(scheme).append(":").append(address);
    
    boolean questionMarkHasBeenOutput = false;
    
    if (amount != null) {
        builder.append(QUESTION_MARK_SEPARATOR).append(FIELD_AMOUNT).append("=");
        builder.append(amount.toPlainString());
        questionMarkHasBeenOutput = true;
    }
    
    if (label != null && !"".equals(label)) {
        if (questionMarkHasBeenOutput) {
            builder.append(AMPERSAND_SEPARATOR);
        } else {
            builder.append(QUESTION_MARK_SEPARATOR);                
            questionMarkHasBeenOutput = true;
        }
        builder.append(FIELD_LABEL).append("=").append(encodeURLString(label));
    }
    
    if (message != null && !"".equals(message)) {
        if (questionMarkHasBeenOutput) {
            builder.append(AMPERSAND_SEPARATOR);
        } else {
            builder.append(QUESTION_MARK_SEPARATOR);
        }
        builder.append(FIELD_MESSAGE).append("=").append(encodeURLString(message));
    }
    
    return builder.toString();
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:54,代码来源:BitcoinURI.java

示例3: bindView

import org.bitcoinj.core.Coin; //导入方法依赖的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.Coin.signum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。