Search in sources :

Example 51 with CharSequenceX

use of com.samourai.wallet.util.CharSequenceX in project samourai-wallet-android by Samourai-Wallet.

the class PayNymDetailsActivity method updatePaynym.

private void updatePaynym(String label, String pcode) {
    if (pcode == null || pcode.length() < 1 || !FormatsUtil.getInstance().isValidPaymentCode(pcode)) {
        Snackbar.make(userAvatar.getRootView(), R.string.invalid_payment_code, Snackbar.LENGTH_SHORT).show();
    } else if (label == null || label.length() < 1) {
        Snackbar.make(userAvatar.getRootView(), R.string.bip47_no_label_error, Snackbar.LENGTH_SHORT).show();
    } else {
        BIP47Meta.getInstance().setLabel(pcode, label);
        new Thread(() -> {
            Looper.prepare();
            try {
                PayloadUtil.getInstance(PayNymDetailsActivity.this).saveWalletToJSON(new CharSequenceX(AccessFactory.getInstance(PayNymDetailsActivity.this).getGUID() + AccessFactory.getInstance().getPIN()));
            } catch (MnemonicException.MnemonicLengthException mle) {
                mle.printStackTrace();
                Toast.makeText(PayNymDetailsActivity.this, R.string.decryption_error, Toast.LENGTH_SHORT).show();
            } catch (DecoderException de) {
                de.printStackTrace();
                Toast.makeText(PayNymDetailsActivity.this, R.string.decryption_error, Toast.LENGTH_SHORT).show();
            } catch (JSONException je) {
                je.printStackTrace();
                Toast.makeText(PayNymDetailsActivity.this, R.string.decryption_error, Toast.LENGTH_SHORT).show();
            } catch (IOException ioe) {
                ioe.printStackTrace();
                Toast.makeText(PayNymDetailsActivity.this, R.string.decryption_error, Toast.LENGTH_SHORT).show();
            } catch (NullPointerException npe) {
                npe.printStackTrace();
                Toast.makeText(PayNymDetailsActivity.this, R.string.decryption_error, Toast.LENGTH_SHORT).show();
            } catch (DecryptionException de) {
                de.printStackTrace();
                Toast.makeText(PayNymDetailsActivity.this, R.string.decryption_error, Toast.LENGTH_SHORT).show();
            } finally {
                ;
            }
            Looper.loop();
            doUpdatePayNymInfo(pcode);
        }).start();
    }
}
Also used : DecoderException(org.bouncycastle.util.encoders.DecoderException) MnemonicException(org.bitcoinj.crypto.MnemonicException) CharSequenceX(com.samourai.wallet.util.CharSequenceX) JSONException(org.json.JSONException) IOException(java.io.IOException) DecryptionException(com.samourai.wallet.crypto.DecryptionException)

Aggregations

CharSequenceX (com.samourai.wallet.util.CharSequenceX)51 IOException (java.io.IOException)38 JSONException (org.json.JSONException)37 DecryptionException (com.samourai.wallet.crypto.DecryptionException)35 MnemonicException (org.bitcoinj.crypto.MnemonicException)35 Intent (android.content.Intent)22 AlertDialog (android.app.AlertDialog)14 DialogInterface (android.content.DialogInterface)14 JSONObject (org.json.JSONObject)14 AddressFormatException (org.bitcoinj.core.AddressFormatException)13 DecoderException (org.bouncycastle.util.encoders.DecoderException)10 DecoderException (org.apache.commons.codec.DecoderException)9 EditText (android.widget.EditText)8 PrivKeyReader (com.samourai.wallet.util.PrivKeyReader)8 MyTransactionOutPoint (com.samourai.wallet.send.MyTransactionOutPoint)7 ProgressDialog (android.app.ProgressDialog)6 PaymentCode (com.samourai.wallet.bip47.rpc.PaymentCode)6 FileNotFoundException (java.io.FileNotFoundException)6 ConcurrentModificationException (java.util.ConcurrentModificationException)6 ClipData (android.content.ClipData)4