|
|
@ -346,19 +346,28 @@ func (api *SignerAPI) startUSBListener() { |
|
|
|
case accounts.WalletOpened: |
|
|
|
case accounts.WalletOpened: |
|
|
|
status, _ := event.Wallet.Status() |
|
|
|
status, _ := event.Wallet.Status() |
|
|
|
log.Info("New wallet appeared", "url", event.Wallet.URL(), "status", status) |
|
|
|
log.Info("New wallet appeared", "url", event.Wallet.URL(), "status", status) |
|
|
|
|
|
|
|
var derive = func(numToDerive int, base accounts.DerivationPath) { |
|
|
|
// Derive first N accounts, hardcoded for now
|
|
|
|
// Derive first N accounts, hardcoded for now
|
|
|
|
var nextPath = make(accounts.DerivationPath, len(accounts.DefaultBaseDerivationPath)) |
|
|
|
var nextPath = make(accounts.DerivationPath, len(base)) |
|
|
|
copy(nextPath[:], accounts.DefaultBaseDerivationPath[:]) |
|
|
|
copy(nextPath[:], base[:]) |
|
|
|
|
|
|
|
|
|
|
|
for i := 0; i < numberOfAccountsToDerive; i++ { |
|
|
|
for i := 0; i < numToDerive; i++ { |
|
|
|
acc, err := event.Wallet.Derive(nextPath, true) |
|
|
|
acc, err := event.Wallet.Derive(nextPath, true) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Warn("account derivation failed", "error", err) |
|
|
|
log.Warn("Account derivation failed", "error", err) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
log.Info("derived account", "address", acc.Address) |
|
|
|
log.Info("Derived account", "address", acc.Address, "path", nextPath) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
nextPath[len(nextPath)-1]++ |
|
|
|
} |
|
|
|
} |
|
|
|
nextPath[len(nextPath)-1]++ |
|
|
|
} |
|
|
|
|
|
|
|
if event.Wallet.URL().Scheme == "ledger" { |
|
|
|
|
|
|
|
log.Info("Deriving ledger default paths") |
|
|
|
|
|
|
|
derive(numberOfAccountsToDerive/2, accounts.DefaultBaseDerivationPath) |
|
|
|
|
|
|
|
log.Info("Deriving ledger legacy paths") |
|
|
|
|
|
|
|
derive(numberOfAccountsToDerive/2, accounts.LegacyLedgerBaseDerivationPath) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
derive(numberOfAccountsToDerive, accounts.DefaultBaseDerivationPath) |
|
|
|
} |
|
|
|
} |
|
|
|
case accounts.WalletDropped: |
|
|
|
case accounts.WalletDropped: |
|
|
|
log.Info("Old wallet dropped", "url", event.Wallet.URL()) |
|
|
|
log.Info("Old wallet dropped", "url", event.Wallet.URL()) |
|
|
|