aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorstoffu <stoffu@protonmail.ch>2018-07-20 21:33:36 +0900
committerstoffu <stoffu@protonmail.ch>2018-07-20 21:33:36 +0900
commit7db7ec8591a3f1e870e158a0b1cf71765e8a835a (patch)
treeb72e297889de5adb1bb4bd174b8c1afa04b7548c /src
parentMerge pull request #4088 (diff)
downloadmonero-7db7ec8591a3f1e870e158a0b1cf71765e8a835a.tar.xz
wallet rpc: support making integrated address of given standard address
Diffstat (limited to 'src')
-rw-r--r--src/wallet/wallet_rpc_server.cpp34
-rw-r--r--src/wallet/wallet_rpc_server_commands_defs.h2
2 files changed, 35 insertions, 1 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index b9cf99635..60206a4a7 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -1255,7 +1255,39 @@ namespace tools
}
}
- res.integrated_address = m_wallet->get_integrated_address_as_str(payment_id);
+ if (req.standard_address.empty())
+ {
+ res.integrated_address = m_wallet->get_integrated_address_as_str(payment_id);
+ }
+ else
+ {
+ cryptonote::address_parse_info info;
+ if(!get_account_address_from_str(info, m_wallet->nettype(), req.standard_address))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_ADDRESS;
+ er.message = "Invalid address";
+ return false;
+ }
+ if (info.is_subaddress)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_ADDRESS;
+ er.message = "Subaddress shouldn't be used";
+ return false;
+ }
+ if (info.has_payment_id)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_ADDRESS;
+ er.message = "Already integrated address";
+ return false;
+ }
+ if (req.payment_id.empty())
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID;
+ er.message = "Payment ID shouldn't be left unspecified";
+ return false;
+ }
+ res.integrated_address = get_account_integrated_address_as_str(m_wallet->nettype(), info.address, payment_id);
+ }
res.payment_id = epee::string_tools::pod_to_hex(payment_id);
return true;
}
diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h
index 1bd572add..026c5d8ad 100644
--- a/src/wallet/wallet_rpc_server_commands_defs.h
+++ b/src/wallet/wallet_rpc_server_commands_defs.h
@@ -914,9 +914,11 @@ namespace wallet_rpc
{
struct request
{
+ std::string standard_address;
std::string payment_id;
BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(standard_address)
KV_SERIALIZE(payment_id)
END_KV_SERIALIZE_MAP()
};