Java Code Examples for net.bither.bitherj.utils.Base58#bas58ToHexWithAddress()
The following examples show how to use
net.bither.bitherj.utils.Base58#bas58ToHexWithAddress() .
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: 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 2
Source File: PasswordSeed.java From bitherj with Apache License 2.0 | 5 votes |
public String toPasswordSeedString() { try { String passwordSeedString = Base58.bas58ToHexWithAddress(this.address) + QRCodeUtil.QR_CODE_SPLIT + QRCodeUtil.getNewVersionEncryptPrivKey(this.keyStr); return passwordSeedString; } catch (AddressFormatException e) { throw new RuntimeException("passwordSeed address is format error ," + this.address); } }
Example 3
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 4
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; }