Skip to content

print P2WSH redeemScript in getrawtransaction if it s not a pubkey - #6

Closed
czzarr wants to merge 1 commit into
masterfrom
print-p2wsh-redeemscript-in-getrawtransaction
Closed

print P2WSH redeemScript in getrawtransaction if it s not a pubkey#6
czzarr wants to merge 1 commit into
masterfrom
print-p2wsh-redeemscript-in-getrawtransaction

Conversation

@czzarr

@czzarr czzarr commented Sep 26, 2016

Copy link
Copy Markdown

This PR adds code to print a readable asm version of the redeemScript of a P2WSH input in the getrawtransaction RPC call which is useful to explore that kind of transactions.

@czzarr

czzarr commented Sep 26, 2016

Copy link
Copy Markdown
Author

I'll make it compatible with @jnewbery when his PRs are merged.

Comment thread src/rpc/rawtransaction.cpp Outdated
}
in.push_back(Pair("txinwitness", txinwitness));
// try to parse the last item as a pubkey
// if someone constructed the script to look like a pubkey, then he's insane

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: suggest you add a bit more context to this comment. eg:

In version 0, there are two valid witness types: P2WPKH and P2WSH. P2WPKH witnesses have two items on the witness stack, the second of which is a public key. We test whether the last item on the witness stack is a valid public key, and if it isn't we try to parse it as a redeem script.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agreed, but aside from that LGTM.

@jnewbery

Copy link
Copy Markdown

Note that to make this compatible with #4 , you'll need to change ScriptPubKeyToJSON() to ScriptPubKeyToUniv().

@czzarr
czzarr force-pushed the print-p2wsh-redeemscript-in-getrawtransaction branch from 101eb45 to 5f18004 Compare September 30, 2016 14:45
@czzarr

czzarr commented Sep 30, 2016

Copy link
Copy Markdown
Author

I have updated the comment as suggested and posted a PR to bitcoin/bitcoin bitcoin#8849

@czzarr czzarr closed this Sep 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants