net.bither.bitherj.core.HDMAddress Java Examples

The following examples show how to use net.bither.bitherj.core.HDMAddress. 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: 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 #2
Source File: AddressDetailActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
protected void optionClicked() {
    Dialog dialog = null;
    if (address.isHDAccount()) {
        return;
    }
    if (address.isHDM()) {
        new DialogHDMAddressOptions(AddressDetailActivity.this, (HDMAddress) address, true)
                .show();
    } else if (address.hasPrivKey()) {
        dialog = new DialogAddressWithPrivateKeyOption(AddressDetailActivity.this, address);
    } else {
        dialog = new DialogAddressWatchOnlyOption(AddressDetailActivity.this, address, new
                Runnable() {
            @Override
            public void run() {
                finish();
            }
        });
    }
    if (dialog != null) {
        dialog.show();
    }
}
 
Example #3
Source File: HotAddressFragmentListAdapter.java    From bither-android with Apache License 2.0 6 votes vote down vote up
public HotAddressFragmentListAdapter(FragmentActivity activity, List<Address> watchOnlys,
                                     List<Address> privates, List<HDMAddress> hdms,
                                     PinnedHeaderAddressExpandableListView listView,
                                      boolean isSplitCoinAddress, SplitCoin splitCoin, boolean isDetectBcc) {

    this.activity = activity;
    this.watchOnlys = watchOnlys;
    this.privates = privates;
    this.hdms = hdms;
    this.isDetectBcc = isDetectBcc;
    this.isSplitCoinAddress = isSplitCoinAddress;
    this.splitCoin = splitCoin;
    hdAccount = AddressManager.getInstance().getHDAccountHot();
    hdAccountMonitored = AddressManager.getInstance().getHDAccountMonitored();
    enterpriseHDMKeychain = AddressManager.getInstance().getEnterpriseHDMKeychain();
    mLayoutInflater = LayoutInflater.from(activity);
    mListView = listView;
}
 
Example #4
Source File: RecoveryHDMApi.java    From bitherj with Apache License 2.0 6 votes vote down vote up
@Override
public void setResult(String response) throws Exception {
    JSONObject json = new JSONObject(response);
    this.result = new ArrayList<HDMAddress.Pubs>();
    List<byte[]> pubHots = new ArrayList<byte[]>();
    List<byte[]> pubColds = new ArrayList<byte[]>();
    List<byte[]> pubService = new ArrayList<byte[]>();
    if (!json.isNull(HttpSetting.PUB_HOT)) {
        String pubHotString = json.getString(HttpSetting.PUB_HOT);
        pubHots = Utils.decodeServiceResult(pubHotString);
    }
    if (!json.isNull(HttpSetting.PUB_COLD)) {
        String pubColdString = json.getString(HttpSetting.PUB_COLD);
        pubColds = Utils.decodeServiceResult(pubColdString);
    }
    if (!json.isNull(HttpSetting.PUB_SERVER)) {
        String pubServiceString = json.getString(HttpSetting.PUB_SERVER);
        pubService = Utils.decodeServiceResult(pubServiceString);
    }

    for (int i = 0; i < pubHots.size(); i++) {
        HDMAddress.Pubs pubs = new HDMAddress.Pubs(pubHots.get(i), pubColds.get(i), pubService.get(i), i);
        this.result.add(pubs);
    }

}
 
Example #5
Source File: AbstractAddressProvider.java    From bitherj with Apache License 2.0 6 votes vote down vote up
@Override
public List<HDMAddress> getHDMAddressInUse(HDMKeychain keychain) {
    String sql = "select hd_seed_index,pub_key_hot,pub_key_cold,pub_key_remote,address,is_synced " +
            " from hdm_addresses " +
            " where hd_seed_id=? and address is not null order by hd_seed_index";
    final List<HDMAddress> addresses = new ArrayList<HDMAddress>();
    final HDMKeychain hdmKeychain = keychain;
    this.execQueryLoop(sql, new String[]{Integer.toString(keychain.getHdSeedId())}, new Function<ICursor, Void>() {
        @Nullable
        @Override
        public Void apply(@Nullable ICursor c) {
            HDMAddress hdmAddress = applyHDMAddress(c, hdmKeychain);
            if (hdmAddress != null) {
                addresses.add(hdmAddress);
            }
            return null;
        }
    });
    return addresses;
}
 
