-
Notifications
You must be signed in to change notification settings - Fork 94
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
Implement requesting balances of HD wallet addresses #1190
Conversation
…otocol * Move `PrivKeyBuildPolicy` to `lp_coins.rs` * Refactor `grpc_web_multi_url_request` * Add `MmRpcResult::map_err`, `RpcTaskStatus::map_err`
* Move `UtxoCoinBuilder`, `UtxoArcBuilder` from `utxo.rs` to a separate module * Add `extended_pubkey`, `derivation_path` to `HDWalletInfo`
* Move `extended_pubkey` from `UtxoHDWallet` to `UtxoHDAccount` * Register `UtxoStandardCoin` at `InitStandaloneCoinActivationOps::init_standalone_coin` * Add `RpcDerivationPath` * Push missed `coin_balance.rs` * Increase `WAIT_DOCKER_READY_TIMEOUT_MS` to 60s * Bump the `ring` crate version to 0.16.15
* Add ZCoinBuilder
* Optimize UTXO coin builders not to clone `UtxoActivationParams` * Refactor `NativeClient::list_transactions_by_address` to `NativeClient::is_address_list_transactions_empty`
* Add `init_qtum`, `init_qtum_status`, `init_qtum_user_action` RPC calls * Add `derivation_path` to `HDAccountBalance`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few questions on the first review iteration :)
mm2src/coins/utxo/utxo_common.rs
Outdated
derivation_path, | ||
} = coin.derive_address(hd_account, address_id, change)?; | ||
|
||
let balance = coin.known_address_balance(&address).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting balances sequentially can become a problem if users will have many addresses after a long time. It's preferable to start using batch requests here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I splitted the wallet_balance
into hd_account_balance
and check_hd_account_balance
, added pagging options to hd_account_balance
. Could you please re-review?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant using JSON RPC batch requests https://www.jsonrpc.org/specification#batch. E.g. request all balances of known addresses from Electrum in a single batch.
Please check if using batches will be more effective - compare the time required to perform e.g. 10 balance requests sequentially or in the batch. If the difference is significant, consider refactoring to batch requests in the next iteration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only 2 minor comments :)
* Return the previous implementation of `grpc_web_multi_url_request` * Split `wallet_balance` into `hd_account_balance` and `check_hd_account_balance` RPC calls
* Add `check_utxo_maturity` to electrum/enable RPC call * Add `QtumCoinBuilder` and `QtumCoinWithIguanaPrivKeyBuilder` that override `check_utxo_maturity` * Add `UtxoCommonOps::list_all_unspent_ordered` that behaves as `UtxoCommonOps::list_unspent_ordered` before * `UtxoCommonOps::list_unspent_ordered` checks the `check_utxo_maturity` flag to use either `list_all_unspent_ordered` or `list_mature_unspent_ordered` * Rename `UtxoCommonOps::ordered_mature_unspents` to `UtxoCommonOps::list_mature_unspent_ordered`
* Use `tokio::RwLock` instead of `parking_lot::Mutex` to store HD accounts * Move HD wallet related traits and structures from lp_coins.rs to coin_hd_wallet.rs * TODO use `HwRpcTaskAwaitingStatus`, `HwRpcTaskUserAction`, `HwRpcTaskUserActionRequest`, `InitRpcTaskResponse`, `RpcTaskActionError`, `RpcTaskStatusError`, `RpcTaskStatusRequest` everywhere it's possible
Since the last review iteration, I added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great Work! 🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 7 comments are sufficient for this review iteration 🙂
* Move the `HDWallet` related methods from `HDWalletCoinOps` into `HDWalletOps` * Move the `HDAccount` related methods from `HDWalletCoinOps` into `HDAccountOps` * Rename `get_new_hd_address` to `get_new_address`, `hd_account_balance` to `account_balance`, `init_create_hd_account` to `init_create_account` RPC calls
* Possible refactoring. * Removed more bounds. * Added HDAccount for HDWalletCoinOps to reduce "as HDWalletOps" constructions. * Continue refactoring * Add a default implementation of `HDWalletCoinOps::generate_new_address` * Remove `HDWalletCoinOps::address_balance` * Make `HDWalletBalanceRpcOps` independent of `HDWalletBalanceOps` Co-authored-by: Artem Vitae <artem@vitae.com>
@artemii235 I hope I've resolved all issues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few more (hopefully minor 🙂 ) changes requests.
mm2src/coins_activation/src/standalone_coin/init_standalone_coin.rs
Outdated
Show resolved
Hide resolved
mm2src/coins_activation/src/utxo_activation/init_qtum_activation.rs
Outdated
Show resolved
Hide resolved
…Id refers to an activated account/address * Add the `WithdrawFrom::AccountId` variant to allow the user to specify account_id, chain and address_id * Add `Bip44DerivationPath`, `Bip44PathToCoin`, `Bip44PathToAccount` * Avoid extracting a pubkey from a Trezor device on `init_withdraw`
# Conflicts: # mm2src/docker_tests/docker_tests_common.rs
* Avoid using `clippy::type_complexity` by refactoring the `RpcTask` module * Typo: address_unspendable_balanAce
* Rename `ExpectedHDWalletDerivationMethod` to `CoinIsActivatedNotWithHDWallet` * Reorder RPCs alphabetically * impl `From<KeyPair>`
I think it's ready for the next review iteration :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 Thanks for all fixes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reapproving.
account_balance
,scan_for_new_addresses
,get_new_address
,init_create_new_account
,init_create_new_account_status
,init_create_new_account_user_action
RPC callsUtxoCoinBuilder
,UtxoArcBuilder
fromutxo.rs
to a separate modulecheck_utxo_maturity
flag to electrum/enable RPC call mature_confirmations not used #1181