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

213 provide hd wallet implementation #363

Merged
merged 22 commits into from
Nov 25, 2024

Conversation

Kammerlo
Copy link
Collaborator

Implementation of a first version HD wallet wrapper.

@Kammerlo Kammerlo requested a review from satran004 January 22, 2024 12:56
@Kammerlo Kammerlo self-assigned this Jan 22, 2024
@Kammerlo Kammerlo linked an issue Jan 22, 2024 that may be closed by this pull request
@satran004 satran004 requested a review from edridudi January 31, 2024 09:34
@satran004
Copy link
Member

Hi @edridudi,

@Kammerlo has implemented an initial version of the HD wallet module in this PR. We are currently reviewing it to finalize the api. Feel free to review it as well and let us know if there are any specific requirements or enhancements you would like to see in this new API.

Thanks

Copy link

@gavinharris-dev gavinharris-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope you don't mind my adding a few comments / observations?! Thank you for doing this work!!

* @param utxoSupplier
* @return
*/
public List<Account> getSignersForTransaction(Transaction tx, WalletUtxoSupplier utxoSupplier) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this method also take into account the following potential location for "signers"?"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gavinharris-dev This is good feedback. I think instead of returning List<Account>, it can return List<TxSigner> or just TxSigner by composing multiple signers.

I agree that we should try to resolve all possible signers for the above scenarios. There are a few additional governance-related signers introduced in the Conway era where we need to sign using Drep credentials.

As the Wallet API will be compatible with the QuickTx API, additional signers can also be added in a standard way.

private final UtxoService utxoService;
@Setter
private Wallet wallet;
private static final int INDEX_SEARCH_RANGE = 20; // according to specifications

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible for this go into a configuration property somewhere? I have seen wallets with 100s of addresses which is super annoying to try supporting; but if we were as users able to configure this it might be good?
I wonder if there would be a way for Dev's to retain a list of Derivation Paths that are known good ones? A lot of the multi address wallets out there have < 5 active addresses, but a heap of addresses that were used once (and no longer have any UTxOs linked).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

We need to revisit this. Apart from the current implementation, which follows the HD wallet specification (scanning 20 unused addresses), we can provide an additional implementation or extend the current one with additional configuration properties. As you mentioned, one of these could be:

  • Specific derivation paths provided by the application. The application needs to store these derivation paths in persistent storage and provide them to this API.

@satran004 satran004 marked this pull request as draft August 2, 2024 03:45
@satran004
Copy link
Member

Hope you don't mind my adding a few comments / observations?! Thank you for doing this work!!

@gavinharris-dev Thanks for your comments / feedback. This PR is still in draft, and the current plan is to finalize it after the Conway HF, as it will impact some existing key APIs. So, please feel free to provide any feedback.

Copy link

Changed the sender wallet handling to return null instead of throwing an exception in Tx.java to allow flexibility in error management. Also, removed redundant 'amounts' field and its initialization from AbstractTx.java for a cleaner codebase.
Move the transaction building logic into a dedicated private method in `TxBuilderContext`. Refactor `QuickTxBuilder` to use the new build method and streamline the signing process, eliminating redundant code and improving code readability.
Refactor Wallet methods and variables for better naming consistency. Remove unused methods and annotations. Add new test for scanning specific indexes in DefaultWalletUtxoSupplier. Update existing tests to align with the refactored method names and structures.
@satran004 satran004 marked this pull request as ready for review November 25, 2024 04:22
@satran004 satran004 marked this pull request as draft November 25, 2024 04:22
@satran004
Copy link
Member

@Kammerlo

I have done some minor cleanup and changes to this PR. It seems the core functionalities are working fine. I think it's ready to be merged. Though there are a few enhancements required before the release, we can handle them in separate PRs.

Can you please have a quick look before we merge this?

@satran004
Copy link
Member

I have added a separate issue to track future enhancements of the Wallet api

#471

Copy link
Collaborator Author

@Kammerlo Kammerlo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look's good!

// * @param utxoSupplier
// * @return
// */
// public List<Account> getSignersForTransaction(Transaction tx, WalletUtxoSupplier utxoSupplier) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function isn't needed? Or will it added later again?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kammerlo This is not needed currently, but I have kept it commented out for now in case it is required for any edge scenarios.

@Kammerlo Kammerlo marked this pull request as ready for review November 25, 2024 09:56
@satran004 satran004 mentioned this pull request Nov 25, 2024
6 tasks
@satran004 satran004 merged commit 75d9a39 into master Nov 25, 2024
5 checks passed
@satran004 satran004 deleted the 213-provide-hd-wallet-implementation branch November 25, 2024 11:23
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

Successfully merging this pull request may close these issues.

Provide HD Wallet implementation
4 participants