Skip to content

Commit cae4ea4

Browse files
committed
fix(backup)_: use compressed pubkey for the local backup name
It is the name that users are used to see, so it will be less confusing
1 parent b949655 commit cae4ea4

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

node/get_status_node.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"github.com/status-im/status-go/services/status"
4242
"github.com/status-im/status-go/services/stickers"
4343
"github.com/status-im/status-go/services/updates"
44+
"github.com/status-im/status-go/services/utils"
4445
"github.com/status-im/status-go/services/wakuv2ext"
4546
"github.com/status-im/status-go/services/wallet"
4647
"github.com/status-im/status-go/timesource"
@@ -214,32 +215,35 @@ func (n *StatusNode) StartLocalBackup() error {
214215
}
215216
}
216217

218+
chatAccount, err := n.gethAccountsManager.SelectedChatAccount()
219+
if err != nil {
220+
return err
221+
}
222+
223+
privateKey := chatAccount.PrivateKey()
224+
217225
filenameGetter := func() (string, error) {
218-
profileKeypair, err := n.accountsSrvc.GetProfileKeypair()
226+
backupPath, err := n.accountsSrvc.GetBackupPath()
219227
if err != nil {
220228
return "", err
221229
}
222230

223-
backupPath, err := n.accountsSrvc.GetBackupPath()
231+
compressedPubKey, err := utils.SerializePublicKey(crypto.CompressPubkey(&privateKey.PublicKey))
224232
if err != nil {
225233
return "", err
226234
}
235+
227236
var backupDir string
228237
if backupPath != "" {
229238
backupDir = backupPath
230239
} else {
231240
backupDir = filepath.Join(n.config.RootDataDir, "backups")
232241
}
233-
fullPath := filepath.Join(backupDir, fmt.Sprintf("%x_user_data.bkp", profileKeypair.KeyUID[len(profileKeypair.KeyUID)-4:]))
234-
return fullPath, nil
235-
}
236242

237-
chatAccount, err := n.gethAccountsManager.SelectedChatAccount()
238-
if err != nil {
239-
return err
240-
}
243+
fullPath := filepath.Join(backupDir, fmt.Sprintf("%s_user_data.bkp", compressedPubKey[len(compressedPubKey)-6:]))
241244

242-
privateKey := chatAccount.PrivateKey()
245+
return fullPath, nil
246+
}
243247

244248
n.localBackup, err = backup.NewController(backup.BackupConfig{
245249
PrivateKey: crypto.Keccak256(crypto.FromECDSA(privateKey)),

services/accounts/service.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ func (s *Service) AccountsAPI() *API {
9494
return NewAccountsAPI(s.manager, s.config, s.db, &s.messenger, s.publisher)
9595
}
9696

97-
func (s *Service) GetProfileKeypair() (*accsmanagementtypes.Keypair, error) {
98-
return s.db.GetProfileKeypair()
99-
}
100-
10197
func (s *Service) GetKeypairByKeyUID(keyUID string) (*accsmanagementtypes.Keypair, error) {
10298
return s.db.GetKeypairByKeyUID(keyUID)
10399
}

0 commit comments

Comments
 (0)