Java Code Examples for net.bither.bitherj.exception.AddressFormatException#printStackTrace()
The following examples show how to use
net.bither.bitherj.exception.AddressFormatException#printStackTrace() .
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: BitherSetting.java From bither-android with Apache License 2.0 | 6 votes |
public boolean checkFormat(String content) { switch (this) { case Bither: //todo checkBitherQrCode return true; case Bip38: boolean check = false; try { check = net.bither.bitherj.crypto.bip38.Bip38.isBip38PrivateKey(content); } catch (AddressFormatException e) { e.printStackTrace(); } return check; } return false; }
Example 2
Source File: DialogImportBip38KeyText.java From bither-android with Apache License 2.0 | 6 votes |
@Override public void onClick(View v) { if (v.getId() == R.id.btn_ok) { String s = et.getText().toString(); if (Utils.isEmpty(s)) { tvError.setVisibility(View.VISIBLE); shake(); return; } try { if (!Bip38.isBip38PrivateKey(s)) { tvError.setVisibility(View.VISIBLE); shake(); return; } bip38KeyString = et.getText().toString(); dismiss(); } catch (AddressFormatException e) { tvError.setVisibility(View.VISIBLE); e.printStackTrace(); } } else { dismiss(); } }
Example 3
Source File: EnterpriseHDMProvider.java From bither-android with Apache License 2.0 | 5 votes |
@Override public List<EnterpriseHDMAddress> getEnterpriseHDMAddress(EnterpriseHDMKeychain keychain) { List<EnterpriseHDMAddress> enterpriseHDMAddressList = new ArrayList<EnterpriseHDMAddress>(); SQLiteDatabase db = this.mDb.getReadableDatabase(); int threshold = 0; Cursor cursor = db.rawQuery("select multi_sign_n from enterprise_multi_sign_set", null); if (cursor.moveToNext()) { int idColumn = cursor.getColumnIndex(AbstractDb.EnterpriseMultiSignSetColumns.MULTI_SIGN_N); if (idColumn != -1) { threshold = cursor.getInt(idColumn); } } cursor.close(); cursor = db.rawQuery("select * from " + AbstractDb.Tables.ENTERPRISE_HDM_ADDRESS + " order by hdm_index asc ", null); try { while (cursor.moveToNext()) { enterpriseHDMAddressList.add(format(cursor, threshold, keychain)); } } catch (AddressFormatException e) { e.printStackTrace(); } cursor.close(); return enterpriseHDMAddressList; }
Example 4
Source File: QRCodeTxTransport.java From bitherj with Apache License 2.0 | 5 votes |
public static String getPresignTxString(Tx tx, String changeAddress, String addressCannotParsed, int hdmIndex, TxTransportType txTransportType) { QRCodeTxTransport qrCodeTransport = fromSendRequestWithUnsignedTransaction(tx, addressCannotParsed, hdmIndex, txTransportType); String preSignString = ""; try { String versionStr = ""; if (txTransportType != null) { versionStr = TX_TRANSPORT_VERSION + txTransportType.getType(); } String changeStr = ""; if (!Utils.isEmpty(changeAddress)) { long changeAmt = tx.amountSentToAddress(changeAddress); if (changeAmt != 0) { String[] changeStrings = new String[]{Base58.bas58ToHexWithAddress (changeAddress), Long.toHexString(changeAmt)}; changeStr = Utils.joinString(changeStrings, QRCodeUtil.QR_CODE_SPLIT); } } String hdmIndexString = ""; if (qrCodeTransport.getHdmIndex() != QRCodeTxTransport.NO_HDM_INDEX) { hdmIndexString = Integer.toHexString(qrCodeTransport.getHdmIndex()); } String[] preSigns = new String[]{versionStr, hdmIndexString, Base58.bas58ToHexWithAddress (qrCodeTransport.getMyAddress()), changeStr, Long.toHexString(qrCodeTransport .getFee()), Base58.bas58ToHexWithAddress(qrCodeTransport.getToAddress()), Long.toHexString(qrCodeTransport.getTo())}; preSignString = Utils.joinString(preSigns, QRCodeUtil.QR_CODE_SPLIT); String[] hashStrings = new String[qrCodeTransport.getHashList().size()]; hashStrings = qrCodeTransport.getHashList().toArray(hashStrings); preSignString = preSignString + QRCodeUtil.QR_CODE_SPLIT + Utils.joinString (hashStrings, QRCodeUtil.QR_CODE_SPLIT); preSignString.toUpperCase(Locale.US); } catch (AddressFormatException e) { e.printStackTrace(); } return preSignString; }
Example 5
Source File: Utils.java From bitherj with Apache License 2.0 | 5 votes |
public static boolean validBitcoinPrivateKey(String str) { try { DumpedPrivateKey dumpedPrivateKey = new DumpedPrivateKey(str); dumpedPrivateKey.clearPrivateKey(); return true; } catch (AddressFormatException e) { e.printStackTrace(); } return false; }
Example 6
Source File: Utils.java From bitherj with Apache License 2.0 | 5 votes |
public static boolean validBicoinAddress(String str) { try { int addressHeader = getAddressHeader(str); return (addressHeader == BitherjSettings.p2shHeader || addressHeader == BitherjSettings.addressHeader); } catch (final AddressFormatException x) { x.printStackTrace(); } return false; }
Example 7
Source File: AbstractTxProvider.java From bitherj with Apache License 2.0 | 5 votes |
public byte[] isIdentify(Tx tx) { HashSet<String> result = new HashSet<String>(); for (In in : tx.getIns()) { String queryPrevTxHashSql = "select tx_hash from ins where prev_tx_hash=? and prev_out_sn=?"; final HashSet<String> each = new HashSet<String>(); this.execQueryOneRecord(this.getReadDb(), queryPrevTxHashSql, new String[]{Base58.encode(in.getPrevTxHash()) , Integer.toString(in.getPrevOutSn())}, new Function<ICursor, Void>() { @Nullable @Override public Void apply(@Nullable ICursor c) { each.add(c.getString(0)); return null; } }); each.remove(Base58.encode(tx.getTxHash())); result.retainAll(each); if (result.size() == 0) { break; } } if (result.size() == 0) { return new byte[0]; } else { try { return Base58.decode((String) result.toArray()[0]); } catch (AddressFormatException e) { e.printStackTrace(); return new byte[0]; } } }
Example 8
Source File: AddressTest.java From bitherj with Apache License 2.0 | 5 votes |
@Test public void testAddress() { try { DumpedPrivateKey dumpedPrivateKey = new DumpedPrivateKey("L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1"); ECKey ecKey = dumpedPrivateKey.getKey(); String addressStr = ecKey.toAddress(); assertEquals(ecKey.toAddress(), "1F3sAm6ZtwLAUnj7d38pGFxtP3RVEvtsbV"); } catch (AddressFormatException e) { e.printStackTrace(); } }
Example 9
Source File: HDAccountProvider.java From bither-desktop-java with Apache License 2.0 | 4 votes |
private HDAccount.HDAccountAddress formatAddress(ResultSet c) throws SQLException { String address = null; byte[] pubs = null; AbstractHD.PathType ternalRootType = AbstractHD.PathType.EXTERNAL_ROOT_PATH; int index = 0; boolean isIssued = false; boolean isSynced = true; HDAccount.HDAccountAddress hdAccountAddress = null; try { int idColumn = c.findColumn(AbstractDb.HDAccountAddressesColumns.ADDRESS); if (idColumn != -1) { address = c.getString(idColumn); } idColumn = c.findColumn(AbstractDb.HDAccountAddressesColumns.PUB); if (idColumn != -1) { pubs = Base58.decode(c.getString(idColumn)); } idColumn = c.findColumn(AbstractDb.HDAccountAddressesColumns.PATH_TYPE); if (idColumn != -1) { ternalRootType = AbstractHD.getTernalRootType(c.getInt(idColumn)); } idColumn = c.findColumn(AbstractDb.HDAccountAddressesColumns.ADDRESS_INDEX); if (idColumn != -1) { index = c.getInt(idColumn); } idColumn = c.findColumn(AbstractDb.HDAccountAddressesColumns.IS_ISSUED); if (idColumn != -1) { isIssued = c.getInt(idColumn) == 1; } idColumn = c.findColumn(AbstractDb.HDAccountAddressesColumns.IS_SYNCED); if (idColumn != -1) { isSynced = c.getInt(idColumn) == 1; } hdAccountAddress = new HDAccount.HDAccountAddress(address, pubs, ternalRootType, index, isIssued, isSynced); } catch (AddressFormatException e) { e.printStackTrace(); } return hdAccountAddress; }
Example 10
Source File: QRCodeTxTransport.java From bitherj with Apache License 2.0 | 4 votes |
public static String getHDAccountMonitoredUnsignedTx(Tx tx, String toAddress, HDAccount account) { TxTransportType txTransportType = TxTransportType.ColdHD; List<HDAccount.HDAccountAddress> addresses = account.getSigningAddressesForInputs(tx .getIns()); List<byte[]> hashes = tx.getUnsignedInHashes(); QRCodeTxTransport qrCodeTransport = new QRCodeTxTransport(); qrCodeTransport.setMyAddress(tx.getFromAddress()); qrCodeTransport.setToAddress(toAddress); qrCodeTransport.setTo(tx.amountSentToAddress(toAddress)); qrCodeTransport.setFee(tx.getFee()); List<String> hashList = new ArrayList<String>(); for (int i = 0; i < addresses.size(); i++) { HDAccount.HDAccountAddress address = addresses.get(i); byte[] h = hashes.get(i); String[] strings = new String[]{Integer.toString(address.getPathType().getValue()), Integer.toString(address.getIndex()), Utils.bytesToHexString(h).toUpperCase (Locale.US)}; hashList.add(Utils.joinString(strings, QRCodeUtil.QR_CODE_SECONDARY_SPLIT)); } qrCodeTransport.setHashList(hashList); String preSignString; try { String versionStr = ""; if (txTransportType != null) { versionStr = TX_TRANSPORT_VERSION + txTransportType.getType(); } String[] preSigns = new String[]{versionStr, Base58.bas58ToHexWithAddress (qrCodeTransport.getMyAddress()), Long.toHexString(qrCodeTransport.getFee()), Base58.bas58ToHexWithAddress(qrCodeTransport.getToAddress()), Long .toHexString(qrCodeTransport.getTo())}; preSignString = Utils.joinString(preSigns, QRCodeUtil.QR_CODE_SPLIT); String[] hashStrings = new String[qrCodeTransport.getHashList().size()]; hashStrings = qrCodeTransport.getHashList().toArray(hashStrings); preSignString = preSignString + QRCodeUtil.QR_CODE_SPLIT + Utils.joinString (hashStrings, QRCodeUtil.QR_CODE_SPLIT); preSignString.toUpperCase(Locale.US); } catch (AddressFormatException e) { e.printStackTrace(); return null; } return preSignString; }
Example 11
Source File: QRCodeTxTransport.java From bitherj with Apache License 2.0 | 4 votes |
public static String getDeskpHDMPresignTxString(TxTransportType txTransportType, Tx tx, String changeAddress, String addressCannotParsed, List<DesktopHDMAddress> desktopHDMAddresses) { QRCodeTxTransport qrCodeTransport = fromDeskpHDMSendRequestWithUnsignedTransaction(txTransportType, tx, desktopHDMAddresses, addressCannotParsed); String preSignString = ""; try { String versionStr = ""; if (txTransportType != null) { versionStr = TX_TRANSPORT_VERSION + txTransportType.getType(); } String changeStr = ""; if (!Utils.isEmpty(changeAddress)) { long changeAmt = tx.amountSentToAddress(changeAddress); if (changeAmt != 0) { String[] changeStrings = new String[]{Base58.bas58ToHexWithAddress (changeAddress), Long.toHexString(changeAmt)}; changeStr = Utils.joinString(changeStrings, QRCodeUtil.QR_CODE_SPLIT); } } String hdmIndexString = ""; if (qrCodeTransport.getHdmIndex() != QRCodeTxTransport.NO_HDM_INDEX) { hdmIndexString = Integer.toHexString(qrCodeTransport.getHdmIndex()); } String[] preSigns = new String[]{versionStr, hdmIndexString, Base58.bas58ToHexWithAddress (qrCodeTransport.getMyAddress()), changeStr, Long.toHexString(qrCodeTransport .getFee()), Base58.bas58ToHexWithAddress(qrCodeTransport.getToAddress()), Long.toHexString(qrCodeTransport.getTo())}; preSignString = Utils.joinString(preSigns, QRCodeUtil.QR_CODE_SPLIT); String[] hashStrings = new String[qrCodeTransport.getHashList().size()]; hashStrings = qrCodeTransport.getHashList().toArray(hashStrings); preSignString = preSignString + QRCodeUtil.QR_CODE_SPLIT + Utils.joinString (hashStrings, QRCodeUtil.QR_CODE_SPLIT); preSignString.toUpperCase(Locale.US); } catch (AddressFormatException e) { e.printStackTrace(); } return preSignString; }
Example 12
Source File: AbstractHDAccountAddressProvider.java From bitherj with Apache License 2.0 | 4 votes |
private HDAccount.HDAccountAddress formatAddress(ICursor c) { String address = null; byte[] pubs = null; AbstractHD.PathType ternalRootType = AbstractHD.PathType.EXTERNAL_ROOT_PATH; int index = 0; boolean isIssued = false; boolean isSynced = true; int hdAccountId = 0; HDAccount.HDAccountAddress hdAccountAddress = null; int idColumn = c.getColumnIndex(AbstractDb.HDAccountAddressesColumns.ADDRESS); if (idColumn != -1) { address = c.getString(idColumn); } idColumn = c.getColumnIndex(AbstractDb.HDAccountAddressesColumns.PUB); if (idColumn != -1) { try { pubs = Base58.decode(c.getString(idColumn)); } catch (AddressFormatException e) { e.printStackTrace(); } } idColumn = c.getColumnIndex(AbstractDb.HDAccountAddressesColumns.PATH_TYPE); if (idColumn != -1) { ternalRootType = AbstractHD.getTernalRootType(c.getInt(idColumn)); } idColumn = c.getColumnIndex(AbstractDb.HDAccountAddressesColumns.ADDRESS_INDEX); if (idColumn != -1) { index = c.getInt(idColumn); } idColumn = c.getColumnIndex(AbstractDb.HDAccountAddressesColumns.IS_ISSUED); if (idColumn != -1) { isIssued = c.getInt(idColumn) == 1; } idColumn = c.getColumnIndex(AbstractDb.HDAccountAddressesColumns.IS_SYNCED); if (idColumn != -1) { isSynced = c.getInt(idColumn) == 1; } idColumn = c.getColumnIndex(AbstractDb.HDAccountAddressesColumns.HD_ACCOUNT_ID); if (idColumn != -1) { hdAccountId = c.getInt(idColumn); } hdAccountAddress = new HDAccount.HDAccountAddress(address, pubs, ternalRootType, index, isIssued, isSynced, hdAccountId); return hdAccountAddress; }
Example 13
Source File: HDAccountProvider.java From bither-desktop-java with Apache License 2.0 | 4 votes |
private HDAccount.HDAccountAddress formatAddress(ResultSet c) throws SQLException { String address = null; byte[] pubs = null; AbstractHD.PathType ternalRootType = AbstractHD.PathType.EXTERNAL_ROOT_PATH; int index = 0; boolean isIssued = false; boolean isSynced = true; HDAccount.HDAccountAddress hdAccountAddress = null; try { int idColumn = c.findColumn(AbstractDb.HDAccountAddressesColumns.ADDRESS); if (idColumn != -1) { address = c.getString(idColumn); } idColumn = c.findColumn(AbstractDb.HDAccountAddressesColumns.PUB); if (idColumn != -1) { pubs = Base58.decode(c.getString(idColumn)); } idColumn = c.findColumn(AbstractDb.HDAccountAddressesColumns.PATH_TYPE); if (idColumn != -1) { ternalRootType = AbstractHD.getTernalRootType(c.getInt(idColumn)); } idColumn = c.findColumn(AbstractDb.HDAccountAddressesColumns.ADDRESS_INDEX); if (idColumn != -1) { index = c.getInt(idColumn); } idColumn = c.findColumn(AbstractDb.HDAccountAddressesColumns.IS_ISSUED); if (idColumn != -1) { isIssued = c.getInt(idColumn) == 1; } idColumn = c.findColumn(AbstractDb.HDAccountAddressesColumns.IS_SYNCED); if (idColumn != -1) { isSynced = c.getInt(idColumn) == 1; } hdAccountAddress = new HDAccount.HDAccountAddress(address, pubs, ternalRootType, index, isIssued, isSynced); } catch (AddressFormatException e) { e.printStackTrace(); } return hdAccountAddress; }