use of com.samourai.whirlpool.client.wallet.beans.WhirlpoolUtxo 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.WhirlpoolUtxo in project samourai-wallet-android by Samourai-Wallet.
the class CycleDetail method setMixStatus.
private void setMixStatus() {
Optional<WhirlpoolWallet> whirlpoolWalletOpt = AndroidWhirlpoolWalletService.getInstance().getWhirlpoolWallet();
if (!whirlpoolWalletOpt.isPresent()) {
// wallet not opened
return;
}
WhirlpoolWallet wallet = whirlpoolWalletOpt.get();
try {
for (WhirlpoolUtxo utxo : wallet.getUtxosPremix()) {
if (utxo.getUtxo().toString().equals(hash)) {
getSupportActionBar().setTitle(utxo.getUtxoConfig().getPoolId());
whirlpoolUtxo = utxo;
makeTxNetworkRequest();
transactionId.setText(utxo.getUtxo().tx_hash);
updateState(whirlpoolUtxo.getUtxoState());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.samourai.whirlpool.client.wallet.beans.WhirlpoolUtxo in project samourai-wallet-android by Samourai-Wallet.
the class WhirlpoolMain method filter.
private Observable<List<WhirlpoolUtxoViewModel>> filter(WhirlpoolWallet wallet, List<WhirlpoolUtxo> mixingUtxos) {
return Observable.fromCallable(() -> {
List<WhirlpoolUtxoViewModel> list = new ArrayList<>();
List<WhirlpoolUtxo> utxoPremix = new ArrayList<>(wallet.getUtxosPremix());
WhirlpoolUtxoViewModel section = WhirlpoolUtxoViewModel.section("Mixing");
list.add(section);
for (WhirlpoolUtxo mixUtxo : mixingUtxos) {
WhirlpoolUtxoViewModel whirlpoolUtxoViewModel = WhirlpoolUtxoViewModel.copy(mixingUtxos.get(mixingUtxos.indexOf(mixUtxo)));
list.add(whirlpoolUtxoViewModel);
}
if (list.size() == 1) {
list.remove(section);
}
WhirlpoolUtxoViewModel queueSection = WhirlpoolUtxoViewModel.section("Unmixed");
list.add(queueSection);
for (WhirlpoolUtxo utxo : utxoPremix) {
WhirlpoolUtxoViewModel whirlpoolUtxoViewModel = null;
for (WhirlpoolUtxo mixUtxo : mixingUtxos) {
if (mixUtxo.getUtxo().tx_hash.equals(utxo.getUtxo().tx_hash) && mixUtxo.getUtxo().tx_output_n == utxo.getUtxo().tx_output_n)
whirlpoolUtxoViewModel = WhirlpoolUtxoViewModel.copy(mixingUtxos.get(mixingUtxos.indexOf(utxo)));
}
if (whirlpoolUtxoViewModel == null) {
whirlpoolUtxoViewModel = WhirlpoolUtxoViewModel.copy(utxo);
}
if (whirlpoolUtxoViewModel.getUtxoState().getStatus() == WhirlpoolUtxoStatus.MIX_QUEUE) {
list.add(whirlpoolUtxoViewModel);
}
}
if (list.get(list.size() - 1).isSection()) {
list.remove(queueSection);
}
for (WhirlpoolUtxoViewModel utxo : list) {
list.get(list.indexOf(utxo)).setId(list.indexOf(utxo));
}
listenPoolState(mixingUtxos);
return list;
});
}
use of com.samourai.whirlpool.client.wallet.beans.WhirlpoolUtxo in project samourai-wallet-android by Samourai-Wallet.
the class WhirlpoolMain method listenPoolState.
private void listenPoolState(List<WhirlpoolUtxo> list) {
List<Observable<WhirlpoolUtxoState>> state = new ArrayList<>();
for (WhirlpoolUtxo utxo : list) {
state.add(utxo.getUtxoState().getObservable());
}
Disposable disposable = Observable.merge(state).subscribeOn(Schedulers.single()).observeOn(AndroidSchedulers.mainThread()).subscribe(whirlpoolUtxoState -> {
loadMixes(true);
});
compositeDisposable.add(disposable);
}
use of com.samourai.whirlpool.client.wallet.beans.WhirlpoolUtxo 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