/** Alias for add */ public Coin plus(final Coin value) { return add(value); }
/** Alias for add */ public Coin plus(final Coin value) { return add(value); }
/** Alias for add */ public Coin plus(final Coin value) { return add(value); }
/** * Gets the sum of the outputs of the transaction. If the outputs are less than the inputs, it does not count the fee. * @return the sum of the outputs regardless of who owns them. */ public Coin getOutputSum() { Coin totalOut = Coin.ZERO; for (TransactionOutput output: outputs) { totalOut = totalOut.add(output.getValue()); } return totalOut; }
/** * Gets the sum of the outputs of the transaction. If the outputs are less than the inputs, it does not count the fee. * @return the sum of the outputs regardless of who owns them. */ public Coin getOutputSum() { Coin totalOut = Coin.ZERO; for (TransactionOutput output: outputs) { totalOut = totalOut.add(output.getValue()); } return totalOut; }
/** * Gets the sum of the inputs, regardless of who owns them. */ public Coin getInputSum() { Coin inputTotal = Coin.ZERO; for (TransactionInput input: inputs) { Coin inputValue = input.getValue(); if (inputValue != null) { inputTotal = inputTotal.add(inputValue); } } return inputTotal; }
/** * Gets the sum of the outputs of the transaction. If the outputs are less than the inputs, it does not count the fee. * @return the sum of the outputs regardless of who owns them. */ public Coin getOutputSum() { Coin totalOut = Coin.ZERO; for (TransactionOutput output: outputs) { totalOut = totalOut.add(output.getValue()); } return totalOut; }
/** * Gets the sum of the outputs of the transaction. If the outputs are less than the inputs, it does not count the fee. * @return the sum of the outputs regardless of who owns them. */ public Coin getOutputSum() { Coin totalOut = Coin.ZERO; for (TransactionOutput output: outputs) { totalOut = totalOut.add(output.getValue()); } return totalOut; }
/** * Convert an amount expressed in the way humans are used to into satoshis. */ public static Coin valueOf(final int coins, final int cents) { checkArgument(cents < 100); checkArgument(cents >= 0); checkArgument(coins >= 0); final Coin coin = COIN.multiply(coins).add(CENT.multiply(cents)); return coin; }
/** * Convert an amount expressed in the way humans are used to into satoshis. */ public static Coin valueOf(final int coins, final int cents) { checkArgument(cents < 100); checkArgument(cents >= 0); checkArgument(coins >= 0); final Coin coin = COIN.multiply(coins).add(CENT.multiply(cents)); return coin; }
/** * Convert an amount expressed in the way humans are used to into satoshis. */ public static Coin valueOf(final int coins, final int cents) { checkArgument(cents < 100); checkArgument(cents >= 0); checkArgument(coins >= 0); final Coin coin = COIN.multiply(coins).add(CENT.multiply(cents)); return coin; }
/** * Convert an amount expressed in the way humans are used to into satoshis. */ public static Coin valueOf(final int coins, final int cents) { checkArgument(cents < 100); checkArgument(cents >= 0); checkArgument(coins >= 0); final Coin coin = COIN.multiply(coins).add(CENT.multiply(cents)); return coin; }
/** * Calculates the sum of the outputs that are sending coins to a key in the wallet. */ public Coin getValueSentToMe(TransactionBag transactionBag) { // This is tested in WalletTest. Coin v = Coin.ZERO; for (TransactionOutput o : outputs) { if (!o.isMineOrWatched(transactionBag)) continue; v = v.add(o.getValue()); } return v; }
/** * Calculates the sum of the outputs that are sending coins to a key in the wallet. */ public Coin getValueSentToMe(TransactionBag transactionBag) { // This is tested in WalletTest. Coin v = Coin.ZERO; for (TransactionOutput o : outputs) { if (!o.isMineOrWatched(transactionBag)) continue; v = v.add(o.getValue()); } return v; }
/** * Calculates the sum of the outputs that are sending coins to a key in the wallet. */ public Coin getValueSentToMe(TransactionBag transactionBag) { // This is tested in WalletTest. Coin v = Coin.ZERO; for (TransactionOutput o : outputs) { if (!o.isMineOrWatched(transactionBag)) continue; v = v.add(o.getValue()); } return v; }
/** * Calculates the sum of the outputs that are sending coins to a key in the wallet. */ public Coin getValueSentToMe(TransactionBag transactionBag) { // This is tested in WalletTest. Coin v = Coin.ZERO; for (TransactionOutput o : outputs) { if (!o.isMineOrWatched(transactionBag)) continue; v = v.add(o.getValue()); } return v; }
private void waitForSufficientBalance(Coin amount) { // Not enough money in the wallet. Coin amountPlusFee = amount.add(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE); // ESTIMATED because we don't really need to wait for confirmation. ListenableFuture<Coin> balanceFuture = appKit.wallet().getBalanceFuture(amountPlusFee, Wallet.BalanceType.ESTIMATED); if (!balanceFuture.isDone()) { System.out.println("Please send " + amountPlusFee.toFriendlyString() + " to " + myKey.toAddress(params)); Futures.getUnchecked(balanceFuture); } } }
@Test(expected = ArithmeticException.class) public void testAdditionOverflow() { Coin.valueOf(Long.MAX_VALUE).add(Coin.SATOSHI); }
@Test(expected = VerificationException.ExcessiveValue.class) public void exceedsMaxMoney2() throws Exception { Coin half = PARAMS.getMaxMoney().divide(2).add(Coin.SATOSHI); tx.getOutput(0).setValue(half); tx.addOutput(half, ADDRESS); tx.verify(); }
@Test public void microcoinScaleTest() throws Exception { BtcFormat coinFormat = BtcFormat.getMicroInstance(Locale.US); assertEquals("1,000,000.00", coinFormat.format(Coin.COIN)); assertEquals("-1,000,000.00", coinFormat.format(Coin.COIN.negate())); assertEquals("1,000,000.10", coinFormat.format(Coin.COIN.add(valueOf(10)))); assertEquals(Coin.parseCoin("0.000001"), coinFormat.parseObject("1.00")); assertEquals(valueOf(1), coinFormat.parseObject("0.01")); assertEquals(Coin.parseCoin("0.001"), coinFormat.parseObject("1,000.00")); assertEquals(Coin.parseCoin("0.001"), coinFormat.parseObject("1000")); }