1

I am trying to understand monero & recieve funds with monero using this python api in my website.

Please check with my plan and correct me freely if I'm wrong.

  1. For every account I will make a sub-address like the following and save it with user info

    w = Wallet(JSONRPCWallet(port=28088)) 
    w.new_address() #create new subaddress for a wallet
    
    new_address_for_user = w.get_addresses()[-1] #get the newly created subaddress
    user_info['monero_subaddress'] = new_address_for_user #save the subaddress with user info
    
  2. If user buys an item, check for the transaction

    w = Wallet(JSONRPCWallet(port=28088)) 
    monero_subaddress_for_user = user_info['monero_subaddress']
    incoming = w.incoming(local_address=monero_subaddress_for_user)[-1] # get transaction with the particular subaddress in user_info
    
    price_of_item = transaction_info['price']
    
    if price_of_item is incoming.amount:
        #check user paid for item correctly
    

Stepping aside bugs and other things for later, is this code the right concept for basic transaction with monero?

1 Answer 1

0

Conceptually, yes. The defaults for wallet.incoming return confirmed transactions. Depending on the rest of your architecture, you may want to make use of unconfirmed transactions (e.g. mark product as sold but not ship until the transaction is confirmed), if this is the case you'll need to also make use of the parameters for incoming: wallet.incoming(unconfirmed=True, confirmed=False).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.