mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-16 21:16:37 +00:00
signer/core: prevent nil pointer panics in keystore operations (#33829)
Add nil checks to prevent potential panics when keystore backend is unavailable in the Clef signer API.
This commit is contained in:
parent
ecee64ecdc
commit
0d043d071e
1 changed files with 8 additions and 3 deletions
|
|
@ -73,8 +73,9 @@ type rawWallet struct {
|
||||||
// Example call
|
// Example call
|
||||||
// {"jsonrpc":"2.0","method":"clef_listWallets","params":[], "id":5}
|
// {"jsonrpc":"2.0","method":"clef_listWallets","params":[], "id":5}
|
||||||
func (api *UIServerAPI) ListWallets() []rawWallet {
|
func (api *UIServerAPI) ListWallets() []rawWallet {
|
||||||
wallets := make([]rawWallet, 0) // return [] instead of nil if empty
|
allWallets := api.am.Wallets()
|
||||||
for _, wallet := range api.am.Wallets() {
|
wallets := make([]rawWallet, 0, len(allWallets)) // return [] instead of nil if empty
|
||||||
|
for _, wallet := range allWallets {
|
||||||
status, failure := wallet.Status()
|
status, failure := wallet.Status()
|
||||||
|
|
||||||
raw := rawWallet{
|
raw := rawWallet{
|
||||||
|
|
@ -130,8 +131,12 @@ func (api *UIServerAPI) ImportRawKey(privkey string, password string) (accounts.
|
||||||
if err := ValidatePasswordFormat(password); err != nil {
|
if err := ValidatePasswordFormat(password); err != nil {
|
||||||
return accounts.Account{}, fmt.Errorf("password requirements not met: %v", err)
|
return accounts.Account{}, fmt.Errorf("password requirements not met: %v", err)
|
||||||
}
|
}
|
||||||
|
ks := fetchKeystore(api.am)
|
||||||
|
if ks == nil {
|
||||||
|
return accounts.Account{}, errors.New("password based accounts not supported")
|
||||||
|
}
|
||||||
// No error
|
// No error
|
||||||
return fetchKeystore(api.am).ImportECDSA(key, password)
|
return ks.ImportECDSA(key, password)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenWallet initiates a hardware wallet opening procedure, establishing a USB
|
// OpenWallet initiates a hardware wallet opening procedure, establishing a USB
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue