Java Code Examples for net.bither.bitherj.utils.Utils#toAddress()
The following examples show how to use
net.bither.bitherj.utils.Utils#toAddress() .
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: Script.java From bitherj with Apache License 2.0 | 6 votes |
public String getFromAddress() throws ScriptException { if (this.chunks.size() == 2 && this.chunks.get(0).data != null && this.chunks.get(0).data.length > 2 && this.chunks.get(1).data != null && this.chunks.get(1).data.length > 2) { return Utils.toAddress(Utils.sha256hash160(this.chunks.get(1).data)); } else if (this.chunks.size() >= 3 && this.chunks.get(0).opcode == OP_0) { boolean isPay2SHScript = true; for (int i = 1; i < this.chunks.size(); i++) { isPay2SHScript &= (this.chunks.get(i).data != null && this.chunks.get(i).data.length > 2); } if (isPay2SHScript) { return Utils.toP2SHAddress(Utils.sha256hash160(this.chunks.get(this.chunks.size() - 1).data)); } } return null; }
Example 2
Source File: QRCodeEnodeUtil.java From bitherj with Apache License 2.0 | 6 votes |
public static List<Address> formatPublicString(String content) { String[] strs = QRCodeUtil.splitString(content); ArrayList<Address> wallets = new ArrayList<Address>(); for (String str : strs) { boolean isXRandom = false; if (str.indexOf(QRCodeUtil.XRANDOM_FLAG) == 0) { isXRandom = true; str = str.substring(1); } byte[] pub = Utils.hexStringToByteArray(str); org.spongycastle.math.ec.ECPoint ecPoint = ECKey.checkPoint(pub); if (ecPoint != null && ecPoint.isValid()) { String addString = Utils.toAddress(Utils.sha256hash160(pub)); Address address = new Address(addString, pub, null, false, isXRandom); wallets.add(address); } } return wallets; }
Example 3
Source File: Script.java From bitherj with Apache License 2.0 | 5 votes |
/** * Gets the destination address from this script, if it's in the required form (see getPubKey). */ public String getToAddress() throws ScriptException { if (isSentToAddress()) return Utils.toAddress(getPubKeyHash()); else if (isSentToP2SH()) return Utils.toP2SHAddress(this.getPubKeyHash()); else throw new ScriptException("Cannot cast this script to a pay-to-address type"); }
Example 4
Source File: AbstractHD.java From bitherj with Apache License 2.0 | 4 votes |
protected String getFirstAddressFromSeed(CharSequence password) { DeterministicKey key = getExternalKey(0, password); String address = Utils.toAddress(key.getPubKeyHash()); key.wipe(); return address; }
Example 5
Source File: HDAccount.java From bitherj with Apache License 2.0 | 4 votes |
protected String getFirstAddressFromSeed(CharSequence password) { DeterministicKey key = getExternalKey(0, password); String address = Utils.toAddress(key.getPubKeyHash()); key.wipe(); return address; }
Example 6
Source File: HDAccount.java From bitherj with Apache License 2.0 | 4 votes |
public HDAccountAddress(byte[] pub, AbstractHD.PathType pathType, int index, boolean isSyncedComplete, int hdAccountId) { this(Utils.toAddress(Utils.sha256hash160(pub)), pub, pathType, index, false, isSyncedComplete, hdAccountId); }
Example 7
Source File: ECKey.java From bitherj with Apache License 2.0 | 2 votes |
/** * Returns the address that corresponds to the public part of this ECKey. Note that an address is derived from * the RIPEMD-160 hash of the public key and is not the public key itself (which is too large to be convenient). */ public String toAddress() { return Utils.toAddress(Utils.sha256hash160(pub)); }