Update wallet.go

This commit is contained in:
Alvarez 2025-12-08 19:28:06 +01:00 committed by GitHub
parent 35c2950d33
commit 0aedc0787f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -340,15 +340,12 @@ func (w *wallet) selfDerive() {
var ( var (
accs []accounts.Account accs []accounts.Account
paths []accounts.DerivationPath paths []accounts.DerivationPath
context = context.Background()
nextPaths = append([]accounts.DerivationPath{}, w.deriveNextPaths...)
nextAddrs = append([]common.Address{}, w.deriveNextAddrs...) nextAddrs = append([]common.Address{}, w.deriveNextAddrs...)
context = context.Background()
) )
// Deep-copy derivation paths so updates inside this section don't mutate
// w.deriveNextPaths while we only hold stateLock.RLock.
nextPaths := make([]accounts.DerivationPath, len(w.deriveNextPaths))
for i, path := range w.deriveNextPaths {
nextPaths[i] = append(accounts.DerivationPath(nil), path...)
}
for i := 0; i < len(nextAddrs); i++ { for i := 0; i < len(nextAddrs); i++ {
for empty := false; !empty; { for empty := false; !empty; {
// Retrieve the next derived Ethereum account // Retrieve the next derived Ethereum account
@ -635,7 +632,7 @@ func (w *wallet) SignTx(account accounts.Account, tx *types.Transaction, chainID
// data is not supported for Ledger wallets, so this method will always return // data is not supported for Ledger wallets, so this method will always return
// an error. // an error.
func (w *wallet) SignTextWithPassphrase(account accounts.Account, passphrase string, text []byte) ([]byte, error) { func (w *wallet) SignTextWithPassphrase(account accounts.Account, passphrase string, text []byte) ([]byte, error) {
return w.SignText(account, text) return w.SignText(account, accounts.TextHash(text))
} }
// SignTxWithPassphrase implements accounts.Wallet, attempting to sign the given // SignTxWithPassphrase implements accounts.Wallet, attempting to sign the given