net.bither.bitherj.core.HDAccount Java Examples

The following examples show how to use net.bither.bitherj.core.HDAccount. 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: HDAccountHotUEntropyActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
void didSuccess(Object obj) {
    final Intent intent = new Intent();
    ArrayList<String> addresses = new ArrayList<String>();
    addresses.add(HDAccount.HDAccountPlaceHolder);
    intent.putExtra(BitherSetting.INTENT_REF.ADDRESS_POSITION_PASS_VALUE_TAG, addresses);
    DialogFragmentHDMSingularColdSeed.newInstance(words, AddressManager.getInstance()
            .getHDAccountHot().getQRCodeFullEncryptPrivKey(), R.string
            .add_hd_account_show_seed_label, R.string.add_hd_account_show_seed_button, new
            DialogFragmentHDMSingularColdSeed.DialogFragmentHDMSingularColdSeedListener() {
                @Override
                public void HDMSingularColdSeedRemembered() {
                    setResult(RESULT_OK, intent);
                    finish();
                    overridePendingTransition(0, R.anim.slide_out_bottom);
                }
            }).show(getSupportFragmentManager(), DialogFragmentHDMSingularColdSeed.FragmentTag);
}
 
Example #2
Source File: SingleWalletForm.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
private void setContent() {
    taAddress.setText(WalletUtils.formatHash(address.getAddress(), 4, 12));
    String iconPath;
    if (address instanceof HDAccount) {
        iconPath = "/images/address_type_hd.png";
    } else if (address instanceof HDMAddress) {
        iconPath = "/images/address_type_hdm.png";
    } else {
        if (address.hasPrivKey()) {
            iconPath = "/images/address_type_private.png";
        } else {
            iconPath = "/images/address_type_watchonly.png";
        }
    }
    ImageIcon icon = ImageLoader.createImageIcon(iconPath);
    icon.setImage(icon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH));
    lblType.setIcon(icon);
    icon = (ImageIcon) lblXRandom.getIcon();
    icon.setImage(icon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH));
    lblXRandom.setIcon(icon);
    lblXRandom.setVisible(address.isFromXRandom());

    icon = (ImageIcon) lblTx.getIcon();
    icon.setImage(icon.getImage().getScaledInstance(12, 12, Image.SCALE_SMOOTH));
    lblTx.setIcon(icon);
}
 
Example #3
Source File: SingleWalletForm.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
private void setContent() {
    taAddress.setText(WalletUtils.formatHash(address.getAddress(), 4, 12));
    String iconPath;
    if (address instanceof HDAccount) {
        iconPath = "/images/address_type_hd.png";
    } else if (address instanceof HDMAddress) {
        iconPath = "/images/address_type_hdm.png";
    } else {
        if (address.hasPrivKey()) {
            iconPath = "/images/address_type_private.png";
        } else {
            iconPath = "/images/address_type_watchonly.png";
        }
    }
    ImageIcon icon = ImageLoader.createImageIcon(iconPath);
    icon.setImage(icon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH));
    lblType.setIcon(icon);
    icon = (ImageIcon) lblXRandom.getIcon();
    icon.setImage(icon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH));
    lblXRandom.setIcon(icon);
    lblXRandom.setVisible(address.isFromXRandom());

    icon = (ImageIcon) lblTx.getIcon();
    icon.setImage(icon.getImage().getScaledInstance(12, 12, Image.SCALE_SMOOTH));
    lblTx.setIcon(icon);
}
 
Example #4
Source File: CheckUtil.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
public static Check initCheckForHDAccount(final HDAccount account, final SecureCharSequence
        password) {
    String title = LocaliserUtils.getString("add_hd_account_tab_hd");
    Check check = new Check(title, new ICheckAction() {
        @Override
        public boolean check() {
            boolean result;
            try {
                result = account.checkWithPassword(password);
            } catch (Exception e) {
                result = false;
            }
            password.wipe();
            return result;
        }
    });
    return check;
}
 
Example #5
Source File: CheckUtil.java    From bither-android with Apache License 2.0 6 votes vote down vote up
public static Check initCheckForHDAccount(final HDAccount account, final SecureCharSequence
        password) {
    String title = BitherApplication.mContext.getString(R.string.address_group_hd);
    Check check = new Check(title, new ICheckAction() {
        @Override
        public boolean check() {
            boolean result;
            try {
                result = account.checkWithPassword(password);
            } catch (Exception e) {
                result = false;
            }
            password.wipe();
            return result;
        }
    });
    return check;
}
 
