mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
wallet_rpc_server: add count parameter to create_address
This commit is contained in:
parent
fe3f6a3e6b
commit
0e0351c456
3 changed files with 37 additions and 10 deletions
|
@ -550,9 +550,29 @@ namespace tools
|
||||||
if (!m_wallet) return not_open(er);
|
if (!m_wallet) return not_open(er);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_wallet->add_subaddress(req.account_index, req.label);
|
if (req.count < 1 || req.count > 64) {
|
||||||
res.address_index = m_wallet->get_num_subaddresses(req.account_index) - 1;
|
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||||
res.address = m_wallet->get_subaddress_as_str({req.account_index, res.address_index});
|
er.message = "Count must be between 1 and 64.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> addresses;
|
||||||
|
std::vector<uint32_t> address_indices;
|
||||||
|
|
||||||
|
addresses.reserve(req.count);
|
||||||
|
address_indices.reserve(req.count);
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < req.count; i++) {
|
||||||
|
m_wallet->add_subaddress(req.account_index, req.label);
|
||||||
|
uint32_t new_address_index = m_wallet->get_num_subaddresses(req.account_index) - 1;
|
||||||
|
address_indices.push_back(new_address_index);
|
||||||
|
addresses.push_back(m_wallet->get_subaddress_as_str({req.account_index, new_address_index}));
|
||||||
|
}
|
||||||
|
|
||||||
|
res.address = addresses[0];
|
||||||
|
res.address_index = address_indices[0];
|
||||||
|
res.addresses = addresses;
|
||||||
|
res.address_indices = address_indices;
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
// advance which version they will stop working with
|
// advance which version they will stop working with
|
||||||
// Don't go over 32767 for any of these
|
// Don't go over 32767 for any of these
|
||||||
#define WALLET_RPC_VERSION_MAJOR 1
|
#define WALLET_RPC_VERSION_MAJOR 1
|
||||||
#define WALLET_RPC_VERSION_MINOR 16
|
#define WALLET_RPC_VERSION_MINOR 17
|
||||||
#define MAKE_WALLET_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
#define MAKE_WALLET_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
||||||
#define WALLET_RPC_VERSION MAKE_WALLET_RPC_VERSION(WALLET_RPC_VERSION_MAJOR, WALLET_RPC_VERSION_MINOR)
|
#define WALLET_RPC_VERSION MAKE_WALLET_RPC_VERSION(WALLET_RPC_VERSION_MAJOR, WALLET_RPC_VERSION_MINOR)
|
||||||
namespace tools
|
namespace tools
|
||||||
|
@ -182,11 +182,13 @@ namespace wallet_rpc
|
||||||
{
|
{
|
||||||
struct request_t
|
struct request_t
|
||||||
{
|
{
|
||||||
uint32_t account_index;
|
uint32_t account_index;
|
||||||
|
uint32_t count;
|
||||||
std::string label;
|
std::string label;
|
||||||
|
|
||||||
BEGIN_KV_SERIALIZE_MAP()
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
KV_SERIALIZE(account_index)
|
KV_SERIALIZE(account_index)
|
||||||
|
KV_SERIALIZE_OPT(count, 1U)
|
||||||
KV_SERIALIZE(label)
|
KV_SERIALIZE(label)
|
||||||
END_KV_SERIALIZE_MAP()
|
END_KV_SERIALIZE_MAP()
|
||||||
};
|
};
|
||||||
|
@ -194,12 +196,16 @@ namespace wallet_rpc
|
||||||
|
|
||||||
struct response_t
|
struct response_t
|
||||||
{
|
{
|
||||||
std::string address;
|
std::string address;
|
||||||
uint32_t address_index;
|
uint32_t address_index;
|
||||||
|
std::vector<std::string> addresses;
|
||||||
|
std::vector<uint32_t> address_indices;
|
||||||
|
|
||||||
BEGIN_KV_SERIALIZE_MAP()
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
KV_SERIALIZE(address)
|
KV_SERIALIZE(address)
|
||||||
KV_SERIALIZE(address_index)
|
KV_SERIALIZE(address_index)
|
||||||
|
KV_SERIALIZE(addresses)
|
||||||
|
KV_SERIALIZE(address_indices)
|
||||||
END_KV_SERIALIZE_MAP()
|
END_KV_SERIALIZE_MAP()
|
||||||
};
|
};
|
||||||
typedef epee::misc_utils::struct_init<response_t> response;
|
typedef epee::misc_utils::struct_init<response_t> response;
|
||||||
|
|
|
@ -237,12 +237,13 @@ class Wallet(object):
|
||||||
}
|
}
|
||||||
return self.rpc.send_json_rpc_request(create_account)
|
return self.rpc.send_json_rpc_request(create_account)
|
||||||
|
|
||||||
def create_address(self, account_index = 0, label = ""):
|
def create_address(self, account_index = 0, label = "", count = 1):
|
||||||
create_address = {
|
create_address = {
|
||||||
'method': 'create_address',
|
'method': 'create_address',
|
||||||
'params' : {
|
'params' : {
|
||||||
'account_index': account_index,
|
'account_index': account_index,
|
||||||
'label': label
|
'label': label,
|
||||||
|
'count': count
|
||||||
},
|
},
|
||||||
'jsonrpc': '2.0',
|
'jsonrpc': '2.0',
|
||||||
'id': '0'
|
'id': '0'
|
||||||
|
|
Loading…
Reference in a new issue