mirror of
https://github.com/status-im/status-go.git
synced 2025-02-02 09:56:52 +00:00
feat_: add KeycardPairingKey for mobile (#6101)
This commit is contained in:
parent
735a422230
commit
c2d79e785e
@ -1713,24 +1713,33 @@ func (b *GethStatusBackend) prepareForKeycard(request *requests.CreateAccount, i
|
|||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
kp := wallet.NewKeycardPairings()
|
if request.KeycardPairingKey != "" {
|
||||||
kp.SetKeycardPairingsFile(response.nodeConfig.KeycardPairingDataFile)
|
// KeycardPairingKey is used only on mobile
|
||||||
pairings, err := kp.GetPairings()
|
response.settings.KeycardPairing = request.KeycardPairingKey
|
||||||
if err != nil {
|
response.account.KeycardPairing = request.KeycardPairingKey
|
||||||
return nil, errors.Wrap(err, "failed to get keycard pairings")
|
} else {
|
||||||
}
|
// KeycardPairingDataFile is used only on desktop
|
||||||
|
kp := wallet.NewKeycardPairings()
|
||||||
|
kp.SetKeycardPairingsFile(response.nodeConfig.KeycardPairingDataFile)
|
||||||
|
pairings, err := kp.GetPairings()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "failed to get keycard pairings")
|
||||||
|
}
|
||||||
|
|
||||||
keycard, ok := pairings[request.KeycardInstanceUID]
|
keycard, ok := pairings[request.KeycardInstanceUID]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errors.New("keycard not found in pairings file")
|
return nil, errors.New("keycard not found in pairings file")
|
||||||
|
}
|
||||||
|
|
||||||
|
response.settings.KeycardPairing = keycard.Key
|
||||||
|
response.account.KeycardPairing = keycard.Key
|
||||||
}
|
}
|
||||||
|
|
||||||
response.settings.KeycardInstanceUID = request.KeycardInstanceUID
|
response.settings.KeycardInstanceUID = request.KeycardInstanceUID
|
||||||
response.settings.KeycardPairedOn = time.Now().Unix()
|
response.settings.KeycardPairedOn = time.Now().Unix()
|
||||||
response.settings.KeycardPairing = keycard.Key
|
|
||||||
response.account.KeycardPairing = keycard.Key
|
|
||||||
|
|
||||||
privateKeyHex := strings.TrimPrefix(input.derivedAddresses[pathDefaultChat].PrivateKey, "0x")
|
privateKeyHex := strings.TrimPrefix(input.derivedAddresses[pathDefaultChat].PrivateKey, "0x")
|
||||||
|
var err error
|
||||||
response.chatPrivateKey, err = crypto.HexToECDSA(privateKeyHex)
|
response.chatPrivateKey, err = crypto.HexToECDSA(privateKeyHex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to parse chat private key hex")
|
return nil, errors.Wrap(err, "failed to parse chat private key hex")
|
||||||
|
@ -79,7 +79,11 @@ type CreateAccount struct {
|
|||||||
|
|
||||||
APIConfig *APIConfig `json:"apiConfig"`
|
APIConfig *APIConfig `json:"apiConfig"`
|
||||||
|
|
||||||
KeycardInstanceUID string `json:"keycardInstanceUID"`
|
KeycardInstanceUID string `json:"keycardInstanceUID"`
|
||||||
|
|
||||||
|
// on mobile there is no KeycardPairingDataFile, so for now KeycardPairingKey will be used
|
||||||
|
// for recovering account
|
||||||
|
KeycardPairingKey string `json:"keycardPairingKey"`
|
||||||
KeycardPairingDataFile *string `json:"keycardPairingDataFile"`
|
KeycardPairingDataFile *string `json:"keycardPairingDataFile"`
|
||||||
StatusProxyEnabled bool `json:"statusProxyEnabled"`
|
StatusProxyEnabled bool `json:"statusProxyEnabled"`
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user