Add address type option to addmultisigaddress #12213

pull promag wants to merge 2 commits into bitcoin:master from promag:2018-01-addmultisigaddress-address-type changing 3 files +17 −10
  1. promag commented at 11:40 pm on January 17, 2018: member

    Adds the option address_type to addmultisigaddress and createmultisg RPC. This also allows to avoid addwitnessaddress to obtain an p2sh-segwit or bech32 multsig address.

    Related to #12210 as this reduces addwitnessaddress usage.

  2. promag renamed this:
    2018 01 addmultisigaddress address type
    Add address type option to addmultisigaddress
    on Jan 17, 2018
  3. promag commented at 0:00 am on January 18, 2018: member
    Another option to avoid addwitnessaddress is to have another node with addresstype=.... Not sure which is preferable.
  4. olledik commented at 3:34 am on January 18, 2018: none
    👍
  5. laanwj added the label RPC/REST/ZMQ on Jan 18, 2018
  6. laanwj added the label Wallet on Jan 18, 2018
  7. laanwj added this to the milestone 0.16.0 on Jan 18, 2018
  8. jonasschnelli approved
  9. jonasschnelli commented at 7:39 pm on January 18, 2018: contributor
    utACK d1d17607eba0cae096bfa0d2dbdc977a071385bd
  10. MarcoFalke commented at 9:02 pm on January 18, 2018: member
    Concept ACK. Should probably do the same for createmultisig?
  11. promag commented at 9:50 pm on January 18, 2018: member
    In this PR?
  12. MarcoFalke commented at 10:10 pm on January 18, 2018: member
    I mean they are related. To me it makes sense to update atomically, since I fail to see why you’d want the one but not the other.
  13. promag commented at 10:21 pm on January 18, 2018: member

    The test framework only calls addwitnessaddress on multisig addresses returned by addmultisigaddress, and this pull changes that.

    But I guess it can be extended to createmultisig.

  14. MarcoFalke commented at 10:28 pm on January 18, 2018: member
    When this is only about tests, we can untag from 0.16, imo. When this is about a needed feature for users, I don’t see why createmultisig shouldn’t support it.
  15. meshcollider commented at 9:19 am on January 19, 2018: contributor
    utACK https://github.com/bitcoin/bitcoin/commit/d1d17607eba0cae096bfa0d2dbdc977a071385bd And createmultisig change suggested by Marco would be nice too IMO
  16. in src/wallet/rpcwallet.cpp:1190 in d1d17607eb outdated
    1186@@ -1188,6 +1187,7 @@ UniValue addmultisigaddress(const JSONRPCRequest& request)
    1187             "       ...,\n"
    1188             "     ]\n"
    1189             "3. \"account\"      (string, optional) DEPRECATED. An account to assign the addresses to.\n"
    1190+            "4. \"address_type\" (string, optional) The address type to use. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\". Default is set by -addresstype.\n"
    


    laanwj commented at 11:18 am on January 19, 2018:
    You need to update the RPC command table as well with this added argument, to make named arguments work.

    MarcoFalke commented at 7:38 pm on January 19, 2018:
    Maybe even add a test for all new options

    meshcollider commented at 1:09 pm on January 22, 2018:
    @promag you missed this update to the RPC command table for addmultisigaddress
  17. ryanofsky commented at 7:13 pm on January 19, 2018: member

    Conditional utACK d1d17607eba0cae096bfa0d2dbdc977a071385bd: this shouldn’t be merged until the named argument fix Wladimir suggested is added.

    Also agree createmultisig update would be nice here.

  18. Sjors commented at 7:41 pm on January 19, 2018: member

    If I set the default address type to bech32 and then create a 1 of 2 multisig address using a wallet address and the public key of some external bech32 address, and I set the type to legacy:

    0bitcoin-cli addmultisigaddress 1 '["bcrt1q0uh7xeh8jmnfzd0se9n39ut9n64sf7mt3ndhal","034c534e0cd400f69a948f7d6eecb891deca140c9e2035658033d5ebbaccd88058"]' "" legacy
    

    The result of validateaddress is confusing:

     0{
     1  "isvalid": true,
     2  "address": "2NEso1BnKq8kPCyZqMaYzw8E6Vf5N4KCZk1",
     3  "scriptPubKey": "a914ed452d142f0601587ba077293a79caa35503797787",
     4  "ismine": false,
     5  "iswatchonly": false,
     6  "isscript": true,
     7  "iswitness": false,
     8  "script": "multisig",
     9  "hex": "512102bdb9ca3346c02befe78dbe4e47b6569df8cb312aebf165dc90439287910cc8d921034c534e0cd400f69a948f7d6eecb891deca140c9e2035658033d5ebbaccd8805852ae",
    10  "sigsrequired": 1,
    11  "pubkeys": [
    12    "02bdb9ca3346c02befe78dbe4e47b6569df8cb312aebf165dc90439287910cc8d9",
    13    "034c534e0cd400f69a948f7d6eecb891deca140c9e2035658033d5ebbaccd88058"
    14  ],
    15  "addresses": [
    16    "ms7TUkdntfebxKQw1oG685Kimdt34VVUaA",
    17    "muQMALGUmB3n4YLcAHUQrM9BHNF3VCEr5z"
    18  ],
    19  "account": ""
    20}
    

    The only thing I recognize is the pub key of the external address. I haven’t tried spending from it. The wallet doesn’t know what address type was used by the external wallet, but shouldn’t it at least know this about itself?

    When setting the multisig address type to bech32 the result makes more sense, because it leaves out the address field:

    0bitcoin-cli addmultisigaddress 1 '["bcrt1q0uh7xeh8jmnfzd0se9n39ut9n64sf7mt3ndhal","034c534e0cd400f69a948f7d6eecb891deca140c9e2035658033d5ebbaccd88058"]' "" bech32
    
     0{
     1  "isvalid": true,
     2  "address": "bcrt1qdpzf4v83kq9gfamz53m4x6wx2rqw72pw87a5jf603g9ckp0j3jmqp0680q",
     3  "scriptPubKey": "002068449ab0f1b00a84f762a4775369c650c0ef282e3fbb49274f8a0b8b05f28cb6",
     4  "ismine": false,
     5  "iswatchonly": false,
     6  "isscript": true,
     7  "iswitness": true,
     8  "witness_version": 0,
     9  "witness_program": "68449ab0f1b00a84f762a4775369c650c0ef282e3fbb49274f8a0b8b05f28cb6",
    10  "script": "multisig",
    11  "hex": "512102bdb9ca3346c02befe78dbe4e47b6569df8cb312aebf165dc90439287910cc8d921034c534e0cd400f69a948f7d6eecb891deca140c9e2035658033d5ebbaccd8805852ae",
    12  "sigsrequired": 1,
    13  "pubkeys": [
    14    "02bdb9ca3346c02befe78dbe4e47b6569df8cb312aebf165dc90439287910cc8d9",
    15    "034c534e0cd400f69a948f7d6eecb891deca140c9e2035658033d5ebbaccd88058"
    16  ],
    17  "account": ""
    18}
    

    Not sure if this is even related to this particular change.

  19. sipa commented at 7:56 pm on January 19, 2018: member
    @Sjors The ‘addresses’ field is very confusing, and I’d like to get rid of it, but it’s there for backward compatibility. Historically there was no difference between addresses (shorthands for scriptPubKeys) and key identifiers, and it lives on in a number of calls. In this case, it’s effectively the same as the ‘pubkeys’ field (which was added in #11403), but encoding the public keys as P2PKH addresses.
  20. promag force-pushed on Jan 21, 2018
  21. promag commented at 10:19 pm on January 21, 2018: member
    Pushed createmultisig with address_type option. Please review. Meanwhile I’ll add tests.
  22. promag renamed this:
    Add address type option to addmultisigaddress
    Add address type to addmultisigaddress and createmultisig
    on Jan 21, 2018
  23. promag force-pushed on Jan 22, 2018
  24. promag force-pushed on Jan 22, 2018
  25. promag force-pushed on Jan 22, 2018
  26. promag force-pushed on Jan 22, 2018
  27. promag force-pushed on Jan 22, 2018
  28. in src/rpc/misc.cpp:341 in 27b8162f25 outdated
    340             "     [\n"
    341-            "       \"key\"    (string) bitcoin address or hex-encoded public key\n"
    342+            "       \"key\"      (string) bitcoin address or hex-encoded public key\n"
    343             "       ,...\n"
    344             "     ]\n"
    345+            "4. \"address_type\" (string, optional) The address type to use. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\". Default is set by -addresstype.\n"
    


    meshcollider commented at 11:13 am on January 22, 2018:
    Should be 3. not 4.
  29. promag commented at 11:18 am on January 22, 2018: member
    @sipa currently when ENABLE_WALLET is false, createmultisig will always create legacy addresses. WDYT?
  30. meshcollider commented at 1:10 pm on January 22, 2018: contributor
  31. promag force-pushed on Jan 22, 2018
  32. jnewbery commented at 5:08 pm on January 22, 2018: member
    needs rebase and comments addressed
  33. fanquake deleted a comment on Jan 23, 2018
  34. jnewbery commented at 9:07 pm on January 23, 2018: member

    utACK the first and third commits:

    • [rpc] Add address type option to addmultisigaddress
    • [qa] Use address type in addmultisigaddress to avoid addwitnessaddress

    I’m NACKish on the second commit ([rpc] Add address type option to createmultisig) because it adds a wallet dependency to server which will be difficult to unpick, and will make substatial work for #11415.

  35. promag commented at 9:41 pm on January 23, 2018: member
    I can move [rpc] Add address type option to createmultisig to a new PR so it doesn’t hold the rest. I don’t feel both must be updated in one shot.
  36. jnewbery commented at 10:49 pm on January 23, 2018: member

    I can move [rpc] Add address type option to createmultisig to a new PR

    I’d be in favour of that, but several other contributors asked for the opposite (for createmultisig to be added to this PR). I think wait to hear what they think.

  37. laanwj commented at 12:12 pm on January 24, 2018: member
    Needs rebase.
  38. meshcollider commented at 12:13 pm on January 24, 2018: contributor

    I’d be in favour of that, but several other contributors asked for the opposite (for createmultisig to be added to this PR). I think wait to hear what they think.

    On second thought yeah, the wallet dependency complicates that part so separating it out for separate discussion would be good, makes this PR easier to merge

  39. promag force-pushed on Jan 24, 2018
  40. promag force-pushed on Jan 24, 2018
  41. promag force-pushed on Jan 24, 2018
  42. [rpc] Add address type option to addmultisigaddress 886a92f25f
  43. promag force-pushed on Jan 24, 2018
  44. promag renamed this:
    Add address type to addmultisigaddress and createmultisig
    Add address type option to addmultisigaddress
    on Jan 24, 2018
  45. in test/functional/nulldummy.py:51 in bca85e6b7d outdated
    47@@ -48,7 +48,7 @@ def run_test(self):
    48         self.address = self.nodes[0].getnewaddress()
    49         self.ms_address = self.nodes[0].addmultisigaddress(1,[self.address])['address']
    50         self.wit_address = self.nodes[0].addwitnessaddress(self.address)
    51-        self.wit_ms_address = self.nodes[0].addwitnessaddress(self.ms_address)
    52+        self.wit_ms_address = self.nodes[0].addmultisigaddress(1, [self.address], '', 'p2sh-segwit')
    


    ryanofsky commented at 4:05 pm on January 24, 2018:
    This line currently causes failure, but appending ['address'] fixes it. Similar changes are needed in segwit.py. This is due to #11415 merge.

    promag commented at 4:11 pm on January 24, 2018:
    Right, like above.
  46. promag force-pushed on Jan 24, 2018
  47. ryanofsky commented at 4:18 pm on January 24, 2018: member
    Conditional utACK 5afbff9755768d191275736a19db078c139a5ec3 if segwit.py test is fixed. Only change since last review is rebase and fixing CRPCCommand args.
  48. [qa] Use address type in addmultisigaddress to avoid addwitnessaddress f523c6bec0
  49. promag force-pushed on Jan 24, 2018
  50. in test/functional/nulldummy.py:51 in f523c6bec0
    47@@ -48,7 +48,7 @@ def run_test(self):
    48         self.address = self.nodes[0].getnewaddress()
    49         self.ms_address = self.nodes[0].addmultisigaddress(1,[self.address])['address']
    50         self.wit_address = self.nodes[0].addwitnessaddress(self.address)
    51-        self.wit_ms_address = self.nodes[0].addwitnessaddress(self.ms_address)
    52+        self.wit_ms_address = self.nodes[0].addmultisigaddress(1, [self.address], '', 'p2sh-segwit')['address']
    


    jnewbery commented at 5:27 pm on January 24, 2018:
    nit: use named arguments (specifically, it’s not clear what the third argument '' is for). Same for segwit.py
  51. jnewbery commented at 5:32 pm on January 24, 2018: member
    Tested ACK f523c6bec005b2c999651787d029dee0fe719eb1. One nit in the tests.
  52. jonasschnelli commented at 7:01 pm on January 24, 2018: contributor
    Re-utACK f523c6bec
  53. jonasschnelli merged this on Jan 24, 2018
  54. jonasschnelli closed this on Jan 24, 2018

  55. jonasschnelli referenced this in commit eadb2dacc3 on Jan 24, 2018
  56. MarcoFalke commented at 8:18 pm on January 24, 2018: member
    Is there a pull request for createmultisig, or am I blind?
  57. promag commented at 9:00 pm on January 24, 2018: member
    @MarcoFalke not yet.
  58. promag deleted the branch on Jan 24, 2018
  59. 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-18 15:12 UTC

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