0
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
}
do you have same code for create the P2SH, if yes, can you public it? – vincenzopalazzo – 2019-09-11T09:14:05.983
@vincenzopalazzo, of course bro: https://pastebin.com/dL5vW22T
– mmo2112 – 2019-09-11T09:44:22.197if possible the bitcoin RPC and the bitcoinj generated two scripts different p2shScript? – vincenzopalazzo – 2019-09-11T10:33:12.280
@vincenzopalazzo, is that true? I don't think that bro... Maybe by someway can create many p2sh address? – mmo2112 – 2019-09-11T12:49:30.617
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 – 2019-09-11T13:11:54.890
1That's because you changed your private/public key when switched method! The private key you posted has a public key starting with
033452B8the "node" is using a public key starting with02a7065a– Coding Enthusiast – 2019-09-11T15:24:03.843@vincenzopalazzo, yeah I read that can create many P2SH address depend on P2SH script, I will check more. – mmo2112 – 2019-09-12T02:08:48.113
@CodingEnthusiast, you're right, I wrong key but out result is still not match. Correct wif is
cUNCS8F8n2dgineo4ENshEo4qFDMTLYa7MC31DKSo8whVZaV6FDu– mmo2112 – 2019-09-17T06:44:48.940If your resulting address is different then it means you are using different scripts, otherwise they should be the same. – Coding Enthusiast – 2019-09-17T11:39:52.063