use of com.samourai.wallet.bip47.rpc.PaymentAddress 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;
});
}
use of com.samourai.wallet.bip47.rpc.PaymentAddress in project samourai-wallet-android by Samourai-Wallet.
the class PayNymDetailsActivity method doSync.
private void doSync() {
progressBar.setVisibility(View.VISIBLE);
Disposable disposable = Observable.fromCallable(() -> {
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("PayNymDetailsActivity", "sync receive from " + i + ":" + BIP47Util.getInstance(PayNymDetailsActivity.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("PayNymDetailsActivity", "p2pkh " + i + ":" + BIP47Util.getInstance(PayNymDetailsActivity.this).getReceiveAddress(payment_code, i).getReceiveECKey().toAddress(SamouraiWallet.getInstance().getCurrentNetworkParams()).toString());
}
String[] s = addrs.toArray(new String[addrs.size()]);
int nb = APIFactory.getInstance(this).syncBIP47Incoming(s);
// Log.i("PayNymDetailsActivity", "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("PayNymDetailsActivity", "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(this).syncBIP47Outgoing(s);
// Log.i("PayNymDetailsActivity", "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()));
return true;
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(aBoolean -> {
progressBar.setVisibility(View.INVISIBLE);
setPayNym();
}, error -> {
error.printStackTrace();
progressBar.setVisibility(View.INVISIBLE);
});
disposables.add(disposable);
}
Aggregations