Skip to content

Conversation

@jnewbery
Copy link
Contributor

be066fa added an RPC to decode a hex input script. The returned object is:

{
  "asm":"asm",   (string) Script public key
  "hex":"hex",   (string) hex encoded public key
  "type":"type", (string) The output type
  "reqSigs": n,    (numeric) The required signatures
  "addresses": [   (json array of string)
     "address"     (string) bitcoin address
     ,...
  ],
  "p2sh","address" (string) script address.
}

That "p2sh" return value is the address of a P2SH with the hex input script as the redeem script.

If the input script is already a P2SH script, this doesn't make sense (we can't wrap a P2SH in a P2SH). Only return a P2SH address if the input script is not a P2SH script.

UniValue type;
type = find_value(r, "type");

if ((!type.isNull()) && (type.isStr()) && (type.get_str() != "scripthash"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably drop the isNull check because a value can't be both a string and a null at the same time.

Also maybe drop the parens around && conditions (searching for "&&" in this file shows no parens used in the other cases).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Both done.

@jnewbery
Copy link
Contributor Author

jnewbery commented Oct 3, 2016

@ryanofsky's suggestions added and rebased.

@sipa
Copy link
Member

sipa commented Oct 4, 2016

utACK

@luke-jr
Copy link
Member

luke-jr commented Oct 5, 2016

"Incorporated suggested changes from @ryanofsky." doesn't belong in the commit description (it will ping him every time the commit goes somewhere..)

@maflcko
Copy link
Member

maflcko commented Oct 5, 2016

Agree. Also please don't put irrelevant information in the commit subject line.

@jnewbery
Copy link
Contributor Author

jnewbery commented Oct 5, 2016

Fixed commit description.

@laanwj
Copy link
Member

laanwj commented Oct 11, 2016

utACK

UniValue type;
type = find_value(r, "type");

if (type.isStr() && type.get_str() != "scripthash") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think looking at the generated JSON here instead of the script object itself is a bit confusing, but I tend to agree it's the best way to go here to not have to repeat ExtractDestinations.

@laanwj laanwj merged commit d51f182 into bitcoin:master Oct 18, 2016
laanwj added a commit that referenced this pull request Oct 18, 2016
d51f182 Don't return the address of a P2SH of a P2SH. (jnewbery)
@jnewbery jnewbery deleted the trivial-P2SH-P2SH branch October 18, 2016 14:15
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Oct 20, 2016
Github-Pull: bitcoin#8845
Rebased-From: cef66cbca48fa969c9fb3374f2892202a4fe31ac
@luke-jr luke-jr mentioned this pull request Oct 25, 2016
laanwj pushed a commit to laanwj/bitcoin that referenced this pull request Oct 27, 2016
schinzelh pushed a commit to dashpay/dash that referenced this pull request Oct 23, 2017
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants