Skip to content

Commit d1a9742

Browse files
committed
Add warnings field to createmultisig to warn about uncompressed keys
1 parent fa3fb46 commit d1a9742

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/rpc/misc.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ static RPCHelpMan createmultisig()
113113
{RPCResult::Type::STR, "address", "The value of the new multisig address."},
114114
{RPCResult::Type::STR_HEX, "redeemScript", "The string value of the hex-encoded redemption script."},
115115
{RPCResult::Type::STR, "descriptor", "The descriptor for this multisig"},
116+
{RPCResult::Type::ARR, "warnings", /* optional */ true, "Any warnings resulting from the creation of this multisig",
117+
{
118+
{RPCResult::Type::STR, "", ""},
119+
}},
116120
}
117121
},
118122
RPCExamples{
@@ -161,6 +165,13 @@ static RPCHelpMan createmultisig()
161165
result.pushKV("redeemScript", HexStr(inner));
162166
result.pushKV("descriptor", descriptor->ToString());
163167

168+
UniValue warnings(UniValue::VARR);
169+
if (!request.params[2].isNull() && OutputTypeFromDestination(dest) != output_type) {
170+
// Only warns if the user has explicitly chosen an address type we cannot generate
171+
warnings.push_back("Unable to make chosen address type, please ensure no uncompressed public keys are present.");
172+
}
173+
if (warnings.size()) result.pushKV("warnings", warnings);
174+
164175
return result;
165176
},
166177
};

test/functional/rpc_createmultisig.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ def run_test(self):
7878
assert_equal(legacy_addr, wmulti0.addmultisigaddress(2, keys, '', 'legacy')['address'])
7979

8080
# Generate addresses with the segwit types. These should all make legacy addresses
81-
assert_equal(legacy_addr, wmulti0.createmultisig(2, keys, 'bech32')['address'])
82-
assert_equal(legacy_addr, wmulti0.createmultisig(2, keys, 'p2sh-segwit')['address'])
81+
for addr_type in ['bech32', 'p2sh-segwit']:
82+
result = wmulti0.createmultisig(2, keys, addr_type)
83+
assert_equal(legacy_addr, result['address'])
84+
assert_equal(result['warnings'], ["Unable to make chosen address type, please ensure no uncompressed public keys are present."])
85+
8386
assert_equal(legacy_addr, wmulti0.addmultisigaddress(2, keys, '', 'bech32')['address'])
8487
assert_equal(legacy_addr, wmulti0.addmultisigaddress(2, keys, '', 'p2sh-segwit')['address'])
8588

0 commit comments

Comments
 (0)