In decodescript output, only show the corresponding P2SH address if the script is a P2SH script.
RPC: decodescript - Only show P2SH address for P2SH scripts #7390
pull Kefkius wants to merge 1 commits into bitcoin:master from Kefkius:rpc-decodescript changing 1 files +2 −1-
Kefkius commented at 5:57 AM on January 22, 2016: none
-
e30473d670
RPC: decodescript - Only show P2SH address for P2SH scripts
In decodescript output, only show the corresponding P2SH address if the script is a P2SH script.
- laanwj added the label RPC on Jan 22, 2016
-
laanwj commented at 12:32 PM on January 22, 2016: member
I may be confusing things, but I think this change is incorrect: One would use this functionality to get the hash to pay to a script (to be specified in the input claiming this output), to use in a P2SH output script. If something is already a P2SH output script (signified by
script.IsPayToScriptHash), there's no use to hash it into another one. After all, you can't pay to another output. -
Kefkius commented at 1:05 PM on January 22, 2016: none
@laanwj No, you're right; the confusion is mine. The p2sh address is the only element in the "addresses" array of the json output. With that in mind, I recommend either
- Using that sole element of the "addresses" array for the "p2sh" string, or
- Not outputting any "p2sh" string.
I can implement either one.
-
laanwj commented at 1:08 PM on January 22, 2016: member
Can you show what is the issue with the current output?
-
laanwj commented at 1:17 PM on January 22, 2016: member
In the current software: e.g. show the output how it is, and how it should be according to you. Which problem are you fixing / trying to fix?
-
Kefkius commented at 1:27 PM on January 22, 2016: none
$ bitcoin-cli decodescript a914000000000000000000000000000000000000000087 { "asm" : "OP_HASH160 0000000000000000000000000000000000000000 OP_EQUAL", "reqSigs" : 1, "type" : "scripthash", "addresses" : [ "31h1vYVSYuKP6AhS86fbRdMw9XHieotbST" ], "p2sh" : "3JN66NLyYtXh1yQH3BsfsJgh9CQU3xYyWx" }In the above output, "3JN66NLyYtXh1yQH3BsfsJgh9CQU3xYyWx" is shown as the P2SH address, while the actual address is 31h1vYVSYuKP6AhS86fbRdMw9XHieotbST, as shown in the "addresses" array. This could cause confusion.
The P2SH address for whatever script is input is shown regardless of the script's contents. Here's it generating an address that shouldn't be paid to:
$ bitcoin-cli decodescript 6a023905 { "asm" : "OP_RETURN 1337", "type" : "nulldata", "p2sh" : "353pyJLTuq9RgFrxC9muEer5CXjKRv8SMJ" }Edit Oh, and how it should be according to me: Just omit "p2sh" in the output.
-
laanwj commented at 1:58 PM on January 22, 2016: member
Just omitting it is not acceptable - people are relying on this functionality. Even moving it to a different place will break software using this.
If you are afraid of people getting confused, improving the documentation (
help decodescript) would be the most effective and realizable solution. - Kefkius closed this on Jan 22, 2016
- DrahtBot locked this on Sep 8, 2021