Java Code Examples for net.bither.bitherj.core.HDAccount

The following examples show how to use net.bither.bitherj.core.HDAccount. 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: CheckUtil.java    License: 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 2
Source Project: bither-desktop-java   Source File: AddressTableModel.java    License: 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 3
Source Project: bither-desktop-java   Source File: TxNotificationCenter.java    License: 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 4
Source Project: bither-desktop-java   Source File: TxNotificationCenter.java    License: 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 5
Source Project: bither-desktop-java   Source File: SingleWalletForm.java    License: 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 6
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 7
@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 8
@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 9
Source Project: bither-android   Source File: TxReceiver.java    License: 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 10
Source Project: bither-android   Source File: DialogAddressFullForHD.java    License: 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 11
Source Project: bither-android   Source File: CheckUtil.java    License: 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 12
Source Project: bitherj   Source File: AbstractHDAccountAddressProvider.java    License: 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 13
Source Project: bitherj   Source File: AbstractHDAccountAddressProvider.java    License: 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 14
Source Project: bitherj   Source File: AbstractHDAccountAddressProvider.java    License: 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 15
Source Project: bitherj   Source File: AbstractHDAccountAddressProvider.java    License: 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 16
Source Project: bitherj   Source File: AbstractHDAccountAddressProvider.java    License: 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 17
Source Project: bitherj   Source File: AbstractHDAccountAddressProvider.java    License: 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 18
Source Project: bither-desktop-java   Source File: CheckUtil.java    License: 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 19
Source Project: bither-desktop-java   Source File: AddressTableModel.java    License: 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 20
Source Project: bither-desktop-java   Source File: TxNotificationCenter.java    License: 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 21
Source Project: bither-desktop-java   Source File: SingleWalletForm.java    License: 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 22
Source Project: bither-desktop-java   Source File: ImportHDSeedDesktop.java    License: Apache License 2.0 5 votes vote down vote up
public void importHDSeed() {
    new Thread() {
        @Override
        public void run() {
            PeerUtil.stopPeer();
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    dialogProgress = new DialogProgress();
                    dialogProgress.pack();
                    dialogProgress.setVisible(true);
                }
            });
            HDAccount result = importHDAccount();
            if (result != null) {
                if (importListener != null) {
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            importListener.importSuccess();
                        }
                    });
                }
                KeyUtil.setHDAccount(result);
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        dialogProgress.dispose();
                        Bither.getCoreController().fireRecreateAllViews(true);
                        new MessageDialog(LocaliserUtils.getString("import_private_key_qr_code_success")).showMsg();
                    }
                });
                Bither.refreshFrame();
                PeerUtil.startPeer();

            }
        }
    }.start();

}
 
Example 23
Source Project: bither-desktop-java   Source File: WalletListPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void addHDAccountAddressList(GridBagConstraints constraints, HDAccount hdAccount) {
    synchronized (walletPanels) {
        JPanel outerPanel = new JPanel();
        outerPanel.setOpaque(false);
        outerPanel.setBorder(BorderFactory.createEmptyBorder(TOP_BORDER, LEFT_BORDER, 0, RIGHT_BORDER));
        outerPanel.setLayout(new GridBagLayout());

        GridBagConstraints constraints2 = new GridBagConstraints();
        constraints2.fill = GridBagConstraints.BOTH;
        constraints2.gridx = 0;
        constraints2.gridy = 0;
        constraints2.weightx = 1.0;
        constraints2.weighty = 1.0;
        constraints2.gridwidth = 1;
        constraints2.gridheight = 1;
        constraints2.anchor = GridBagConstraints.CENTER;

        SingleWalletForm singleWalletForm = new SingleWalletForm(hdAccount, this);
        singleWalletForm.getPanel().setComponentOrientation(ComponentOrientation
                .getOrientation(LocaliserUtils.getLocale()));


        outerPanel.add(singleWalletForm.getPanel(), constraints2);


        walletListPanel.add(outerPanel, constraints);
        walletPanels.add(singleWalletForm);
        constraints.gridy = constraints.gridy + 1;


    }


}
 
Example 24
Source Project: bither-desktop-java   Source File: HDAccountSendPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void send() {
    tx = null;
    HDAccount account = (HDAccount) Bither.getActionAddress();
    SecureCharSequence password = new SecureCharSequence(currentPassword.getPassword());
    try {
        tx = account.newTx(toAddress, btcAmount, password);
    } catch (Exception e) {
        e.printStackTrace();
        btcAmount = 0;
        tx = null;
        String msg = LocaliserUtils.getString("send_failed");
        if (e instanceof KeyCrypterException || e instanceof MnemonicException
                .MnemonicLengthException) {
            msg = LocaliserUtils.getString("password_wrong");
        } else if (e instanceof TxBuilderException) {
            msg = e.getMessage();
        }
        final String m = msg;
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                dp.dispose();
                new MessageDialog(m).showMsg();
            }
        });
    } finally {
        password.wipe();
    }
    if (tx != null) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                showConfirm();
            }
        });
    }
}
 
Example 25
Source Project: bither-desktop-java   Source File: ShowTransactionsForm.java    License: Apache License 2.0 5 votes vote down vote up
private void refreshTx() {
    new Thread(new Runnable() {
        @Override
        public void run() {
            if (Bither.getActionAddress() != null) {
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        if (Bither.getActionAddress() instanceof HDAccount) {
                            btnAddress.setVisible(false);
                        } else {
                            btnAddress.setVisible(true);
                        }
                    }
                });

                final List<Tx> actionTxList = Bither.getActionAddress().getTxs();
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {

                        txList.clear();
                        txList.addAll(actionTxList);
                        txTableModel.fireTableDataChanged();
                    }
                });

            }

        }
    }).start();
}
 
Example 26
Source Project: bither-android   Source File: SignHashActivity.java    License: Apache License 2.0 5 votes vote down vote up
private HDAccount.HDAccountAddress addressForIndex(int index, AbstractHD.PathType pathType) {
    if (isBitpieCold) {
        return bitpieHDAccountCold.addressForPath(pathType, index);
    } else if (isHot) {
        return hdAccount.addressForPath(pathType, index);
    } else {
        return hdAccountCold.addressForPath(pathType, index);
    }
}
 
Example 27
Source Project: bither-android   Source File: ColdAddressFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    if (addressesToShowAdded == null
            || addressesToShowAdded.size() == 0) {
        return;
    }
    int startIndex = 0;
    if(AddressManager.getInstance().hasHDMKeychain()){
        startIndex = 1;
        if(addressesToShowAdded.contains(AddAddressColdHDMFragment.HDMSeedAddressPlaceHolder)){
            startIndex = 0;
        }
    }
    if (AddressManager.getInstance().hasHDAccountCold()) {
        startIndex = 1;
        if (addressesToShowAdded.contains(HDAccount.HDAccountPlaceHolder)) {
            startIndex = 0;
        }
    }
    for (int i = 0; i < addressesToShowAdded.size()
            && i + startIndex < lvPrivate.getChildCount(); i++) {
        View v = lvPrivate.getChildAt(i + startIndex);
        v.startAnimation(AnimationUtils.loadAnimation(getActivity(),
                R.anim.address_notification));
    }
    addressesToShowAdded = null;
}
 
Example 28
@Override
public ArrayList<String> getAddresses() {
    ArrayList<String> addresses = new ArrayList<String>();
    if (hdAccount != null) {
        addresses.add(HDAccount.HDAccountPlaceHolder);
    }
    return addresses;
}
 
Example 29
@Override
public ArrayList<String> getAddresses() {
    ArrayList<String> addresses = new ArrayList<String>();
    if (hdAccount != null) {
        addresses.add(HDAccount.HDAccountPlaceHolder);
    }
    return addresses;
}
 
Example 30
@Override
public ArrayList<String> getAddresses() {
    ArrayList<String> addresses = new ArrayList<String>();
    if (hdAccount != null) {
        addresses.add(HDAccount.HDAccountPlaceHolder);
    }
    return addresses;
}