Skip to content

Commit

Permalink
Add warnings field to addmultisigaddress to warn about uncompressed keys
Browse files Browse the repository at this point in the history
Github-Pull: bitcoin#23113
Rebased-From: 2067502
  • Loading branch information
meshcollider authored and luke-jr committed Oct 5, 2021
1 parent 8db937d commit e866db9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,10 @@ static RPCHelpMan addmultisigaddress()
{RPCResult::Type::STR, "address", "The value of the new multisig address"},
{RPCResult::Type::STR_HEX, "redeemScript", "The string value of the hex-encoded redemption script"},
{RPCResult::Type::STR, "descriptor", "The descriptor for this multisig"},
{RPCResult::Type::ARR, "warnings", /* optional */ true, "Any warnings resulting from the creation of this multisig",
{
{RPCResult::Type::STR, "", ""},
}},
}
},
RPCExamples{
Expand Down Expand Up @@ -1032,6 +1036,14 @@ static RPCHelpMan addmultisigaddress()
result.pushKV("address", EncodeDestination(dest));
result.pushKV("redeemScript", HexStr(inner));
result.pushKV("descriptor", descriptor->ToString());

UniValue warnings(UniValue::VARR);
std::optional<OutputType> created_output_type = OutputTypeFromDestination(dest);
if (!created_output_type || created_output_type.value() != output_type) {
warnings.push_back("Unable to make chosen address type, please ensure no uncompressed public keys are present.");
}
if (warnings.size()) result.pushKV("warnings", warnings);

return result;
},
};
Expand Down
5 changes: 3 additions & 2 deletions test/functional/rpc_createmultisig.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ def run_test(self):
assert_equal(legacy_addr, result['address'])
assert_equal(result['warnings'], ["Unable to make chosen address type, please ensure no uncompressed public keys are present."])

assert_equal(legacy_addr, wmulti0.addmultisigaddress(2, keys, '', 'bech32')['address'])
assert_equal(legacy_addr, wmulti0.addmultisigaddress(2, keys, '', 'p2sh-segwit')['address'])
result = wmulti0.addmultisigaddress(2, keys, '', addr_type)
assert_equal(legacy_addr, result['address'])
assert_equal(result['warnings'], ["Unable to make chosen address type, please ensure no uncompressed public keys are present."])

self.log.info('Testing sortedmulti descriptors with BIP 67 test vectors')
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data/rpc_bip67.json'), encoding='utf-8') as f:
Expand Down

0 comments on commit e866db9

Please sign in to comment.