@@ -294,23 +294,27 @@ static RPCHelpMan getnewaddress()
294294 label = LabelFromValue (request.params [0 ]);
295295
296296 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+
298300 if (!request.params [1 ].isNull ()) {
299301 if (!ParseOutputType (request.params [1 ].get_str (), output_type)) {
300302 throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY , strprintf (" Unknown address type '%s'" , request.params [1 ].get_str ()));
301303 }
302304 if (output_type == OutputType::BECH32M && pwallet->GetLegacyScriptPubKeyMan ()) {
303305 throw JSONRPCError (RPC_INVALID_PARAMETER , " Legacy wallets cannot provide bech32m addresses" );
304306 }
305- // Special case for "blech32" when `-blindedaddresses=0` in the config.
306307 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 (request.params [1 ].get_str () == " bech32" ) {
311+ // never blind for "bech32"
312+ add_blinding_key = false ;
308313 }
309314 }
310315
311316 CTxDestination dest;
312317 std::string error;
313- bool add_blinding_key = force_blind || gArgs .GetBoolArg (" -blindedaddresses" , g_con_elementsmode);
314318 if (!pwallet->GetNewDestination (output_type, label, dest, error, add_blinding_key)) {
315319 throw JSONRPCError (RPC_WALLET_KEYPOOL_RAN_OUT , error);
316320 }
0 commit comments