use of com.samourai.wallet.util.CharSequenceX in project samourai-wallet-android by Samourai-Wallet.
the class PinEntryActivity method validateThread.
private void validateThread(final String pin, final String uri) {
progressBar.setVisibility(View.VISIBLE);
new Thread(() -> {
Looper.prepare();
if (pin.length() < AccessFactory.MIN_PIN_LENGTH || pin.length() > AccessFactory.MAX_PIN_LENGTH) {
runOnUiThread(() -> {
progressBar.setVisibility(View.INVISIBLE);
});
Toast.makeText(PinEntryActivity.this, R.string.pin_error, Toast.LENGTH_SHORT).show();
AppUtil.getInstance(PinEntryActivity.this).restartApp(getIntent().getExtras());
finish();
}
String randomKey = AccessFactory.getInstance(PinEntryActivity.this).getGUID();
if (randomKey.length() < 1) {
runOnUiThread(() -> {
progressBar.setVisibility(View.INVISIBLE);
});
Toast.makeText(PinEntryActivity.this, R.string.random_key_error, Toast.LENGTH_SHORT).show();
AppUtil.getInstance(PinEntryActivity.this).restartApp(getIntent().getExtras());
finish();
}
String hash = PrefsUtil.getInstance(PinEntryActivity.this).getValue(PrefsUtil.ACCESS_HASH, "");
if (AccessFactory.getInstance(PinEntryActivity.this).validateHash(hash, randomKey, new CharSequenceX(pin), AESUtil.DefaultPBKDF2Iterations)) {
AccessFactory.getInstance(PinEntryActivity.this).setPIN(pin);
try {
HD_Wallet hdw = PayloadUtil.getInstance(PinEntryActivity.this).restoreWalletfromJSON(new CharSequenceX(AccessFactory.getInstance(PinEntryActivity.this).getGUID() + pin));
runOnUiThread(() -> {
progressBar.setVisibility(View.INVISIBLE);
});
if (hdw == null) {
runOnUiThread(() -> {
failures++;
Toast.makeText(PinEntryActivity.this, PinEntryActivity.this.getText(R.string.login_error) + ":" + failures + "/3", Toast.LENGTH_SHORT).show();
if (failures == 3) {
failures = 0;
doBackupRestore();
} else {
Intent intent = new Intent(PinEntryActivity.this, PinEntryActivity.class);
// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
}
});
}
AccessFactory.getInstance(PinEntryActivity.this).setIsLoggedIn(true);
TimeOutUtil.getInstance().updatePin();
if (isOpenDime) {
runOnUiThread(() -> {
Intent intent = new Intent(PinEntryActivity.this, OpenDimeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
});
} else {
AppUtil.getInstance(PinEntryActivity.this).restartApp(getIntent().getExtras());
finish();
}
} catch (MnemonicException.MnemonicLengthException mle) {
mle.printStackTrace();
} catch (DecoderException de) {
de.printStackTrace();
} finally {
runOnUiThread(() -> {
progressBar.setVisibility(View.INVISIBLE);
});
}
} else {
runOnUiThread(() -> {
progressBar.setVisibility(View.INVISIBLE);
failures++;
Toast.makeText(PinEntryActivity.this, PinEntryActivity.this.getText(R.string.login_error) + ":" + failures + "/3", Toast.LENGTH_SHORT).show();
if (failures == 3) {
failures = 0;
doBackupRestore();
} else {
Intent intent = new Intent(PinEntryActivity.this, PinEntryActivity.class);
// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
if (getIntent().getExtras() != null)
intent.putExtras(getIntent().getExtras());
startActivity(intent);
finish();
}
});
}
runOnUiThread(() -> {
progressBar.setVisibility(View.INVISIBLE);
});
}).start();
}
use of com.samourai.wallet.util.CharSequenceX in project samourai-wallet-android by Samourai-Wallet.
the class SettingsActivity2 method getTrustedNode.
private void getTrustedNode() {
final EditText edNode = new EditText(SettingsActivity2.this);
edNode.setHint(R.string.trusted_node_ip_hint);
edNode.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
edNode.setText(TrustedNodeUtil.getInstance().getNode() == null ? "" : TrustedNodeUtil.getInstance().getNode());
final EditText edPort = new EditText(SettingsActivity2.this);
edPort.setHint(R.string.trusted_node_port_hint);
edPort.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_CLASS_NUMBER);
edPort.setText(TrustedNodeUtil.getInstance().getPort() == 0 ? Integer.toString(TrustedNodeUtil.DEFAULT_PORT) : Integer.toString(TrustedNodeUtil.getInstance().getPort()));
final EditText edUser = new EditText(SettingsActivity2.this);
edUser.setHint(R.string.trusted_node_user_hint);
edUser.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
edUser.setText(TrustedNodeUtil.getInstance().getUser() == null ? "" : TrustedNodeUtil.getInstance().getUser());
final EditText edPassword = new EditText(SettingsActivity2.this);
edPassword.setHint(R.string.trusted_node_password_hint);
edPassword.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_PASSWORD);
edPassword.setSingleLine(true);
edPassword.setText(TrustedNodeUtil.getInstance().getPassword() == null ? "" : TrustedNodeUtil.getInstance().getPassword());
LinearLayout restoreLayout = new LinearLayout(SettingsActivity2.this);
restoreLayout.setOrientation(LinearLayout.VERTICAL);
restoreLayout.addView(edNode);
restoreLayout.addView(edPort);
restoreLayout.addView(edUser);
restoreLayout.addView(edPassword);
AlertDialog.Builder dlg = new AlertDialog.Builder(SettingsActivity2.this).setTitle(R.string.app_name).setMessage(R.string.trusted_node).setView(restoreLayout).setCancelable(false).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
final String node = edNode.getText().toString();
final String port = edPort.getText().toString().length() == 0 ? Integer.toString(TrustedNodeUtil.DEFAULT_PORT) : edPort.getText().toString();
final String user = edUser.getText().toString();
final String password = edPassword.getText().toString();
if (node != null && node.length() > 0 && port != null && port.length() > 0 && user != null && user.length() > 0 && password != null && password.length() > 0) {
TrustedNodeUtil.getInstance().setParams(user, new CharSequenceX(password), node, Integer.parseInt(port));
final Handler handler = new Handler();
new Thread(new Runnable() {
@Override
public void run() {
Looper.prepare();
final CheckBoxPreference cbPref8 = (CheckBoxPreference) SettingsActivity2.this.findPreference("useTrustedNode");
boolean isOK = false;
JSONRPC jsonrpc = new JSONRPC(user, new CharSequenceX(password), node, Integer.parseInt(port));
String result = jsonrpc.getNetworkInfoAsString();
Log.d("TrustedNodeUtil", "getnetworkinfo:" + result);
if (result != null) {
try {
JSONObject obj = new JSONObject(result);
if (obj != null && obj.has("version") && obj.has("subversion")) {
if (obj.getString("subversion").contains("Bitcoin XT") || obj.getString("subversion").contains("Classic") || obj.getString("subversion").contains("BitcoinUnlimited") || obj.getString("subversion").contains("SegWit2x") || obj.getString("subversion").contains("Segwit2x") || obj.getString("subversion").contains("Bitcoin ABC") || obj.getString("subversion").contains("Satoshi:1.14")) {
Toast.makeText(SettingsActivity2.this, R.string.trusted_node_breaks_consensus, Toast.LENGTH_SHORT).show();
} else if (obj.getInt("version") < 130100 || !obj.getString("subversion").contains("Satoshi")) {
isOK = true;
Toast.makeText(SettingsActivity2.this, R.string.trusted_node_not_core_131, Toast.LENGTH_SHORT).show();
} else {
isOK = true;
Toast.makeText(SettingsActivity2.this, "Trusted node running:\n" + obj.getString("subversion") + ", " + obj.getInt("version"), Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(SettingsActivity2.this, R.string.trusted_node_ko, Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
Toast.makeText(SettingsActivity2.this, e.getMessage() + "\n" + R.string.trusted_node_error, Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(SettingsActivity2.this, R.string.trusted_node_not_responding, Toast.LENGTH_SHORT).show();
}
final boolean _isOK = isOK;
handler.post(new Runnable() {
@Override
public void run() {
if (_isOK) {
cbPref8.setEnabled(true);
TrustedNodeUtil.getInstance().setValidated(true);
} else {
cbPref8.setChecked(false);
cbPref8.setEnabled(false);
PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.USE_TRUSTED_NODE, false);
PrefsUtil.getInstance(SettingsActivity2.this).setValue(PrefsUtil.FEE_PROVIDER_SEL, 0);
TrustedNodeUtil.getInstance().setValidated(false);
}
SettingsActivity2.this.recreate();
}
});
Looper.loop();
}
}).start();
dialog.dismiss();
} else if ((node == null || node.length() == 0) && (port == null || port.length() == 0) && (user == null || user.length() == 0) && (password == null || password.length() == 0)) {
TrustedNodeUtil.getInstance().reset();
} else {
Toast.makeText(SettingsActivity2.this, R.string.trusted_node_not_valid, Toast.LENGTH_SHORT).show();
}
}
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.dismiss();
}
});
if (!isFinishing()) {
dlg.show();
}
}
use of com.samourai.wallet.util.CharSequenceX in project samourai-wallet-android by Samourai-Wallet.
the class SettingsActivity2 method doTroubleshoot.
private void doTroubleshoot() {
try {
final String strExpected = HD_WalletFactory.getInstance(SettingsActivity2.this).get().getPassphrase();
final EditText passphrase = new EditText(SettingsActivity2.this);
passphrase.setSingleLine(true);
passphrase.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
AlertDialog.Builder dlg = new AlertDialog.Builder(SettingsActivity2.this).setTitle(R.string.app_name).setMessage(R.string.wallet_passphrase).setView(passphrase).setCancelable(false).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
final String _passphrase39 = passphrase.getText().toString();
if (_passphrase39.equals(strExpected)) {
Toast.makeText(SettingsActivity2.this, R.string.bip39_match, Toast.LENGTH_SHORT).show();
final File file = PayloadUtil.getInstance(SettingsActivity2.this).getBackupFile();
if (file != null && file.exists()) {
new AlertDialog.Builder(SettingsActivity2.this).setTitle(R.string.app_name).setMessage(R.string.bip39_decrypt_test).setCancelable(false).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
new Thread(new Runnable() {
@Override
public void run() {
Looper.prepare();
StringBuilder sb = new StringBuilder();
try {
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF8"));
String str = null;
while ((str = in.readLine()) != null) {
sb.append(str);
}
in.close();
String data = sb.toString();
String decrypted = PayloadUtil.getInstance(SettingsActivity2.this).getDecryptedBackupPayload(data, new CharSequenceX(_passphrase39));
if (decrypted == null || decrypted.length() < 1) {
Toast.makeText(SettingsActivity2.this, R.string.backup_read_error, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(SettingsActivity2.this, R.string.backup_read_ok, Toast.LENGTH_SHORT).show();
}
} catch (FileNotFoundException fnfe) {
Toast.makeText(SettingsActivity2.this, R.string.backup_read_error, Toast.LENGTH_SHORT).show();
} catch (IOException ioe) {
Toast.makeText(SettingsActivity2.this, R.string.backup_read_error, Toast.LENGTH_SHORT).show();
}
Looper.loop();
}
}).start();
}
}).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
;
}
}).show();
}
} else {
Toast.makeText(SettingsActivity2.this, R.string.invalid_passphrase, Toast.LENGTH_SHORT).show();
}
}
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
;
}
});
if (!isFinishing()) {
dlg.show();
}
} catch (IOException ioe) {
ioe.printStackTrace();
Toast.makeText(SettingsActivity2.this, "HD wallet error", Toast.LENGTH_SHORT).show();
} catch (MnemonicException.MnemonicLengthException mle) {
mle.printStackTrace();
Toast.makeText(SettingsActivity2.this, "HD wallet error", Toast.LENGTH_SHORT).show();
}
}
use of com.samourai.wallet.util.CharSequenceX in project samourai-wallet-android by Samourai-Wallet.
the class JobRefreshService method onHandleWork.
@Override
protected void onHandleWork(@NonNull Intent intent) {
boolean dragged = intent.getBooleanExtra("dragged", false);
boolean launch = intent.getBooleanExtra("launch", false);
boolean notifTx = intent.getBooleanExtra("notifTx", false);
Log.d("JobRefreshService", "doInBackground()");
APIFactory.getInstance(this.getApplicationContext()).stayingAlive();
APIFactory.getInstance(this.getApplicationContext()).initWallet();
try {
int acc = 0;
if (AddressFactory.getInstance().getHighestTxReceiveIdx(acc) > HD_WalletFactory.getInstance(this.getApplicationContext()).get().getAccount(acc).getReceive().getAddrIdx()) {
HD_WalletFactory.getInstance(this.getApplicationContext()).get().getAccount(acc).getReceive().setAddrIdx(AddressFactory.getInstance().getHighestTxReceiveIdx(acc));
}
if (AddressFactory.getInstance().getHighestTxChangeIdx(acc) > HD_WalletFactory.getInstance(this.getApplicationContext()).get().getAccount(acc).getChange().getAddrIdx()) {
HD_WalletFactory.getInstance(this.getApplicationContext()).get().getAccount(acc).getChange().setAddrIdx(AddressFactory.getInstance().getHighestTxChangeIdx(acc));
}
if (AddressFactory.getInstance().getHighestBIP49ReceiveIdx() > BIP49Util.getInstance(this.getApplicationContext()).getWallet().getAccount(0).getReceive().getAddrIdx()) {
BIP49Util.getInstance(this.getApplicationContext()).getWallet().getAccount(0).getReceive().setAddrIdx(AddressFactory.getInstance().getHighestBIP49ReceiveIdx());
}
if (AddressFactory.getInstance().getHighestBIP49ChangeIdx() > BIP49Util.getInstance(this.getApplicationContext()).getWallet().getAccount(0).getChange().getAddrIdx()) {
BIP49Util.getInstance(this.getApplicationContext()).getWallet().getAccount(0).getChange().setAddrIdx(AddressFactory.getInstance().getHighestBIP49ChangeIdx());
}
if (AddressFactory.getInstance().getHighestBIP84ReceiveIdx() > BIP84Util.getInstance(this.getApplicationContext()).getWallet().getAccount(0).getReceive().getAddrIdx()) {
BIP84Util.getInstance(this.getApplicationContext()).getWallet().getAccount(0).getReceive().setAddrIdx(AddressFactory.getInstance().getHighestBIP84ReceiveIdx());
}
if (AddressFactory.getInstance().getHighestBIP84ChangeIdx() > BIP84Util.getInstance(this.getApplicationContext()).getWallet().getAccount(0).getChange().getAddrIdx()) {
BIP84Util.getInstance(this.getApplicationContext()).getWallet().getAccount(0).getChange().setAddrIdx(AddressFactory.getInstance().getHighestBIP84ChangeIdx());
}
} catch (IOException | MnemonicException.MnemonicLengthException | NullPointerException ioe) {
ioe.printStackTrace();
} finally {
Intent _intent = new Intent("com.samourai.wallet.BalanceFragment.DISPLAY");
LocalBroadcastManager.getInstance(this.getApplicationContext()).sendBroadcast(_intent);
}
PrefsUtil.getInstance(this.getApplicationContext()).setValue(PrefsUtil.FIRST_RUN, false);
if (notifTx && !AppUtil.getInstance(this.getApplicationContext()).isOfflineMode()) {
//
try {
PaymentCode pcode = BIP47Util.getInstance(this.getApplicationContext()).getPaymentCode();
// Log.i("BalanceFragment", "payment code:" + pcode.toString());
// Log.i("BalanceFragment", "notification address:" + pcode.notificationAddress().getAddressString());
APIFactory.getInstance(this.getApplicationContext()).getNotifAddress(pcode.notificationAddress(SamouraiWallet.getInstance().getCurrentNetworkParams()).getAddressString());
} catch (AddressFormatException afe) {
afe.printStackTrace();
Toast.makeText(this.getApplicationContext(), "HD wallet error", Toast.LENGTH_SHORT).show();
} catch (Exception ex) {
ex.printStackTrace();
}
//
// check on outgoing payment code notification tx
//
List<Pair<String, String>> outgoingUnconfirmed = BIP47Meta.getInstance().getOutgoingUnconfirmed();
// Log.i("BalanceFragment", "outgoingUnconfirmed:" + outgoingUnconfirmed.size());
for (Pair<String, String> pair : outgoingUnconfirmed) {
// Log.i("BalanceFragment", "outgoing payment code:" + pair.getLeft());
// Log.i("BalanceFragment", "outgoing payment code tx:" + pair.getRight());
int confirmations = APIFactory.getInstance(this.getApplicationContext()).getNotifTxConfirmations(pair.getRight());
if (confirmations > 0) {
BIP47Meta.getInstance().setOutgoingStatus(pair.getLeft(), BIP47Meta.STATUS_SENT_CFM);
}
if (confirmations == -1) {
BIP47Meta.getInstance().setOutgoingStatus(pair.getLeft(), BIP47Meta.STATUS_NOT_SENT);
}
}
Intent _intent = new Intent("com.samourai.wallet.MainActivity2.RESTART_SERVICE");
LocalBroadcastManager.getInstance(this.getApplicationContext()).sendBroadcast(_intent);
}
if (launch) {
if (PrefsUtil.getInstance(this.getApplicationContext()).getValue(PrefsUtil.GUID_V, 0) < 4) {
Log.i("JobIntentService", "guid_v < 4");
try {
String _guid = AccessFactory.getInstance(this.getApplicationContext()).createGUID();
String _hash = AccessFactory.getInstance(this.getApplicationContext()).getHash(_guid, new CharSequenceX(AccessFactory.getInstance(this.getApplicationContext()).getPIN()), AESUtil.DefaultPBKDF2Iterations);
PayloadUtil.getInstance(this.getApplicationContext()).saveWalletToJSON(new CharSequenceX(_guid + AccessFactory.getInstance().getPIN()));
PrefsUtil.getInstance(this.getApplicationContext()).setValue(PrefsUtil.ACCESS_HASH, _hash);
PrefsUtil.getInstance(this.getApplicationContext()).setValue(PrefsUtil.ACCESS_HASH2, _hash);
Log.i("JobIntentService", "guid_v == 4");
} catch (MnemonicException.MnemonicLengthException | IOException | JSONException | DecryptionException e) {
;
}
}
if (!PrefsUtil.getInstance(this.getApplicationContext().getApplicationContext()).getValue(PrefsUtil.XPUB44LOCK, false)) {
try {
String[] s = HD_WalletFactory.getInstance(this.getApplicationContext()).get().getXPUBs();
APIFactory.getInstance(this.getApplicationContext()).lockXPUB(s[0], 44, null);
} catch (IOException | MnemonicException.MnemonicLengthException e) {
;
}
}
if (!PrefsUtil.getInstance(this.getApplicationContext()).getValue(PrefsUtil.XPUB49LOCK, false)) {
String ypub = BIP49Util.getInstance(this.getApplicationContext()).getWallet().getAccount(0).ypubstr();
APIFactory.getInstance(this.getApplicationContext()).lockXPUB(ypub, 49, null);
}
if (!PrefsUtil.getInstance(this.getApplicationContext()).getValue(PrefsUtil.XPUB84LOCK, false)) {
String zpub = BIP84Util.getInstance(this.getApplicationContext()).getWallet().getAccount(0).zpubstr();
APIFactory.getInstance(this.getApplicationContext()).lockXPUB(zpub, 84, null);
}
if (!PrefsUtil.getInstance(this.getApplicationContext()).getValue(PrefsUtil.XPUBPRELOCK, false)) {
String zpub = BIP84Util.getInstance(this.getApplicationContext()).getWallet().getAccountAt(WhirlpoolMeta.getInstance(this.getApplicationContext()).getWhirlpoolPremixAccount()).zpubstr();
APIFactory.getInstance(this.getApplicationContext()).lockXPUB(zpub, 84, PrefsUtil.XPUBPRELOCK);
}
if (!PrefsUtil.getInstance(this.getApplicationContext()).getValue(PrefsUtil.XPUBPOSTLOCK, false)) {
String zpub = BIP84Util.getInstance(this.getApplicationContext()).getWallet().getAccountAt(WhirlpoolMeta.getInstance(this.getApplicationContext()).getWhirlpoolPostmix()).zpubstr();
APIFactory.getInstance(this.getApplicationContext()).lockXPUB(zpub, 84, PrefsUtil.XPUBPRELOCK);
}
if (!PrefsUtil.getInstance(this.getApplicationContext()).getValue(PrefsUtil.XPUBBADBANKLOCK, false)) {
String zpub = BIP84Util.getInstance(this.getApplicationContext()).getWallet().getAccountAt(WhirlpoolMeta.getInstance(this.getApplicationContext()).getWhirlpoolBadBank()).zpubstr();
APIFactory.getInstance(this.getApplicationContext()).lockXPUB(zpub, 84, PrefsUtil.XPUBBADBANKLOCK);
}
} else {
try {
PayloadUtil.getInstance(this.getApplicationContext()).saveWalletToJSON(new CharSequenceX(AccessFactory.getInstance(this.getApplicationContext()).getGUID() + AccessFactory.getInstance(this.getApplicationContext()).getPIN()));
} catch (Exception ignored) {
;
}
}
Intent _intent = new Intent("com.samourai.wallet.BalanceFragment.DISPLAY");
LocalBroadcastManager.getInstance(this.getApplicationContext()).sendBroadcast(_intent);
}
use of com.samourai.wallet.util.CharSequenceX in project samourai-wallet-android by Samourai-Wallet.
the class PayNymHome method getPcodeSyncObservable.
private Observable<String> getPcodeSyncObservable(String pcode) {
return Observable.fromCallable(() -> {
try {
PaymentCode payment_code = new PaymentCode(pcode);
int idx = 0;
boolean loop = true;
ArrayList<String> addrs = new ArrayList<String>();
while (loop) {
addrs.clear();
for (int i = idx; i < (idx + 20); i++) {
// Log.i("BIP47Activity", "sync receive from " + i + ":" + BIP47Util.getInstance(BIP47Activity.this).getReceivePubKey(payment_code, i));
BIP47Meta.getInstance().getIdx4AddrLookup().put(BIP47Util.getInstance(this).getReceivePubKey(payment_code, i), i);
BIP47Meta.getInstance().getPCode4AddrLookup().put(BIP47Util.getInstance(this).getReceivePubKey(payment_code, i), payment_code.toString());
addrs.add(BIP47Util.getInstance(this).getReceivePubKey(payment_code, i));
// Log.i("BIP47Activity", "p2pkh " + i + ":" + BIP47Util.getInstance(BIP47Activity.this).getReceiveAddress(payment_code, i).getReceiveECKey().toAddress(SamouraiWallet.getInstance().getCurrentNetworkParams()).toString());
}
String[] s = addrs.toArray(new String[addrs.size()]);
int nb = APIFactory.getInstance(getApplicationContext()).syncBIP47Incoming(s);
// Log.i("BIP47Activity", "sync receive idx:" + idx + ", nb == " + nb);
if (nb == 0) {
loop = false;
}
idx += 20;
}
idx = 0;
loop = true;
BIP47Meta.getInstance().setOutgoingIdx(pcode, 0);
while (loop) {
addrs.clear();
for (int i = idx; i < (idx + 20); i++) {
PaymentAddress sendAddress = BIP47Util.getInstance(this).getSendAddress(payment_code, i);
// Log.i("BIP47Activity", "sync send to " + i + ":" + sendAddress.getSendECKey().toAddress(SamouraiWallet.getInstance().getCurrentNetworkParams()).toString());
// BIP47Meta.getInstance().setOutgoingIdx(payment_code.toString(), i);
BIP47Meta.getInstance().getIdx4AddrLookup().put(BIP47Util.getInstance(this).getSendPubKey(payment_code, i), i);
BIP47Meta.getInstance().getPCode4AddrLookup().put(BIP47Util.getInstance(this).getSendPubKey(payment_code, i), payment_code.toString());
addrs.add(BIP47Util.getInstance(this).getSendPubKey(payment_code, i));
}
String[] s = addrs.toArray(new String[addrs.size()]);
int nb = APIFactory.getInstance(getApplicationContext()).syncBIP47Outgoing(s);
// Log.i("BIP47Activity", "sync send idx:" + idx + ", nb == " + nb);
if (nb == 0) {
loop = false;
}
idx += 20;
}
BIP47Meta.getInstance().pruneIncoming();
PayloadUtil.getInstance(this).saveWalletToJSON(new CharSequenceX(AccessFactory.getInstance(this).getGUID() + AccessFactory.getInstance(this).getPIN()));
} catch (IOException ioe) {
;
} catch (JSONException je) {
;
} catch (DecryptionException de) {
;
} catch (NotSecp256k1Exception nse) {
;
} catch (InvalidKeySpecException ikse) {
;
} catch (InvalidKeyException ike) {
;
} catch (NoSuchAlgorithmException nsae) {
;
} catch (NoSuchProviderException nspe) {
;
} catch (MnemonicException.MnemonicLengthException mle) {
;
} catch (Exception ex) {
}
return pcode;
});
}
Aggregations