mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-10 10:52:31 -05:00
Add warnings field to createmultisig to warn about uncompressed keys
This commit is contained in:
parent
fa3fb46b81
commit
d1a9742623
2 changed files with 16 additions and 2 deletions
|
@ -113,6 +113,10 @@ static RPCHelpMan createmultisig()
|
||||||
{RPCResult::Type::STR, "address", "The value of the new multisig address."},
|
{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_HEX, "redeemScript", "The string value of the hex-encoded redemption script."},
|
||||||
{RPCResult::Type::STR, "descriptor", "The descriptor for this multisig"},
|
{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{
|
RPCExamples{
|
||||||
|
@ -161,6 +165,13 @@ static RPCHelpMan createmultisig()
|
||||||
result.pushKV("redeemScript", HexStr(inner));
|
result.pushKV("redeemScript", HexStr(inner));
|
||||||
result.pushKV("descriptor", descriptor->ToString());
|
result.pushKV("descriptor", descriptor->ToString());
|
||||||
|
|
||||||
|
UniValue warnings(UniValue::VARR);
|
||||||
|
if (!request.params[2].isNull() && OutputTypeFromDestination(dest) != output_type) {
|
||||||
|
// Only warns if the user has explicitly chosen an address type we cannot generate
|
||||||
|
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;
|
return result;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -78,8 +78,11 @@ class RpcCreateMultiSigTest(BitcoinTestFramework):
|
||||||
assert_equal(legacy_addr, wmulti0.addmultisigaddress(2, keys, '', 'legacy')['address'])
|
assert_equal(legacy_addr, wmulti0.addmultisigaddress(2, keys, '', 'legacy')['address'])
|
||||||
|
|
||||||
# Generate addresses with the segwit types. These should all make legacy addresses
|
# Generate addresses with the segwit types. These should all make legacy addresses
|
||||||
assert_equal(legacy_addr, wmulti0.createmultisig(2, keys, 'bech32')['address'])
|
for addr_type in ['bech32', 'p2sh-segwit']:
|
||||||
assert_equal(legacy_addr, wmulti0.createmultisig(2, keys, 'p2sh-segwit')['address'])
|
result = wmulti0.createmultisig(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."])
|
||||||
|
|
||||||
assert_equal(legacy_addr, wmulti0.addmultisigaddress(2, keys, '', 'bech32')['address'])
|
assert_equal(legacy_addr, wmulti0.addmultisigaddress(2, keys, '', 'bech32')['address'])
|
||||||
assert_equal(legacy_addr, wmulti0.addmultisigaddress(2, keys, '', 'p2sh-segwit')['address'])
|
assert_equal(legacy_addr, wmulti0.addmultisigaddress(2, keys, '', 'p2sh-segwit')['address'])
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue