@Override public void onCoinsSent( Wallet wallet, Transaction tx, BigInteger prevBalance, BigInteger newBalance) { BigInteger amt = prevBalance.subtract(newBalance); final long amount = amt.longValue(); WalletApplication app = (WalletApplication) getApplicationContext(); final BTCFmt btcfmt = app.getBTCFmt(); // We allocate a new notification id for each receive. // We use it on both the receive and confirm so it // will replace the receive note with the confirm ... final int noteId = ++mNoteId; mLogger.info(String.format("showing notification send %d", amount)); showEventNotification( noteId, R.drawable.ic_note_bc_red_lt, mRes.getString(R.string.wallet_service_note_sent_title, btcfmt.unitStr()), mRes.getString( R.string.wallet_service_note_sent_msg, btcfmt.format(amount), btcfmt.unitStr())); final TransactionConfidence txconf = tx.getConfidence(); final TransactionConfidence.Listener listener = new TransactionConfidence.Listener() { @Override public void onConfidenceChanged(Transaction tx, ChangeReason reason) { // Wait until it's not pending anymore. if (tx.isPending()) return; ConfidenceType ct = tx.getConfidence().getConfidenceType(); if (ct == ConfidenceType.BUILDING) { mLogger.info(String.format("send %d confirm", amount)); // Show no longer pending. showEventNotification( noteId, R.drawable.ic_note_bc_red, mRes.getString(R.string.wallet_service_note_scnf_title, btcfmt.unitStr()), mRes.getString( R.string.wallet_service_note_scnf_msg, btcfmt.format(amount), btcfmt.unitStr())); } else if (ct == ConfidenceType.DEAD) { mLogger.info(String.format("send %d dead", amount)); // Notify dead. showEventNotification( noteId, R.drawable.ic_note_bc_gray, mRes.getString(R.string.wallet_service_note_sdead_title, btcfmt.unitStr()), mRes.getString( R.string.wallet_service_note_sdead_msg, btcfmt.format(amount), btcfmt.unitStr())); } else { mLogger.info(String.format("send %d unknown", amount)); } // We're all done listening ... txconf.removeEventListener(this); } }; txconf.addEventListener(listener); }