Search in sources :

Example 1 with UTXOCoin

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);
}
Also used : UTXOCoin(com.samourai.wallet.utxos.models.UTXOCoin) ArrayList(java.util.ArrayList)

Example 2 with UTXOCoin

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);
        }
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) ImageView(android.widget.ImageView) LinearLayoutManagerWrapper(com.samourai.wallet.util.LinearLayoutManagerWrapper) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager) Optional(java8.util.Optional) Drawable(android.graphics.drawable.Drawable) Group(android.support.constraint.Group) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) Cahoots(com.samourai.wallet.cahoots.Cahoots) ItemDividerDecorator(com.samourai.wallet.widgets.ItemDividerDecorator) WhirlpoolAccount(com.samourai.whirlpool.client.wallet.beans.WhirlpoolAccount) DojoUtil(com.samourai.wallet.network.dojo.DojoUtil) UTXOSActivity(com.samourai.wallet.utxos.UTXOSActivity) WhirlpoolWallet(com.samourai.whirlpool.client.wallet.WhirlpoolWallet) BalanceActivity(com.samourai.wallet.home.BalanceActivity) Handler(android.os.Handler) NewPoolActivity(com.samourai.wallet.whirlpool.newPool.NewPoolActivity) View(android.view.View) SendActivity(com.samourai.wallet.send.SendActivity) ManualCahootsActivity(com.samourai.wallet.send.cahoots.ManualCahootsActivity) Schedulers(io.reactivex.schedulers.Schedulers) UTXOUtil(com.samourai.wallet.utxos.UTXOUtil) PreSelectUtil(com.samourai.wallet.utxos.PreSelectUtil) FeeUtil(com.samourai.wallet.send.FeeUtil) AndroidWhirlpoolWalletService(com.samourai.whirlpool.client.wallet.AndroidWhirlpoolWalletService) IntentFilter(android.content.IntentFilter) NetworkDashboard(com.samourai.wallet.network.NetworkDashboard) BroadcastReceiver(android.content.BroadcastReceiver) AppUtil(com.samourai.wallet.util.AppUtil) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) TextView(android.widget.TextView) Nullable(android.support.annotation.Nullable) FormatsUtil(com.samourai.wallet.util.FormatsUtil) WhirlpoolUtxoViewModel(com.samourai.wallet.whirlpool.models.WhirlpoolUtxoViewModel) Context(android.content.Context) Intent(android.content.Intent) FormatsUtil.getBTCDecimalFormat(com.samourai.wallet.util.FormatsUtil.getBTCDecimalFormat) CahootsUtil(com.samourai.wallet.cahoots.CahootsUtil) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) Toast(android.widget.Toast) Menu(android.view.Menu) Observable(io.reactivex.Observable) WhirlPoolLoaderDialog(com.samourai.wallet.whirlpool.fragments.WhirlPoolLoaderDialog) DialogInterface(android.content.DialogInterface) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) UTXOCoin(com.samourai.wallet.utxos.models.UTXOCoin) WhirlpoolUtxoStatus(com.samourai.whirlpool.client.wallet.beans.WhirlpoolUtxoStatus) CollapsingToolbarLayout(android.support.design.widget.CollapsingToolbarLayout) WhirlpoolUtxo(com.samourai.whirlpool.client.wallet.beans.WhirlpoolUtxo) LayoutInflater(android.view.LayoutInflater) DiffUtil(android.support.v7.util.DiffUtil) R(com.samourai.wallet.R) WhirlpoolUtxoState(com.samourai.whirlpool.client.wallet.beans.WhirlpoolUtxoState) RecyclerView(android.support.v7.widget.RecyclerView) WhirlpoolDialog(com.samourai.wallet.whirlpool.newPool.WhirlpoolDialog) AlertDialog(android.support.v7.app.AlertDialog) Toolbar(android.support.v7.widget.Toolbar) CameraFragmentBottomSheet(com.samourai.wallet.fragments.CameraFragmentBottomSheet) JobRefreshService(com.samourai.wallet.service.JobRefreshService) APIFactory(com.samourai.wallet.api.APIFactory) WhirlpoolNotificationService(com.samourai.wallet.whirlpool.service.WhirlpoolNotificationService) Activity(android.app.Activity) EditText(android.widget.EditText) UTXOCoin(com.samourai.wallet.utxos.models.UTXOCoin) Intent(android.content.Intent)

Example 3 with UTXOCoin

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();
}
Also used : AlertDialog(android.app.AlertDialog) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) Completable(io.reactivex.Completable) Uri(android.net.Uri) ImageView(android.widget.ImageView) TransitionManager(android.transition.TransitionManager) WriterException(com.google.zxing.WriterException) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) WhirlpoolMeta(com.samourai.wallet.whirlpool.WhirlpoolMeta) Picasso(com.squareup.picasso.Picasso) MyTransactionOutPoint(com.samourai.wallet.send.MyTransactionOutPoint) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) View(android.view.View) Button(android.widget.Button) SendActivity(com.samourai.wallet.send.SendActivity) UTXO(com.samourai.wallet.send.UTXO) Schedulers(io.reactivex.schedulers.Schedulers) Log(android.util.Log) AccessFactory(com.samourai.wallet.access.AccessFactory) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) WebUtil(com.samourai.wallet.bip47.paynym.WebUtil) UUID(java.util.UUID) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) ECKey(org.bitcoinj.core.ECKey) AlertDialog(android.app.AlertDialog) Objects(java.util.Objects) Contents(com.google.zxing.client.android.Contents) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) TextView(android.widget.TextView) Address(org.bitcoinj.core.Address) BIP47Meta(com.samourai.wallet.bip47.BIP47Meta) Snackbar(android.support.design.widget.Snackbar) BarcodeFormat(com.google.zxing.BarcodeFormat) FormatsUtil(com.samourai.wallet.util.FormatsUtil) BottomSheetDialog(android.support.design.widget.BottomSheetDialog) BlockedUTXO(com.samourai.wallet.send.BlockedUTXO) Intent(android.content.Intent) PayloadUtil(com.samourai.wallet.payload.PayloadUtil) MnemonicException(org.bitcoinj.crypto.MnemonicException) MenuItem(android.view.MenuItem) Hex(org.bouncycastle.util.encoders.Hex) ArrayList(java.util.ArrayList) BIP47Add(com.samourai.wallet.bip47.BIP47Add) SamouraiWallet(com.samourai.wallet.SamouraiWallet) SendFactory(com.samourai.wallet.send.SendFactory) Toast(android.widget.Toast) Menu(android.view.Menu) Observable(io.reactivex.Observable) DecryptionException(com.samourai.wallet.crypto.DecryptionException) CharSequenceX(com.samourai.wallet.util.CharSequenceX) UTXOCoin(com.samourai.wallet.utxos.models.UTXOCoin) MessageSignUtil(com.samourai.wallet.util.MessageSignUtil) SegwitAddress(com.samourai.wallet.segwit.SegwitAddress) PayNymDetailsActivity(com.samourai.wallet.paynym.paynymDetails.PayNymDetailsActivity) DecimalFormat(java.text.DecimalFormat) IOException(java.io.IOException) R(com.samourai.wallet.R) QRCodeEncoder(com.google.zxing.client.android.encode.QRCodeEncoder) Bitmap(android.graphics.Bitmap) WhirlpoolMain(com.samourai.wallet.whirlpool.WhirlpoolMain) APIFactory(com.samourai.wallet.api.APIFactory) LogUtil(com.samourai.wallet.util.LogUtil) EditText(android.widget.EditText) UTXOCoin(com.samourai.wallet.utxos.models.UTXOCoin) ArrayList(java.util.ArrayList) Intent(android.content.Intent)

Example 4 with UTXOCoin

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;
    });
}
Also used : UTXO(com.samourai.wallet.send.UTXO) UTXOCoin(com.samourai.wallet.utxos.models.UTXOCoin) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MyTransactionOutPoint(com.samourai.wallet.send.MyTransactionOutPoint)

Example 5 with UTXOCoin

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();
}
Also used : UTXOCoin(com.samourai.wallet.utxos.models.UTXOCoin)

Aggregations

UTXOCoin (com.samourai.wallet.utxos.models.UTXOCoin)20 ArrayList (java.util.ArrayList)16 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)7 Disposable (io.reactivex.disposables.Disposable)7 MyTransactionOutPoint (com.samourai.wallet.send.MyTransactionOutPoint)6 List (java.util.List)6 View (android.view.View)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 IOException (java.io.IOException)5 MnemonicException (org.bitcoinj.crypto.MnemonicException)5 AlertDialog (android.app.AlertDialog)4 Intent (android.content.Intent)4 Bundle (android.os.Bundle)4 AppCompatActivity (android.support.v7.app.AppCompatActivity)4 MenuItem (android.view.MenuItem)4 Toast (android.widget.Toast)4 R (com.samourai.wallet.R)4 UTXO (com.samourai.wallet.send.UTXO)4 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)4