use of com.samourai.wallet.utxos.models.UTXOCoin in project samourai-wallet-android by Samourai-Wallet.
the class UTXOSActivity method clearSelection.
// Clears current Toolbar action mode
void clearSelection() {
ArrayList<UTXOCoin> models = new ArrayList<>();
for (UTXOCoin model : this.filteredUTXOs) {
model.isSelected = false;
models.add(model);
}
this.filteredUTXOs = new ArrayList<>();
this.filteredUTXOs.addAll(models);
}
use of com.samourai.wallet.utxos.models.UTXOCoin in project samourai-wallet-android by Samourai-Wallet.
the class WhirlpoolMain method validateIntentAndStartNewPool.
private void validateIntentAndStartNewPool() {
if (getIntent().getExtras() != null && getIntent().getExtras().containsKey("preselected")) {
Intent intent = new Intent(getApplicationContext(), NewPoolActivity.class);
int account = getIntent().getExtras().getInt("_account");
intent.putExtra("_account", getIntent().getExtras().getInt("_account"));
intent.putExtra("preselected", getIntent().getExtras().getString("preselected"));
if (account == WhirlpoolMeta.getInstance(getApplication()).getWhirlpoolPostmix()) {
List<UTXOCoin> coins = PreSelectUtil.getInstance().getPreSelected(getIntent().getExtras().getString("preselected"));
long mediumFee = FeeUtil.getInstance().getNormalFee().getDefaultPerKB().longValue() / 1000L;
WhirlpoolTx0 tx0 = new WhirlpoolTx0(1000000L, mediumFee, 0, coins);
try {
tx0.make();
} catch (Exception ex) {
Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show();
ex.printStackTrace();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Tx0 is not possible with selected utxo.").setCancelable(true);
builder.setPositiveButton(R.string.ok, (dialogInterface, i) -> dialogInterface.dismiss());
builder.create().show();
return;
}
if (tx0.getTx0() == null) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Tx0 is not possible with selected utxo.").setCancelable(true);
builder.setPositiveButton(R.string.ok, (dialogInterface, i) -> dialogInterface.dismiss());
builder.create().show();
} else {
startActivityForResult(intent, NEWPOOL_REQ_CODE);
}
} else {
startActivityForResult(intent, NEWPOOL_REQ_CODE);
}
}
}
use of com.samourai.wallet.utxos.models.UTXOCoin in project samourai-wallet-android by Samourai-Wallet.
the class UTXODetailsActivity method sendUTXOtoWhirlpool.
private void sendUTXOtoWhirlpool() {
new AlertDialog.Builder(this).setMessage("Send utxo to whirlpool").setCancelable(false).setPositiveButton(R.string.ok, (dialog, whichButton) -> {
ArrayList<UTXOCoin> list = new ArrayList<>();
list.add(utxoCoin);
String id = UUID.randomUUID().toString();
PreSelectUtil.getInstance().clear();
PreSelectUtil.getInstance().add(id, list);
if (account == WhirlpoolMeta.getInstance(getApplication()).getWhirlpoolPostmix()) {
if (!utxoCoin.path.startsWith("M/1/")) {
Snackbar.make(paynymLayout.getRootView(), R.string.only_change_utxos_allowed, Snackbar.LENGTH_LONG).show();
return;
}
}
if (utxoCoin.doNotSpend) {
Snackbar.make(paynymLayout.getRootView(), R.string.selection_contains_blocked_utxo, Snackbar.LENGTH_LONG).show();
return;
}
if (id != null) {
Intent intent = new Intent(getApplicationContext(), WhirlpoolMain.class);
intent.putExtra("preselected", id);
intent.putExtra("_account", account);
startActivity(intent);
}
}).setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
}).show();
}
use of com.samourai.wallet.utxos.models.UTXOCoin in project samourai-wallet-android by Samourai-Wallet.
the class ChooseUTXOsFragment method getUTXOs.
private Observable<List<UTXOCoin>> getUTXOs() {
return Observable.fromCallable(() -> {
Map<String, Object> dataSet = new HashMap<>();
List<UTXO> utxos = new ArrayList<>();
List<UTXO> account0 = APIFactory.getInstance(getActivity()).getUtxos(true);
// List<UTXO> accountWhirlpool = APIFactory.getInstance(getActivity()).getUtxosPostMix(false);
utxos.addAll(account0);
// utxos.addAll(accountWhirlpool);
long amount = 0L;
for (UTXO utxo : utxos) {
for (MyTransactionOutPoint out : utxo.getOutpoints()) {
debug(TAG, "utxo:" + out.getAddress() + "," + out.getValue());
debug(TAG, "utxo:" + utxo.getPath());
amount += out.getValue().longValue();
}
}
ArrayList<UTXOCoin> items = new ArrayList<>();
for (UTXO utxo : utxos) {
for (MyTransactionOutPoint outpoint : utxo.getOutpoints()) {
UTXOCoin displayData = new UTXOCoin(outpoint, utxo);
if (account0.contains(utxo)) {
displayData.account = 0;
} else {
displayData.account = WhirlpoolMeta.getInstance(getActivity()).getWhirlpoolPostmix();
}
items.add(displayData);
}
}
return items;
});
}
use of com.samourai.wallet.utxos.models.UTXOCoin in project samourai-wallet-android by Samourai-Wallet.
the class UTXOSActivity method markAsUnSpendable.
private void markAsUnSpendable() {
for (UTXOCoin model : filteredUTXOs) {
if (model.isSelected) {
if (model.amount < BlockedUTXO.BLOCKED_UTXO_THRESHOLD && BlockedUTXO.getInstance().contains(model.hash, model.idx)) {
// No-op
} else if (BlockedUTXO.getInstance().contains(model.hash, model.idx)) {
// No-op
} else if (BlockedUTXO.getInstance().containsPostMix(model.hash, model.idx)) {
} else {
if (account == 0) {
BlockedUTXO.getInstance().add(model.hash, model.idx, model.amount);
} else {
BlockedUTXO.getInstance().addPostMix(model.hash, model.idx, model.amount);
}
LogUtil.debug("UTXOActivity", "added:" + model.hash + "-" + model.idx);
setResult(RESULT_OK);
}
utxoList.post(() -> loadUTXOs(true));
}
}
saveWalletState();
}
Aggregations