From e46fc935aa6eb392ef9411dad310697aba601f6a Mon Sep 17 00:00:00 2001 From: Samuel Dobson Date: Wed, 8 Dec 2021 17:05:16 +1300 Subject: Add warnings field to addmultisigaddress to warn about uncompressed keys --- src/wallet/rpc/addresses.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/wallet') diff --git a/src/wallet/rpc/addresses.cpp b/src/wallet/rpc/addresses.cpp index edc4c26eeb..3c07354e80 100644 --- a/src/wallet/rpc/addresses.cpp +++ b/src/wallet/rpc/addresses.cpp @@ -238,6 +238,10 @@ 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{ @@ -295,6 +299,14 @@ RPCHelpMan addmultisigaddress() result.pushKV("address", EncodeDestination(dest)); result.pushKV("redeemScript", HexStr(inner)); result.pushKV("descriptor", descriptor->ToString()); + + UniValue warnings(UniValue::VARR); + if (!request.params[3].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; }, }; -- cgit v1.2.3