use of com.samourai.wallet.util.CharSequenceX in project samourai-wallet-android by Samourai-Wallet.
the class PayloadUtil method serializeUTXOBadBank.
public void serializeUTXOBadBank(JSONObject obj) throws IOException, JSONException, DecryptionException, UnsupportedEncodingException {
if (!AppUtil.getInstance(context).isOfflineMode()) {
if (obj != null) {
JSONObject utxoObj = new JSONObject();
utxoObj.put("unspent_outputs", obj);
serializeAux(utxoObj, new CharSequenceX(AccessFactory.getInstance(context).getGUID() + AccessFactory.getInstance().getPIN()), strUTXOBadBankFilename);
}
}
}
use of com.samourai.wallet.util.CharSequenceX in project samourai-wallet-android by Samourai-Wallet.
the class PayloadUtil method serializeUTXOPost.
public void serializeUTXOPost(JSONObject obj) throws IOException, JSONException, DecryptionException, UnsupportedEncodingException {
if (!AppUtil.getInstance(context).isOfflineMode()) {
if (obj != null) {
JSONObject utxoObj = new JSONObject();
utxoObj.put("unspent_outputs", obj);
serializeAux(utxoObj, new CharSequenceX(AccessFactory.getInstance(context).getGUID() + AccessFactory.getInstance().getPIN()), strUTXOPostFilename);
}
}
}
use of com.samourai.wallet.util.CharSequenceX in project samourai-wallet-android by Samourai-Wallet.
the class PayloadUtil method wipe.
public synchronized void wipe() throws IOException {
BIP47Util.getInstance(context).reset();
BIP47Meta.getInstance().clear();
BIP49Util.getInstance(context).reset();
BIP84Util.getInstance(context).reset();
DojoUtil.getInstance(context).clear();
APIFactory.getInstance(context).reset();
PrefsUtil.getInstance(context).setValue(PrefsUtil.ENABLE_TOR, false);
PrefsUtil.getInstance(context).setValue(PrefsUtil.IS_RESTORE, false);
PrefsUtil.getInstance(context).setValue(PrefsUtil.USE_TRUSTED_NODE, false);
PrefsUtil.getInstance(context).clear();
try {
int nbAccounts = HD_WalletFactory.getInstance(context).get().getAccounts().size();
for (int i = 0; i < nbAccounts; i++) {
HD_WalletFactory.getInstance(context).get().getAccount(i).getReceive().setAddrIdx(0);
HD_WalletFactory.getInstance(context).get().getAccount(i).getChange().setAddrIdx(0);
AddressFactory.getInstance().setHighestTxReceiveIdx(i, 0);
AddressFactory.getInstance().setHighestTxChangeIdx(i, 0);
}
AddressFactory.getInstance().setHighestBIP49ReceiveIdx(0);
AddressFactory.getInstance().setHighestBIP49ChangeIdx(0);
AddressFactory.getInstance().setHighestBIP84ReceiveIdx(0);
AddressFactory.getInstance().setHighestBIP84ChangeIdx(0);
BIP49Util.getInstance(context).getWallet().getAccount(0).getReceive().setAddrIdx(0);
BIP49Util.getInstance(context).getWallet().getAccount(0).getChange().setAddrIdx(0);
BIP84Util.getInstance(context).getWallet().getAccount(0).getReceive().setAddrIdx(0);
BIP84Util.getInstance(context).getWallet().getAccount(0).getChange().setAddrIdx(0);
AddressFactory.getInstance().setHighestPreReceiveIdx(0);
AddressFactory.getInstance().setHighestPreChangeIdx(0);
AddressFactory.getInstance().setHighestPostReceiveIdx(0);
AddressFactory.getInstance().setHighestPostChangeIdx(0);
AddressFactory.getInstance().setHighestBadBankReceiveIdx(0);
AddressFactory.getInstance().setHighestBadBankChangeIdx(0);
HD_WalletFactory.getInstance(context).set(null);
} catch (MnemonicException.MnemonicLengthException mle) {
mle.printStackTrace();
}
HD_WalletFactory.getInstance(context).clear();
File dir = context.getDir(dataDir, Context.MODE_PRIVATE);
File datfile = new File(dir, strFilename);
File tmpfile = new File(dir, strTmpFilename);
if (tmpfile.exists()) {
secureDelete(tmpfile);
}
if (datfile.exists()) {
secureDelete(datfile);
try {
serialize(new JSONObject("{}"), new CharSequenceX(""));
} catch (JSONException je) {
je.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of com.samourai.wallet.util.CharSequenceX in project samourai-wallet-android by Samourai-Wallet.
the class BalanceActivity method doScan.
private void doScan() {
CameraFragmentBottomSheet cameraFragmentBottomSheet = new CameraFragmentBottomSheet();
cameraFragmentBottomSheet.show(getSupportFragmentManager(), cameraFragmentBottomSheet.getTag());
cameraFragmentBottomSheet.setQrCodeScanLisenter(code -> {
cameraFragmentBottomSheet.dismissAllowingStateLoss();
PrivKeyReader privKeyReader = new PrivKeyReader(new CharSequenceX(code.trim()));
try {
if (privKeyReader.getFormat() != null) {
doPrivKey(code.trim());
} else if (Cahoots.isCahoots(code.trim())) {
Intent cahootIntent = new Intent(this, ManualCahootsActivity.class);
cahootIntent.putExtra("payload", code.trim());
cahootIntent.putExtra("_account", account);
startActivity(cahootIntent);
// CahootsUtil.getInstance(BalanceActivity.this).processCahoots(code.trim(), 0);
} else if (FormatsUtil.getInstance().isPSBT(code.trim())) {
CahootsUtil.getInstance(BalanceActivity.this).doPSBT(code.trim());
} else if (DojoUtil.getInstance(BalanceActivity.this).isValidPairingPayload(code.trim())) {
Intent intent = new Intent(BalanceActivity.this, NetworkDashboard.class);
intent.putExtra("params", code.trim());
startActivity(intent);
} else {
Intent intent = new Intent(BalanceActivity.this, SendActivity.class);
intent.putExtra("uri", code.trim());
intent.putExtra("_account", account);
startActivity(intent);
}
} catch (Exception e) {
}
});
}
use of com.samourai.wallet.util.CharSequenceX in project samourai-wallet-android by Samourai-Wallet.
the class BalanceActivity method doClipboardCheck.
private void doClipboardCheck() {
final android.content.ClipboardManager clipboard = (android.content.ClipboardManager) BalanceActivity.this.getSystemService(android.content.Context.CLIPBOARD_SERVICE);
if (clipboard.hasPrimaryClip()) {
final ClipData clip = clipboard.getPrimaryClip();
ClipData.Item item = clip.getItemAt(0);
if (item.getText() != null) {
String text = item.getText().toString();
String[] s = text.split("\\s+");
try {
for (int i = 0; i < s.length; i++) {
PrivKeyReader privKeyReader = new PrivKeyReader(new CharSequenceX(s[i]));
if (privKeyReader.getFormat() != null && (privKeyReader.getFormat().equals(PrivKeyReader.WIF_COMPRESSED) || privKeyReader.getFormat().equals(PrivKeyReader.WIF_UNCOMPRESSED) || privKeyReader.getFormat().equals(PrivKeyReader.BIP38) || FormatsUtil.getInstance().isValidXprv(s[i]))) {
new AlertDialog.Builder(BalanceActivity.this).setTitle(R.string.app_name).setMessage(R.string.privkey_clipboard).setCancelable(false).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
clipboard.setPrimaryClip(ClipData.newPlainText("", ""));
}
}).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
;
}
}).show();
}
}
} catch (Exception e) {
;
}
}
}
}
Aggregations