Java Code Examples for net.bither.bitherj.crypto.PasswordSeed

The following examples show how to use net.bither.bitherj.crypto.PasswordSeed. These examples are extracted from open source projects. 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 Project: bither-desktop-java   Source File: AddressProvider.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void addAddress(final Address address) {
    try {

        this.mDb.getConn().setAutoCommit(false);
        String[] params = new String[]{address.getAddress(), address.hasPrivKey() ? address.getEncryptPrivKeyOfDb() : null, Base58.encode(address.getPubKey()),
                Integer.toString(address.isFromXRandom() ? 1 : 0), Integer.toString(address.isSyncComplete() ? 1 : 0), Integer.toString(address.isTrashed() ? 1 : 0), Long.toString(address.getSortTime())};
        PreparedStatement stmt = this.mDb.getConn().prepareStatement(insertAddressSql);
        if (params != null) {
            for (int i = 0; i < params.length; i++) {
                stmt.setString(i + 1, params[i]);
            }
        }
        stmt.executeUpdate();
        if (address.hasPrivKey()) {
            if (!hasPasswordSeed(this.mDb.getConn())) {
                PasswordSeed passwordSeed = new PasswordSeed(address.getAddress(), address.getFullEncryptPrivKeyOfDb());
                addPasswordSeed(this.mDb.getConn(), passwordSeed);
            }
        }
        this.mDb.getConn().commit();
        stmt.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
 
Example 2
Source Project: bither-desktop-java   Source File: AdvancePanel.java    License: Apache License 2.0 6 votes vote down vote up
private void callPassword() {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            if (PasswordSeed.hasPasswordSeed()) {
                closePanel();
                PasswordPanel dialogPassword = new PasswordPanel(new IDialogPasswordListener() {
                    @Override
                    public void onPasswordEntered(SecureCharSequence password) {
                        resetTx();

                    }
                });
                dialogPassword.showPanel();

            } else {
                resetTx();
            }
        }
    });
}
 
Example 3
Source Project: bither-android   Source File: HotAdvanceActivity.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * end
 */

private void callPassword() {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (PasswordSeed.hasPasswordSeed()) {
                DialogPassword dialogPassword = new DialogPassword(HotAdvanceActivity.this,
                        new IDialogPasswordListener() {
                            @Override
                            public void onPasswordEntered(SecureCharSequence password) {
                                AddressManager addressManager = AddressManager.getInstance();
                                if (addressManager.hasHDAccountHot()) {
                                    addressManager.getHDAccountHot().addSegwitPub(password);
                                }
                                resetTx();
                            }
                        });
                dialogPassword.show();
            } else {
                resetTx();
            }
        }
    });
}
 
Example 4
Source Project: bither-desktop-java   Source File: AddressProvider.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void addAddress(final Address address) {
    try {

        this.mDb.getConn().setAutoCommit(false);
        String[] params = new String[]{address.getAddress(), address.hasPrivKey() ? address.getEncryptPrivKeyOfDb() : null, Base58.encode(address.getPubKey()),
                Integer.toString(address.isFromXRandom() ? 1 : 0), Integer.toString(address.isSyncComplete() ? 1 : 0), Integer.toString(address.isTrashed() ? 1 : 0), Long.toString(address.getSortTime())};
        PreparedStatement stmt = this.mDb.getConn().prepareStatement(insertAddressSql);
        if (params != null) {
            for (int i = 0; i < params.length; i++) {
                stmt.setString(i + 1, params[i]);
            }
        }
        stmt.executeUpdate();
        if (address.hasPrivKey()) {
            if (!hasPasswordSeed(this.mDb.getConn())) {
                PasswordSeed passwordSeed = new PasswordSeed(address.getAddress(), address.getFullEncryptPrivKeyOfDb());
                addPasswordSeed(this.mDb.getConn(), passwordSeed);
            }
        }
        this.mDb.getConn().commit();
        stmt.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
 
Example 5
Source Project: bither-desktop-java   Source File: AdvancePanel.java    License: Apache License 2.0 6 votes vote down vote up
private void callPassword() {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            if (PasswordSeed.hasPasswordSeed()) {
                closePanel();
                PasswordPanel dialogPassword = new PasswordPanel(new IDialogPasswordListener() {
                    @Override
                    public void onPasswordEntered(SecureCharSequence password) {
                        resetTx();

                    }
                });
                dialogPassword.showPanel();

            } else {
                resetTx();
            }
        }
    });
}
 
Example 6
Source Project: bither-desktop-java   Source File: CheckUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static Check initCheckForPrivateKey(
        final Address address, final SecureCharSequence password) {
    String title = String.format(LocaliserUtils.getString("check_address_private_key_title"), address
            .getShortAddress());
    Check check = new Check(title, new ICheckAction() {

        @Override
        public boolean check() {
            boolean result = new PasswordSeed(address.getAddress(), address.getFullEncryptPrivKey()).checkPassword(password);
            if (!result) {
                try {
                    ECKey eckeyFromBackup = BackupUtil.getEckeyFromBackup(
                            address.getAddress(), password);
                    if (eckeyFromBackup != null) {
                        String encryptPrivateKey = PrivateKeyUtil.getEncryptedString(eckeyFromBackup);
                        if (!Utils.isEmpty(encryptPrivateKey)) {
                            address.recoverFromBackup(encryptPrivateKey);
                            result = true;
                        }
                        eckeyFromBackup.clearPrivateKey();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    password.wipe();
                }


            }
            return result;
        }
    });
    return check;
}
 
Example 7
Source Project: bither-desktop-java   Source File: AddressProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int addHDKey(final String encryptedMnemonicSeed, final String encryptHdSeed, final String firstAddress, final boolean isXrandom, final String addressOfPS) {
    int result = 0;
    try {
        this.mDb.getConn().setAutoCommit(false);
        String[] params = new String[]{encryptedMnemonicSeed, encryptHdSeed, Integer.toString(isXrandom ? 1 : 0), firstAddress};
        PreparedStatement stmt = this.mDb.getConn().prepareStatement(insertHDSeedSql);
        if (params != null) {
            for (int i = 0; i < params.length; i++) {
                stmt.setString(i + 1, params[i]);
            }
        }
        stmt.executeUpdate();
        stmt.close();
        if (!hasPasswordSeed(this.mDb.getConn()) && !Utils.isEmpty(addressOfPS)) {
            addPasswordSeed(this.mDb.getConn(), new PasswordSeed(addressOfPS, encryptedMnemonicSeed));
        }
        this.mDb.getConn().commit();
        PreparedStatement statement = this.mDb.getPreparedStatement("select hd_seed_id from hd_seeds where encrypt_seed=? and encrypt_hd_seed=? and is_xrandom=? and hdm_address=?"
                , new String[]{encryptedMnemonicSeed, encryptHdSeed, Integer.toString(isXrandom ? 1 : 0), firstAddress});
        ResultSet cursor = statement.executeQuery();

        if (cursor.next()) {
            int idColumn = cursor.findColumn(AbstractDb.HDSeedsColumns.HD_SEED_ID);
            if (idColumn != -1) {
                result = cursor.getInt(idColumn);
            }

        }
        cursor.close();
        statement.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return result;
}
 
Example 8
Source Project: bither-desktop-java   Source File: AdvancePanel.java    License: Apache License 2.0 5 votes vote down vote up
private void reloadTx() {

        if (Bither.canReloadTx()) {
            Runnable confirmRunnable = new Runnable() {
                @Override
                public void run() {
                    Bither.reloadTxTime = System.currentTimeMillis();
                    PasswordSeed passwordSeed = PasswordSeed.getPasswordSeed();
                    if (passwordSeed == null) {
                        resetTx();
                    } else {
                        callPassword();
                    }
                }
            };
            DialogConfirmTask dialogConfirmTask = new DialogConfirmTask(
                    LocaliserUtils.getString("reload_tx_need_too_much_time"), confirmRunnable
            );
            dialogConfirmTask.pack();
            dialogConfirmTask.setVisible(true);
        } else {
            new MessageDialog(LocaliserUtils.getString("tx_cannot_reloding")).showMsg();

        }


    }
 
Example 9
Source Project: bither-desktop-java   Source File: PasswordPanel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initialiseContent(JPanel panel) {

    panel.setLayout(new MigLayout(
            Panels.migXYLayout(),
            "[]", // Column constraints
            "[][]" // Row constraints
    ));


    panel.add(progressPanel, "align center,shrink,wrap");

    panel.add(newPasswordPanel, "wrap");

    if (PasswordSeed.hasPasswordSeed()) {
        labConfirmPassword.setVisible(false);
        repeatNewPassword.setVisible(false);
    }

    passwordCheck.setCheckListener(passwordCheckListener);
    newPassword.addKeyListener(passwordWatcher);
    repeatNewPassword.addKeyListener(passwordWatcher);
    configureCheckPre();
    showCheckPre();


}
 
Example 10
Source Project: bither-desktop-java   Source File: UserPreference.java    License: Apache License 2.0 5 votes vote down vote up
private PasswordSeed getPasswordSeed() {
    String str = getString(PASSWORD_SEED, "");
    if (Utils.isEmpty(str)) {
        return null;
    }
    return new PasswordSeed(str);
}
 
Example 11
Source Project: bither-android   Source File: AddColdAddressActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    setContentView(R.layout.activity_add_cold_address);
    if (!PasswordSeed.hasPasswordSeed()) {
        shouldSuggestCheck = true;
    } else {
        shouldSuggestCheck = false;
    }
    initView();
}
 
Example 12
Source Project: bither-android   Source File: AddHotAddressActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    setContentView(R.layout.activity_add_hot_address);
    if (!PasswordSeed.hasPasswordSeed()) {
        shouldSuggestCheck = true;
    } else {
        shouldSuggestCheck = false;
    }
    initView();
}
 
Example 13
Source Project: bither-android   Source File: HotAdvanceActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {

    if (BitherApplication.canReloadTx()) {
        final Runnable confirmRunnable = new Runnable() {
            @Override
            public void run() {
                BitherApplication.reloadTxTime = System.currentTimeMillis();
                PasswordSeed passwordSeed = PasswordSeed.getPasswordSeed();
                if (passwordSeed == null) {
                    // TODO: the dialog determine the web type
                    // showSelectedDialog();

                    resetTx();

                } else {
                    callPassword();
                }
            }

        };

        DialogConfirmTask dialogConfirmTask = new DialogConfirmTask(HotAdvanceActivity
                .this, getString(R.string.reload_tx_need_too_much_time), confirmRunnable);
        dialogConfirmTask.show();

    } else {
        DropdownMessage.showDropdownMessage(HotAdvanceActivity.this,
                R.string.tx_cannot_reloding);
    }


}
 
Example 14
Source Project: bither-android   Source File: CheckUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static Check initCheckForPrivateKey(
        final Address address, final SecureCharSequence password) {
    String title = String.format(BitherApplication.mContext.getString(R.string
            .check_address_private_key_title), address.getShortAddress());
    Check check = new Check(title, new ICheckAction() {

        @Override
        public boolean check() {
            PasswordSeed passwordSeed = new PasswordSeed(address.getAddress(), address.getFullEncryptPrivKey());
            boolean result = passwordSeed.checkPassword(password);
            if (!result) {
                try {
                    ECKey eckeyFromBackup = BackupUtil.getEckeyFromBackup(
                            address.getAddress(), password);
                    if (eckeyFromBackup != null) {
                        String encryptPrivateKey = PrivateKeyUtil.getEncryptedString(eckeyFromBackup);
                        eckeyFromBackup.clearPrivateKey();
                        if (!Utils.isEmpty(encryptPrivateKey)) {
                            address.recoverFromBackup(encryptPrivateKey);
                            result = true;
                        }

                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            password.wipe();
            return result;
        }
    });
    return check;
}
 
Example 15
Source Project: bitherj   Source File: ImportPrivateKey.java    License: Apache License 2.0 5 votes vote down vote up
private Address addECKey(ECKey ecKey) {
    String encryptedPrivateString;
    if (importPrivateKeyType == ImportPrivateKeyType.BitherQrcode) {
        encryptedPrivateString = QRCodeUtil.getNewVersionEncryptPrivKey(content);
    } else {
        ecKey = PrivateKeyUtil.encrypt(ecKey, password);
        encryptedPrivateString = PrivateKeyUtil.getEncryptedString(ecKey);
    }
    Address address = new Address(ecKey.toAddress(), ecKey.getPubKey(), encryptedPrivateString
            , false, ecKey.isFromXRandom());
    if (AddressManager.getInstance().getWatchOnlyAddresses().contains(address)) {
        password.wipe();
        importError(CAN_NOT_IMPORT_BITHER_COLD_PRIVATE_KEY);
        return null;
    } else if (AddressManager.getInstance().getPrivKeyAddresses().contains(address)) {
        password.wipe();
        importError(PRIVATE_KEY_ALREADY_EXISTS);
        return null;

    } else {
        if (importPrivateKeyType == ImportPrivateKeyType.BitherQrcode) {
            PasswordSeed passwordSeed = PasswordSeed.getPasswordSeed();
            if (passwordSeed != null && !passwordSeed.checkPassword(password)) {
                password.wipe();
                importError(PASSWORD_IS_DIFFEREND_LOCAL);
                return null;
            }
        } else {
            password.wipe();
        }
        return address;


    }

}
 
Example 16
Source Project: bitherj   Source File: AbstractAddressProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public PasswordSeed getPasswordSeed() {
    final PasswordSeed[] passwordSeed = {null};
    String sql = "select password_seed from password_seed limit 1";
    this.execQueryOneRecord(sql, null, new Function<ICursor, Void>() {
        @Nullable
        @Override
        public Void apply(@Nullable ICursor c) {
            passwordSeed[0] = applyPasswordSeed(c);
            return null;
        }
    });
    return passwordSeed[0];
}
 
Example 17
Source Project: bitherj   Source File: AbstractAddressProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int addHDKey(String encryptedMnemonicSeed, String encryptHdSeed, String firstAddress, boolean isXrandom, String addressOfPS) {
    IDb db = this.getWriteDb();
    db.beginTransaction();
    int seedId = this.insertHDKeyToDb(db, encryptedMnemonicSeed, encryptHdSeed, firstAddress, isXrandom);
    if (!hasPasswordSeed(db) && !Utils.isEmpty(addressOfPS)) {
        this.addPasswordSeed(db, new PasswordSeed(addressOfPS, encryptedMnemonicSeed));
    }
    db.endTransaction();
    return seedId;
}
 
Example 18
Source Project: bitherj   Source File: AbstractAddressProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int addEnterpriseHDKey(String encryptedMnemonicSeed, String encryptHdSeed, String firstAddress, boolean isXrandom, String addressOfPS) {
    IDb writeDb = this.getWriteDb();
    writeDb.beginTransaction();
    int seedId = this.insertEnterpriseHDKeyToDb(writeDb, encryptedMnemonicSeed, encryptHdSeed, firstAddress, isXrandom);
    if (!hasPasswordSeed(writeDb) && !Utils.isEmpty(addressOfPS)) {
        addPasswordSeed(writeDb, new PasswordSeed(addressOfPS, encryptedMnemonicSeed));
    }
    writeDb.endTransaction();
    return seedId;
}
 
Example 19
Source Project: bitherj   Source File: AbstractAddressProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void addAddress(Address address) {
    IDb writeDb = this.getWriteDb();
    writeDb.beginTransaction();
    this.insertAddressToDb(writeDb, address);
    if (address.hasPrivKey()) {
        if (!hasPasswordSeed(writeDb)) {
            PasswordSeed passwordSeed = new PasswordSeed(address.getAddress(), address.getFullEncryptPrivKeyOfDb());
            addPasswordSeed(writeDb, passwordSeed);
        }
    }
    writeDb.endTransaction();
}
 
Example 20
Source Project: bitherj   Source File: AbstractAddressProvider.java    License: Apache License 2.0 5 votes vote down vote up
public PasswordSeed applyPasswordSeed(ICursor c) {
    int idColumn = c.getColumnIndex(AbstractDb.PasswordSeedColumns.PASSWORD_SEED);
    String passwordSeed = null;
    if (idColumn != -1) {
        passwordSeed = c.getString(idColumn);
    }
    if (Utils.isEmpty(passwordSeed)) {
        return null;
    }
    return new PasswordSeed(passwordSeed);
}
 
Example 21
Source Project: bitherj   Source File: AbstractHDAccountProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
    public int addHDAccount(String encryptedMnemonicSeed, String encryptSeed, String firstAddress
            , boolean isXrandom, String addressOfPS, byte[] externalPub
            , byte[] internalPub) {
        if (this.isPubExist(externalPub, internalPub)) {
            return -1;
        }
        IDb writeDb = this.getWriteDb();
        writeDb.beginTransaction();
        int hdAccountId = this.insertHDAccountToDb(writeDb, encryptedMnemonicSeed, encryptSeed
                , firstAddress, isXrandom, externalPub, internalPub);
        if (!this.hasPasswordSeed(writeDb) && !Utils.isEmpty(addressOfPS)) {
            this.addPasswordSeed(writeDb, new PasswordSeed(addressOfPS, encryptedMnemonicSeed));
        }
        writeDb.endTransaction();
        return hdAccountId;

//        SQLiteDatabase db = this.mDb.getWritableDatabase();
//        db.beginTransaction();
//        ContentValues cv = new ContentValues();
//        cv.put(AbstractDb.HDAccountColumns.ENCRYPT_SEED, encryptSeed);
//        cv.put(AbstractDb.HDAccountColumns.ENCRYPT_MNMONIC_SEED, encryptedMnemonicSeed);
//        cv.put(AbstractDb.HDAccountColumns.IS_XRANDOM, isXrandom ? 1 : 0);
//        cv.put(AbstractDb.HDAccountColumns.HD_ADDRESS, firstAddress);
//        cv.put(AbstractDb.HDAccountColumns.EXTERNAL_PUB, Base58.encode(externalPub));
//        cv.put(AbstractDb.HDAccountColumns.INTERNAL_PUB, Base58.encode(internalPub));
//        int seedId = (int) db.insert(AbstractDb.Tables.HD_ACCOUNT, null, cv);
//        if (!AddressProvider.hasPasswordSeed(db) && !Utils.isEmpty(addressOfPS)) {
//            AddressProvider.addPasswordSeed(db, new PasswordSeed(addressOfPS, encryptedMnemonicSeed));
//        }
//        db.setTransactionSuccessful();
//        db.endTransaction();
//        return seedId;
    }
 
Example 22
Source Project: bitherj   Source File: HDMKeychain.java    License: Apache License 2.0 5 votes vote down vote up
public PasswordSeed createPasswordSeed(CharSequence password) {
    if (isInRecovery()) {
        throw new AssertionError("HDM in recovery can not create passwordSeed");
    }
    String encrypted = AbstractDb.addressProvider.getEncryptMnemonicSeed(hdSeedId);
    byte[] priv = new EncryptedData(encrypted).decrypt(password);
    ECKey k = new ECKey(priv, null);
    String address = k.toAddress();
    Utils.wipeBytes(priv);
    k.clearPrivateKey();
    return new PasswordSeed(address, encrypted);
}
 
Example 23
Source Project: bither-desktop-java   Source File: CheckUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static Check initCheckForPrivateKey(
        final Address address, final SecureCharSequence password) {
    String title = String.format(LocaliserUtils.getString("check_address_private_key_title"), address
            .getShortAddress());
    Check check = new Check(title, new ICheckAction() {

        @Override
        public boolean check() {
            boolean result = new PasswordSeed(address.getAddress(), address.getFullEncryptPrivKey()).checkPassword(password);
            if (!result) {
                try {
                    ECKey eckeyFromBackup = BackupUtil.getEckeyFromBackup(
                            address.getAddress(), password);
                    if (eckeyFromBackup != null) {
                        String encryptPrivateKey = PrivateKeyUtil.getEncryptedString(eckeyFromBackup);
                        if (!Utils.isEmpty(encryptPrivateKey)) {
                            address.recoverFromBackup(encryptPrivateKey);
                            result = true;
                        }
                        eckeyFromBackup.clearPrivateKey();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    password.wipe();
                }


            }
            return result;
        }
    });
    return check;
}
 
Example 24
Source Project: bither-desktop-java   Source File: AddressProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int addHDKey(final String encryptedMnemonicSeed, final String encryptHdSeed, final String firstAddress, final boolean isXrandom, final String addressOfPS) {
    int result = 0;
    try {
        this.mDb.getConn().setAutoCommit(false);
        String[] params = new String[]{encryptedMnemonicSeed, encryptHdSeed, Integer.toString(isXrandom ? 1 : 0), firstAddress};
        PreparedStatement stmt = this.mDb.getConn().prepareStatement(insertHDSeedSql);
        if (params != null) {
            for (int i = 0; i < params.length; i++) {
                stmt.setString(i + 1, params[i]);
            }
        }
        stmt.executeUpdate();
        stmt.close();
        if (!hasPasswordSeed(this.mDb.getConn()) && !Utils.isEmpty(addressOfPS)) {
            addPasswordSeed(this.mDb.getConn(), new PasswordSeed(addressOfPS, encryptedMnemonicSeed));
        }
        this.mDb.getConn().commit();
        PreparedStatement statement = this.mDb.getPreparedStatement("select hd_seed_id from hd_seeds where encrypt_seed=? and encrypt_hd_seed=? and is_xrandom=? and hdm_address=?"
                , new String[]{encryptedMnemonicSeed, encryptHdSeed, Integer.toString(isXrandom ? 1 : 0), firstAddress});
        ResultSet cursor = statement.executeQuery();

        if (cursor.next()) {
            int idColumn = cursor.findColumn(AbstractDb.HDSeedsColumns.HD_SEED_ID);
            if (idColumn != -1) {
                result = cursor.getInt(idColumn);
            }

        }
        cursor.close();
        statement.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return result;
}
 
Example 25
Source Project: bither-desktop-java   Source File: AdvancePanel.java    License: Apache License 2.0 5 votes vote down vote up
private void reloadTx() {

        if (Bither.canReloadTx()) {
            Runnable confirmRunnable = new Runnable() {
                @Override
                public void run() {
                    Bither.reloadTxTime = System.currentTimeMillis();
                    PasswordSeed passwordSeed = PasswordSeed.getPasswordSeed();
                    if (passwordSeed == null) {
                        resetTx();
                    } else {
                        callPassword();
                    }
                }
            };
            DialogConfirmTask dialogConfirmTask = new DialogConfirmTask(
                    LocaliserUtils.getString("reload_tx_need_too_much_time"), confirmRunnable
            );
            dialogConfirmTask.pack();
            dialogConfirmTask.setVisible(true);
        } else {
            new MessageDialog(LocaliserUtils.getString("tx_cannot_reloding")).showMsg();

        }


    }
 
Example 26
Source Project: bither-desktop-java   Source File: PasswordPanel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initialiseContent(JPanel panel) {

    panel.setLayout(new MigLayout(
            Panels.migXYLayout(),
            "[]", // Column constraints
            "[][]" // Row constraints
    ));


    panel.add(progressPanel, "align center,shrink,wrap");

    panel.add(newPasswordPanel, "wrap");

    if (PasswordSeed.hasPasswordSeed()) {
        labConfirmPassword.setVisible(false);
        repeatNewPassword.setVisible(false);
    }

    passwordCheck.setCheckListener(passwordCheckListener);
    newPassword.addKeyListener(passwordWatcher);
    repeatNewPassword.addKeyListener(passwordWatcher);
    configureCheckPre();
    showCheckPre();


}
 
Example 27
Source Project: bither-desktop-java   Source File: UserPreference.java    License: Apache License 2.0 5 votes vote down vote up
private PasswordSeed getPasswordSeed() {
    String str = getString(PASSWORD_SEED, "");
    if (Utils.isEmpty(str)) {
        return null;
    }
    return new PasswordSeed(str);
}
 
Example 28
Source Project: bither-desktop-java   Source File: AddressProvider.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public int addHDAccount(String encryptedMnemonicSeed, String encryptSeed,
                        String firstAddress, boolean isXrandom, String addressOfPS,
                        byte[] externalPub, byte[] internalPub) {
    int result = 0;
    try {

        String[] params = new String[]{encryptedMnemonicSeed, encryptSeed, firstAddress, Base58.encode(externalPub)
                , Base58.encode(internalPub), Integer.toString(isXrandom ? 1 : 0),};
        String sql = "insert into hd_account(encrypt_mnemonic_seed,encrypt_seed" +
                ",hd_address,external_pub,internal_pub,is_xrandom) " +
                " values(?,?,?,?,?,?)";

        this.mDb.getConn().setAutoCommit(false);

        PreparedStatement stmt = this.mDb.getConn().prepareStatement(sql);
        if (params != null) {
            for (int i = 0; i < params.length; i++) {
                stmt.setString(i + 1, params[i]);
            }
        }
        stmt.executeUpdate();
        stmt.close();
        if (!hasPasswordSeed(this.mDb.getConn()) && !Utils.isEmpty(addressOfPS)) {
            addPasswordSeed(this.mDb.getConn(), new PasswordSeed(addressOfPS, encryptedMnemonicSeed));
        }
        this.mDb.getConn().commit();
        stmt = this.mDb.getPreparedStatement("select hd_account_id from hd_account where encrypt_mnemonic_seed=? and encrypt_seed=? and is_xrandom=? and hd_address=?"
                , new String[]{encryptedMnemonicSeed, encryptSeed, Integer.toString(isXrandom ? 1 : 0), firstAddress});
        ResultSet cursor = stmt.executeQuery();
        if (cursor.next()) {
            int idColumn = cursor.findColumn(AbstractDb.HDAccountColumns.HD_ACCOUNT_ID);
            if (idColumn != -1) {
                result = cursor.getInt(idColumn);
            }

        }
        cursor.close();
        stmt.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return result;

}
 
Example 29
Source Project: bither-desktop-java   Source File: AddressProvider.java    License: Apache License 2.0 4 votes vote down vote up
public void addPasswordSeed(Connection conn, PasswordSeed passwordSeed) throws SQLException {
    PreparedStatement stmt = conn.prepareStatement("insert into password_seed (password_seed)  values (?)");
    stmt.setString(1, passwordSeed.toPasswordSeedString());
    stmt.executeUpdate();
    stmt.close();
}
 
Example 30
Source Project: bither-desktop-java   Source File: PasswordPanel.java    License: Apache License 2.0 4 votes vote down vote up
private PasswordSeed getPasswordSeed() {
    return PasswordSeed.getPasswordSeed();
}