fix: changes lost while rebasing
- send transferred keyuids instead of number of transferred files - updating keypair's operability for transferred keypairs - unnecessary check of a number of transferred keystore files
This commit is contained in:
parent
3bf0bed78d
commit
3c6087e5c4
|
@ -177,10 +177,6 @@ func emptyDir(dir string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateReceivedKeystoreFiles(expectedKeys []string, keys map[string][]byte, password string) error {
|
func validateReceivedKeystoreFiles(expectedKeys []string, keys map[string][]byte, password string) error {
|
||||||
if len(expectedKeys) != len(keys) {
|
|
||||||
return fmt.Errorf("one or more keystore files were not sent")
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, searchKey := range expectedKeys {
|
for _, searchKey := range expectedKeys {
|
||||||
found := false
|
found := false
|
||||||
for key := range keys {
|
for key := range keys {
|
||||||
|
|
|
@ -371,7 +371,7 @@ func NewKeystoreFilesPayloadReceiver(backend *api.GethStatusBackend, e *PayloadE
|
||||||
|
|
||||||
return NewBasePayloadReceiver(e, NewPairingPayloadMarshaller(p, l), kfps,
|
return NewBasePayloadReceiver(e, NewPairingPayloadMarshaller(p, l), kfps,
|
||||||
func() {
|
func() {
|
||||||
data := len(p.keys)
|
data := config.KeypairsToImport
|
||||||
signal.SendLocalPairingEvent(Event{Type: EventReceivedKeystoreFiles, Action: ActionKeystoreFilesTransfer, Data: data})
|
signal.SendLocalPairingEvent(Event{Type: EventReceivedKeystoreFiles, Action: ActionKeystoreFilesTransfer, Data: data})
|
||||||
},
|
},
|
||||||
), nil
|
), nil
|
||||||
|
@ -382,7 +382,9 @@ type KeystoreFilesPayloadStorer struct {
|
||||||
|
|
||||||
keystorePath string
|
keystorePath string
|
||||||
loggedInKeyUID string
|
loggedInKeyUID string
|
||||||
|
expectedKeypairsToImport []string
|
||||||
expectedKeystoreFilesToReceive []string
|
expectedKeystoreFilesToReceive []string
|
||||||
|
backend *api.GethStatusBackend
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewKeystoreFilesPayloadStorer(backend *api.GethStatusBackend, p *AccountPayload, config *KeystoreFilesReceiverConfig) (*KeystoreFilesPayloadStorer, error) {
|
func NewKeystoreFilesPayloadStorer(backend *api.GethStatusBackend, p *AccountPayload, config *KeystoreFilesReceiverConfig) (*KeystoreFilesPayloadStorer, error) {
|
||||||
|
@ -394,11 +396,13 @@ func NewKeystoreFilesPayloadStorer(backend *api.GethStatusBackend, p *AccountPay
|
||||||
AccountPayload: p,
|
AccountPayload: p,
|
||||||
keystorePath: config.KeystorePath,
|
keystorePath: config.KeystorePath,
|
||||||
loggedInKeyUID: config.LoggedInKeyUID,
|
loggedInKeyUID: config.LoggedInKeyUID,
|
||||||
|
expectedKeypairsToImport: config.KeypairsToImport,
|
||||||
|
backend: backend,
|
||||||
}
|
}
|
||||||
|
|
||||||
accountService := backend.StatusNode().AccountService()
|
accountService := backend.StatusNode().AccountService()
|
||||||
|
|
||||||
for _, keyUID := range config.KeypairsToImport {
|
for _, keyUID := range kfps.expectedKeypairsToImport {
|
||||||
kp, err := accountService.GetKeypairByKeyUID(keyUID)
|
kp, err := accountService.GetKeypairByKeyUID(keyUID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -426,6 +430,11 @@ func (kfps *KeystoreFilesPayloadStorer) Store() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (kfps *KeystoreFilesPayloadStorer) storeKeys(keyStorePath string) error {
|
func (kfps *KeystoreFilesPayloadStorer) storeKeys(keyStorePath string) error {
|
||||||
|
messenger := kfps.backend.Messenger()
|
||||||
|
if messenger == nil {
|
||||||
|
return fmt.Errorf("messenger is nil")
|
||||||
|
}
|
||||||
|
|
||||||
if keyStorePath == "" {
|
if keyStorePath == "" {
|
||||||
return fmt.Errorf("keyStorePath can not be empty")
|
return fmt.Errorf("keyStorePath can not be empty")
|
||||||
}
|
}
|
||||||
|
@ -471,5 +480,13 @@ func (kfps *KeystoreFilesPayloadStorer) storeKeys(keyStorePath string) error {
|
||||||
return writeErr
|
return writeErr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, keyUID := range kfps.expectedKeypairsToImport {
|
||||||
|
err := messenger.MarkKeypairFullyOperable(keyUID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue