<p>I have a private key and trying to create P2SH address on testnet like my node created but they're not same. Please help me a bit, thanks so much.
<br>
PrivateKey: <code>c5964e19634e473e9c8fed3b149c4d44b6d62d62724035aad3eb911a1495ae27</code>
<br>
P2SH address from 1 threshold and 1 pubkey:
<code>2N4GriyLchUgwwCBonzYHgsCHNhYRHW45w7</code>
<br>
P2WPKH address: <code>2NGA8uGdnaQ21phNpVyV5uye5cbUtudxBWh</code> || <code>tb1qld2fzw9gj30wxjamsz73fug62das7cyq0em4mn</code>
<br>
Address from node: <code>2N8qKVKuR3QAy2cA5fF2QbuCpBGfGCmbUHx</code>
<br>
Here is more detail from <code>getaddressinfo</code>:</p>

<pre><code>{
    "result": {
        "address": "2N8qKVKuR3QAy2cA5fF2QbuCpBGfGCmbUHx",
        "scriptPubKey": "a914aafc9f09b99cbb1ba46001ec4868ba4fb32543ca87",
        "ismine": true,
        "solvable": true,
        "desc": "sh(wpkh([a1696bdc/0'/0'/375509']02a7065a210c28d27a591e55ac6be092111349fc4b23927bb4d13c46a683bcfff7))#hrgzj3gs",
        "iswatchonly": false,
        "isscript": true,
        "iswitness": false,
        "script": "witness_v0_keyhash",
        "hex": "00146da71bc5de0c0b59bbf73520df7e7d4048d02594",
        "pubkey": "02a7065a210c28d27a591e55ac6be092111349fc4b23927bb4d13c46a683bcfff7",
        "embedded": {
            "isscript": false,
            "iswitness": true,
            "witness_version": 0,
            "witness_program": "6da71bc5de0c0b59bbf73520df7e7d4048d02594",
            "pubkey": "02a7065a210c28d27a591e55ac6be092111349fc4b23927bb4d13c46a683bcfff7",
            "address": "tb1qdkn3h3w7ps94nwlhx5sd7lnagpydqfv5pyqurf",
            "scriptPubKey": "00146da71bc5de0c0b59bbf73520df7e7d4048d02594"
        },
        "label": "test",
        "ischange": false,
        "timestamp": 1561438016,
        "hdkeypath": "m/0'/0'/375509'",
        "hdseedid": "e2e9dd17501f967b789c28c4be1dbf64897ad8d2",
        "hdmasterfingerprint": "a1696bdc",
        "labels": [
            {
                "name": "test",
                "purpose": "receive"
            }
        ]
    },
    "error": null,
    "id": 1
}
</code></pre>

CC BY-SA 4.0
2019-09-11T09:14:05.983Z
do you have same code for create the P2SH, if yes, can you public it?
vincenzopalazzo
CC BY-SA 4.0
2019-09-11T09:44:22.197Z
@vincenzopalazzo, 
of course bro: https://pastebin.com/dL5vW22T
mmo2112
CC BY-SA 4.0
2019-09-11T10:33:12.280Z
if possible the bitcoin RPC and the bitcoinj generated two scripts different p2shScript?
vincenzopalazzo
CC BY-SA 4.0
2019-09-11T12:49:30.617Z
@vincenzopalazzo, is that true? I don't think that bro... Maybe by someway can create many p2sh address?
mmo2112
CC BY-SA 4.0
2019-09-11T13:11:54.890Z
The address p2sh is created from the hex of the script if the script is different the p2sh address is different. ps. Yes is possible to generate much p2sh address, one script p2sh <-> address p2sh
vincenzopalazzo
CC BY-SA 4.0
2019-09-11T15:24:03.843Z
That's because you changed your private/public key when switched method! The private key you posted has a public key starting with `033452B8` the "node" is using a public key starting with `02a7065a`
Coding Enthusiast
CC BY-SA 4.0
2019-09-12T02:08:48.113Z
@vincenzopalazzo, yeah I read that can create many P2SH address depend on P2SH script, I will check more.
mmo2112
CC BY-SA 4.0
2019-09-17T06:44:48.940Z
@CodingEnthusiast, you're right, I wrong key but out result is still not match. Correct wif is `cUNCS8F8n2dgineo4ENshEo4qFDMTLYa7MC31DKSo8whVZaV6FDu`
mmo2112
CC BY-SA 4.0
2019-09-17T11:39:52.063Z
If your resulting address is different then it means you are using different scripts, otherwise they should be the same.
Coding Enthusiast
<bitcoin-core><bitcoinj><p2sh>
Create P2SH address is not same as address saved on rpc node
mmo2112
# Create P2SH address is not same as address saved on rpc node

(Asked by: username_0 on 2019-09-11)

I have a private key and trying to create P2SH address on testnet like my node created but they're not same. Please help me a bit, thanks so much.

PrivateKey: c5964e19634e473e9c8fed3b149c4d44b6d62d62724035aad3eb911a1495ae27

P2SH address from 1 threshold and 1 pubkey:
2N4GriyLchUgwwCBonzYHgsCHNhYRHW45w7

P2WPKH address: 2NGA8uGdnaQ21phNpVyV5uye5cbUtudxBWh || tb1qld2fzw9gj30wxjamsz73fug62das7cyq0em4mn

Address from node: 2N8qKVKuR3QAy2cA5fF2QbuCpBGfGCmbUHx

Here is more detail from getaddressinfo:
{
    "result": {
        "address": "2N8qKVKuR3QAy2cA5fF2QbuCpBGfGCmbUHx",
        "scriptPubKey": "a914aafc9f09b99cbb1ba46001ec4868ba4fb32543ca87",
        "ismine": true,
        "solvable": true,
        "desc": "sh(wpkh([a1696bdc/0'/0'/375509']02a7065a210c28d27a591e55ac6be092111349fc4b23927bb4d13c46a683bcfff7))#hrgzj3gs",
        "iswatchonly": false,
        "isscript": true,
        "iswitness": false,
        "script": "witness_v0_keyhash",
        "hex": "00146da71bc5de0c0b59bbf73520df7e7d4048d02594",
        "pubkey": "02a7065a210c28d27a591e55ac6be092111349fc4b23927bb4d13c46a683bcfff7",
        "embedded": {
            "isscript": false,
            "iswitness": true,
            "witness_version": 0,
            "witness_program": "6da71bc5de0c0b59bbf73520df7e7d4048d02594",
            "pubkey": "02a7065a210c28d27a591e55ac6be092111349fc4b23927bb4d13c46a683bcfff7",
            "address": "tb1qdkn3h3w7ps94nwlhx5sd7lnagpydqfv5pyqurf",
            "scriptPubKey": "00146da71bc5de0c0b59bbf73520df7e7d4048d02594"
        },
        "label": "test",
        "ischange": false,
        "timestamp": 1561438016,
        "hdkeypath": "m/0'/0'/375509'",
        "hdseedid": "e2e9dd17501f967b789c28c4be1dbf64897ad8d2",
        "hdmasterfingerprint": "a1696bdc",
        "labels": [
            {
                "name": "test",
                "purpose": "receive"
            }
        ]
    },
    "error": null,
    "id": 1
}

**Tags:** bitcoin-core, bitcoinj, p2sh

> **Comments:**
> **username_1**: do you have same code for create the P2SH, if yes, can you public it?  
> **username_0**: @username_1,  of course bro: https://pastebin.com/dL5vW22T  
> **username_1**: if possible the bitcoin RPC and the bitcoinj generated two scripts different p2shScript?  
> **username_0**: @username_1, is that true? I don't think that bro... Maybe by someway can create many p2sh address?  
> **username_1**: The address p2sh is created from the hex of the script if the script is different the p2sh address is different. ps. Yes is possible to generate much p2sh address, one script p2sh <-> address p2sh  
> **username_2**: That's because you changed your private/public key when switched method! The private key you posted has a public key starting with `033452B8` the "node" is using a public key starting with `02a7065a`  
> **username_0**: @username_1, yeah I read that can create many P2SH address depend on P2SH script, I will check more.  
> **username_0**: @CodingEnthusiast, you're right, I wrong key but out result is still not match. Correct wif is `cUNCS8F8n2dgineo4ENshEo4qFDMTLYa7MC31DKSo8whVZaV6FDu`  
> **username_2**: If your resulting address is different then it means you are using different scripts, otherwise they should be the same.  

---

## 0 answers

