本文整理汇总了Java中org.bitcoinj.core.Coin.isPositive方法的典型用法代码示例。如果您正苦于以下问题:Java Coin.isPositive方法的具体用法?Java Coin.isPositive怎么用?Java Coin.isPositive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bitcoinj.core.Coin
的用法示例。
在下文中一共展示了Coin.isPositive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCoinsReceived
import org.bitcoinj.core.Coin; //导入方法依赖的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();
}
}
示例2: getTotalReceived
import org.bitcoinj.core.Coin; //导入方法依赖的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: handleMaybeShowNotification
import org.bitcoinj.core.Coin; //导入方法依赖的package包/类
private void handleMaybeShowNotification() {
final Coin estimatedBalance = wallet.getBalance(BalanceType.ESTIMATED_SPENDABLE);
if (estimatedBalance.isPositive()) {
log.info("detected balance, showing inactivity notification");
final Coin availableBalance = wallet.getBalance(BalanceType.AVAILABLE_SPENDABLE);
final boolean canDonate = Constants.DONATION_ADDRESS != null && availableBalance.isPositive();
final MonetaryFormat btcFormat = config.getFormat();
final String title = getString(R.string.notification_inactivity_title);
final StringBuilder text = new StringBuilder(
getString(R.string.notification_inactivity_message, btcFormat.format(estimatedBalance)));
if (canDonate)
text.append("\n\n").append(getString(R.string.notification_inactivity_message_donate));
final Intent dismissIntent = new Intent(this, InactivityNotificationService.class);
dismissIntent.setAction(ACTION_DISMISS);
final Intent dismissForeverIntent = new Intent(this, InactivityNotificationService.class);
dismissForeverIntent.setAction(ACTION_DISMISS_FOREVER);
final Intent donateIntent = new Intent(this, InactivityNotificationService.class);
donateIntent.setAction(ACTION_DONATE);
final NotificationCompat.Builder notification = new NotificationCompat.Builder(this,
Constants.NOTIFICATION_CHANNEL_ID_IMPORTANT);
notification.setStyle(new NotificationCompat.BigTextStyle().bigText(text));
notification.setSmallIcon(R.drawable.stat_notify_received_24dp);
notification.setContentTitle(title);
notification.setContentText(text);
notification
.setContentIntent(PendingIntent.getActivity(this, 0, new Intent(this, WalletActivity.class), 0));
notification.setAutoCancel(true);
if (!canDonate)
notification.addAction(new NotificationCompat.Action.Builder(0,
getString(R.string.notification_inactivity_action_dismiss),
PendingIntent.getService(this, 0, dismissIntent, 0)).build());
notification.addAction(new NotificationCompat.Action.Builder(0,
getString(R.string.notification_inactivity_action_dismiss_forever),
PendingIntent.getService(this, 0, dismissForeverIntent, 0)).build());
if (canDonate)
notification
.addAction(new NotificationCompat.Action.Builder(0, getString(R.string.wallet_options_donate),
PendingIntent.getService(this, 0, donateIntent, 0)).build());
nm.notify(Constants.NOTIFICATION_ID_INACTIVITY, notification.build());
}
}