@@ -15,7 +15,7 @@ import (
1515// If it's a profile keypair, it also sets the chat account.
1616// Passed `walletAccount` is used to generate address using its path and set other details accordingly.
1717func (m * AccountsManager ) CreateKeypairFromMnemonicAndStore (mnemonic string , password string , keypairName string ,
18- walletAccount * types.AccountCreationDetails , profile bool , clock uint64 ) (keypair * types.Keypair , err error ) {
18+ coldWallet types. ColdWalletType , walletAccount * types.AccountCreationDetails , profile bool , clock uint64 ) (keypair * types.Keypair , err error ) {
1919
2020 if walletAccount == nil {
2121 err = ErrKeypairDoesNotHaveWalletAccount
@@ -75,8 +75,14 @@ func (m *AccountsManager) CreateKeypairFromMnemonicAndStore(mnemonic string, pas
7575 m .setKeystore (keystore )
7676 }
7777
78+ walletXPub , err := generator .DeriveExtendedPublicKeyAtPath (mnemonic , "" , common .PathWalletXPub )
79+ if err != nil {
80+ return
81+ }
82+
7883 // prepare keypair
79- keypair , err = m .prepareKeypair (masterAccount , derivedAccounts , keypairName , walletAccount , keypairType , profile , clock )
84+ keypair , err = m .prepareKeypair (masterAccount , derivedAccounts , keypairName , walletAccount , keypairType , profile ,
85+ walletXPub , coldWallet , clock )
8086 if err != nil {
8187 return
8288 }
@@ -105,7 +111,7 @@ func (m *AccountsManager) CreateKeypairFromMnemonicAndStore(mnemonic string, pas
105111 return
106112}
107113
108- func (m * AccountsManager ) AddKeypairStoredToKeycard (keyUID string , masterAddress string , name string , xpub string ,
114+ func (m * AccountsManager ) AddKeypairStoredToColdWallet (keyUID string , masterAddress string , name string , walletXPub string ,
109115 coldWallet types.ColdWalletType , walletAccounts []* types.Account , clock uint64 ) (keypair * types.Keypair , err error ) {
110116
111117 if len (walletAccounts ) == 0 {
@@ -161,7 +167,7 @@ func (m *AccountsManager) AddKeypairStoredToKeycard(keyUID string, masterAddress
161167 LastUsedDerivationIndex : 0 ,
162168 Clock : clock ,
163169 Accounts : walletAccounts ,
164- XPub : xpub ,
170+ XPub : walletXPub ,
165171 ColdWallet : coldWallet ,
166172 }
167173
@@ -172,7 +178,8 @@ func (m *AccountsManager) AddKeypairStoredToKeycard(keyUID string, masterAddress
172178}
173179
174180func (m * AccountsManager ) prepareKeypair (account * generator.Account , derivedAccounts map [string ]* generator.Account , keypairName string ,
175- walletAccount * types.AccountCreationDetails , keypairType types.KeypairType , profile bool , clock uint64 ) (* types.Keypair , error ) {
181+ walletAccount * types.AccountCreationDetails , keypairType types.KeypairType , profile bool , walletXPub string , coldWallet types.ColdWalletType ,
182+ clock uint64 ) (* types.Keypair , error ) {
176183 // set up keypair
177184 keypair := & types.Keypair {
178185 Name : keypairName ,
@@ -181,6 +188,8 @@ func (m *AccountsManager) prepareKeypair(account *generator.Account, derivedAcco
181188 DerivedFrom : account .Address ().Hex (),
182189 LastUsedDerivationIndex : 0 ,
183190 Clock : clock ,
191+ XPub : walletXPub ,
192+ ColdWallet : coldWallet ,
184193 }
185194
186195 // add chat account
@@ -279,7 +288,8 @@ func (m *AccountsManager) CreateKeypairFromPrivateKeyAndStore(privateKey string,
279288 }
280289
281290 // prepare keypair
282- keypair , err = m .prepareKeypair (masterAccount , nil , keypairName , walletAccount , types .KeypairTypeKey , false , clock )
291+ keypair , err = m .prepareKeypair (masterAccount , nil , keypairName , walletAccount , types .KeypairTypeKey , false , "" ,
292+ types .ColdWalletTypeNone , clock )
283293 if err != nil {
284294 return nil , err
285295 }
0 commit comments