/** Alias for multiply */ public Coin times(final int factor) { return multiply(factor); }
/** Alias for multiply */ public Coin times(final long factor) { return multiply(factor); }
/** Alias for multiply */ public Coin times(final long factor) { return multiply(factor); }
/** Alias for multiply */ public Coin times(final int factor) { return multiply(factor); }
/** * 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; }
/** * Returns the minimum value for this output to be considered "not dust", i.e. the transaction will be relayable * and mined by default miners. For normal pay to address outputs, this is 2730 satoshis, the same as * {@link Transaction#MIN_NONDUST_OUTPUT}. */ public Coin getMinNonDustValue() { return getMinNonDustValue(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.multiply(3)); }
/** * Returns the minimum value for this output to be considered "not dust", i.e. the transaction will be relayable * and mined by default miners. For normal pay to address outputs, this is 2730 satoshis, the same as * {@link Transaction#MIN_NONDUST_OUTPUT}. */ public Coin getMinNonDustValue() { return getMinNonDustValue(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.multiply(3)); }
/** * Returns the minimum value for this output to be considered "not dust", i.e. the transaction will be relayable * and mined by default miners. For normal pay to address outputs, this is 2730 satoshis, the same as * {@link Transaction#MIN_NONDUST_OUTPUT}. */ public Coin getMinNonDustValue() { return getMinNonDustValue(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.multiply(3)); }
/** * Returns the minimum value for this output to be considered "not dust", i.e. the transaction will be relayable * and mined by default miners. For normal pay to address outputs, this is 2730 satoshis, the same as * {@link Transaction#MIN_NONDUST_OUTPUT}. */ public Coin getMinNonDustValue() { return getMinNonDustValue(params.isDIP0001ActiveAtTip() ? Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.multiply(3).div(10) : Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.multiply(3)); }
@Override public Coin getBlockSubsidy(final int height) { return COIN.multiply(50).shiftRight(height / getSubsidyDecreaseBlockCount()); }
/** Reduce the value of the first output of a transaction to pay the given feePerKb as appropriate for its size. */ private boolean adjustOutputDownwardsForFee(Transaction tx, CoinSelection coinSelection, Coin feePerKb, boolean ensureMinRequiredFee) { final int size = tx.unsafeBitcoinSerialize().length + estimateBytesForSigning(coinSelection); Coin fee = feePerKb.multiply(size).divide(1000); if (ensureMinRequiredFee && fee.compareTo(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE) < 0) fee = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE; TransactionOutput output = tx.getOutput(0); output.setValue(output.getValue().subtract(fee)); return !output.isDust(); }
/** Reduce the value of the first output of a transaction to pay the given feePerKb as appropriate for its size. */ private boolean adjustOutputDownwardsForFee(Transaction tx, CoinSelection coinSelection, Coin feePerKb, boolean ensureMinRequiredFee) { final int size = tx.unsafeBitcoinSerialize().length + estimateBytesForSigning(coinSelection); Coin fee = feePerKb.multiply(size).divide(1000); if (ensureMinRequiredFee && fee.compareTo(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE) < 0) fee = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE; TransactionOutput output = tx.getOutput(0); output.setValue(output.getValue().subtract(fee)); return !output.isDust(); }
/** Reduce the value of the first output of a transaction to pay the given feePerKb as appropriate for its size. */ private boolean adjustOutputDownwardsForFee(Transaction tx, CoinSelection coinSelection, Coin feePerKb, boolean ensureMinRequiredFee) { final int size = tx.unsafeBitcoinSerialize().length + estimateBytesForSigning(coinSelection); Coin fee = feePerKb.multiply(size).divide(1000); if (ensureMinRequiredFee && fee.compareTo(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE) < 0) fee = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE; TransactionOutput output = tx.getOutput(0); output.setValue(output.getValue().subtract(fee)); return !output.isDust(); }
@Test public void repeatOptionalDecimals() { assertEquals("0.00000001", formatRepeat(SATOSHI, 2, 4)); assertEquals("0.00000010", formatRepeat(SATOSHI.multiply(10), 2, 4)); assertEquals("0.01", formatRepeat(CENT, 2, 4)); assertEquals("0.10", formatRepeat(CENT.multiply(10), 2, 4)); assertEquals("0", formatRepeat(SATOSHI, 2, 2)); assertEquals("0", formatRepeat(SATOSHI.multiply(10), 2, 2)); assertEquals("0.01", formatRepeat(CENT, 2, 2)); assertEquals("0.10", formatRepeat(CENT.multiply(10), 2, 2)); assertEquals("0", formatRepeat(CENT, 2, 0)); assertEquals("0", formatRepeat(CENT.multiply(10), 2, 0)); }
@Test public void sendRequestP2PKHTest() { SendRequest req = SendRequest.to(OTHER_ADDRESS, SATOSHI.multiply(12)); assertEquals(OTHER_ADDRESS, req.tx.getOutputs().get(0).getScriptPubKey().getToAddress(PARAMS)); }
@Test(expected = java.lang.IllegalStateException.class) public void sendCoinsNoBroadcasterTest() throws InsufficientMoneyException { ECKey key = ECKey.fromPrivate(BigInteger.TEN); SendRequest req = SendRequest.to(OTHER_ADDRESS.getParameters(), key, SATOSHI.multiply(12)); wallet.sendCoins(req); }
@Test public void sendRequestP2PKTest() { ECKey key = new ECKey(); SendRequest req = SendRequest.to(PARAMS, key, SATOSHI.multiply(12)); assertArrayEquals(key.getPubKey(), req.tx.getOutputs().get(0).getScriptPubKey().getPubKey()); }