Add generated_locally to login endpoint

https://github.com/mymonero/mymonero-app-js/issues/278
pull/135/head
moneroexamples 5 years ago
parent 2a82dcc30d
commit ab0b12c629

@ -34,7 +34,7 @@
"wallet_import" : "wallet_import" :
{ {
"_comment": "if fee is 0, then importing is free. fee is in base 1e12, e.g., 0.1 xmr is 0.1 x 1e12 = 100000000000", "_comment": "if fee is 0, then importing is free. fee is in base 1e12, e.g., 0.1 xmr is 0.1 x 1e12 = 100000000000",
"fee" : 0, "fee" : 1000000000,
"testnet" : "testnet" :
{ {
"address" : "9tzmPMTViHYM3z6NAgQni1Qm1Emzxy5hQFibPgWD3LVTAz91yok5Eni1pH6zKhBHzpTU15GZooPHSGHXFvFuXEdmEG2sWAZ", "address" : "9tzmPMTViHYM3z6NAgQni1Qm1Emzxy5hQFibPgWD3LVTAz91yok5Eni1pH6zKhBHzpTU15GZooPHSGHXFvFuXEdmEG2sWAZ",

@ -57,10 +57,22 @@ OpenMoneroRequests::login(const shared_ptr<Session> session, const Bytes & body)
string xmr_address; string xmr_address;
string view_key; string view_key;
// this is true for both newly created accounts
// and existing/imported ones
bool create_accountt {true};
// client sends generated_localy as true
// for new accounts, and false for
// adding existing accounts (i.e., importing wallet)
bool generated_locally {false};
try try
{ {
xmr_address = j_request["address"]; xmr_address = j_request["address"];
view_key = j_request["view_key"]; view_key = j_request["view_key"];
create_accountt = j_request["create_account"];
if (j_request.count("generated_locally"))
generated_locally = j_request["generated_locally"];
} }
catch (json::exception const& e) catch (json::exception const& e)
{ {
@ -69,6 +81,24 @@ OpenMoneroRequests::login(const shared_ptr<Session> session, const Bytes & body)
return; return;
} }
if (create_accountt == false)
{
j_response = json {{"status", "error"},
{"reason", "Not making an account"}};
session_close(session, j_response);
return;
}
// return same as what we recieved to client
j_response["generated_locally"] = generated_locally;
//j_response["generated_locally"] = true;
// optinoal field, but we set it to current height
j_response["start_height"] = current_bc_status
->get_current_blockchain_height();
// a placeholder for exciting or new account data // a placeholder for exciting or new account data
uint64_t acc_id {0}; uint64_t acc_id {0};

@ -28,7 +28,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 OPENMONERO_RPC_VERSION_MAJOR 1 #define OPENMONERO_RPC_VERSION_MAJOR 1
#define OPENMONERO_RPC_VERSION_MINOR 3 #define OPENMONERO_RPC_VERSION_MINOR 5
#define MAKE_OPENMONERO_RPC_VERSION(major,minor) (((major)<<16)|(minor)) #define MAKE_OPENMONERO_RPC_VERSION(major,minor) (((major)<<16)|(minor))
#define OPENMONERO_RPC_VERSION \ #define OPENMONERO_RPC_VERSION \
MAKE_OPENMONERO_RPC_VERSION(OPENMONERO_RPC_VERSION_MAJOR, OPENMONERO_RPC_VERSION_MINOR) MAKE_OPENMONERO_RPC_VERSION(OPENMONERO_RPC_VERSION_MAJOR, OPENMONERO_RPC_VERSION_MINOR)

Loading…
Cancel
Save