diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1036923dbe4..3235accb125 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -294,7 +294,9 @@ static RPCHelpMan getnewaddress() label = LabelFromValue(request.params[0]); OutputType output_type = pwallet->m_default_address_type; - bool force_blind = false; + // default blinding to the blindedaddresses setting + bool add_blinding_key = gArgs.GetBoolArg("-blindedaddresses", g_con_elementsmode); + if (!request.params[1].isNull()) { if (!ParseOutputType(request.params[1].get_str(), output_type)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[1].get_str())); @@ -302,15 +304,17 @@ static RPCHelpMan getnewaddress() if (output_type == OutputType::BECH32M && pwallet->GetLegacyScriptPubKeyMan()) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Legacy wallets cannot provide bech32m addresses"); } - // Special case for "blech32" when `-blindedaddresses=0` in the config. if (request.params[1].get_str() == "blech32") { - force_blind = true; + // always blind for "blech32" even if `-blindedaddresses=0` in the config. + add_blinding_key = true; + } else if (request.params[1].get_str() == "bech32") { + // never blind for "bech32" + add_blinding_key = false; } } CTxDestination dest; std::string error; - bool add_blinding_key = force_blind || gArgs.GetBoolArg("-blindedaddresses", g_con_elementsmode); if (!pwallet->GetNewDestination(output_type, label, dest, error, add_blinding_key)) { throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, error); } diff --git a/test/functional/feature_confidential_transactions.py b/test/functional/feature_confidential_transactions.py index cceed177281..db3c7080f6d 100755 --- a/test/functional/feature_confidential_transactions.py +++ b/test/functional/feature_confidential_transactions.py @@ -164,13 +164,13 @@ def run_test(self): self.test_wallet_recovery() print("Test blech32 python roundtrip") - # blech/bech are aliased, both are blech32 - for addrtype in ["bech32", "blech32"]: - addr_to_rt = self.nodes[0].getnewaddress("", addrtype) - hrp = addr_to_rt[:2] - assert_equal(hrp, "el") - (witver, witprog) = decode(hrp, addr_to_rt) - assert_equal(encode(hrp, witver, witprog), addr_to_rt) + # test only blech32, since getnewaddress for bech32 was changed to return an unblinded address + addr_to_rt = self.nodes[0].getnewaddress("", "blech32") + hrp = addr_to_rt[:2] + assert_equal(hrp, "el") + + (witver, witprog) = decode(hrp, addr_to_rt) + assert_equal(encode(hrp, witver, witprog), addr_to_rt) # Test that "blech32" gives a blinded segwit address. blech32_addr = self.nodes[0].getnewaddress("", "blech32") diff --git a/test/functional/feature_sighash_rangeproof.py b/test/functional/feature_sighash_rangeproof.py index 2950bbfc472..c173607671d 100755 --- a/test/functional/feature_sighash_rangeproof.py +++ b/test/functional/feature_sighash_rangeproof.py @@ -130,7 +130,7 @@ def prepare_tx_signed_with_sighash(self, address_type, sighash_rangeproof_aware, struct.pack("