importmulti changes not backward compatible #15392

issue bitcoinhodler opened this issue on February 12, 2019
  1. bitcoinhodler commented at 6:42 PM on February 12, 2019: contributor

    In v0.17.1, importing a p2wsh-in-p2sh multisig address as watchonly+solvable requires importing it as two separate addresses, once with each of the two scripts. See my question on StackExchange.

    In the current bitcoin master (d8794a78a887a920276c7124f1c46d69592c6c4e), this breaks, I suspect due to #14454. While that PR is a nice improvement, isn't it bad to break backward compatibility?

    Problem

    I want to import a p2wsh-in-p2sh multisig address as watchonly+solvable. I run:

    bitcoin-cli -testnet importmulti '[{"redeemscript": "5221035a0cf2b8ad46945154d80b339f730ac0cdbc39a95550a95821adf6df6e6e3c9421038f339e9149fda8496360d689b5d6b4d66f8e64e28b1c89846efd0831512eab882103442945263f31819baf5799dc9595eba49b8f6674dadf21189f717abd630ab15053ae", "scriptPubKey": {"address": "2MvQKEWTdtH7uM5C72quuMukWNFkFYjm34N"}, "timestamp": "now"}, {"redeemscript": "0020d017965b0cae52a8b6f6e43b00118be27dae84b825959dcb77ca6b5310e53ea3", "scriptPubKey": {"address": "2MvQKEWTdtH7uM5C72quuMukWNFkFYjm34N"}, "timestamp": "now"}]'
    

    The result comes back as:

    [
      {
        "success": true,
        "warnings": [
          "Importing as non-solvable: redeemScript does not match the scriptPubKey. If this is intentional, don't provide any keys, pubkeys, witnessscript, or redeemscript."
        ]
      },
      {
        "success": true,
        "warnings": [
          "Importing as non-solvable: missing witnessscript. If this is intentional, don't provide any keys, pubkeys, witnessscript, or redeemscript."
        ]
      }
    ]
    

    And then getaddressinfo shows that it is not solvable:

    {
      "address": "2MvQKEWTdtH7uM5C72quuMukWNFkFYjm34N",
      "scriptPubKey": "a91422a07fe0ea8b8293eb336b9423f7e3958917924387",
      "ismine": false,
      "solvable": false,
      "iswatchonly": true,
      "isscript": true,
      "iswitness": false,
      "label": "",
      "ischange": false,
      "timestamp": 1296688602,
      "labels": [
        {
          "name": "",
          "purpose": "receive"
        }
      ]
    }
    

    Firstly, is it okay for the importmulti to report success:true when some of the provided information was ignored? That seems...not good.

    Secondly, how can I import this address in a way that will work on both v0.17.1 and (future) v0.18?

    v0.17.1 behavior

    Address is imported successfully:

    [
      {
        "success": true
      },
      {
        "success": true
      }
    ]
    

    And the getaddressinfo shows everything I expect:

    {
      "address": "2MvQKEWTdtH7uM5C72quuMukWNFkFYjm34N",
      "scriptPubKey": "a91422a07fe0ea8b8293eb336b9423f7e3958917924387",
      "ismine": false,
      "iswatchonly": true,
      "isscript": true,
      "iswitness": false,
      "script": "witness_v0_scripthash",
      "hex": "0020d017965b0cae52a8b6f6e43b00118be27dae84b825959dcb77ca6b5310e53ea3",
      "embedded": {
        "isscript": true,
        "iswitness": true,
        "witness_version": 0,
        "witness_program": "d017965b0cae52a8b6f6e43b00118be27dae84b825959dcb77ca6b5310e53ea3",
        "script": "multisig",
        "hex": "5221035a0cf2b8ad46945154d80b339f730ac0cdbc39a95550a95821adf6df6e6e3c9421038f339e9149fda8496360d689b5d6b4d66f8e64e28b1c89846efd0831512eab882103442945263f31819baf5799dc9595eba49b8f6674dadf21189f717abd630ab15053ae",
        "sigsrequired": 2,
        "pubkeys": [
          "035a0cf2b8ad46945154d80b339f730ac0cdbc39a95550a95821adf6df6e6e3c94",
          "038f339e9149fda8496360d689b5d6b4d66f8e64e28b1c89846efd0831512eab88",
          "03442945263f31819baf5799dc9595eba49b8f6674dadf21189f717abd630ab150"
        ],
        "address": "tb1q6qtevkcv4ef23dhkusasqyvtuf76ap9cyk2emjmhef44xy89863s6yyfks",
        "scriptPubKey": "0020d017965b0cae52a8b6f6e43b00118be27dae84b825959dcb77ca6b5310e53ea3"
      },
      "label": "",
      "timestamp": 1296688602,
      "labels": [
        {
          "name": "",
          "purpose": "receive"
        }
      ]
    }
    
    
  2. jnewbery added the label Wallet on Feb 12, 2019
  3. jnewbery commented at 6:45 PM on February 12, 2019: member
  4. achow101 commented at 6:59 PM on February 12, 2019: member

    While we do try to keep backwards compatibility, what you were able to do in 0.17.1 was (IMO) a bug so we shouldn't keep compatibility with it.

  5. bitcoinhodler commented at 7:06 PM on February 12, 2019: contributor

    Is there any other way to import this into v0.17.1?

  6. achow101 commented at 7:37 PM on February 12, 2019: member

    Is there any other way to import this into v0.17.1?

    There is not, but that is also a bug.

  7. bitcoinhodler commented at 8:04 PM on February 12, 2019: contributor

    OK...I guess I will wait for v0.18.

    There is still the question of importmulti reporting success:true despite ignoring some of the information provided. Is that acceptable?

  8. sipa commented at 8:14 PM on February 12, 2019: member

    The reason for making a number of things acceptable with a warning instead of failing was to improve backward compatibility.

    I'm actually a bit confused why just providing a redeemScript for multisig used to be enough. But it doesn't seem unreasonable to make sure it keeps working in 0.18, depending on the complexity of doing so.

    TL:DR: I think breaking backward compatibility is a bug, and to the extent possible it should keep working, but with a warning.

  9. bitcoinhodler commented at 8:26 PM on February 12, 2019: contributor

    Providing only the redeemScript was insufficient; I had to import the same address twice, once with the redeemScript and once with the witnessScript (in the redeemScript field). This ugly double-importmulti was similar to #12418 which was fixed by allowing the multisig script to sign either p2sh or p2wsh-in-p2sh.

    Perhaps I should have opened a new issue at the time, instead of assuming this double-import was the only/best way.

  10. bitcoinhodler commented at 8:29 PM on February 12, 2019: contributor

    In my specific case, this double-importmulti code is not yet deployed, so it's not a big deal to me if it breaks. I'll just hold off on deploying it until I can redo it in v0.18.

  11. bitcoinhodler commented at 9:33 PM on February 15, 2019: contributor

    Another concern here is that addmultisigaddress with p2sh-segwit does not give me the redeemScript, only the witnessScript. (Or do I have that backwards? Anyway it's one or the other.)

    So to use that address with importmulti I first have to run decodescript to get the matching redeemScript, then pass that back in to importmulti. That feels rather uncoordinated.

    Do you think it would make sense to have importmulti work similar to signrawtransactionwithkeys, where I can sign a p2sh-segwit by providing only the witnessScript? (See #12418) That would also cleanly solve this backward compatibility issue.

  12. sipa commented at 9:52 PM on February 15, 2019: member

    @bitcoinhodler In 0.18 the ideal way for doing these things will be using descriptors; so you can just import "descriptor":"sh(wsh(multi(2,<pubkey>,<pubkey>,<pubkey>)))" for example to get P2SH-P2WSH-multisig.

  13. meshcollider commented at 11:23 AM on February 16, 2019: contributor

    Agree with the above comments, it was definitely a bug + temporary workaround not intended behaviour, so I don't think it should be preserved. But regarding the addmultisigaddress comment, I plan on opening a PR to add the redeemScript to that output anyway, as a follow-up to #14481

  14. bitcoinhodler commented at 10:44 PM on February 16, 2019: contributor

    I'll close this as not-a-bug, or wont-fix, depending on interpretation ;)

  15. bitcoinhodler closed this on Feb 16, 2019

  16. MarcoFalke locked this on Dec 16, 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: 2026-04-21 15:14 UTC

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