I am generating Segwit address like this

Address.fromP2SHScript(params,segWitOutputScript());


public static Script segWitOutputScript()    {

    //
    // OP_HASH160 hash160(redeemScript) OP_EQUAL
    //
    byte[] hash = Utils.sha256hash160(segWitRedeemScript().getProgram());
    byte[] buf = new byte[3 + hash.length];
    buf[0] = (byte)0xa9;    // HASH160
    buf[1] = (byte)0x14;    // push 20 bytes
    System.arraycopy(hash, 0, buf, 2, hash.length); // keyhash
    buf[22] = (byte)0x87;   // OP_EQUAL

    return new Script(buf);
}

public static Script segWitRedeemScript()    {

    //
    // The P2SH segwit redeemScript is always 22 bytes. It starts with a OP_0, 
followed by a canonical push of the keyhash (i.e. 0x0014{20-byte keyhash})
    //
    ECKey ecKey = new ECKey();

    byte[] hash = Utils.sha256hash160(ecKey.getPubKey());
    byte[] buf = new byte[2 + hash.length];
    buf[0] = (byte)0x00;  // OP_0
    buf[1] = (byte)0x14;  // push 20 bytes
    System.arraycopy(hash, 0, buf, 2, hash.length); // keyhash

    return new Script(buf);
}


i am not able to receive payment on the Segwit Address, but when i send payment 
on Standard Addr then i receive it.

what i am doing wrong here ?

-- 
You received this message because you are subscribed to the Google Groups 
"bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bitcoinj+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to