monero-project / monero

Monero: the secure, private, untraceable cryptocurrency
https://getmonero.org
Other
8.87k stars 3.09k forks source link

monero-wallet-rpc get_transfers(..., pending=True) does not work #8140

Open elibroftw opened 2 years ago

elibroftw commented 2 years ago
  1. Startup an RPC in stagenet (bind to port 38088)
  2. Open Stagenet wallet and send to address in RPC
  3. This issue occurs regardless if the daemon is marked as trusted or not
  4. Also the seed for the wallets is the same but the accounts are different. The Monero GUI can detect that the transaction is received pending but the RPC cant.
    
    from dotenv import load_dotenv
    import os
    from pathlib import Path
    import requests
    from requests.auth import HTTPDigestAuth

load_dotenv('.env')

import requests

monero_rpc_session.auth = HTTPDigestAuth('monero', os.environ['SIMPLE_PWD'])

XMR_RPC_ENDPOINT = 'http://127.0.0.1:38088/json_rpc' XMR_RPC_AUTH = HTTPDigestAuth('monero', os.environ['XMR_RPC_PW'])

def xmr_rpc_api(method_name, params): rpc_defaults = {'jsonrpc': '2.0', 'id': '0'} if '_in' in params: params['in'] = params.pop('_in') return requests.post(XMR_RPC_ENDPOINT, json={rpc_defaults, 'method': method_name, 'params': params}, auth=XMR_RPC_AUTH)

r = xmr_rpc_api('get_transfers', _in=True, out=False, pending=True, account_index=1, subaddr_indices=[]).json() print(r['result'].keys())

Expected:
```py
dict_keys(['in', 'pending']

Got:

dict_keys(['in']
selsta commented 2 years ago

Also the seed for the wallets is the same but the accounts are different.

Can you explain this in more detail?

elibroftw commented 2 years ago

I'm using the same wallet for RPC and GUI, but sending and receiving from two different accounts.

elibroftw commented 2 years ago

https://github.com/comit-network/xmr-btc-swap/issues/523#issuecomment-846487263 I'm not the only one experiencing this bug

rbrunner7 commented 2 years ago

I built a web wallet that is using the RPC interface and the monero-wallet-rpc binary, and it does not show the slightest problem of picking up pending transactions. (Pending transactions are displayed with a red "Pending" in the Type column.) Of course it uses the call you mention, get_transfers, because it's the only one and thus no way around it, as far as I remember.

So no idea what's the reason for your problems, but I highly doubt it can be a general problem in the RPC daemon or even in the wallet.

elibroftw commented 2 years ago

@rbrunner7 did you see the comment I linked to Comit's swap tool? They also experience the same problem.

Is there a specific way to call get transfers then?

rbrunner7 commented 2 years ago

Yes, I checked the link. It may well possible that there are special circumstances that prevent pending transfers getting reported, and if yes, it's the big question how to sensibly narrow down here. Their comment is without any details thus unfortunately it's not helpful in this regard.

As I had a dedicated goal of always showing all transactions in all states in my web wallet, I think any error there would have jumped at me. So I can confirm that the call at least works pretty reliably under some circumstances; it's certainly not completely broken.

rbrunner7 commented 2 years ago

Is there a specific way to call get transfers then?

Not that I know of. You set, like you did, the pending boolean, and call get_transfers.

elibroftw commented 2 years ago

Okay but am I calling get transfers incorrectly then? Or is it a bug if the incoming transfer for one account is the outgoing of another account?

rbrunner7 commented 2 years ago

Maybe only some such combinations are problematic, yeah. Maybe if you send to yourself, from one account to another, you only get a pool transfer reported, but not a pending one? I myself don't know, never tried that, and my web wallet does not support accounts.

rbrunner7 commented 2 years ago

Quite in general, the RPC daemon pretty much uses the same calls into wallet2 as the CLI wallet does. If there is a problem you should have a good chance to catch it with the CLI wallet as well, which would be much easier to reproduce for people and then investigate.

elibroftw commented 2 years ago

The issue isn't just from me. I linked a comment which shows the commit people have also faced this issue.

elibroftw commented 2 years ago

The bug is not present in the wallet-cli

elibroftw commented 2 years ago

@rbrunner7 , do I need to use "pool": True? https://monerodocs.org/interacting/monero-wallet-rpc-reference/#get_transfers

elibroftw commented 2 years ago

If this works, then it's a bug if pending: true also requires pool: true.

rbrunner7 commented 2 years ago

I had a look at the code of wallet_rpc_server::on_get_transfers: It's simple enough, and all I saw is a clean separation between the pending and the pool boolean in the processing. No surprising dependence between those two in sight anywhere so that it would only work with both set.

The code also looks unchanged sine aeons, written and last modified by @moneromooo-monero 5 years ago.

I would say the riddle is still unsolved.

elibroftw commented 2 years ago

I'll just run experiments again when I get the time.