Based on JAXX problem in integrate the monero wallet on their service I was wonder how can one run all the blockchain and check the blocks for belolonging TX from certain viewkey Is there any avaliable script with this function ?
-
monero-wallet-cli already does this. With some work I would imagine one could extend that to scanning for n accounts instead of one. Note for example Kenshi's one-time scheme already does a form of this (however, it's completely unsuitable for something like JAXX; please don't use it for that).– LuigiNov 29, 2016 at 22:51
1 Answer
A certain account will always scan all blocks to look if any transactions belong to it, i.e., if P' = P
* (note that P
is a stealth address). As you may have already noticed, this will be quite resource intensive. Therefore, services like MyMonero usually use high end servers to do this. In addition, they charge a fee (such as the import fee in case of MyMonero) to cover some of the costs.
*A more extensive explanation can be found below and is taken from luigi1111's article:
Now let's look at Bob's perspective:
Bob receives a transaction; he wants to check if it belongs to him.
Bob retrieves R, which Alice has helpfully attached to the transaction.
Bob computes D'. Note Bob doesn't (yet) know if D' is equal to D. D' = aR.
Bob computes f' = Hs(D').
Bob computes F' = f'G.
Bob computes P' = F' + B.
Bob checks if P' is equal to P, which was included in the transaction as the destination. If yes, Bob realizes he's been paid and does some additional steps (below). If no, Bob ignores the transaction.
To add, I'll clarify some of the letters used in the quote above. In addition, the view key that we can publish is known as the tracking key (a,B)
in the CryptoNote whitepaper.
R
= Public transaction key
D
= Shared secret that is only known to Alice (sender) and Bob (receiver)
Note that D = rA
(private tx key (r) times public view key (A) from Bob), whereas D' = aR
(private view key (a) times public transaction key (R) that was included by Alice)
Hs
= Hash to scalar, i.e., a hashing algorithm that returns a scalar (private key).
G
= The Ed25519 base point
B
= Bob's public spend key
Is there any avaliable script with this function ?
You can simply type payments <payment_ID>
into the wallet to see all transactions belong to that account. If you need to check for payments programmatically, then see below from the "Accepting Monero Payments" page:
Checking for a Payment Programatically
In order to check for a payment programatically you can use the get_payments or get_bulk_payments JSON RPC API calls.
get_payments: this requires a payment_id parameter with a single payment ID.
get_bulk_payments: this is the preferred method, and requires two parameters, payment_ids - a JSON array of payment IDs - and an optional min_block_height - the block height to scan from.
An example of returned data is as follows:
It is important to note that the amounts returned are in base Monero units and not in the display units normally used in end-user applications. Also, since a transaction will typically have multiple outputs that add up to the total required for the payment, the amounts should be grouped by the tx_hash or the payment_id and added together. Additionally, as multiple outputs can have the same amount, it is imperative not to try and filter out the returned data from a single get_bulk_payments call.
Before scanning for payments it is useful to check against the daemon RPC API (the get_info RPC call) to see if additional blocks have been received. Typically you would want to then scan only from that received block on by specifying it as the min_block_height to get_bulk_payments.
Programatically Scanning for Payments
- Get the current block height from the daemon, only proceed if it has increased since our last scan
- Call the get_bulk_payments RPC API call with our last scanned height and the list of all payment IDs in our system
- Store the current block height as our last scanned height
- Remove duplicates based on transaction hashes we have already received and processed
Some background information that may come in handy when you are trying to understand this Q&A on a deeper, more technical level:
[2] Constructing a Stealth Monero Address?
[3] Examples of real stealth address from the blockchain
[4] Why does the stealth address involve a hash function?
[5] Mandatory vs optional stealth address use
[6] Why is the viewkey able to track incoming transactions, but not outgoing transactions?
-
I don't feel like this response is sufficient. OP asks for specific code and the explainations are rather abstract. Nov 30, 2016 at 9:31
-