Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Balance discrepancy in stagenet network #137

Open
Demontager opened this issue Oct 4, 2024 · 3 comments
Open

Balance discrepancy in stagenet network #137

Demontager opened this issue Oct 4, 2024 · 3 comments

Comments

@Demontager
Copy link

Demontager commented Oct 4, 2024

While running monerod-lws-daemon development against monero master in stagenet i have noticed that monero-lws rest server responds with a wrong account balance, but when i call monero-wallet-rpc it replies with correct one.

Getting balance with monero-lws while fully synced to pruned stagenet:

starting monero-lws-daemon
monero-lws-daemon --daemon tcp://127.0.0.1:18082 --db-path /home/dem/.lws --rest-server http://127.0.0.1:8443 --log-level=2 --network=stage --admin-rest-server http://127.0.0.1:8444 --auto-accept-creation

request
$ curl --location --request POST 'http://127.0.0.1:8443/get_address_info' --header 'Content-Type: application/json' --data-raw '{"address":"56QfWzKA55rePZLXySYNPoRM5pMDsUCZN2KtEGqBe7NNfeRoRQ3NY1iTsYhZkymWqWUyUNa1s2H2i2vNsYFKau7SMdV8XE8","view_key":"2383530d2a71d0d6b464f5154968f7afa1f828cfbd42a7f9ee09ba9d2fb1d004"}'
{"locked_funds":"0","total_received":"19899926890000","total_sent":"19899926890000","scanned_height":1702197,"scanned_block_height":1702197,"start_height":1000000,"transaction_height":1702197,"blockchain_height":1702197,"spent_outputs":[{"amount":"10000000000000","key_image":"c461e166100134a8c14c4d2380fdb9f8c04d4caf962a39c84f996e6b8be35a36","tx_pub_key":"6a93b36c054a4fe9edc3d6694e7f7764552c0fe8933a6ef30db0a5544446b538","out_index":0,"mixin":15,"sender":{"maj_i":0,"min_i":0}},{"amount":"9899926890000","key_image":"f3c6fb96718b2f8f214b9c0af69d946f094f1c71b80ba13a42163dc62b3b66b0","tx_pub_key":"ee53ee0a1ab90ac3d99ad5b5764dd07c3f403c21d436f5b27eef3dae2bd4ee7f","out_index":1,"mixin":15,"sender":{"maj_i":0,"min_i":0}}]}(venv)

Now counting wallet balance
total_received: 19899926890000 - total_sent: 19899926890000 = 0

And getting actual correct balance by calling wallet rpc server

starting wallet rpc server
$ monero-wallet-rpc --stagenet --rpc-bind-port 38083 --rpc-bind-ip 127.0.0.1 --wallet-file /home/dem/Monero/wallet2 --password SecretPassword --trusted-daemon --disable-rpc-login --non-interactive

request
$ curl -s -X POST http://127.0.0.1:38083/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_balance"}' -H 'Content-Type: application/json' | jq '.result | {balance: (.balance / 1e12), unlocked_balance: (.unlocked_balance / 1e12)}'
{
  "balance": 9.89992689,
  "unlocked_balance": 9.89992689
}
@vtnerd
Copy link
Owner

vtnerd commented Oct 4, 2024

LWS doesn't have the spend private key, so it cannot compute the correct balance. The spend key is needed to determine the "real" spends, and filter out the times an output was used in someone else's ring signature. This should change with "carrot" (the next version of Monero addresses), where LWS could have a balance-view-key but still not have the spend key.

The total_received and total_sent aren't particularly useful (IMO), but an original part of the spec. The total_received includes change, and total_sent includes "dummy" spends, so the numbers can't really be used directly.

It does look like LWS is missing a receive, so perhaps a rescan from an earlier height is needed?

@Demontager
Copy link
Author

Demontager commented Oct 5, 2024

It does look like LWS is missing a receive, so perhaps a rescan from an earlier height is needed?

Rescanning from earlier hight doesn't change figures.
I thought mymonero using some sort of modified LWS as you wrote earlier and therefore provides actual balance.
Is it possible to provide LWS with private spend key instead to calculate correct balance?

@vtnerd
Copy link
Owner

vtnerd commented Oct 5, 2024

I thought mymonero using some sort of modified LWS as you wrote earlier and therefore provides actual balance.
Is it possible to provide LWS with private spend key instead to calculate correct balance?

Not currently. The closest is the unfinished lwfs project.

Perhaps a custom REST endpoint (for just for the balance) or a small custom frontend for the same. Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants