mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
Always return blind address for "blech32" type
Even when -blindedaddresses=0.
This commit is contained in:
parent
c977f2b99d
commit
4e84596892
2 changed files with 22 additions and 2 deletions
|
|
@ -206,10 +206,15 @@ static UniValue getnewaddress(const JSONRPCRequest& request)
|
|||
label = LabelFromValue(request.params[0]);
|
||||
|
||||
OutputType output_type = pwallet->m_default_address_type;
|
||||
bool force_blind = false;
|
||||
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()));
|
||||
}
|
||||
// Special case for "blech32" when `-blindedaddresses=0` in the config.
|
||||
if (request.params[1].get_str() == "blech32") {
|
||||
force_blind = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pwallet->IsLocked()) {
|
||||
|
|
@ -223,7 +228,7 @@ static UniValue getnewaddress(const JSONRPCRequest& request)
|
|||
}
|
||||
pwallet->LearnRelatedScripts(newKey, output_type);
|
||||
CTxDestination dest = GetDestinationForKey(newKey, output_type);
|
||||
if (gArgs.GetBoolArg("-blindedaddresses", g_con_elementsmode)) {
|
||||
if (gArgs.GetBoolArg("-blindedaddresses", g_con_elementsmode) || force_blind) {
|
||||
CPubKey blinding_pubkey = pwallet->GetBlindingPubKey(GetScriptForDestination(dest));
|
||||
dest = GetDestinationForKey(newKey, output_type, blinding_pubkey);
|
||||
}
|
||||
|
|
@ -270,10 +275,15 @@ static UniValue getrawchangeaddress(const JSONRPCRequest& request)
|
|||
}
|
||||
|
||||
OutputType output_type = pwallet->m_default_change_type != OutputType::CHANGE_AUTO ? pwallet->m_default_change_type : pwallet->m_default_address_type;
|
||||
bool force_blind = false;
|
||||
if (!request.params[0].isNull()) {
|
||||
if (!ParseOutputType(request.params[0].get_str(), output_type)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[0].get_str()));
|
||||
}
|
||||
// Special case for "blech32" when `-blindedaddresses=0` in the config.
|
||||
if (request.params[0].get_str() == "blech32") {
|
||||
force_blind = true;
|
||||
}
|
||||
}
|
||||
|
||||
CReserveKey reservekey(pwallet);
|
||||
|
|
@ -285,7 +295,7 @@ static UniValue getrawchangeaddress(const JSONRPCRequest& request)
|
|||
|
||||
pwallet->LearnRelatedScripts(vchPubKey, output_type);
|
||||
CTxDestination dest = GetDestinationForKey(vchPubKey, output_type);
|
||||
if (gArgs.GetBoolArg("-blindedaddresses", g_con_elementsmode)) {
|
||||
if (gArgs.GetBoolArg("-blindedaddresses", g_con_elementsmode) || force_blind) {
|
||||
CPubKey blinding_pubkey = pwallet->GetBlindingPubKey(GetScriptForDestination(dest));
|
||||
dest = GetDestinationForKey(vchPubKey, output_type, blinding_pubkey);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -369,5 +369,15 @@ class AddressTypeTest(BitcoinTestFramework):
|
|||
self.test_address(4, self.nodes[4].getrawchangeaddress(), multisig=False, typ='p2sh-segwit')
|
||||
self.test_address(4, self.nodes[4].getrawchangeaddress('bech32'), multisig=False, typ='bech32')
|
||||
|
||||
# test blech32 addresses
|
||||
info_unblinded = self.nodes[0].getaddressinfo(self.nodes[0].getnewaddress("", "bech32"))
|
||||
assert(len(info_unblinded["confidential_key"]) == 0)
|
||||
# getnewaddress
|
||||
info1 = self.nodes[0].getaddressinfo(self.nodes[0].getnewaddress("", "blech32"))
|
||||
assert(len(info1["confidential_key"]) > 0)
|
||||
# getrawchangeaddress
|
||||
info2 = self.nodes[0].getaddressinfo(self.nodes[0].getrawchangeaddress("blech32"))
|
||||
assert(len(info2["confidential_key"]) > 0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
AddressTypeTest().main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue