Signing raw transaction that has p2sh-p2wsh input #11693

issue kgcorps openend this issue on November 15, 2017
  1. kgcorps commented at 1:17 pm on November 15, 2017: none

    Description:

    I am trying to sign an input that was sent to a p2sh-p2wsh address, but signrawtransaction RPC method returns an error stating = Witness program was passed an empty witness. All the data can be seen through pastebin

    Reproduction

    Reproducible by following these actions (note that wallet does NOT know anything about address/private keys used): Related address info (2of2 P2SH-P2WSH address): https://pastebin.com/TE1LrR44

    1. Raw transaction request/response: https://pastebin.com/r6HdMwsy

    2. SignRaw transaction request/response:

    Expected behavior

    I’d expect for it to sign a transaction just as if spendable input was inside wallet. Which I tested works just fine. I imported the address using import priv key->add multisig address->addwitnessaddress then created a deposit to it and then spent it, transaction went through without a hitch.

    Actual behaviour

    You can see the result in step 2.2.

    Additional info

    I talked about it at IRC bitcoin-core-dev channel with meshcollider. He said there might be an issue where I would need to pass in witness program as well to the signrawtransaction method and that it should add witness object if it is required since createrawtransaction method can’t possibly know if output is plain p2sh or a segwit wrapper.

    What version of bitcoin-core are you using?

    I am running v0.15.1.0-g7b57bc998f retrieved through Ubuntu PPA.

  2. fanquake added the label RPC/REST/ZMQ on Nov 15, 2017
  3. meshcollider commented at 1:35 pm on November 15, 2017: contributor

    where I would need to pass in witness program as well to the signrawtransaction method

    Indeed, I couldn’t work out any way currently to pass both the P2SH wrapper redeem script and the P2WSH witness program redeem script in, so if that’s not currently possible I’ll make a PR tomorrow to accept it as a standalone input. Need someone more familiar with it to weigh in though.

  4. kgcorps commented at 11:09 am on November 16, 2017: none
    I’ve found a way to add the witness program as well to the input when signing it, but it is definitely not straight forward, so basically what you have to do is add the same input 2x once with p2sh redeem script and once with p2wsh redeem script (props go to https://bitcoin.stackexchange.com/users/64730/arubi for figuring this one out). The example signing request for this particular example: https://pastebin.com/8CFhFP2Z Whether to change anything in the RPC API or not is up to you of course, but it is confusing to say the least. Might be a good idea for each input to add an optional witness script field with explanation when it should be passed.
  5. meshcollider commented at 4:36 am on October 15, 2018: contributor
    This was fixed by #12427
  6. meshcollider closed this on Oct 15, 2018

  7. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-19 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me