Java Code Examples for org.bitcoinj.core.Address#fromP2SHHash()

The following examples show how to use org.bitcoinj.core.Address#fromP2SHHash() . 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: ConfidentialAddress.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
public Address getBitcoinAddress(final NetworkParameters params) {
    if (bytes[0] == params.getP2SHHeader())
        return Address.fromP2SHHash(params, Arrays.copyOfRange(bytes, 34, 54));
    if (bytes[0] == params.getP2WPKHHeader())
        return Address.fromP2WPKHHash(params, Arrays.copyOfRange(bytes, 34, 54));
    throw new RuntimeException();  // Cannot happen.
}
 
Example 2
Source File: ConfidentialAddress.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
public Address getBitcoinAddress(final NetworkParameters params) {
    if (bytes[0] == params.getP2SHHeader())
        return Address.fromP2SHHash(params, Arrays.copyOfRange(bytes, 34, 54));
    if (bytes[0] == params.getP2WPKHHeader())
        return Address.fromP2WPKHHash(params, Arrays.copyOfRange(bytes, 34, 54));
    throw new RuntimeException();  // Cannot happen.
}
 
Example 3
Source File: SegWitBitcoinAddressCreator.java    From token-core-android with Apache License 2.0 4 votes vote down vote up
public Address fromPrivateKey(ECKey ecKey) {
  String redeemScript = String.format("0x0014%s", NumericUtil.bytesToHex(ecKey.getPubKeyHash()));
  return Address.fromP2SHHash(networkParameters, Utils.sha256hash160(NumericUtil.hexToBytes(redeemScript)));
}
 
Example 4
Source File: GATx.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
private static Address createChangeAddress(final JSONMap addrInfo, final NetworkParameters params) {
    byte[] script = addrInfo.getBytes("script");
    if (addrInfo.getString("addr_type").equals("p2wsh"))
        script = ScriptBuilder.createP2WSHOutputScript(Wally.sha256(script)).getProgram();
    return Address.fromP2SHHash(params, Wally.hash160(script));
}