public InsufficientMoneyException(Coin missing) { this(missing, "Insufficient money, missing " + missing.toFriendlyString()); }
public InsufficientMoneyException(Coin missing) { this(missing, "Insufficient money, missing " + missing.toFriendlyString()); }
public InsufficientMoneyException(Coin missing) { this(missing, "Insufficient money, missing " + missing.toFriendlyString()); }
public InsufficientMoneyException(Coin missing) { this(missing, "Insufficient money, missing " + missing.toFriendlyString()); }
@Override public String toString() { return String.format(Locale.US, "Stored TxOut of %s (%s:%d)", value.toFriendlyString(), hash, index); }
@Override public String toString() { return String.format(Locale.US, "Stored TxOut of %s (%s:%d)", value.toFriendlyString(), hash, index); }
@Override public String toString() { return String.format(Locale.US, "Stored TxOut of %s (%s:%d)", value.toFriendlyString(), hash, index); }
@Override public String toString() { return String.format(Locale.US, "Stored TxOut of %s (%s:%d)", value.toFriendlyString(), hash, index); }
static synchronized void onChange(final CountDownLatch latch) { saveWallet(walletFile); Coin balance = wallet.getBalance(Wallet.BalanceType.ESTIMATED); if (condition.matchBitcoins(balance)) { System.out.println(balance.toFriendlyString()); latch.countDown(); } }
private void toStringHelper(StringBuilder builder, Map<Sha256Hash, Transaction> transactionMap, @Nullable AbstractBlockChain chain, @Nullable Comparator<Transaction> sortOrder) { checkState(lock.isHeldByCurrentThread()); final Collection<Transaction> txns; if (sortOrder != null) { txns = new TreeSet<>(sortOrder); txns.addAll(transactionMap.values()); } else { txns = transactionMap.values(); } for (Transaction tx : txns) { try { builder.append(tx.getValue(this).toFriendlyString()); builder.append(" total value (sends "); builder.append(tx.getValueSentFromMe(this).toFriendlyString()); builder.append(" and receives "); builder.append(tx.getValueSentToMe(this).toFriendlyString()); builder.append(")\n"); } catch (ScriptException e) { // Ignore and don't print this line. } if (tx.hasConfidence()) builder.append(" confidence: ").append(tx.getConfidence()).append('\n'); builder.append(tx.toString(chain)); } }
private void toStringHelper(StringBuilder builder, Map<Sha256Hash, Transaction> transactionMap, @Nullable AbstractBlockChain chain, @Nullable Comparator<Transaction> sortOrder) { checkState(lock.isHeldByCurrentThread()); final Collection<Transaction> txns; if (sortOrder != null) { txns = new TreeSet<Transaction>(sortOrder); txns.addAll(transactionMap.values()); } else { txns = transactionMap.values(); } for (Transaction tx : txns) { try { builder.append(tx.getValue(this).toFriendlyString()); builder.append(" total value (sends "); builder.append(tx.getValueSentFromMe(this).toFriendlyString()); builder.append(" and receives "); builder.append(tx.getValueSentToMe(this).toFriendlyString()); builder.append(")\n"); } catch (ScriptException e) { // Ignore and don't print this line. } if (tx.hasConfidence()) builder.append(" confidence: ").append(tx.getConfidence()).append('\n'); builder.append(tx.toString(chain)); } }
/** * Returns a human readable debug string. */ @Override public String toString() { try { Script script = getScriptPubKey(); StringBuilder buf = new StringBuilder("TxOut of "); buf.append(Coin.valueOf(value).toFriendlyString()); if (script.isSentToAddress() || script.isPayToScriptHash()) buf.append(" to ").append(script.getToAddress(params)); else if (script.isSentToRawPubKey()) buf.append(" to pubkey ").append(Utils.HEX.encode(script.getPubKey())); else if (script.isSentToMultiSig()) buf.append(" to multisig"); else buf.append(" (unknown type)"); buf.append(" script:").append(script); return buf.toString(); } catch (ScriptException e) { throw new RuntimeException(e); } }
/** * Returns a human readable debug string. */ @Override public String toString() { try { Script script = getScriptPubKey(); StringBuilder buf = new StringBuilder("TxOut of "); buf.append(Coin.valueOf(value).toFriendlyString()); if (script.isSentToAddress() || script.isPayToScriptHash()) buf.append(" to ").append(script.getToAddress(params)); else if (script.isSentToRawPubKey()) buf.append(" to pubkey ").append(Utils.HEX.encode(script.getPubKey())); else if (script.isSentToMultiSig()) buf.append(" to multisig"); else buf.append(" (unknown type)"); buf.append(" script:").append(script); return buf.toString(); } catch (ScriptException e) { throw new RuntimeException(e); } }
/** * Returns a human readable debug string. */ @Override public String toString() { try { Script script = getScriptPubKey(); StringBuilder buf = new StringBuilder("TxOut of "); buf.append(Coin.valueOf(value).toFriendlyString()); if (script.isSentToAddress() || script.isPayToScriptHash()) buf.append(" to ").append(script.getToAddress(params)); else if (script.isSentToRawPubKey()) buf.append(" to pubkey ").append(Utils.HEX.encode(script.getPubKey())); else if (script.isSentToMultiSig()) buf.append(" to multisig"); else buf.append(" (unknown type)"); buf.append(" script:").append(script); return buf.toString(); } catch (ScriptException e) { throw new RuntimeException(e); } }
/** * Returns a human readable debug string. */ @Override public String toString() { try { Script script = getScriptPubKey(); StringBuilder buf = new StringBuilder("TxOut of "); buf.append(Coin.valueOf(value).toFriendlyString()); if (script.isSentToAddress() || script.isPayToScriptHash()) buf.append(" to ").append(script.getToAddress(params)); else if (script.isSentToRawPubKey()) buf.append(" to pubkey ").append(Utils.HEX.encode(script.getPubKey())); else if (script.isSentToMultiSig()) buf.append(" to multisig"); else buf.append(" (unknown type)"); buf.append(" script:").append(script); return buf.toString(); } catch (ScriptException e) { throw new RuntimeException(e); } }
public static void main(String[] args) throws Exception { BriefLogFormatter.initWithSilentBitcoinJ(); if (args.length == 0) { System.err.println("Specify the fee level to test in satoshis as the first argument."); return; } Coin feeToTest = Coin.valueOf(Long.parseLong(args[0])); System.out.println("Fee to test is " + feeToTest.toFriendlyString()); kit = new WalletAppKit(PARAMS, new File("."), "testfeelevel"); kit.startAsync(); kit.awaitRunning(); try { go(feeToTest, NUM_OUTPUTS); } finally { kit.stopAsync(); kit.awaitTerminated(); } }
private void setupWalletListeners(Wallet wallet) { wallet.addCoinsReceivedEventListener((wallet1, tx, prevBalance, newBalance) -> { view.displayMyBalance(wallet.getBalance().toFriendlyString()); if(tx.getPurpose() == Transaction.Purpose.UNKNOWN) view.showToastMessage("Receive " + newBalance.minus(prevBalance).toFriendlyString()); }); wallet.addCoinsSentEventListener((wallet12, tx, prevBalance, newBalance) -> { view.displayMyBalance(wallet.getBalance().toFriendlyString()); view.clearAmount(); view.displayRecipientAddress(null); view.showToastMessage("Sent " + prevBalance.minus(newBalance).minus(tx.getFee()).toFriendlyString()); }); } }
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 public void testToFriendlyString() { assertEquals("1.00 BTC", COIN.toFriendlyString()); assertEquals("1.23 BTC", valueOf(1, 23).toFriendlyString()); assertEquals("0.001 BTC", COIN.divide(1000).toFriendlyString()); assertEquals("-1.23 BTC", valueOf(1, 23).negate().toFriendlyString()); }
@Override public void refresh() { String myAddress = walletAppKit.wallet().freshReceiveAddress().toBase58(); view.displayMyBalance(walletAppKit.wallet().getBalance().toFriendlyString()); view.displayMyAddress(myAddress); }