Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | static UniValue getnewaddress(const Config &config, | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
// Parse the label first so we don't generate a key if there's an error | // Parse the label first so we don't generate a key if there's an error | ||||
std::string label; | std::string label; | ||||
if (!request.params[0].isNull()) { | if (!request.params[0].isNull()) { | ||||
label = LabelFromValue(request.params[0]); | label = LabelFromValue(request.params[0]); | ||||
} | } | ||||
OutputType output_type = g_address_type; | OutputType output_type = pwallet->m_default_address_type; | ||||
if (!request.params[1].isNull()) { | if (!request.params[1].isNull()) { | ||||
output_type = | output_type = ParseOutputType(request.params[1].get_str(), | ||||
ParseOutputType(request.params[1].get_str(), g_address_type); | pwallet->m_default_address_type); | ||||
if (output_type == OutputType::NONE) { | if (output_type == OutputType::NONE) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
strprintf("Unknown address type '%s'", | strprintf("Unknown address type '%s'", | ||||
request.params[1].get_str())); | request.params[1].get_str())); | ||||
} | } | ||||
} | } | ||||
if (!pwallet->IsLocked()) { | if (!pwallet->IsLocked()) { | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | static UniValue getrawchangeaddress(const Config &config, | ||||
} | } | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
if (!pwallet->IsLocked()) { | if (!pwallet->IsLocked()) { | ||||
pwallet->TopUpKeyPool(); | pwallet->TopUpKeyPool(); | ||||
} | } | ||||
OutputType output_type = | OutputType output_type = pwallet->m_default_change_type != OutputType::NONE | ||||
g_change_type != OutputType::NONE ? g_change_type : g_address_type; | ? pwallet->m_default_change_type | ||||
: pwallet->m_default_address_type; | |||||
if (!request.params[0].isNull()) { | if (!request.params[0].isNull()) { | ||||
output_type = ParseOutputType(request.params[0].get_str(), output_type); | output_type = ParseOutputType(request.params[0].get_str(), output_type); | ||||
if (output_type == OutputType::NONE) { | if (output_type == OutputType::NONE) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
strprintf("Unknown address type '%s'", | strprintf("Unknown address type '%s'", | ||||
request.params[0].get_str())); | request.params[0].get_str())); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,147 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < keys_or_addrs.size(); ++i) { | ||||
keys_or_addrs[i].get_str().length() == 130)) { | keys_or_addrs[i].get_str().length() == 130)) { | ||||
pubkeys.push_back(HexToPubKey(keys_or_addrs[i].get_str())); | pubkeys.push_back(HexToPubKey(keys_or_addrs[i].get_str())); | ||||
} else { | } else { | ||||
pubkeys.push_back(AddrToPubKey(config.GetChainParams(), pwallet, | pubkeys.push_back(AddrToPubKey(config.GetChainParams(), pwallet, | ||||
keys_or_addrs[i].get_str())); | keys_or_addrs[i].get_str())); | ||||
} | } | ||||
} | } | ||||
OutputType output_type = pwallet->m_default_address_type; | |||||
// Construct using pay-to-script-hash: | // Construct using pay-to-script-hash: | ||||
CScript inner = CreateMultisigRedeemscript(required, pubkeys); | CScript inner = CreateMultisigRedeemscript(required, pubkeys); | ||||
pwallet->AddCScript(inner); | pwallet->AddCScript(inner); | ||||
CTxDestination dest = | CTxDestination dest = | ||||
pwallet->AddAndGetDestinationForScript(inner, g_address_type); | pwallet->AddAndGetDestinationForScript(inner, output_type); | ||||
pwallet->SetAddressBook(dest, label, "send"); | pwallet->SetAddressBook(dest, label, "send"); | ||||
// Return old style interface | // Return old style interface | ||||
if (IsDeprecatedRPCEnabled(gArgs, "addmultisigaddress")) { | if (IsDeprecatedRPCEnabled(gArgs, "addmultisigaddress")) { | ||||
return EncodeDestination(dest, config); | return EncodeDestination(dest, config); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,831 Lines • Show Last 20 Lines |