Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Don't return the address of a P2SH of a P2SH #8845

Merged
merged 1 commit into from Oct 18, 2016

Conversation

Projects
None yet
6 participants
Member

jnewbery commented Sep 29, 2016

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.

src/rpc/rawtransaction.cpp
+ UniValue type;
+ type = find_value(r, "type");
+
+ if ((!type.isNull()) && (type.isStr()) && (type.get_str() != "scripthash"))
@ryanofsky

ryanofsky Oct 3, 2016

Contributor

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).

@jnewbery

jnewbery Oct 3, 2016

Member

Thanks. Both done.

Member

jnewbery commented Oct 3, 2016

@ryanofsky's suggestions added and rebased.

Owner

sipa commented Oct 4, 2016

utACK

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..)

Member

MarcoFalke commented Oct 5, 2016

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

Member

jnewbery commented Oct 5, 2016

Fixed commit description.

Owner

laanwj commented Oct 11, 2016

utACK

+ UniValue type;
+ type = find_value(r, "type");
+
+ if (type.isStr() && type.get_str() != "scripthash") {
@laanwj

laanwj Oct 11, 2016

Owner

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

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

laanwj added a commit that referenced this pull request Oct 18, 2016

Merge #8845: Don't return the address of a P2SH of a P2SH
d51f182 Don't return the address of a P2SH of a P2SH. (jnewbery)

@jnewbery jnewbery deleted the jnewbery:trivial-P2SH-P2SH branch Oct 18, 2016

luke-jr added a commit to bitcoinknots/bitcoin that referenced this pull request Oct 20, 2016

@luke-jr luke-jr referenced this pull request Oct 25, 2016

Merged

0.13.2 backports #9011

laanwj added a commit to laanwj/bitcoin that referenced this pull request Oct 25, 2016

laanwj added a commit to laanwj/bitcoin that referenced this pull request Oct 27, 2016

schinzelh added a commit to dashpay/dash that referenced this pull request Oct 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment