@@ -52,6 +52,10 @@ static RPCHelpMan validateaddress()
52
52
{RPCResult::Type::NUM, " witness_version" , /* optional */ true , " The version number of the witness program" },
53
53
{RPCResult::Type::STR_HEX, " witness_program" , /* optional */ true , " The hex value of the witness program" },
54
54
{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
+ }},
55
59
}
56
60
},
57
61
RPCExamples{
@@ -61,7 +65,8 @@ static RPCHelpMan validateaddress()
61
65
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
62
66
{
63
67
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);
65
70
const bool isValid = IsValidDestination (dest);
66
71
CHECK_NONFATAL (isValid == error_msg.empty ());
67
72
@@ -77,6 +82,9 @@ static RPCHelpMan validateaddress()
77
82
UniValue detail = DescribeAddress (dest);
78
83
ret.pushKVs (detail);
79
84
} 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);
80
88
ret.pushKV (" error" , error_msg);
81
89
}
82
90
0 commit comments