Example #6
Source File: AbstractAddressProvider.java    From bitherj with Apache License 2.0 6 votes vote down vote up
@Override
public List<HDMAddress.Pubs> getUncompletedHDMAddressPubs(int hdSeedId, int count) {
    String sql = "select * from hdm_addresses where hd_seed_id=? and pub_key_remote is null limit ? ";
    final List<HDMAddress.Pubs> pubsList = new ArrayList<HDMAddress.Pubs>();

    this.execQueryLoop(sql, new String[]{Integer.toString(hdSeedId), Integer.toString(count)}, new Function<ICursor, Void>() {
        @Nullable
        @Override
        public Void apply(@Nullable ICursor c) {
            HDMAddress.Pubs pubs = applyPubs(c);
            if (pubs != null) {
                pubsList.add(pubs);
            }
            return null;
        }
    });
    return pubsList;
}
 
Example #7
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 #8
Source File: AddressProvider.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
@Override
public List<HDMAddress> getHDMAddressInUse(HDMKeychain keychain) {
    List<HDMAddress> addresses = new ArrayList<HDMAddress>();

    try {
        ResultSet c = null;

        String sql = "select hd_seed_index,pub_key_hot,pub_key_cold,pub_key_remote,address,is_synced " +
                "from hdm_addresses " +
                "where hd_seed_id=? and address is not null order by hd_seed_index";
        PreparedStatement statement = this.mDb.getPreparedStatement(sql, new String[]{Integer.toString(keychain.getHdSeedId())});
        c = statement.executeQuery();
        while (c.next()) {
            HDMAddress hdmAddress = applyHDMAddress(c, keychain);
            if (hdmAddress != null) {
                addresses.add(hdmAddress);
            }
        }
        c.close();
        statement.close();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return addresses;
}
 
Example #9
Source File: AddressProvider.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
@Override
public void recoverHDMAddresses(final int hdSeedId, final List<HDMAddress> addresses) {
    try {
        this.mDb.getConn().setAutoCommit(false);
        for (int i = 0; i < addresses.size(); i++) {
            HDMAddress address = addresses.get(i);
            applyHDMAddressContentValues(this.mDb.getConn(), address.getAddress(), hdSeedId,
                    address.getIndex(), address.getPubHot(), address.getPubCold(), address.getPubRemote(), false);


        }
        this.mDb.getConn().commit();
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
 
Example #10
Source File: AddressProvider.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
@Override
public List<HDMAddress> getHDMAddressInUse(HDMKeychain keychain) {
    List<HDMAddress> addresses = new ArrayList<HDMAddress>();

    try {
        ResultSet c = null;

        String sql = "select hd_seed_index,pub_key_hot,pub_key_cold,pub_key_remote,address,is_synced " +
                "from hdm_addresses " +
                "where hd_seed_id=? and address is not null order by hd_seed_index";
        PreparedStatement statement = this.mDb.getPreparedStatement(sql, new String[]{Integer.toString(keychain.getHdSeedId())});
        c = statement.executeQuery();
        while (c.next()) {
            HDMAddress hdmAddress = applyHDMAddress(c, keychain);
            if (hdmAddress != null) {
                addresses.add(hdmAddress);
            }
        }
        c.close();
        statement.close();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return addresses;
}
 
Example #11
Source File: AddressProvider.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
@Override
public void recoverHDMAddresses(final int hdSeedId, final List<HDMAddress> addresses) {
    try {
        this.mDb.getConn().setAutoCommit(false);
        for (int i = 0; i < addresses.size(); i++) {
            HDMAddress address = addresses.get(i);
            applyHDMAddressContentValues(this.mDb.getConn(), address.getAddress(), hdSeedId,
                    address.getIndex(), address.getPubHot(), address.getPubCold(), address.getPubRemote(), false);


        }
        this.mDb.getConn().commit();
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
 
Example #12
Source File: HDMSingularDesktop.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public void server() {
    new Thread() {
        @Override
        public void run() {
            callInServer(new HDMHotAdd.IGenerateHDMKeyChain() {
                @Override
                public void generateHDMKeyChain(HDMKeychain hdmKeychain) {
                    KeyUtil.setHDKeyChain(hdmKeychain);

                }

                @Override
                public void beginCompleteAddress() {
                    PeerUtil.stopPeer();
                }

                @Override
                public void completeAddrees(List<HDMAddress> hdmAddresses) {
                    Bither.refreshFrame();
                }


            });
        }


    }.start();
}
 
Example #13
Source File: CompleteTransactionRunnable.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public CompleteTransactionRunnable(Address a, long amount, String toAddress,
                                   String changeAddress, SecureCharSequence password,
                                   HDMAddress.HDMFetchOtherSignatureDelegate
                                           otherSigFetcher1,
                                   HDMAddress.HDMFetchOtherSignatureDelegate
                                           otherSigFetcher2) throws Exception {
    boolean isHDM = otherSigFetcher1 != null || otherSigFetcher2 != null;
    this.amount = amount;
    this.toAddress = toAddress;
    this.password = password;
    sigFetcher1 = otherSigFetcher1;
    sigFetcher2 = otherSigFetcher2;
    if (isHDM) {
        wallet = a;
        toSign = true;
    } else if (password == null || password.length() == 0) {
        wallet = a;
        toSign = false;
    } else {
        if (a.hasPrivKey()) {
            wallet = a;
        } else {
            throw new Exception("address not with private key");
        }
        toSign = true;
    }
    if (!Utils.isEmpty(changeAddress)) {
        this.changeAddress = changeAddress;
    } else {
        this.changeAddress = wallet.getAddress();
    }
}
 
Example #14
Source File: AbstractAddressProvider.java    From bitherj with Apache License 2.0 5 votes vote down vote up
@Override
public void recoverHDMAddresses(int hdSeedId, List<HDMAddress> addresses) {
    IDb writeDb = this.getWriteDb();
    writeDb.beginTransaction();
    for (int i = 0; i < addresses.size(); i++) {
        HDMAddress address = addresses.get(i);
        this.insertHDMAddressToDb(writeDb, address.getAddress(), hdSeedId, address.getIndex()
                , address.getPubHot(), address.getPubCold(), address.getPubRemote(), false);
    }
    writeDb.endTransaction();
}
 
Example #15
Source File: WalletUtils.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public static Address findPrivateKey(String address) {
    for (Address bitherAddressWithPrivateKey : AddressManager.getInstance().getPrivKeyAddresses()) {
        if (Utils.compareString(address, bitherAddressWithPrivateKey.getAddress())) {
            return bitherAddressWithPrivateKey;
        }
    }
    if (AddressManager.getInstance().hasHDMKeychain()) {
        for (HDMAddress a : AddressManager.getInstance().getHdmKeychain().getAddresses()) {
            if (Utils.compareString(address, a.getAddress())) {
                return a;
            }
        }
    }
    return null;
}
 
Example #16
Source File: WalletListPanel.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
private void addHDMHotAddressList(GridBagConstraints constraints, List<HDMAddress> addresses) {
    synchronized (walletPanels) {
        for (Address loopPerWalletModelData : addresses) {
            if (loopPerWalletModelData != null) {
                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(loopPerWalletModelData, 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 #17
Source File: HDMSingularAndroid.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public void server() {
    new ThreadNeedService(null, context) {
        @Override
        public void runWithService(final BlockchainService service) {
            callInServer(new HDMHotAdd.IGenerateHDMKeyChain() {
                @Override
                public void generateHDMKeyChain(HDMKeychain hdmKeychain) {
                    KeyUtil.setHDKeyChain(hdmKeychain);

                }

                @Override
                public void beginCompleteAddress() {
                    if (service != null) {
                        service.stopAndUnregister();
                    }
                }

                @Override
                public void completeAddrees(List<HDMAddress> hdmAddresses) {
                    if (service != null) {
                        service.startAndRegister();
                    }
                }


            });
        }
    }.start();
}
 
Example #18
Source File: CompleteTransactionRunnable.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public CompleteTransactionRunnable(Address a, long amount, String toAddress,
                                   String changeAddress, SecureCharSequence password,
                                   HDMAddress.HDMFetchOtherSignatureDelegate
                                           otherSigFetcher1,
                                   HDMAddress.HDMFetchOtherSignatureDelegate
                                           otherSigFetcher2) throws Exception {
    boolean isHDM = otherSigFetcher1 != null || otherSigFetcher2 != null;
    this.amount = amount;
    this.toAddress = toAddress;
    this.password = password;
    sigFetcher1 = otherSigFetcher1;
    sigFetcher2 = otherSigFetcher2;
    if (isHDM) {
        wallet = a;
        toSign = true;
    } else if (password == null || password.length() == 0) {
        wallet = a;
        toSign = false;
    } else {
        if (a.hasPrivKey()) {
            wallet = a;
        } else {
            throw new Exception("address not with private key");
        }
        toSign = true;
    }
    if (!Utils.isEmpty(changeAddress)) {
        this.changeAddress = changeAddress;
    } else {
        this.changeAddress = wallet.getAddress();
    }
}
 
Example #19
Source File: HotAddressFragmentListAdapter.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onLongClick(View v) {
    if (address.isHDM()) {
        new DialogHDMAddressOptions(activity, (HDMAddress) address).show();
    } else if (address.hasPrivKey()) {
        new DialogAddressWithShowPrivateKey(activity, address, null).show();
    } else {
        new DialogAddressWatchOnlyLongClick(activity, address).show();
    }
    return true;
}
 
Example #20
Source File: HDMSingularDesktop.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public void server() {
    new Thread() {
        @Override
        public void run() {
            callInServer(new HDMHotAdd.IGenerateHDMKeyChain() {
                @Override
                public void generateHDMKeyChain(HDMKeychain hdmKeychain) {
                    KeyUtil.setHDKeyChain(hdmKeychain);

                }

                @Override
                public void beginCompleteAddress() {
                    PeerUtil.stopPeer();
                }

                @Override
                public void completeAddrees(List<HDMAddress> hdmAddresses) {
                    Bither.refreshFrame();
                }


            });
        }


    }.start();
}
 
Example #21
Source File: WalletListPanel.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
private void addHDMHotAddressList(GridBagConstraints constraints, List<HDMAddress> addresses) {
    synchronized (walletPanels) {
        for (Address loopPerWalletModelData : addresses) {
            if (loopPerWalletModelData != null) {
                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(loopPerWalletModelData, 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 #22
Source File: CompleteTransactionRunnable.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public CompleteTransactionRunnable(int addressPosition, long amount, String toAddress,
                                   String changeAddress, SecureCharSequence password,
                                   HDMAddress.HDMFetchOtherSignatureDelegate
                                           otherSigFetcher1,HDMAddress.HDMFetchOtherSignatureDelegate
                                           otherSigFetcher2) throws Exception {
    this(Coin.BTC, addressPosition, amount, toAddress, changeAddress, password, otherSigFetcher1, otherSigFetcher2);
}
 
Example #23
Source File: AddAddressHotHDMFragment.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public ArrayList<String> getAddresses() {
    List<HDMAddress> as = AddressManager.getInstance().getHdmKeychain().getAddresses();
    ArrayList<String> s = new ArrayList<String>();
    for (HDMAddress a : as) {
        s.add(a.getAddress());
    }
    return s;
}
 
Example #24
Source File: HotAddressFragment.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle paramBundle) {
    super.onCreate(paramBundle);
    broadcastIntentFilter.addAction(BroadcastUtil.ACTION_MARKET);
    watchOnlys = new ArrayList<Address>();
    privates = new ArrayList<Address>();
    hdms = new ArrayList<HDMAddress>();
}
 
Example #25
Source File: DialogHDMAddressOptions.java    From bither-android with Apache License 2.0 4 votes vote down vote up
public DialogHDMAddressOptions(Activity activity, HDMAddress address, boolean withAlias) {
    super(activity);
    this.address = address;
    this.activity = activity;
    this.withAlias = withAlias;
}
 
Example #26
Source File: CompleteTransactionRunnable.java    From bither-desktop-java with Apache License 2.0 4 votes vote down vote up
@Override
public void run() {
    prepare();

    try {
        Tx tx = wallet.buildTx(amount, toAddress, changeAddress);
        if (tx == null) {
            error(0, LocaliserUtils.getString("send_failed"));

            return;
        }
        if (toSign) {
            if (wallet.isHDM()) {
                if (sigFetcher1 != null && sigFetcher2 != null) {
                    ((HDMAddress) wallet).signTx(tx, password, sigFetcher1, sigFetcher2);
                } else if (sigFetcher1 != null || sigFetcher2 != null) {
                    ((HDMAddress) wallet).signTx(tx, password,
                            sigFetcher1 != null ? sigFetcher1 : sigFetcher2);
                } else {
                    throw new RuntimeException("need sig fetcher to sign hdm tx");
                }
            } else {
                wallet.signTx(tx, password);
            }
            if (password != null) {
                password.wipe();
            }
            if (!tx.verifySignatures()) {
                error(0, getMessageFromException(null));

                return;
            }

        }
        success(tx);

    } catch (Exception e) {
        if (password != null) {
            password.wipe();
        }
        if (e instanceof HDMSignUserCancelExcetion) {
            error(0, null);
            return;
        }
        e.printStackTrace();
        String msg = getMessageFromException(e);
        error(0, msg);
    }

}
 
Example #27
Source File: CompleteTransactionRunnable.java    From bither-desktop-java with Apache License 2.0 4 votes vote down vote up
@Override
public void run() {
    prepare();

    try {
        Tx tx = wallet.buildTx(amount, toAddress, changeAddress);
        if (tx == null) {
            error(0, LocaliserUtils.getString("send_failed"));

            return;
        }
        if (toSign) {
            if (wallet.isHDM()) {
                if (sigFetcher1 != null && sigFetcher2 != null) {
                    ((HDMAddress) wallet).signTx(tx, password, sigFetcher1, sigFetcher2);
                } else if (sigFetcher1 != null || sigFetcher2 != null) {
                    ((HDMAddress) wallet).signTx(tx, password,
                            sigFetcher1 != null ? sigFetcher1 : sigFetcher2);
                } else {
                    throw new RuntimeException("need sig fetcher to sign hdm tx");
                }
            } else {
                wallet.signTx(tx, password);
            }
            if (password != null) {
                password.wipe();
            }
            if (!tx.verifySignatures()) {
                error(0, getMessageFromException(null));

                return;
            }

        }
        success(tx);

    } catch (Exception e) {
        if (password != null) {
            password.wipe();
        }
        if (e instanceof HDMSignUserCancelExcetion) {
            error(0, null);
            return;
        }
        e.printStackTrace();
        String msg = getMessageFromException(e);
        error(0, msg);
    }

}
 
Example #28
Source File: CompleteTransactionRunnable.java    From bither-desktop-java with Apache License 2.0 4 votes vote down vote up
public CompleteTransactionRunnable(Address a, long amount, String toAddress,
                                   String changeAddress, SecureCharSequence password,
                                   HDMAddress.HDMFetchOtherSignatureDelegate
                                           otherSigFetcher1) throws Exception {
    this(a, amount, toAddress, changeAddress, password, otherSigFetcher1, null);
}
 
Example #29
Source File: HotAddressFragment.java    From bither-android with Apache License 2.0 4 votes vote down vote up
public void refresh() {
    if (AbstractApp.addressIsReady) {
        List<Address> ps = AddressManager.getInstance().getPrivKeyAddresses();
        List<Address> ws = AddressManager.getInstance().getWatchOnlyAddresses();
        List<HDMAddress> hs = AddressManager.getInstance().hasHDMKeychain() ? AddressManager
                .getInstance().getHdmKeychain().getAddresses() : null;
        watchOnlys.clear();
        privates.clear();
        hdms.clear();
        if (ws != null) {
            watchOnlys.addAll(ws);
        }
        if (ps != null) {
            privates.addAll(ps);
        }
        if (hs != null) {
            hdms.addAll(hs);
        }
        mAdapter.notifyDataSetChanged();
        if (watchOnlys.size() + privates.size() + hdms.size() + (AddressManager.getInstance()
                .hasHDAccountHot() ? 1 : 0) + (AddressManager.getInstance()
                .hasHDAccountMonitored() ? 1 : 0) +
                (AddressManager.getInstance().hasEnterpriseHDMKeychain() ? 1 : 0) == 0) {
            ivNoAddress.setVisibility(View.VISIBLE);
            lv.setVisibility(View.GONE);
        } else {
            ivNoAddress.setVisibility(View.GONE);
            lv.setVisibility(View.VISIBLE);
        }
        for (int i = 0;
             i < mAdapter.getGroupCount();
             i++) {
            lv.expandGroup(i);
        }
        if (notifyAddress != null) {
            scrollToAddress(notifyAddress);
        }
        lv.removeCallbacks(showAddressesAddedRunnable);
        if (addressesToShowAdded != null) {
            lv.postDelayed(showAddressesAddedRunnable, 600);
        }
    }
}
 
Example #30
Source File: CompleteTransactionRunnable.java    From bither-android with Apache License 2.0 4 votes vote down vote up
public CompleteTransactionRunnable(int addressPosition, long amount, String toAddress,
                                   String changeAddress, SecureCharSequence password,
                                   HDMAddress.HDMFetchOtherSignatureDelegate
                                           otherSigFetcher1) throws Exception {
    this(Coin.BTC, addressPosition, amount, toAddress, changeAddress, password, otherSigFetcher1, null);
}