use of com.samourai.whirlpool.client.wallet.beans.MixingState in project samourai-wallet-android by Samourai-Wallet.
the class WhirlpoolNotificationService method setMixState.
private void setMixState(NotificationCompat.Builder builder) {
Optional<WhirlpoolWallet> whirlpoolWalletOpt = androidWhirlpoolWalletService.getWhirlpoolWallet();
if (whirlpoolWalletOpt.isPresent()) {
MixingState mixingState = whirlpoolWalletOpt.get().getMixingState();
builder.setContentTitle("Whirlpool online: ".concat(String.valueOf(mixingState.getNbMixing())).concat(" MIXING :").concat(String.valueOf(mixingState.getNbQueued())).concat(" QUEUED"));
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
for (WhirlpoolUtxo whirlpoolUtxo : mixingState.getUtxosMixing()) {
if (whirlpoolUtxo.getUtxoState().getMessage() != null && whirlpoolUtxo.getUtxoConfig().getPoolId() != null)
inboxStyle.addLine(whirlpoolUtxo.getUtxoConfig().getPoolId().concat(" : ").concat(whirlpoolUtxo.getUtxoState().getMessage()));
}
builder.setStyle(inboxStyle);
} else {
builder.setContentText("Whirlpool");
}
}
use of com.samourai.whirlpool.client.wallet.beans.MixingState in project samourai-wallet-android by Samourai-Wallet.
the class WhirlpoolNotificationService method listenService.
private void listenService() {
try {
Optional<WhirlpoolWallet> whirlpoolWalletOpt = androidWhirlpoolWalletService.getWhirlpoolWallet();
if (!whirlpoolWalletOpt.isPresent()) {
// whirlpool wallet not opened yet
return;
}
// whirlpool wallet is opened
WhirlpoolWallet whirlpoolWallet = whirlpoolWalletOpt.get();
updateNotification();
Disposable stateDisposable = whirlpoolWallet.getMixingState().getObservable().observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribe(mixingState -> updateNotification());
Disposable repeatedChecks = Observable.fromCallable(() -> true).repeatWhen(completed -> completed.delay(3, TimeUnit.SECONDS)).subscribe(aBoolean -> {
updateNotification();
notifySuccessMixes(whirlpoolWallet.getMixingState());
}, er -> {
});
compositeDisposable.add(repeatedChecks);
compositeDisposable.add(stateDisposable);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.samourai.whirlpool.client.wallet.beans.MixingState in project samourai-wallet-android by Samourai-Wallet.
the class WhirlpoolWalletTest method testStart.
@Test
public void testStart() throws Exception {
// start whirlpool wallet
whirlpoolWallet.start();
// list pools
Collection<Pool> pools = whirlpoolWallet.getPools();
Assert.assertTrue(!pools.isEmpty());
// find pool by poolId
Pool pool = whirlpoolWallet.findPoolById("0.01btc");
Assert.assertNotNull(pool);
// list premix utxos
Collection<WhirlpoolUtxo> utxosPremix = whirlpoolWallet.getUtxosPremix();
log.info(utxosPremix.size() + " PREMIX utxos:");
ClientUtils.logWhirlpoolUtxos(utxosPremix, whirlpoolWallet.getConfig().getMixsTarget());
// list postmix utxos
Collection<WhirlpoolUtxo> utxosPostmix = whirlpoolWallet.getUtxosPremix();
log.info(utxosPostmix.size() + " POSTMIX utxos:");
ClientUtils.logWhirlpoolUtxos(utxosPostmix, whirlpoolWallet.getConfig().getMixsTarget());
// keep running
for (int i = 0; i < 50; i++) {
MixingState mixingState = whirlpoolWallet.getMixingState();
log.debug("WHIRLPOOL: " + mixingState.getNbQueued() + " queued, " + mixingState.getNbMixing() + " mixing: " + mixingState.getUtxosMixing());
synchronized (this) {
wait(10000);
}
}
}
Aggregations