com.btchip.BTChipConstants Java Examples

The following examples show how to use com.btchip.BTChipConstants. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LedgerTransportTEEProxy.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
private boolean needExternalUI(byte[] commandParam) {
	// Some commands need to call the Trusted UI :
	// SETUP, VERIFY PIN, HASH INPUT FINALIZE, HASH INPUT FINALIZE FULL
	byte ins = commandParam[1];
	switch(ins) {
		case BTChipConstants.BTCHIP_INS_SETUP:
		case BTChipConstants.BTCHIP_INS_VERIFY_PIN:
		case BTChipConstants.BTCHIP_INS_HASH_INPUT_FINALIZE:
		case BTChipConstants.BTCHIP_INS_HASH_INPUT_FINALIZE_FULL:
			return true;
		default:
			return false;
	}
}
 
Example #2
Source File: AbstractTest.java    From ledger-javacard with GNU Affero General Public License v3.0 5 votes vote down vote up
protected BTChipDongle prepareDongleRestoreTestnet(boolean debug) throws BTChipException {
	BTChipDongle dongle = getDongle(debug);
	dongle.setup(
		new BTChipDongle.OperationMode[] { BTChipDongle.OperationMode.WALLET },
		new BTChipDongle.Feature[] { BTChipDongle.Feature.RFC6979, BTChipDongle.Feature.NO_2FA_P2SH},
		TESTNET_VERSION,
		TESTNET_P2SH_VERSION,
		DEFAULT_PIN,
		null,
		BTChipConstants.QWERTY_KEYMAP,
		DEFAULT_SEED,
		null);
	return dongle;
}
 
Example #3
Source File: RequestLoginActivity.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
private void setupLedgerConnection() {
    showInstructions(R.string.logging_in);
    final String pin = mPin;
    mPin = null;

    final BTChipTransport transport;
    if (mUsb != null) {
        transport = BTChipTransportAndroid.open(mUsbManager, mUsb);
        if (transport == null) {
            showInstructions(R.string.hw_wallet_reconnect);
            return;
        }
    } else if ((transport = getTransport(mTag)) == null) {
        showInstructions(R.string.hw_wallet_headline);

        // Prompt the user to tap
        runOnUiThread(new Runnable() {
            public void run() {
                mNfcWaitDialog = new MaterialDialog.Builder(RequestLoginActivity.this)
                    .title(R.string.btchip).content(R.string.please_tap_card).build();
                mNfcWaitDialog.show();
            }
        });
        return;
    }

    transport.setDebug(BuildConfig.DEBUG);
    try {
        final BTChipFirmware fw = (new BTChipDongle(transport, true)).getFirmwareVersion();
        final int major = fw.getMajor(), minor = fw.getMinor(), patch = fw.getPatch();

        Log.d(TAG, "BTChip/Ledger firmware version " + fw.toString() + '(' +
                major + '.' + minor + '.' + patch + ')');

        boolean isFirmwareOutdated = false;
        if (mVendorId == VENDOR_BTCHIP) {
            isFirmwareOutdated = major < 0x2001 ||
                (major == 0x2001 && minor < 0) || // Just for consistency in checking code
                (major == 0x2001 && minor == 0 && patch < 4);
        } else if (mVendorId == VENDOR_LEDGER) {
            isFirmwareOutdated = major < 0x3001 ||
                (major == 0x3001 && minor < 2) ||
                (major == 0x3001 && minor == 2 && patch < 5);
        }

        if (!isFirmwareOutdated) {
            onLedgerConnected(transport, pin);
            return;
        }

        showFirmwareOutdated(R.string.ledger_firmware_outdated,
                             new Runnable() { public void run() { onLedgerConnected(transport, pin); } });
    } catch (final BTChipException e) {
        if (e.getSW() != BTChipConstants.SW_INS_NOT_SUPPORTED)
            e.printStackTrace();
        // We are in dashboard mode, prompt the user to open the btcoin app.
        showInstructions(R.string.ledger_open_bitcoin_app);
    }
}