-
Notifications
You must be signed in to change notification settings - Fork 101
backend: add eth account to software keystore. #3329
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
Conversation
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.
Pull Request Overview
This PR introduces support for Ethereum accounts within the software keystore, allowing ETH transactions to be signed along with existing BTC support.
- Added the Ethereum coin import and updated type switches in SupportsCoin and SupportsAccount.
- Introduced a dedicated signETHTransaction function and refactored SignTransaction to handle both BTC and ETH transaction proposals.
Comments suppressed due to low confidence (2)
backend/keystore/software/software.go:270
- The alias 'ethTypes' is referenced here but is not imported. Please update the import or alias usage to match the correct package name for Ethereum types.
tx.Tx, err = ethTypes.SignTx(tx.Tx, tx.Signer, privKey.ToECDSA())
backend/keystore/software/software.go:284
- [nitpick] Consider returning an error instead of panicking in the default case of SignTransaction to improve fault tolerance in production scenarios.
panic("unknown proposal type")
func (keystore *Keystore) signETHTransaction(tx *eth.TxProposal) error { | ||
xprv, err := tx.Keypath.Derive(keystore.master) | ||
if err != nil { | ||
return errp.Newf("failed to derive key: %v", err) | ||
} | ||
privKey, err := xprv.ECPrivKey() | ||
if err != nil { | ||
return errp.Newf("failed to get private key: %v", err) | ||
} | ||
tx.Tx, err = ethTypes.SignTx(tx.Tx, tx.Signer, privKey.ToECDSA()) | ||
return err | ||
} |
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 don't know how correct this is :) It works, but it was mostly a result of try-and-error, copy-paste, and ChatGPT :)
Open to feedback!
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.
tACK
With this addition, we can use ETH accounts in a software keystore. As shown in the screenshot, accounts can be added, and they can correctly receive/send/send-to-self:
Before asking for reviews, here is a check list of the most common things you might need to consider: