@@ -294,23 +294,27 @@ static RPCHelpMan getnewaddress()
294
294
label = LabelFromValue (request.params [0 ]);
295
295
296
296
OutputType output_type = pwallet->m_default_address_type ;
297
- bool force_blind = false ;
297
+ // default blinding to the blindedaddresses setting
298
+ bool add_blinding_key = gArgs .GetBoolArg (" -blindedaddresses" , g_con_elementsmode);
299
+
298
300
if (!request.params [1 ].isNull ()) {
299
301
if (!ParseOutputType (request.params [1 ].get_str (), output_type)) {
300
302
throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, strprintf (" Unknown address type '%s'" , request.params [1 ].get_str ()));
301
303
}
302
304
if (output_type == OutputType::BECH32M && pwallet->GetLegacyScriptPubKeyMan ()) {
303
305
throw JSONRPCError (RPC_INVALID_PARAMETER, " Legacy wallets cannot provide bech32m addresses" );
304
306
}
305
- // Special case for "blech32" when `-blindedaddresses=0` in the config.
306
307
if (request.params [1 ].get_str () == " blech32" ) {
307
- force_blind = true ;
308
+ // always blind for "blech32" even if `-blindedaddresses=0` in the config.
309
+ add_blinding_key = true ;
310
+ } else if (output_type == OutputType::BECH32) {
311
+ // never blind for "bech32"
312
+ add_blinding_key = false ;
308
313
}
309
314
}
310
315
311
316
CTxDestination dest;
312
317
std::string error;
313
- bool add_blinding_key = force_blind || gArgs .GetBoolArg (" -blindedaddresses" , g_con_elementsmode);
314
318
if (!pwallet->GetNewDestination (output_type, label, dest, error, add_blinding_key)) {
315
319
throw JSONRPCError (RPC_WALLET_KEYPOOL_RAN_OUT, error);
316
320
}
0 commit comments