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.
addwitnessaddress
is to have another node with addresstype=...
. Not sure which is preferable.
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
.
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"
addmultisigaddress
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.
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.
createmultisig
with address_type
option. Please review. Meanwhile I’ll add tests.
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"
3.
not 4.
utACK the first and third commits:
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.
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.
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
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')
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']
''
is for). Same for segwit.py
promag
olledik
jonasschnelli
MarcoFalke
meshcollider
laanwj
ryanofsky
Sjors
sipa
jnewbery
Labels
Wallet
RPC/REST/ZMQ
Milestone
0.16.0