searching by payment id in integrated addresses added

master
moneroexamples 8 years ago
parent 840e81426e
commit 51b1a6494d

@ -1415,8 +1415,6 @@ namespace xmreg {
// if yes, then we can only show its public components // if yes, then we can only show its public components
if (search_text.length() == 95) if (search_text.length() == 95)
{ {
cout << "address is given " << endl;
// parse string representing given monero address // parse string representing given monero address
cryptonote::account_public_address address; cryptonote::account_public_address address;
@ -1432,12 +1430,37 @@ namespace xmreg {
+ search_text; + search_text;
} }
cout << "public spend key: " << address.m_spend_public_key << endl;
cout << "public view key: " << address.m_view_public_key << endl;
return show_address_details(address, testnet); return show_address_details(address, testnet);
} }
// check if integrated monero address is given based on its length
// if yes, then show its public components search tx based on encrypted id
if (search_text.length() == 106)
{
cryptonote::account_public_address address;
bool has_payment_id;
crypto::hash8 encrypted_payment_id;
bool testnet;
if (!get_account_integrated_address_from_str(address,
has_payment_id,
encrypted_payment_id,
testnet,
search_text))
{
cerr << "Cant parse string integerated address: " << search_text << endl;
return string("Cant parse address (probably incorrect format): ")
+ search_text;
}
return show_integrated_address_details(address, encrypted_payment_id, testnet);
}
// second let try searching for tx // second let try searching for tx
result_html = show_tx(search_text); result_html = show_tx(search_text);
@ -1688,10 +1711,11 @@ namespace xmreg {
string pub_spendkey_str = fmt::format("{:s}", address.m_spend_public_key); string pub_spendkey_str = fmt::format("{:s}", address.m_spend_public_key);
mstch::map context { mstch::map context {
{"xmr_address" , REMOVE_HASH_BRAKETS(address_str)}, {"xmr_address" , REMOVE_HASH_BRAKETS(address_str)},
{"public_viewkey" , REMOVE_HASH_BRAKETS(pub_viewkey_str)}, {"public_viewkey" , REMOVE_HASH_BRAKETS(pub_viewkey_str)},
{"public_spendkey" , REMOVE_HASH_BRAKETS(pub_spendkey_str)}, {"public_spendkey" , REMOVE_HASH_BRAKETS(pub_spendkey_str)},
{"testnet" , testnet}, {"is_integrated_addr" , false},
{"testnet" , testnet},
}; };
// read address.html // read address.html
@ -1704,6 +1728,36 @@ namespace xmreg {
return mstch::render(full_page, context); return mstch::render(full_page, context);
} }
// ;
string
show_integrated_address_details(const account_public_address& address,
const crypto::hash8& encrypted_payment_id,
bool testnet = false)
{
string address_str = xmreg::print_address(address, testnet);
string pub_viewkey_str = fmt::format("{:s}", address.m_view_public_key);
string pub_spendkey_str = fmt::format("{:s}", address.m_spend_public_key);
string enc_payment_id_str = fmt::format("{:s}", encrypted_payment_id);
mstch::map context {
{"xmr_address" , REMOVE_HASH_BRAKETS(address_str)},
{"public_viewkey" , REMOVE_HASH_BRAKETS(pub_viewkey_str)},
{"public_spendkey" , REMOVE_HASH_BRAKETS(pub_spendkey_str)},
{"encrypted_payment_id" , REMOVE_HASH_BRAKETS(enc_payment_id_str)},
{"is_integrated_addr" , true},
{"testnet" , testnet},
};
// read address.html
string address_html = xmreg::read(TMPL_ADDRESS);
// add header and footer
string full_page = get_full_page(address_html);
// render the page
return mstch::render(full_page, context);
}
map<string, vector<string>> map<string, vector<string>>
search_txs(vector<transaction> txs, const string& search_text) search_txs(vector<transaction> txs, const string& search_text)

@ -5,23 +5,34 @@
<br/> <br/>
{{#testnet}} {{#testnet}}
<H4 style="margin:5px">Testnet address: Yes</H4> <H4 style="margin:5px">Testnet address: Yes</H4>
{{/testnet}} {{/testnet}}
{{^testnet}} {{^testnet}}
<H4 style="margin:5px">Testnet address: No</H4> <H4 style="margin:5px">Testnet address: No</H4>
{{/testnet}} {{/testnet}}
<br/> <br/>
<H4 style="margin:5px">Associated public keys</H4> <H4 style="margin:5px">Associated public keys</H4>
<H4 style="margin:5px">Public view key: {{public_viewkey}}</H4> <H4 style="margin:5px">View key: {{public_viewkey}}</H4>
<H4 style="margin:5px">Public spend key: {{public_spendkey}}</H4> <H4 style="margin:5px">Spend key: {{public_spendkey}}</H4>
<br/>
{{#is_integrated_addr}}
<H4 style="margin:5px">Encrypted payment id: {{encrypted_payment_id}}</H4>
<br/>
<H4 style="margin:5px">
<a href="/search?value={{encrypted_payment_id}}">Search for transactions associated with this encrypted payment id</a>
</H4>
{{/is_integrated_addr}}
{{^is_integrated_addr}}
<H4 style="margin:5px">
Transactions:<br/> Sorry, its not possible to find txs associated with
normal addresses in Monero
</H4>
{{/is_integrated_addr}}
<br/> <br/>
<H4 style="margin:5px">
Transactions:<br/> Sorry, its not possible to find txs associated with
normal addresses in Monero
</H4>
</div> </div>
<br/> <br/>

Loading…
Cancel
Save