Cannot sign a transaction with P2WSH/P2SH while using signrawtransactionwithwallet #22451

issue liorko87 opened this issue on July 15, 2021
  1. liorko87 commented at 9:27 AM on July 15, 2021: none

    <!-- This issue tracker is only for technical issues related to Bitcoin Core. General bitcoin questions and/or support requests are best directed to the Bitcoin StackExchange at https://bitcoin.stackexchange.com. For reporting security issues, please read instructions at https://bitcoincore.org/en/contact/. If the node is "stuck" during sync or giving "block checksum mismatch" errors, please ensure your hardware is stable by running memtest and observe CPU temperature with a load-test tool such as linpack before creating an issue! Any report, issue or feature request related to the GUI should be reported at https://github.com/bitcoin-core/gui/issues/ -->

    <!-- Describe the issue -->

    I'm creating a raw transaction using the RPC command createrawtransaction When I'm signing the transaction with the RPC command signrawtransactionwithwallet- I'm receiving the following error:

    response code: 500 responseMessage Internal Server Error, response: {"result":null,"error":{"code":-8,"message":"redeemScript/witnessScript does not match scriptPubKey"},"id":"1"
    

    When I'm using signrawtransactionwithkey the transaction signed (and sent) correctly.

    Bitcoin version: 0.21 OS: Linux/Windows

    <!--- What behavior did you expect? -->

    <!--- What was the actual behavior (provide screenshots if the issue is GUI-related)? -->

    <!--- How reliably can you reproduce the issue, what are the steps to do so? -->

    <!-- What version of Bitcoin Core are you using, where did you get it (website, self-compiled, etc)? -->

    <!-- What type of machine are you observing the error on (OS/CPU and disk type)? -->

    <!-- GUI-related issue? What is your operating system and its version? If Linux, what is your desktop environment and graphical shell? -->

    <!-- Any extra information that might be useful in the debugging process. -->

    <!--- This is normally the contents of a `debug.log` or `config.log` file. Raw text or a link to a pastebin type site are preferred. -->

  2. MarcoFalke commented at 9:38 AM on July 15, 2021: member

    What are the steps to reproduce (on regtest, if possible)?

  3. MarcoFalke added the label Questions and Help on Jul 15, 2021
  4. MarcoFalke added the label RPC/REST/ZMQ on Jul 15, 2021
  5. liorko87 commented at 10:45 AM on July 15, 2021: none

    I tried it on mainnet, but I'm assume that the steps are identical for regtest.

    1. Create a new address: 'getnewaddress`
    2. Create raw transaction using createrawtransaction
    3. Sign the transaction with signrawtransactionwithwallet

    At the bitcoin.conf I added this line:

    addresstype=p2sh-segwit
    
  6. ghost commented at 1:12 AM on July 22, 2021: none

    I tried it on mainnet, but I'm assume that the steps are identical for regtest. @liorko87 Can you try this on testnet in a new wallet?

    1. Create raw transaction using createrawtransaction

    What parameters did you use with createrawtransaction? I am not able to reproduce this using the steps you mentioned

  7. liorko87 commented at 9:11 AM on July 28, 2021: none

    @prayank23 I tried also on the testnet and the same happens to me. I also generated new SegWit addresses and received this error after I called signrawtransactionwithkey: "error": "Witness program hash mismatch"

  8. MarcoFalke commented at 9:13 AM on July 28, 2021: member

    We will need exact steps to reproduce (with arguments you provided to the calls)

  9. liorko87 commented at 2:06 PM on August 1, 2021: none

    Steps to reproduce:

    1. Generate two new addresses in different wallets
    ./bitcoin-cli --datadir=~/bitcoinNodes/node1 getnewaddress
    ./bitcoin-cli --datadir=~/bitcoinNodes/node2 getnewaddress
    
    1. Set transaction fee
    ./bitcoin-cli --datadir=~/bitcoinNodes/node1 settxfee 0.02
    
    1. Send money to address
    ./bitcoin-cli --datadir=~/bitcoinNodes/node1 sendtoaddress <wallet_2_address> 0.5
    
    1. Create raw transaction
    ./bitcoin-cli --datadir=~/bitcoinNodes/node1 createrawtransaction \
     '[{"txid":"tx_id_stage#3","vout":0}]' \
     '[{"<wallet_1_address>": amount_available_after_transaction_completed}]
    
    1. Signed the raw transaction- I tried with signedrawtransactionwithwallet and signrawtransactionwithkey
    ./bitcoin-cli --datadir=~/bitcoinNodes/node1/signrawtransactionwithkey signed_tx_hex \
     '[private_key_array]'
    
  10. liorko87 commented at 8:26 AM on August 2, 2021: none

    Here is another insight- when I'm generating two SegWit addresses and remove the last stage (signrawtransactionwithkey), everything works perfectly.

  11. liorko87 commented at 8:11 AM on September 13, 2021: none

    The issue was using an address that is not in the wallet. Therefore, I could not sign the transaction.

  12. liorko87 closed this on Sep 13, 2021

  13. DrahtBot locked this on Nov 24, 2022

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: 2026-04-13 15:14 UTC

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