use of com.samourai.wallet.util.PrivKeyReader in project samourai-wallet-android by Samourai-Wallet.
the class OpenDimeActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_opendime);
setTitle(R.string.samourai_opendime);
if (!AccessFactory.getInstance(OpenDimeActivity.this).isLoggedIn()) {
Intent _intent = new Intent(OpenDimeActivity.this, PinEntryActivity.class);
_intent.putExtra("opendime", true);
_intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(_intent);
}
display = (OpenDimeActivity.this).getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
imgWidth = Math.max(size.x - 300, 150);
tvAddress = (TextView) findViewById(R.id.address);
tvBalance = (TextView) findViewById(R.id.balanceAmount);
tvKey = (TextView) findViewById(R.id.keyStatus);
ivQR = (ImageView) findViewById(R.id.qr);
btTopUp = (Button) findViewById(R.id.topup);
btView = (Button) findViewById(R.id.view);
btSweep = (Button) findViewById(R.id.sweep);
btTopUp.setVisibility(View.GONE);
/*
btTopUp = (Button)findViewById(R.id.topup);
btTopUp.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
});
*/
btView = (Button) findViewById(R.id.view);
btView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (strAddress != null) {
String blockExplorer = "https://m.oxt.me/transaction/";
if (SamouraiWallet.getInstance().isTestNet()) {
blockExplorer = "https://blockstream.info/testnet/";
}
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(blockExplorer + strAddress));
startActivity(browserIntent);
}
}
});
btSweep = (Button) findViewById(R.id.sweep);
btSweep.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (strPrivKey != null) {
SweepUtil.getInstance(OpenDimeActivity.this).sweep(new PrivKeyReader(strPrivKey), SweepUtil.TYPE_P2PKH);
}
}
});
ivQR.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (strAddress != null) {
new AlertDialog.Builder(OpenDimeActivity.this).setTitle(R.string.app_name).setMessage(R.string.receive_address_to_clipboard).setCancelable(false).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) OpenDimeActivity.this.getSystemService(android.content.Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = null;
clip = android.content.ClipData.newPlainText("Receive address", strAddress);
clipboard.setPrimaryClip(clip);
Toast.makeText(OpenDimeActivity.this, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show();
}
}).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
;
}
}).show();
}
return false;
}
});
IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
registerReceiver(usbReceiver, filter);
readOpenDimeUSB();
}
use of com.samourai.wallet.util.PrivKeyReader 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.PrivKeyReader 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) {
;
}
}
}
}
use of com.samourai.wallet.util.PrivKeyReader in project samourai-wallet-android by Samourai-Wallet.
the class BalanceActivity method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK && requestCode == SCAN_COLD_STORAGE) {
if (data != null && data.getStringExtra(ZBarConstants.SCAN_RESULT) != null) {
final String strResult = data.getStringExtra(ZBarConstants.SCAN_RESULT);
doPrivKey(strResult);
}
} else if (resultCode == Activity.RESULT_CANCELED && requestCode == SCAN_COLD_STORAGE) {
} else if (resultCode == Activity.RESULT_OK && requestCode == SCAN_QR) {
if (data != null && data.getStringExtra(ZBarConstants.SCAN_RESULT) != null) {
final String strResult = data.getStringExtra(ZBarConstants.SCAN_RESULT);
PrivKeyReader privKeyReader = new PrivKeyReader(new CharSequenceX(strResult.trim()));
try {
if (privKeyReader.getFormat() != null) {
doPrivKey(strResult.trim());
} else if (Cahoots.isCahoots(strResult.trim())) {
Intent cahootIntent = new Intent(this, ManualCahootsActivity.class);
cahootIntent.putExtra("_account", account);
cahootIntent.putExtra("payload", strResult.trim());
startActivity(cahootIntent);
} else if (FormatsUtil.getInstance().isPSBT(strResult.trim())) {
CahootsUtil.getInstance(BalanceActivity.this).doPSBT(strResult.trim());
} else if (DojoUtil.getInstance(BalanceActivity.this).isValidPairingPayload(strResult.trim())) {
Intent intent = new Intent(BalanceActivity.this, NetworkDashboard.class);
intent.putExtra("params", strResult.trim());
startActivity(intent);
} else {
Intent intent = new Intent(BalanceActivity.this, SendActivity.class);
intent.putExtra("uri", strResult.trim());
intent.putExtra("_account", account);
startActivity(intent);
}
} catch (Exception e) {
}
}
}
if (resultCode == Activity.RESULT_OK && requestCode == UTXO_REQUESTCODE) {
refreshTx(false, false, false);
progressBar.setVisibility(View.VISIBLE);
} else {
;
}
}
Aggregations