monero-project / monero

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

wallet: add no_initial_sync argument to open_wallet rpc command. #9579

Open 0xFFFC0000 opened 1 week ago

0xFFFC0000 commented 1 week ago

Add refresh step when opening a wallet with open_wallet.

  1. add no_initial_sync argument to open_wallet rpc command.
  2. Clean --no-initial-sync implementation.
  3. Fix spelling error.

The interface for open_wallet has stayed the same. Passing no_initial_sync to open_wallet RPC will prevent open_wallet from doing a refresh after opening a wallet.

Open wallet with default refresh:

open_wallet': curl http://localhost:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"open_wallet","params":{"filename":"WalletName","password":""}}' -H 'Content-Type: application/json'

Open wallet without refresh after opening wallet:

open_wallet': curl http://localhost:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"open_wallet","params":{"filename":"MainNetWallet","password":"", "no_initial_sync": true}}' -H 'Content-Type: application/json'

plowsof commented 4 days ago

echoing my comment on the original --no-inital-sync pull request from mooo https://github.com/monero-project/monero/pull/8941#issuecomment-1627294195 to say this is great. Adding this as an on the fly flag per open wallet means that devs will see this flag in a more prominent place in docs, instead of in a separate startup flag section. I will sanity check this now and update this comment

plowsof commented 4 days ago

can you confirm my sanity check test? starting wallet rpc (without --no-initial-sync / no open wallet)

./monero-wallet-rpc --disable-rpc-login --wallet-dir . --rpc-bind-port 58084 --log-level 2

test wallet has a height of 0. open test wallet without no_initial_sync:

curl http://localhost:58084/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"open_wallet","params":{"filename":"test","password":""}}' -H 'Content-Type: application/json'

i see:

2024-11-25 10:40:31.523 W Loaded wallet keys file, with public address: 44j98gLoxv6FKD9LwhtaH29DjWPHq3UoU1memboviCeSNViQtDUoBTg2yqmJDtj6MvjSgMk6mxz3F1Su7jRYK9mpMc6KGmZ
2024-11-25 10:40:31.552 I Trying to decrypt cache data
2024-11-25 10:40:31.630 I No message store file found: ./test.mms
2024-11-25 10:40:31.630 D /json_rpc[open_wallet] processed with 0/2264/0ms
2024-11-25 10:40:31.630 D Destructing connection #0 to 0.0.0.0
2024-11-25 10:40:42.632 D Pulling blocks: start_height 0
2024-11-25 10:40:42.632 D Reconnecting...
2024-11-25 10:40:42.789 W SSL peer has not been verified
2024-11-25 10:40:42.789 W SSL peer has not been verified
2024-11-25 10:40:42.789 W SSL peer has not been verified
2024-11-25 10:40:42.880 D SSL handshake success
2024-11-25 10:40:42.948 D Pulled blocks: blocks_start_height 425574, count 1000, height 426574, node height 3289068, pool info 2

exiting wallet-rpc and starting with the same params. then opening test with no_initial_sync:

curl http://localhost:58084/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"open_wallet","params":{"filename":"test","password":"", "no_initial_sync": true}}' -H 'Content-Type: application/json'

I should not see the same logs output as the original open_wallet curl without no_initial_sync?

0xFFFC0000 commented 4 days ago

@plowsof Yes, that is correct.

Good suggestion and I updated the PR.

Right now, when it does not sync, it will print a log : no-initial-sync passed. Not syncing the wallet..

0xFFFC0000 commented 4 days ago

@plowsof

I misread you question.

I should not see the same logs output as the original open_wallet curl without no_initial_sync?

In original PR, the logs were exactly same. No special output for passing no-initial-sync.

That is not the case anymore. Right now, when you pass no-initial-sync whether to RPC call or as wallet flag, you will see a no-initial-sync passed. Not syncing the wallet in your log.