Java Code Examples for net.bither.bitherj.core.Address#getAddress()

The following examples show how to use net.bither.bitherj.core.Address#getAddress() . 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: AddressTableModel.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
@Override
public Object getValueAt(int i, int i2) {
    Address address = this.addressList.get(i);
    switch (i2) {
        case 0:
            if (address instanceof HDAccount) {
                return LocaliserUtils.getString("add_hd_account_tab_hd");
            }
            return address.getAddress();
        case 1:

            return address.hasPrivKey();
        case 2:
            return Utils.compareString(address.getAddress(), selectAddress);

    }

    return "";
}
 
Example 2
Source File: AddressProvider.java    From bither-desktop-java with 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 3
Source File: AddressTableModel.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
@Override
public Object getValueAt(int i, int i2) {
    Address address = this.addressList.get(i);
    switch (i2) {
        case 0:
            if (address instanceof HDAccount) {
                return LocaliserUtils.getString("add_hd_account_tab_hd");
            }
            return address.getAddress();
        case 1:

            return address.hasPrivKey();
        case 2:
            return Utils.compareString(address.getAddress(), selectAddress);

    }

    return "";
}
 
Example 4
Source File: AddressProvider.java    From bither-desktop-java with 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 File: AddressCheck.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public AddressCheck(Address address, CheckStatus checkStatus) {
    this.address = address;
    this.checkStatus = checkStatus;
    this.dispalyName = address.getAddress();
    this.checkType = CheckType.Address;

}
 
Example 6
Source File: DialogAddressWithShowPrivateKey.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public DialogAddressWithShowPrivateKey(Activity context, Address address,
                                       DialogAddressAlias.DialogAddressAliasDelegate
                                               aliasDelegate) {
    super(context);
    this.activity = context;
    this.address = address;
    this.aliasDelegate = aliasDelegate;
    setOnDismissListener(this);
    setContentView(R.layout.dialog_address_with_show_private_key);
    llOriginQRCode = (LinearLayout) findViewById(R.id.ll_origin_qr_code);
    llSignMessage = (LinearLayout) findViewById(R.id.ll_sign_message);
    findViewById(R.id.tv_view_show_private_key).setOnClickListener(this);
    findViewById(R.id.tv_private_key_qr_code_decrypted).setOnClickListener(this);
    findViewById(R.id.tv_private_key_qr_code_encrypted).setOnClickListener(this);
    findViewById(R.id.tv_private_key_qr_code_bip38).setOnClickListener(this);
    findViewById(R.id.tv_trash_private_key).setOnClickListener(this);
    findViewById(R.id.ll_address_alias).setOnClickListener(this);
    llOriginQRCode.setOnClickListener(this);
    llOriginQRCode.setVisibility(View.GONE);
    if (AppSharedPreference.getInstance().getAppMode() == BitherjSettings.AppMode.COLD) {
        llSignMessage.setVisibility(View.VISIBLE);
        llSignMessage.setOnClickListener(this);
    } else {
        llSignMessage.setVisibility(View.GONE);
    }
    findViewById(R.id.tv_close).setOnClickListener(this);
    dialogQr = new DialogFancyQrCode(context, address.getAddress(), false, true);
    dialogPrivateKey = new DialogPrivateKeyQrCode(context, address.getFullEncryptPrivKey(),
            address.getAddress());
    if (aliasDelegate == null) {
        findViewById(R.id.ll_address_alias).setVisibility(View.GONE);
    }
}
 
Example 7
Source File: CheckUtil.java    From bither-android with 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 8
Source File: AbstractAddressProvider.java    From bitherj with 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 9
Source File: AddressCheck.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public AddressCheck(Address address, CheckStatus checkStatus) {
    this.address = address;
    this.checkStatus = checkStatus;
    this.dispalyName = address.getAddress();
    this.checkType = CheckType.Address;

}
 
Example 10
Source File: SendBitcoinPanel.java    From bither-desktop-java with Apache License 2.0 4 votes vote down vote up
@Override
public void selectAddress(Address address) {
    changeAddress = address.getAddress();
}
 
Example 11
Source File: UnSignTxPanel.java    From bither-desktop-java with Apache License 2.0 4 votes vote down vote up
@Override
public void selectAddress(Address address) {
    changeAddress = address.getAddress();
}
 
Example 12
Source File: AddressDetailHeader.java    From bither-android with Apache License 2.0 4 votes vote down vote up
public void showAddress(final Address address, int addressPosition, boolean isSegwitAddress) {
        this.addressPosition = addressPosition;
        String addrStr;
        if (address.isHDAccount()) {
            addrStr = address.getAddress(isSegwitAddress);
        } else {
            addrStr = address.getAddress();
        }
        if (addrStr == null) {
            return;
        }
        tvAddress.setText(WalletUtils.formatHash(addrStr,4,12));
        if (!Utils.compareString(strAddress, addrStr)) {
            Qr.QrCodeTheme theme = AppSharedPreference.getInstance().getFancyQrCodeTheme();
            ivQr.setContent(addrStr, theme.getFgColor(), theme.getBgColor());
        }
        strAddress = addrStr;
        llMore.setVisibility(View.VISIBLE);
        if (address.txCount() == 0) {
            tvNoTransactions.setVisibility(View.VISIBLE);
        } else {
            tvNoTransactions.setVisibility(View.GONE);
        }
        btnBalance.setAmount(address.getBalance());
        if ((address.isHDM() && !(address instanceof EnterpriseHDMAddress)) || address.hasPrivKey
                ()) {
            btnSend.setCompoundDrawables(null, null, null, null);
        } else {
            Drawable d = getContext().getResources().getDrawable(R.drawable
                    .unsigned_transaction_button_icon);
            int size = UIUtil.dip2pix(20);
            int topOffset = UIUtil.dip2pix(0.5f);
            d.setBounds(0, topOffset, size, size + topOffset);
            btnSend.setCompoundDrawables(null, null, d, null);
        }
//        } else {
//            llMore.setVisibility(View.GONE);
//        }
        llMonitorFailed.setVisibility(View.GONE);
//        } else {
//            llMore.setVisibility(View.GONE);
//            tvNoTransactions.setVisibility(View.GONE);
//            llMonitorFailed.setVisibility(View.VISIBLE);
//        }
        if (address.isHDAccount()) {
            ibtnBalanceDetail.setVisibility(View.GONE);
        } else {
            ibtnBalanceDetail.setVisibility(View.VISIBLE);
        }
        this.address = address;
        if(balanceDetailFuture != null){
            balanceDetailFuture.cancel(true);
        }
        balanceDetailFuture = new FutureTask<DialogBalanceDetail.Info>(getBalanceInfo);
        new Thread(balanceDetailFuture).start();
    }
 
Example 13
Source File: SendBitcoinPanel.java    From bither-desktop-java with Apache License 2.0 4 votes vote down vote up
@Override
public void selectAddress(Address address) {
    changeAddress = address.getAddress();
}
 
Example 14
Source File: UnSignTxPanel.java    From bither-desktop-java with Apache License 2.0 4 votes vote down vote up
@Override
public void selectAddress(Address address) {
    changeAddress = address.getAddress();
}