Closed xmrsale closed 2 years ago
Your original intuition is correct, if you can retrieve a block and its transactions then you can check for payments with a viewpair. Using the Monero Blocks API, you can get the blocks and transactions: https://localmonero.co/blocks/api
There are libraries available to help process the transactions you receive from the block explorer. In AcceptXMR, I relied heavily on monero-rs (a really well made library btw, highly recommend). I am primarily a rust programmer, but I see that there is a similar library for python which may get you the same functionality: https://github.com/monero-ecosystem/monero-python
You can see the overall flow of checking the transactions in https://github.com/busyboredom/acceptxmr/blob/main/src/scanner.rs. Under the hood, monero-rs is using a hashmap of keys by subaddress index to iterate through the transactions to see if any are owned by one of your subaddresses: https://github.com/monero-rs/monero-rs/blob/main/src/blockdata/transaction.rs
Edit: I had hoped that python library would have some tools pre-made for you, but it looks like it's not really a parallel of monero-rs. I am not sure what library would be best for you; it would stink if you had to re-implement a lot that low-level work.
Edit2: Looks like monero-python would probably work after all. You can use the offline backend with the view key so there's no wallet RPC connection, and then the logic for retrieving owned amounts from transactions is already implemented here.
My misunderstanding is in the ability to use a block explorer alone, which does not seem possible as you require a backend to process transactions from blocks.
Currently opting to use tried and tested monero-wallet-rpc
with public nodes, solves this fine. Having explored monero-python library, there's no great reason to go for custom solution just yet.
It seems monero's transaction protocol (updates? or maybe it has always been this way and I misunderstood it :/) means that to verify a payment using
view keys
via a 3rd party, requires additional information such as A) a transaction proof provided by the customer (very bad UX) B) txid and viewkey (responding with txid is also bad UX) https://www.reddit.com/r/Monero/comments/9206nx/checking_if_the_way_is_correct_to_confirm_the/ https://monero.stackexchange.com/questions/6191/can-you-view-the-payment-id-in-a-monero-block-explorer https://monero.stackexchange.com/questions/12887/verifying-a-payment-in-monero-in-an-automatic-manner-without-a-third-pary-and-wPreviously I was working under the assumption that you could create a view-only wallet and easily check payments using a block-explorer -- as on other blockchains with address derivation from an extended public key.
Since we have not been able to configure xmrsale with offline wallet in this way, the development pathway has focused on a lighter
monero-wallet-rpc
based version that connects to a public node.If you have any ideas of how we can configure this setup, please let us know!
Exploration in this branch https://github.com/xmrsale/xmrSale/tree/viewonly