Example #6
Source File: TxNotificationCenter.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
private static void notifyCoins(String address, final long amount,
                                boolean isReceived) {
    String contentText = address;
    if (Utils.compareString(address, HDAccount.HDAccountPlaceHolder)) {
        contentText = LocaliserUtils.getString("add_hd_account_tab_hd");
    }
    String title = UnitUtil.formatValue(amount, UnitUtil.BitcoinUnit.BTC) + " " + UnitUtil.BitcoinUnit.BTC.name();
    if (isReceived) {
        title = LocaliserUtils.getString("feed_received_btc") + " " + title;
    } else {
        title = LocaliserUtils.getString("feed_send_btc") + " " + title;
    }
    final String msg = contentText + " \n" + title;
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            new MessageDialog(msg).showMsg();
        }
    });

}
 
Example #7
Source File: TxNotificationCenter.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
public static void notificatTx(final String address, final Tx tx,
                               final Tx.TxNotificationType txNotificationType, final long deltaBalance) {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            if (Utils.compareString(address, HDAccount.HDAccountPlaceHolder)) {
                Bither.refreshFrame();
            }
            for (ITxListener txListener : txListenerList) {
                txListener.notificatTx(address, tx, txNotificationType, deltaBalance);
            }
            if (txNotificationType == Tx.TxNotificationType.txReceive) {
                boolean isReceived = deltaBalance > 0;
                long balance = Math.abs(deltaBalance);
                notifyCoins(address, balance, isReceived);
            }
        }
    });


}
 
Example #8
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 #9
Source File: AbstractHDAccountAddressProvider.java    From bitherj with Apache License 2.0 6 votes vote down vote up
public List<HDAccount.HDAccountAddress> getAllHDAddress(int hdAccountId) {
    final List<HDAccount.HDAccountAddress> adressPubList = new ArrayList<HDAccount
            .HDAccountAddress>();
    String sql = "select address,pub,path_type,address_index,is_issued,is_synced,hd_account_id " +
            "from hd_account_addresses where hd_account_id=? ";
    this.execQueryLoop(sql, new String[]{Integer.toString(hdAccountId)}, new Function<ICursor, Void>() {
        @Nullable
        @Override
        public Void apply(@Nullable ICursor c) {
            HDAccount.HDAccountAddress hdAccountAddress = formatAddress(c);
            if (hdAccountAddress != null) {
                adressPubList.add(hdAccountAddress);
            }
            return null;
        }
    });
    return adressPubList;
}
 
Example #10
Source File: AbstractHDAccountAddressProvider.java    From bitherj with Apache License 2.0 6 votes vote down vote up
@Override
public HDAccount.HDAccountAddress addressForPath(int hdAccountId, AbstractHD.PathType type, int index) {
    String sql = "select address,pub,path_type,address_index,is_issued," +
            "is_synced,hd_account_id from hd_account_addresses" +
            " where path_type=? and address_index=? and hd_account_id=?";
    final HDAccount.HDAccountAddress[] accountAddress = {null};
    this.execQueryOneRecord(sql, new String[]{Integer.toString(type.getValue()), Integer.toString(index), Integer.toString(hdAccountId)}, new Function<ICursor, Void>() {
        @Nullable
        @Override
        public Void apply(@Nullable ICursor c) {
            accountAddress[0] = formatAddress(c);
            return null;
        }
    });
    return accountAddress[0];
}
 
Example #11
Source File: AbstractHDAccountAddressProvider.java    From bitherj with Apache License 2.0 6 votes vote down vote up
@Override
public List<HDAccount.HDAccountAddress> belongAccount(int hdAccountId, List<String> addresses) {
    final List<HDAccount.HDAccountAddress> hdAccountAddressList = new ArrayList<HDAccount
            .HDAccountAddress>();
    List<String> temp = new ArrayList<String>();
    for (String str : addresses) {
        temp.add(Utils.format("'%s'", str));
    }
    String sql = "select address,pub,path_type,address_index,is_issued,is_synced,hd_account_id " +
            " from hd_account_addresses" +
            " where hd_account_id=? and address in (" + Utils.joinString(temp, ",") + ")";
    this.execQueryLoop(sql, new String[]{Integer.toString(hdAccountId)}, new Function<ICursor, Void>() {
        @Nullable
        @Override
        public Void apply(@Nullable ICursor c) {
            hdAccountAddressList.add(formatAddress(c));
            return null;
        }
    });
    return hdAccountAddressList;
}
 
Example #12
Source File: TxNotificationCenter.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
private static void notifyCoins(String address, final long amount,
                                boolean isReceived) {
    String contentText = address;
    if (Utils.compareString(address, HDAccount.HDAccountPlaceHolder)) {
        contentText = LocaliserUtils.getString("add_hd_account_tab_hd");
    }
    String title = UnitUtil.formatValue(amount, UnitUtil.BitcoinUnit.BTC) + " " + UnitUtil.BitcoinUnit.BTC.name();
    if (isReceived) {
        title = LocaliserUtils.getString("feed_received_btc") + " " + title;
    } else {
        title = LocaliserUtils.getString("feed_send_btc") + " " + title;
    }
    final String msg = contentText + " \n" + title;
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            new MessageDialog(msg).showMsg();
        }
    });

}
 
Example #13
Source File: AbstractHDAccountAddressProvider.java    From bitherj with Apache License 2.0 6 votes vote down vote up
@Override
public void addAddress(List<HDAccount.HDAccountAddress> hdAccountAddresses) {
    String sql = "insert into hd_account_addresses(hd_account_id,path_type,address_index,is_issued,address,pub,is_synced) values(?,?,?,?,?,?,?)";
    IDb writeDb = this.getWriteDb();
    writeDb.beginTransaction();
    for (HDAccount.HDAccountAddress hdAccountAddress : hdAccountAddresses) {
        this.execUpdate(writeDb, sql, new String[] {
                Integer.toString(hdAccountAddress.getHdAccountId())
                , Integer.toString(hdAccountAddress.getPathType().getValue())
                , Integer.toString(hdAccountAddress.getIndex())
                , hdAccountAddress.isIssued() ? "1" : "0"
                , hdAccountAddress.getAddress()
                , Base58.encode(hdAccountAddress.getPub())
                , hdAccountAddress.isSyncedComplete() ? "1" : "0"
        });
    }
    writeDb.endTransaction();
}
 
Example #14
Source File: TxReceiver.java    From bither-android with Apache License 2.0 6 votes vote down vote up
private void notifyCoins(String address, final long amount,
                         boolean isReceived) {
    String contentText = address;
    if (Utils.compareString(address, HDAccount.HDAccountPlaceHolder)) {
        contentText = BitherApplication.mContext.getString(R.string.address_group_hd);
    } else if (Utils.compareString(address, HDAccount.HDAccountMonitoredPlaceHolder)) {
        contentText = BitherApplication.mContext.getString(R.string.address_group_hd_monitored);
    }
    String title = UnitUtilWrapper.formatValue(amount) + " " + AppSharedPreference.getInstance().getBitcoinUnit().name();
    if (isReceived) {
        title = blockchainService.getString(R.string.feed_received_btc) + " " + title;
    } else {
        title = blockchainService.getString(R.string.feed_send_btc) + " " + title;
    }
    Intent intent = new Intent(blockchainService, HotActivity.class);
    intent.putExtra(BitherSetting.INTENT_REF.NOTIFICATION_ADDRESS, address);
    SystemUtil.nmNotifyOfWallet(nm, blockchainService,
            BitherSetting.NOTIFICATION_ID_COINS_RECEIVED, intent, title,
            contentText, R.drawable.ic_launcher, R.raw.coins_received);

}
 
Example #15
Source File: HDAccountColdUEntropyActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
void didSuccess(Object obj) {
    final Intent intent = new Intent();
    ArrayList<String> addresses = new ArrayList<String>();
    addresses.add(HDAccount.HDAccountPlaceHolder);
    intent.putExtra(BitherSetting.INTENT_REF.ADDRESS_POSITION_PASS_VALUE_TAG, addresses);
    DialogFragmentHDMSingularColdSeed.newInstance(words, AddressManager.getInstance().getHDAccountCold()
            .getQRCodeFullEncryptPrivKey(), R.string
            .add_hd_account_show_seed_label, R.string.add_hd_account_show_seed_button, new
            DialogFragmentHDMSingularColdSeed.DialogFragmentHDMSingularColdSeedListener() {
        @Override
        public void HDMSingularColdSeedRemembered() {
            setResult(RESULT_OK, intent);
            finish();
            overridePendingTransition(0, R.anim.slide_out_bottom);
        }
    }).show(getSupportFragmentManager(), DialogFragmentHDMSingularColdSeed.FragmentTag);
}
 
Example #16
Source File: DialogAddressFullForHD.java    From bither-android with Apache License 2.0 6 votes vote down vote up
public DialogAddressFullForHD(Activity context, Tx tx, HDAccount account) {
    super(context);
    activity = context;
    List<String> inAddresses = tx.getInAddresses();
    List<String> outAddresses = tx.getOutAddressList();
    ownAddresses = account.getRelatedAddressesForTx(tx, inAddresses);
    Collections.sort(ownAddresses, new Comparator<HDAccount.HDAccountAddress>() {
        @Override
        public int compare(HDAccount.HDAccountAddress lhs, HDAccount.HDAccountAddress rhs) {
            if (lhs.getPathType() != rhs.getPathType()) {
                return lhs.getPathType().getValue() - rhs.getPathType().getValue();
            }
            return lhs.getIndex() - rhs.getIndex();
        }
    });
    boolean isIncoming = true;
    try {
        isIncoming = tx.deltaAmountFrom(account) >= 0;
    } catch (ScriptException e) {
        e.printStackTrace();
    }
    List<String> foreign = foreignAddresses(isIncoming ? inAddresses : outAddresses);
    initForeignAddresses(isIncoming, tx, foreign);
    initView();
}
 
Example #17
Source File: CheckUtil.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
public static Check initCheckForHDAccount(final HDAccount account, final SecureCharSequence
        password) {
    String title = LocaliserUtils.getString("add_hd_account_tab_hd");
    Check check = new Check(title, new ICheckAction() {
        @Override
        public boolean check() {
            boolean result;
            try {
                result = account.checkWithPassword(password);
            } catch (Exception e) {
                result = false;
            }
            password.wipe();
            return result;
        }
    });
    return check;
}
 
Example #18
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 #19
Source File: AbstractHDAccountAddressProvider.java    From bitherj with Apache License 2.0 6 votes vote down vote up
@Override
public boolean requestNewReceivingAddress(int hdAccountId) {
    int issuedIndex = this.issuedIndex(hdAccountId, AbstractHD.PathType.EXTERNAL_ROOT_PATH);
    final boolean[] result = {false};
    if (issuedIndex >= HDAccount.MaxUnusedNewAddressCount - 2) {
        String sql = "select count(0) from hd_account_addresses a,outs b " +
                " where a.address=b.out_address and a.hd_account_id=? and a.path_type=0 and a.address_index>? and a.is_issued=?";
        this.execQueryOneRecord(sql, new String[]{Integer.toString(hdAccountId), Integer.toString(issuedIndex - HDAccount.MaxUnusedNewAddressCount + 1), "1"}, new Function<ICursor, Void>() {
            @Nullable
            @Override
            public Void apply(@Nullable ICursor c) {
                result[0] = c.getInt(0) > 0;
                return null;
            }
        });
    } else {
        result[0] = true;
    }
    if (result[0]) {
        this.updateIssuedIndex(hdAccountId, AbstractHD.PathType.EXTERNAL_ROOT_PATH, issuedIndex + 1);
    }
    return result[0];
}
 
Example #20
Source File: BCCAssetsDetectListActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
private void loadAddress() {
    if (!isLoading && hasMore) {
        isLoading = true;
        List<HDAccount.HDAccountAddress> address;
        if (isMonitored) {
            address = hdAccountMonitored.getHdHotAddresses(page, pathType, password);
        } else {
            address = hdAccount.getHdHotAddresses(page, pathType, password);
        }
        if (page == 1) {
            hdAccountAddresses.clear();
        }
        if (address != null && address.size() > 0) {
            hdAccountAddresses.addAll(address);
            hasMore = true;
        } else {
            hasMore = false;
        }
        adapter.notifyDataSetChanged();
        isLoading = false;
    }
}
 
Example #21
Source File: AbstractHDAccountAddressProvider.java    From bitherj with Apache License 2.0 6 votes vote down vote up
@Override
public List<HDAccount.HDAccountAddress> getSigningAddressesForInputs(int hdAccountId, List<In> inList) {
    final List<HDAccount.HDAccountAddress> hdAccountAddressList =
            new ArrayList<HDAccount.HDAccountAddress>();
    for (In in : inList) {
        String sql = "select a.address,a.path_type,a.address_index,a.is_synced,a.hd_account_id" +
                " from hd_account_addresses a ,outs b" +
                " where a.address=b.out_address" +
                " and b.tx_hash=? and b.out_sn=? and a.hd_account_id=?";
        OutPoint outPoint = in.getOutpoint();
        this.execQueryOneRecord(sql, new String[]{Base58.encode(in.getPrevTxHash()), Integer.toString
                (outPoint.getOutSn()), Integer.toString(hdAccountId)}, new Function<ICursor, Void>() {
            @Nullable
            @Override
            public Void apply(@Nullable ICursor c) {
                hdAccountAddressList.add(formatAddress(c));
                return null;
            }
        });
    }
    return hdAccountAddressList;
}
 
Example #22
Source File: DialogHdAccountOldAddresses.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public DialogHdAccountOldAddresses(Activity context, HDAccount hdAccount, AbstractHD.PathType pathType) {
    super(context);
    this.hdAccount = hdAccount;
    activity = context;
    this.pathType = pathType;
    initView();
}
 
Example #23
Source File: PrivateKeyUtil.java    From bitherj with Apache License 2.0 5 votes vote down vote up
public static String getEncryptPrivateKeyStringFromAllAddresses() {
    String content = "";
    List<Address> privates = AddressManager.getInstance().getPrivKeyAddresses();
    for (int i = 0;
         i < privates.size();
         i++) {
        Address address = privates.get(i);
        content += address.getFullEncryptPrivKey();
        if (i < privates.size() - 1) {
            content += QRCodeUtil.QR_CODE_SPLIT;
        }
    }
    HDMKeychain keychain = AddressManager.getInstance().getHdmKeychain();
    if (keychain != null) {
        if (Utils.isEmpty(content)) {
            content += keychain.getQRCodeFullEncryptPrivKey();
        } else {
            content += QRCodeUtil.QR_CODE_SPLIT + keychain.getQRCodeFullEncryptPrivKey();
        }
    }
    HDAccount hdAccount = AddressManager.getInstance().getHDAccountHot();
    if (hdAccount != null) {
        if (Utils.isEmpty(content)) {
            content += hdAccount.getQRCodeFullEncryptPrivKey();
        } else {
            content += QRCodeUtil.QR_CODE_SPLIT + hdAccount.getQRCodeFullEncryptPrivKey();
        }
    }
    HDAccountCold hdAccountCold = AddressManager.getInstance().getHDAccountCold();
    if (hdAccountCold != null) {
        if (Utils.isEmpty(content)) {
            content += hdAccountCold.getQRCodeFullEncryptPrivKey();
        } else {
            content += QRCodeUtil.QR_CODE_SPLIT + hdAccountCold.getQRCodeFullEncryptPrivKey();
        }
    }
    return content;
}
 
Example #24
Source File: HDAccountMonitoredSendActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onConfirm() {
    Intent intent = new Intent(this, UnsignedTxQrCodeActivity.class);
    intent.putExtra(BitherSetting.INTENT_REF.QR_CODE_STRING, QRCodeTxTransport.getHDAccountMonitoredUnsignedTx(tx, toAddress, (HDAccount) address));
    intent.putExtra(BitherSetting.INTENT_REF.TITLE_STRING, getString(R.string
            .unsigned_transaction_qr_code_title));
    startActivityForResult(intent, BitherSetting.INTENT_REF.SIGN_TX_REQUEST_CODE);
    btnSend.setEnabled(false);
}
 
Example #25
Source File: HDAccountSendActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void send() {
    tx = null;
    HDAccount account = (HDAccount) address;
    SecureCharSequence password = new SecureCharSequence(etPassword.getText());
    try {
        tx = account.newTx(toAddress, btcAmount, AppSharedPreference.getInstance().isSegwitAddressType(), password);
    } catch (Exception e) {
        e.printStackTrace();
        btcAmount = 0;
        tx = null;
        String msg = getString(R.string.send_failed);
        if (e instanceof KeyCrypterException || e instanceof MnemonicException
                .MnemonicLengthException) {
            msg = getString(R.string.password_wrong);
        } else if (e instanceof TxBuilderException) {
            msg = e.getMessage();
        }
        final String m = msg;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (dp.isShowing()) {
                    dp.dismiss();
                }
                DropdownMessage.showDropdownMessage(HDAccountSendActivity.this, m);
            }
        });
    } finally {
        password.wipe();
    }
    if (tx != null) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showConfirm();
            }
        });
    }
}
 
Example #26
Source File: SplitBCCHDAccountSendActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void send(String...blockhash) {
    txs = null;
    HDAccount account = (HDAccount) address;
    SecureCharSequence password = new SecureCharSequence(etPassword.getText());
    try {
        txs = account.newForkTx(etAddress.getText().toString().trim(), btcAmount, password, splitCoin,blockhash);
    } catch (Exception e) {
        e.printStackTrace();
        btcAmount = 0;
        txs = null;
        String msg = getString(R.string.send_failed);
        if (e instanceof KeyCrypterException || e instanceof MnemonicException
                .MnemonicLengthException) {
            msg = getString(R.string.password_wrong);
        } else if (e instanceof TxBuilderException) {
            msg = e.getMessage();
        }
        final String m = msg;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (dp.isShowing()) {
                    dp.dismiss();
                }
                DropdownMessage.showDropdownMessage(SplitBCCHDAccountSendActivity.this, m);
            }
        });
    } finally {
        password.wipe();
    }
    if (txs != null) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showConfirm();

            }
        });
    }
}
 
Example #27
Source File: HDAccountMonitoredDetailActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void initAddress() {
    address = AddressManager.getInstance().getHDAccountMonitored();
    if (isSegwitAddress) {
        if (address instanceof HDAccount && ((HDAccount) address).getExternalPub(AbstractHD.PathType.EXTERNAL_BIP49_PATH) == null) {
            isSegwitAddress = false;
        }
    }
    addressPosition = 0;
}
 
Example #28
Source File: DialogAddressFullForHD.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private List<String> foreignAddresses(List<String> addresses) {
    ArrayList<String> result = new ArrayList<String>(addresses);
    for (HDAccount.HDAccountAddress a : ownAddresses) {
        if (result.contains(a.getAddress())) {
            result.remove(a.getAddress());
        }
    }
    return result;
}
 
Example #29
Source File: SplitBCCHDAccountMonitoredSendActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void send() {
    this.txs = null;
    HDAccount account = (HDAccount) address;
    try {
        txs = account.newForkTx(toAddress, btcAmount, splitCoin);
    } catch (Exception e) {
        e.printStackTrace();
        btcAmount = 0;
        txs = null;
        String msg = getString(R.string.send_failed);
        if (e instanceof KeyCrypterException || e instanceof MnemonicException
                .MnemonicLengthException) {
            msg = getString(R.string.password_wrong);
        } else if (e instanceof TxBuilderException) {
            msg = e.getMessage();
        }
        final String m = msg;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (dp.isShowing()) {
                    dp.dismiss();
                }
                DropdownMessage.showDropdownMessage(SplitBCCHDAccountMonitoredSendActivity.this, m);
            }
        });
    }

    if (this.txs != null) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showConfirm();
            }
        });
    }
}
 
Example #30
Source File: AddressFragmentListItemView.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onAddressInfoChanged(String address) {
    if (this.address != null) {
        if (Utils.compareString(address, this.address.getAddress(AppSharedPreference.getInstance().isSegwitAddressType())) || (this.address
                .isHDAccount() && this.address.hasPrivKey() && Utils.compareString(address,
                HDAccount.HDAccountPlaceHolder)) || (this.address.isHDAccount() && !this
                .address.hasPrivKey() && Utils.compareString(address, HDAccount
                .HDAccountMonitoredPlaceHolder))) {
            showAddressInfo();
        }
    }
}