signrawtransaction shows errors after partially signing a multisig transaction #9988

issue achow101 openend this issue on March 14, 2017
  1. achow101 commented at 2:48 am on March 14, 2017: member

    Describe the issue

    Can you reliably reproduce the issue?

    If so, please list the steps to reproduce below:

    1. Follow the steps in https://gist.github.com/gavinandresen/3966071

    Expected behaviour

    The first signrawtransaction command should be successful and return a partially signed transaction that can be sent to the other cosigners for signing.

    Actual behaviour

    Instead signrawtransaction fails and does not return a partially signed transaction.

    What version of bitcoin-core are you using?

    This was reported for 0.14.0. However we have determined that it affects 0.11.1 and later, and likely 0.11.0. It does not affect 0.10.3.

    It appears that the bug is caused by this VerifyScript call which was introduced in 8ac2a4e1788426329b842eea7121b8eac7875c76 which has been a part of all versions since 0.11.0rc1.

    See also: https://bitcointalk.org/index.php?topic=1823847.msg18164848#msg18164848

  2. fanquake added the label Bug on Mar 14, 2017
  3. fanquake added the label RPC/REST/ZMQ on Mar 14, 2017
  4. paveljanik commented at 4:17 pm on May 15, 2017: contributor
    @achow101 Looks like nobody wants to read that URL. Can you please paste commands that can be used on the testnet right away and demonstrate the issue?
  5. achow101 commented at 4:54 pm on May 15, 2017: member

    From the thread I linked to:

    Three addresses and their private and public keys:

     0cMpfNfuasJcrCv8RKMG35C8YtUVpaheFbNMwDuBXVvdcjaeYE7oh
     1024c5965fb18701569ec09e8d2979c45e3d6e0c60ddb3c9d6af0692124d3890e8a
     2mgMZZtLSX1cU9jhAdQWMqMyoPv4JncZqcU
     3
     4cVM5Kaoim2MKzT8MxVHHAu9BixJKTJgMhqape1eHgjHGhFPkf2mn
     503c9084cf82f74f764829a7d3c842462e03f4bbaf59981cb3b98cd3974438e5771
     6mrdkuGp2wcXhcmtN7RwwUs7CYevJpYuLnV
     7
     8cU4mHYwU2X1oTWBfYBGYFN69oYdrpWnBMrWd4nCoeRPUzmRY89vM
     90256d87a1997bad87ebdd409a3437ecec02885300a1bb0a1159e289ae66af78b34
    10mospdWZdHtym59yMwUUi8w4HcWQxd7sQsv
    

    Create 2-of-3 multisig address:

    0createmultisig 2 '["024c5965fb18701569ec09e8d2979c45e3d6e0c60ddb3c9d6af0692124d3890e8a","03c9084cf82f74f764829a7d3c842462e03f4bbaf59981cb3b98cd3974438e5771","0256d87a1997bad87ebdd409a3437ecec02885300a1bb0a1159e289ae66af78b34"]'
    1
    2{
    3  "address": "2N9nn3aMYzTjs2ccTRAvDUmdKykL9YjM2cj",
    4  "redeemScript": "5221024c5965fb18701569ec09e8d2979c45e3d6e0c60ddb3c9d6af0692124d3890e8a2103c9084cf82f74f764829a7d3c842462e03f4bbaf59981cb3b98cd3974438e5771210256d87a1997bad87ebdd409a3437ecec02885300a1bb0a1159e289ae66af78b3453ae"
    5}
    

    Import address and fund it:

     0importaddress 2N9nn3aMYzTjs2ccTRAvDUmdKykL9YjM2cj "" false
     1
     2//sent 0.1btc to 2N9nn3aMYzTjs2ccTRAvDUmdKykL9YjM2cj
     3
     4listunspent
     5[
     6  {
     7    "txid": "ff65917ac6cbe36d55893d9e1ce63cad1140c2ab38e9c7d099170b16d1a55d70",
     8    "vout": 0,
     9    "address": "2N9nn3aMYzTjs2ccTRAvDUmdKykL9YjM2cj",
    10    "account": "",
    11    "scriptPubKey": "a914b579aabfd350ed75ee056ff4d6d56718c74f55df87",
    12    "amount": 0.10000000,
    13    "confirmations": 1,
    14    "spendable": false,
    15    "solvable": false
    16  }, 
    

    Make unsigned spending tx:

    0createrawtransaction '[{"txid":"ff65917ac6cbe36d55893d9e1ce63cad1140c2ab38e9c7d099170b16d1a55d70","vout":0,"scriptPubKey":"a914b579aabfd350ed75ee056ff4d6d56718c74f55df87","redeemScript":"5221024c5965fb18701569ec09e8d2979c45e3d6e0c60ddb3c9d6af0692124d3890e8a2103c9084cf82f74f764829a7d3c842462e03f4bbaf59981cb3b98cd3974438e5771210256d87a1997bad87ebdd409a3437ecec02885300a1bb0a1159e289ae66af78b3453ae"}]' '{"mqZa1zbDg5RHVYbX6ea1QxPuuxAyuGVSoK":0.0999}'
    1
    20100000001705da5d1160b1799d0c7e938abc24011ad3ce61c9e3d89556de3cbc67a9165ff0000000000ffffffff01706f9800000000001976a9146e2fe8ef5dcb05fd258e2f51d3f15ba3781cd96b88ac00000000
    

    Attempt to sign with first privkey fails:

     0signrawtransaction '0100000001705da5d1160b1799d0c7e938abc24011ad3ce61c9e3d89556de3cbc67a9165ff0000000000ffffffff01706f9800000000001976a9146e2fe8ef5dcb05fd258e2f51d3f15ba3781cd96b88ac00000000' '[{"txid":"ff65917ac6cbe36d55893d9e1ce63cad1140c2ab38e9c7d099170b16d1a55d70","vout":0,"scriptPubKey":"a914b579aabfd350ed75ee056ff4d6d56718c74f55df87","redeemScript":"5221024c5965fb18701569ec09e8d2979c45e3d6e0c60ddb3c9d6af0692124d3890e8a2103c9084cf82f74f764829a7d3c842462e03f4bbaf59981cb3b98cd3974438e5771210256d87a1997bad87ebdd409a3437ecec02885300a1bb0a1159e289ae66af78b3453ae"}]' '["cMpfNfuasJcrCv8RKMG35C8YtUVpaheFbNMwDuBXVvdcjaeYE7oh"]'
     1
     2
     3{
     4  "hex": "0100000001705da5d1160b1799d0c7e938abc24011ad3ce61c9e3d89556de3cbc67a9165ff00000000b5004830450221009d4f252bc47a8ab7078c3f93929bd091da175ed115bbe4953a3704d1e8027e12022005ab1434847d64bc6551ce6044b970becad36fc0cf6380847c33b241a30fc085014c695221024c5965fb18701569ec09e8d2979c45e3d6e0c60ddb3c9d6af0692124d3890e8a2103c9084cf82f74f764829a7d3c842462e03f4bbaf59981cb3b98cd3974438e5771210256d87a1997bad87ebdd409a3437ecec02885300a1bb0a1159e289ae66af78b3453aeffffffff01706f9800000000001976a9146e2fe8ef5dcb05fd258e2f51d3f15ba3781cd96b88ac00000000",
     5  "complete": false,
     6  "errors": [
     7    {
     8      "txid": "ff65917ac6cbe36d55893d9e1ce63cad1140c2ab38e9c7d099170b16d1a55d70",
     9      "vout": 0,
    10      "scriptSig": "004830450221009d4f252bc47a8ab7078c3f93929bd091da175ed115bbe4953a3704d1e8027e12022005ab1434847d64bc6551ce6044b970becad36fc0cf6380847c33b241a30fc085014c695221024c5965fb18701569ec09e8d2979c45e3d6e0c60ddb3c9d6af0692124d3890e8a2103c9084cf82f74f764829a7d3c842462e03f4bbaf59981cb3b98cd3974438e5771210256d87a1997bad87ebdd409a3437ecec02885300a1bb0a1159e289ae66af78b3453ae",
    11      "sequence": 4294967295,
    12      "error": "Operation not valid with the current stack size"
    13    }
    14  ]
    15}
    
  6. jnewbery commented at 9:16 pm on May 24, 2017: member

    I’ve tested this and I can sign the returned partial transaction:

     0// Sign with the first key
     1→ bitcoin-cli signrawtransaction '02000000011cde84bb4859cef89c748d85072511f45be4db9df4ae833951e2bf883e8c86850100000000ffffffff01706f98000
     200000001976a9146e2fe8ef5dcb05fd258e2f51d3f15ba3781cd96b88ac00000000' '[{"txid":"85868c3e88bfe2513983aef49ddbe45bf4112507858d749cf8ce5948bb84de1c","vout":1,"scriptPubKey":"a914b579aabfd350ed75ee056ff4d6d56718c74f55df87","redeemScript":"5221024c5965fb18701569ec09e8d2979c45e3d
     36e0c60ddb3c9d6af0692124d3890e8a2103c9084cf82f74f764829a7d3c842462e03f4bbaf59981cb3b98cd3974438e5771210256d87a1997bad87ebdd409a3437ecec028
     485300a1bb0a1159e289ae66af78b3453ae"}]' '["cMpfNfuasJcrCv8RKMG35C8YtUVpaheFbNMwDuBXVvdcjaeYE7oh"]'
     5{
     6  "hex": "02000000011cde84bb4859cef89c748d85072511f45be4db9df4ae833951e2bf883e8c868501000000b400473044022053bf59c161ada753cd4de4ecd86a7d4719a6d903f0ff0aa7a0e8f1d3a7eb46e50220511bf2308f9b708c8eef11c71ae4198c0b59fde19b559a27c03a43edc8d7e103014c695221024c5965fb18701569ec09e8d2979c45e3d6e0c60ddb3c9d6af0692124d3890e8a2103c9084cf82f74f764829a7d3c842462e03f4bbaf59981cb3b98cd3974438e5771210256d87a1997bad87ebdd409a3437ecec02885300a1bb0a1159e289ae66af78b3453aeffffffff01706f9800000000001976a9146e2fe8ef5dcb05fd258e2f51d3f15ba3781cd96b88ac00000000",
     7  "complete": false,
     8  "errors": [
     9    {
    10      "txid": "85868c3e88bfe2513983aef49ddbe45bf4112507858d749cf8ce5948bb84de1c",
    11      "vout": 1,
    12      "witness": [
    13      ],
    14      "scriptSig": "00473044022053bf59c161ada753cd4de4ecd86a7d4719a6d903f0ff0aa7a0e8f1d3a7eb46e50220511bf2308f9b708c8eef11c71ae4198c0b59fde19b559a27c03a43edc8d7e103014c695221024c5965fb18701569ec09e8d2979c45e3d6e0c60ddb3c9d6af0692124d3890e8a2103c9084cf82f74f764829a7d3c842462e03f4bbaf59981cb3b98cd3974438e5771210256d87a1997bad87ebdd409a3437ecec02885300a1bb0a1159e289ae66af78b3453ae",
    15      "sequence": 4294967295,
    16      "error": "Operation not valid with the current stack size"
    17    }
    18  ]
    19}
    20
    21// An error is shown, but the returned hex *is* a valid partially signed tx.
    22// Now sign with a second key
    23
    24→ bitcoin-cli signrawtransaction '02000000011cde84bb4859cef89c748d85072511f45be4db9df4ae833951e2bf883e8c868501000000b400473044022053bf59c161ada753cd4de4ecd86a7d4719a6d903f0ff0aa7a0e8f1d3a7eb46e50220511bf2308f9b708c8eef11c71ae4198c0b59fde19b559a27c03a43edc8d7e103014c695221024c5965fb18701569ec09e8d2979c45e3d6e0c60ddb3c9d6af0692124d3890e8a2103c9084cf82f74f764829a7d3c842462e03f4bbaf59981cb3b98cd3974438e5771210256d87a1997bad87ebdd409a3437ecec02885300a1bb0a1159e289ae66af78b3453aeffffffff01706f9800000000001976a9146e2fe8ef5dcb05fd258e2f51d3f15ba3781cd96b88ac00000000' '[{"txid":"85868c3e88bfe2513983aef49ddbe45bf4112507858d749cf8ce5948bb84de1c","vout":1,"scriptPubKey":"a914b579aabfd350e
    25d75ee056ff4d6d56718c74f55df87","redeemScript":"5221024c5965fb18701569ec09e8d2979c45e3d6e0c60ddb3c9d6af0692124d3890e8a2103c9084cf82f74f764
    26829a7d3c842462e03f4bbaf59981cb3b98cd3974438e5771210256d87a1997bad87ebdd409a3437ecec02885300a1bb0a1159e289ae66af78b3453ae"}]' '["cVM5Kaoim2MKzT8MxVHHAu9BixJKTJgMhqape1eHgjHGhFPkf2mn"]'
    27{
    28  "hex": "02000000011cde84bb4859cef89c748d85072511f45be4db9df4ae833951e2bf883e8c868501000000fc00473044022053bf59c161ada753cd4de4ecd86a7d4719a6d903f0ff0aa7a0e8f1d3a7eb46e50220511bf2308f9b708c8eef11c71ae4198c0b59fde19b559a27c03a43edc8d7e10301473044022026ec2ccf9067b5ae0b3c7f108b0c79546de7187630eafba1a723a77437829a4202205404cbe251e3a165a47bc7555bf09cd5a81e7f0aa4e35cafc207be202aa834bf014c695221024c5965fb18701569ec09e8d2979c45e3d6e0c60ddb3c9d6af0692124d3890e8a2103c9084cf82f74f764829a7d3c842462e03f4bbaf59981cb3b98cd3974438e5771210256d87a1997bad87ebdd409a3437ecec02885300a1bb0a1159e289ae66af78b3453aeffffffff01706f9800000000001976a9146e2fe8ef5dcb05fd258e2f51d3f15ba3781cd96b88ac00000000",
    29  "complete": true
    30}
    31
    32// returned hex is a fully signed multisig tx
    

    It’s confusing that the first call to signrawtransaction() returns an error “Operation not valid with the current stack size”, but I don’t think that stops you from signing the partial transaction.

  7. achow101 commented at 10:42 pm on May 24, 2017: member

    It’s confusing that the first call to signrawtransaction() returns an error “Operation not valid with the current stack size”, but I don’t think that stops you from signing the partial transaction.

    Ah. I see. That it returns an error even when partially signed is still an issue though. That shouldn’t happen.

  8. achow101 renamed this:
    Cannot create partially signed multisig transactions anymore
    signrawtransaction shows errors after partially signing a multisig transaction
    on Jun 9, 2017
  9. laanwj closed this on Sep 26, 2017

  10. laanwj referenced this in commit 0f8e09599d on Sep 26, 2017
  11. mozaboy commented at 7:54 am on November 16, 2018: none
    how to find the redeemScript in UTXO , i get the UTXO by the blockchain.info’s api . i can’t find the UTXO through the bitcoin full node on local , my address is external , not create in my node. how to find ? i have the privateKey and the UTXO without the redeemScript
  12. kot-begemot commented at 11:07 am on February 12, 2019: none

    how to find the redeemScript in UTXO , i get the UTXO by the blockchain.info’s api . i can’t find the UTXO through the bitcoin full node on local , my address is external , not create in my node. how to find ? i have the privateKey and the UTXO without the redeemScript

    Short answer: You can generate it.

    Long answer: UTXO contains only script pub key (locking script). Redeem script is a part of signature script (unlocking script). It is generated during signature process, and you need to know all the public keys that are involved in this multisig. Then you append you minimum signature amount required for transaction and this is your signature script with which you can unlock you UTXO.

    Detailed answer: I suggest you to check “Mastering Bitcoin” by Andreas M. Antonopoulos. It is explained in Chapter 6, page 132-133 and Chapter 7 page 149-153.

  13. PastaPastaPasta referenced this in commit c53d9a4075 on Dec 22, 2019
  14. PastaPastaPasta referenced this in commit 50f8e063f0 on Jan 2, 2020
  15. PastaPastaPasta referenced this in commit 7de2fb5927 on Jan 4, 2020
  16. PastaPastaPasta referenced this in commit 6cd5df75d4 on Jan 12, 2020
  17. PastaPastaPasta referenced this in commit 268f3a23a8 on Jan 12, 2020
  18. PastaPastaPasta referenced this in commit 40389c5fa5 on Jan 12, 2020
  19. PastaPastaPasta referenced this in commit c9e865fc16 on Jan 12, 2020
  20. PastaPastaPasta referenced this in commit 8af0f8e2d8 on Jan 12, 2020
  21. ckti referenced this in commit 9df4fced2f on Mar 28, 2021
  22. malbit referenced this in commit bb17604101 on Nov 5, 2021
  23. DrahtBot locked this on Dec 16, 2021
  24. gades referenced this in commit af64538882 on Jan 28, 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: 2024-10-04 22:12 UTC

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