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