@@ -52,6 +52,10 @@ static RPCHelpMan validateaddress()
5252 {RPCResult::Type::NUM, " witness_version" , /* optional */ true , " The version number of the witness program" },
5353 {RPCResult::Type::STR_HEX, " witness_program" , /* optional */ true , " The hex value of the witness program" },
5454 {RPCResult::Type::STR, " error" , /* optional */ true , " Error message, if any" },
55+ {RPCResult::Type::ARR, " error_locations" , " Indices of likely error locations in address, if known (e.g. Bech32 errors)" ,
56+ {
57+ {RPCResult::Type::NUM, " index" , " index of a potential error" },
58+ }},
5559 }
5660 },
5761 RPCExamples{
@@ -61,7 +65,8 @@ static RPCHelpMan validateaddress()
6165 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
6266{
6367 std::string error_msg;
64- CTxDestination dest = DecodeDestination (request.params [0 ].get_str (), error_msg);
68+ std::vector<int > error_locations;
69+ CTxDestination dest = DecodeDestination (request.params [0 ].get_str (), error_msg, &error_locations);
6570 const bool isValid = IsValidDestination (dest);
6671 CHECK_NONFATAL (isValid == error_msg.empty ());
6772
@@ -77,6 +82,9 @@ static RPCHelpMan validateaddress()
7782 UniValue detail = DescribeAddress (dest);
7883 ret.pushKVs (detail);
7984 } else {
85+ UniValue error_indices (UniValue::VARR);
86+ for (int i : error_locations) error_indices.push_back (i);
87+ ret.pushKV (" error_locations" , error_indices);
8088 ret.pushKV (" error" , error_msg);
8189 }
8290
0 commit comments