@@ -251,21 +251,25 @@ class DescriptorImpl : public Descriptor
251
251
return false ;
252
252
}
253
253
254
- bool ToPrivateString (const SigningProvider& arg, std::string& out) const final
254
+ bool ToStringHelper (const SigningProvider* arg, std::string& out, bool priv ) const
255
255
{
256
256
std::string extra = ToStringExtra ();
257
257
size_t pos = extra.size () > 0 ? 1 : 0 ;
258
258
std::string ret = m_name + " (" + extra;
259
259
for (const auto & pubkey : m_pubkey_args) {
260
260
if (pos++) ret += " ," ;
261
261
std::string tmp;
262
- if (!pubkey->ToPrivateString (arg, tmp)) return false ;
262
+ if (priv) {
263
+ if (!pubkey->ToPrivateString (*arg, tmp)) return false ;
264
+ } else {
265
+ tmp = pubkey->ToString ();
266
+ }
263
267
ret += std::move (tmp);
264
268
}
265
269
if (m_script_arg) {
266
270
if (pos++) ret += " ," ;
267
271
std::string tmp;
268
- if (!m_script_arg->ToPrivateString (arg, tmp)) return false ;
272
+ if (!m_script_arg->ToStringHelper (arg, tmp, priv )) return false ;
269
273
ret += std::move (tmp);
270
274
}
271
275
out = std::move (ret) + " )" ;
@@ -274,20 +278,13 @@ class DescriptorImpl : public Descriptor
274
278
275
279
std::string ToString () const final
276
280
{
277
- std::string extra = ToStringExtra ();
278
- size_t pos = extra.size () > 0 ? 1 : 0 ;
279
- std::string ret = m_name + " (" + extra;
280
- for (const auto & pubkey : m_pubkey_args) {
281
- if (pos++) ret += " ," ;
282
- ret += pubkey->ToString ();
283
- }
284
- if (m_script_arg) {
285
- if (pos++) ret += " ," ;
286
- ret += m_script_arg->ToString ();
287
- }
288
- return std::move (ret) + " )" ;
281
+ std::string ret;
282
+ ToStringHelper (nullptr , ret, false );
283
+ return ret;
289
284
}
290
285
286
+ bool ToPrivateString (const SigningProvider& arg, std::string& out) const override final { return ToStringHelper (&arg, out, true ); }
287
+
291
288
bool Expand (int pos, const SigningProvider& arg, std::vector<CScript>& output_scripts, FlatSigningProvider& out) const final
292
289
{
293
290
std::vector<std::pair<CPubKey, KeyOriginInfo>> entries;
0 commit comments