fix: Add derivation path to wallet account generation (#2618)
This commit is contained in:
parent
5e2a33115c
commit
b83f4a6c83
|
@ -275,8 +275,6 @@ func (g *Generator) store(acc *Account, password string) (AccountInfo, error) {
|
|||
}
|
||||
}
|
||||
|
||||
g.Reset()
|
||||
|
||||
return acc.ToAccountInfo(), nil
|
||||
}
|
||||
|
||||
|
|
|
@ -1,28 +1,29 @@
|
|||
// Code generated by go-bindata. DO NOT EDIT.
|
||||
// Code generated by go-bindata.
|
||||
// sources:
|
||||
// 1640111208_dummy.up.sql (258B)
|
||||
// 1642666031_add_removed_clock_to_bookmarks.up.sql (117B)
|
||||
// 1643644541_gif_api_key_setting.up.sql (108B)
|
||||
// 1644188994_recent_stickers.up.sql (79B)
|
||||
// 1646659233_add_address_to_dapp_permisssion.up.sql (700B)
|
||||
// 1646841105_add_emoji_account.up.sql (96B)
|
||||
// 1647278782_display_name.up.sql (110B)
|
||||
// 1647862838_reset_last_backup.up.sql (37B)
|
||||
// 1647871652_add_settings_sync_clock_table.up.sql (1.044kB)
|
||||
// 1647880168_add_torrent_config.up.sql (211B)
|
||||
// 1647882837_add_communities_settings_table.up.sql (206B)
|
||||
// 1647956635_add_waku_messages_table.up.sql (266B)
|
||||
// 1648554928_network_test.up.sql (132B)
|
||||
// 1649164719_add_community_archives_info_table.up.sql (208B)
|
||||
// 1649174829_add_visitble_token.up.sql (84B)
|
||||
// doc.go (74B)
|
||||
// 1640111208_dummy.up.sql
|
||||
// 1642666031_add_removed_clock_to_bookmarks.up.sql
|
||||
// 1643644541_gif_api_key_setting.up.sql
|
||||
// 1644188994_recent_stickers.up.sql
|
||||
// 1646659233_add_address_to_dapp_permisssion.up.sql
|
||||
// 1646841105_add_emoji_account.up.sql
|
||||
// 1647278782_display_name.up.sql
|
||||
// 1647862838_reset_last_backup.up.sql
|
||||
// 1647871652_add_settings_sync_clock_table.up.sql
|
||||
// 1647880168_add_torrent_config.up.sql
|
||||
// 1647882837_add_communities_settings_table.up.sql
|
||||
// 1647956635_add_waku_messages_table.up.sql
|
||||
// 1648554928_network_test.up.sql
|
||||
// 1648826780_add_derived_from_accounts.up.sql
|
||||
// 1649164719_add_community_archives_info_table.up.sql
|
||||
// 1649174829_add_visitble_token.up.sql
|
||||
// doc.go
|
||||
// DO NOT EDIT!
|
||||
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
@ -35,7 +36,7 @@ import (
|
|||
func bindataRead(data []byte, name string) ([]byte, error) {
|
||||
gz, err := gzip.NewReader(bytes.NewBuffer(data))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read %q: %w", name, err)
|
||||
return nil, fmt.Errorf("Read %q: %v", name, err)
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
|
@ -43,7 +44,7 @@ func bindataRead(data []byte, name string) ([]byte, error) {
|
|||
clErr := gz.Close()
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read %q: %w", name, err)
|
||||
return nil, fmt.Errorf("Read %q: %v", name, err)
|
||||
}
|
||||
if clErr != nil {
|
||||
return nil, err
|
||||
|
@ -53,9 +54,8 @@ func bindataRead(data []byte, name string) ([]byte, error) {
|
|||
}
|
||||
|
||||
type asset struct {
|
||||
bytes []byte
|
||||
info os.FileInfo
|
||||
digest [sha256.Size]byte
|
||||
bytes []byte
|
||||
info os.FileInfo
|
||||
}
|
||||
|
||||
type bindataFileInfo struct {
|
||||
|
@ -99,8 +99,8 @@ func _1640111208_dummyUpSql() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1640111208_dummy.up.sql", size: 258, mode: os.FileMode(0664), modTime: time.Unix(1649674292, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x3e, 0xf0, 0xae, 0x20, 0x6e, 0x75, 0xd1, 0x36, 0x14, 0xf2, 0x40, 0xe5, 0xd6, 0x7a, 0xc4, 0xa5, 0x72, 0xaa, 0xb5, 0x4d, 0x71, 0x97, 0xb8, 0xe8, 0x95, 0x22, 0x95, 0xa2, 0xac, 0xaf, 0x48, 0x58}}
|
||||
info := bindataFileInfo{name: "1640111208_dummy.up.sql", size: 258, mode: os.FileMode(436), modTime: time.Unix(1649749129, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -119,8 +119,8 @@ func _1642666031_add_removed_clock_to_bookmarksUpSql() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1642666031_add_removed_clock_to_bookmarks.up.sql", size: 117, mode: os.FileMode(0664), modTime: time.Unix(1649674292, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x84, 0x4e, 0x38, 0x99, 0x7a, 0xc, 0x90, 0x13, 0xec, 0xfe, 0x2f, 0x55, 0xff, 0xb7, 0xb6, 0xaa, 0x96, 0xc6, 0x92, 0x79, 0xcc, 0xee, 0x4e, 0x99, 0x53, 0xfe, 0x1c, 0xbb, 0x32, 0x2, 0xa4, 0x27}}
|
||||
info := bindataFileInfo{name: "1642666031_add_removed_clock_to_bookmarks.up.sql", size: 117, mode: os.FileMode(436), modTime: time.Unix(1649749129, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -139,8 +139,8 @@ func _1643644541_gif_api_key_settingUpSql() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1643644541_gif_api_key_setting.up.sql", size: 108, mode: os.FileMode(0664), modTime: time.Unix(1649674292, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1b, 0x94, 0x28, 0xfb, 0x66, 0xd1, 0x7c, 0xb8, 0x89, 0xe2, 0xb4, 0x71, 0x65, 0x24, 0x57, 0x22, 0x95, 0x38, 0x97, 0x3, 0x9b, 0xc6, 0xa4, 0x41, 0x7b, 0xba, 0xf7, 0xdb, 0x70, 0xf7, 0x20, 0x3a}}
|
||||
info := bindataFileInfo{name: "1643644541_gif_api_key_setting.up.sql", size: 108, mode: os.FileMode(436), modTime: time.Unix(1649749129, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -159,8 +159,8 @@ func _1644188994_recent_stickersUpSql() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1644188994_recent_stickers.up.sql", size: 79, mode: os.FileMode(0664), modTime: time.Unix(1649674292, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1e, 0xad, 0xaa, 0x30, 0xbf, 0x4, 0x7, 0xf8, 0xc3, 0x3, 0xb8, 0x97, 0x23, 0x2b, 0xbd, 0x1c, 0x60, 0x69, 0xb0, 0x42, 0x5e, 0x6b, 0xd, 0xa7, 0xa3, 0x6b, 0x2e, 0xdc, 0x70, 0x13, 0x72, 0x7}}
|
||||
info := bindataFileInfo{name: "1644188994_recent_stickers.up.sql", size: 79, mode: os.FileMode(436), modTime: time.Unix(1649749129, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -179,8 +179,8 @@ func _1646659233_add_address_to_dapp_permisssionUpSql() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1646659233_add_address_to_dapp_permisssion.up.sql", size: 700, mode: os.FileMode(0664), modTime: time.Unix(1649674292, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xed, 0xb0, 0x35, 0xcc, 0x2e, 0x16, 0xe6, 0x15, 0x86, 0x2c, 0x37, 0x80, 0xae, 0xa3, 0xc5, 0x31, 0x78, 0x5, 0x9d, 0xcd, 0x7b, 0xeb, 0x5f, 0xf2, 0xb3, 0x74, 0x72, 0xdf, 0xcf, 0x88, 0xb, 0x40}}
|
||||
info := bindataFileInfo{name: "1646659233_add_address_to_dapp_permisssion.up.sql", size: 700, mode: os.FileMode(436), modTime: time.Unix(1649749129, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -199,8 +199,8 @@ func _1646841105_add_emoji_accountUpSql() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1646841105_add_emoji_account.up.sql", size: 96, mode: os.FileMode(0664), modTime: time.Unix(1649674292, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe6, 0x77, 0x29, 0x95, 0x18, 0x64, 0x82, 0x63, 0xe7, 0xaf, 0x6c, 0xa9, 0x15, 0x7d, 0x46, 0xa6, 0xbc, 0xdf, 0xa7, 0xd, 0x2b, 0xd2, 0x2d, 0x97, 0x4d, 0xa, 0x6b, 0xd, 0x6e, 0x90, 0x42, 0x5c}}
|
||||
info := bindataFileInfo{name: "1646841105_add_emoji_account.up.sql", size: 96, mode: os.FileMode(436), modTime: time.Unix(1649749129, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -219,8 +219,8 @@ func _1647278782_display_nameUpSql() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1647278782_display_name.up.sql", size: 110, mode: os.FileMode(0664), modTime: time.Unix(1649674292, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf4, 0xa1, 0x1f, 0x3e, 0x61, 0x65, 0x8d, 0xff, 0xee, 0xde, 0xc5, 0x91, 0xd9, 0x5c, 0xb5, 0xe2, 0xf0, 0xb7, 0xe7, 0x5c, 0x5c, 0x16, 0x25, 0x89, 0xee, 0x78, 0x12, 0xea, 0x3e, 0x48, 0x41, 0xa6}}
|
||||
info := bindataFileInfo{name: "1647278782_display_name.up.sql", size: 110, mode: os.FileMode(436), modTime: time.Unix(1649749129, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -239,8 +239,8 @@ func _1647862838_reset_last_backupUpSql() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1647862838_reset_last_backup.up.sql", size: 37, mode: os.FileMode(0664), modTime: time.Unix(1649674292, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x21, 0xe3, 0xd5, 0xf6, 0x5f, 0xfe, 0x65, 0xfa, 0x1d, 0x88, 0xf8, 0x5f, 0x24, 0x71, 0x34, 0x68, 0x96, 0x2a, 0x60, 0x87, 0x15, 0x82, 0x4d, 0x8a, 0x59, 0x3d, 0x1f, 0xd8, 0x56, 0xd4, 0xfb, 0xda}}
|
||||
info := bindataFileInfo{name: "1647862838_reset_last_backup.up.sql", size: 37, mode: os.FileMode(436), modTime: time.Unix(1649749129, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -259,8 +259,8 @@ func _1647871652_add_settings_sync_clock_tableUpSql() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1647871652_add_settings_sync_clock_table.up.sql", size: 1044, mode: os.FileMode(0664), modTime: time.Unix(1649674292, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd8, 0x58, 0xec, 0x85, 0x90, 0xfa, 0x30, 0x98, 0x98, 0x9a, 0xa6, 0xa8, 0x96, 0x2b, 0x38, 0x93, 0xf3, 0xae, 0x46, 0x74, 0xa4, 0x41, 0x62, 0x9b, 0x2, 0x86, 0xbf, 0xe5, 0x2a, 0xce, 0xe2, 0xc0}}
|
||||
info := bindataFileInfo{name: "1647871652_add_settings_sync_clock_table.up.sql", size: 1044, mode: os.FileMode(436), modTime: time.Unix(1649749129, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -279,8 +279,8 @@ func _1647880168_add_torrent_configUpSql() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1647880168_add_torrent_config.up.sql", size: 211, mode: os.FileMode(0664), modTime: time.Unix(1649674292, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1, 0x92, 0x22, 0x37, 0x96, 0xf3, 0xb5, 0x5b, 0x27, 0xd0, 0x7d, 0x43, 0x5, 0x4e, 0x9d, 0xe2, 0x49, 0xbe, 0x86, 0x31, 0xa1, 0x89, 0xff, 0xd6, 0x51, 0xe0, 0x9c, 0xb, 0xda, 0xfc, 0xf2, 0x93}}
|
||||
info := bindataFileInfo{name: "1647880168_add_torrent_config.up.sql", size: 211, mode: os.FileMode(436), modTime: time.Unix(1649749129, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -299,8 +299,8 @@ func _1647882837_add_communities_settings_tableUpSql() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1647882837_add_communities_settings_table.up.sql", size: 206, mode: os.FileMode(0664), modTime: time.Unix(1649674292, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xbd, 0x87, 0x78, 0x99, 0xd9, 0x5d, 0xbd, 0xf7, 0x57, 0x9c, 0xca, 0x97, 0xbd, 0xb3, 0xe9, 0xb5, 0x89, 0x31, 0x3f, 0xf6, 0x5c, 0x13, 0xb, 0xc3, 0x54, 0x93, 0x18, 0x40, 0x7, 0x82, 0xfe, 0x7e}}
|
||||
info := bindataFileInfo{name: "1647882837_add_communities_settings_table.up.sql", size: 206, mode: os.FileMode(436), modTime: time.Unix(1649749129, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -319,8 +319,8 @@ func _1647956635_add_waku_messages_tableUpSql() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1647956635_add_waku_messages_table.up.sql", size: 266, mode: os.FileMode(0664), modTime: time.Unix(1649674292, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd1, 0xe, 0xe1, 0xdc, 0xda, 0x2e, 0x89, 0x8d, 0xdc, 0x2a, 0x1c, 0x13, 0xa1, 0xfc, 0xfe, 0xf, 0xb2, 0xb9, 0x85, 0xc8, 0x45, 0xd6, 0xd1, 0x7, 0x5c, 0xa3, 0x8, 0x47, 0x44, 0x6d, 0x96, 0xe0}}
|
||||
info := bindataFileInfo{name: "1647956635_add_waku_messages_table.up.sql", size: 266, mode: os.FileMode(436), modTime: time.Unix(1649749129, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -339,8 +339,28 @@ func _1648554928_network_testUpSql() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1648554928_network_test.up.sql", size: 132, mode: os.FileMode(0664), modTime: time.Unix(1649674292, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x9a, 0xc5, 0x7f, 0x87, 0xf3, 0x2c, 0xf7, 0xbb, 0xd3, 0x3a, 0x4e, 0x76, 0x88, 0xca, 0xaf, 0x73, 0xce, 0x8f, 0xa1, 0xf6, 0x3d, 0x4d, 0xed, 0x6f, 0x49, 0xf2, 0xfe, 0x56, 0x2a, 0x60, 0x68, 0xca}}
|
||||
info := bindataFileInfo{name: "1648554928_network_test.up.sql", size: 132, mode: os.FileMode(436), modTime: time.Unix(1649749129, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
var __1648826780_add_derived_from_accountsUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x4c\x4e\xce\x2f\xcd\x2b\x29\x56\x70\x74\x71\x51\x70\xf6\xf7\x09\xf5\xf5\x53\x48\x49\x2d\xca\x2c\x4b\x4d\x89\x4f\x2b\xca\xcf\x55\x08\x71\x8d\x08\x51\xf0\xf3\x0f\x51\xf0\x0b\xf5\xf1\x51\x70\x71\x75\x73\x0c\xf5\x09\x51\x50\x52\xb2\xe6\x0a\x0d\x70\x71\x0c\x41\x32\x21\xd8\x35\x04\x55\xab\x2d\x58\x19\x20\x00\x00\xff\xff\x3e\x48\xa7\x03\x6e\x00\x00\x00")
|
||||
|
||||
func _1648826780_add_derived_from_accountsUpSqlBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
__1648826780_add_derived_from_accountsUpSql,
|
||||
"1648826780_add_derived_from_accounts.up.sql",
|
||||
)
|
||||
}
|
||||
|
||||
func _1648826780_add_derived_from_accountsUpSql() (*asset, error) {
|
||||
bytes, err := _1648826780_add_derived_from_accountsUpSqlBytes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1648826780_add_derived_from_accounts.up.sql", size: 110, mode: os.FileMode(436), modTime: time.Unix(1649840191, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -359,8 +379,8 @@ func _1649164719_add_community_archives_info_tableUpSql() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1649164719_add_community_archives_info_table.up.sql", size: 208, mode: os.FileMode(0664), modTime: time.Unix(1649674439, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd1, 0x4f, 0x80, 0x45, 0xb9, 0xd9, 0x15, 0xe2, 0x78, 0xd0, 0xcb, 0x71, 0xc1, 0x1b, 0xb7, 0x1b, 0x1b, 0x97, 0xfe, 0x47, 0x53, 0x3c, 0x62, 0xbc, 0xdd, 0x3a, 0x94, 0x1a, 0xc, 0x48, 0x76, 0xe}}
|
||||
info := bindataFileInfo{name: "1649164719_add_community_archives_info_table.up.sql", size: 208, mode: os.FileMode(436), modTime: time.Unix(1649749129, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -379,8 +399,8 @@ func _1649174829_add_visitble_tokenUpSql() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1649174829_add_visitble_token.up.sql", size: 84, mode: os.FileMode(0664), modTime: time.Unix(1649674441, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa3, 0x22, 0xc0, 0x2b, 0x3f, 0x4f, 0x3d, 0x5e, 0x4c, 0x68, 0x7c, 0xd0, 0x15, 0x36, 0x9f, 0xec, 0xa1, 0x2a, 0x7b, 0xb4, 0xe3, 0xc6, 0xc9, 0xb4, 0x81, 0x50, 0x4a, 0x11, 0x3b, 0x35, 0x7, 0xcf}}
|
||||
info := bindataFileInfo{name: "1649174829_add_visitble_token.up.sql", size: 84, mode: os.FileMode(436), modTime: time.Unix(1649840191, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -399,8 +419,8 @@ func docGo() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "doc.go", size: 74, mode: os.FileMode(0664), modTime: time.Unix(1649674292, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xde, 0x7c, 0x28, 0xcd, 0x47, 0xf2, 0xfa, 0x7c, 0x51, 0x2d, 0xd8, 0x38, 0xb, 0xb0, 0x34, 0x9d, 0x4c, 0x62, 0xa, 0x9e, 0x28, 0xc3, 0x31, 0x23, 0xd9, 0xbb, 0x89, 0x9f, 0xa0, 0x89, 0x1f, 0xe8}}
|
||||
info := bindataFileInfo{name: "doc.go", size: 74, mode: os.FileMode(436), modTime: time.Unix(1649749129, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -408,8 +428,8 @@ func docGo() (*asset, error) {
|
|||
// It returns an error if the asset could not be found or
|
||||
// could not be loaded.
|
||||
func Asset(name string) ([]byte, error) {
|
||||
canonicalName := strings.Replace(name, "\\", "/", -1)
|
||||
if f, ok := _bindata[canonicalName]; ok {
|
||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||
if f, ok := _bindata[cannonicalName]; ok {
|
||||
a, err := f()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
|
||||
|
@ -419,12 +439,6 @@ func Asset(name string) ([]byte, error) {
|
|||
return nil, fmt.Errorf("Asset %s not found", name)
|
||||
}
|
||||
|
||||
// AssetString returns the asset contents as a string (instead of a []byte).
|
||||
func AssetString(name string) (string, error) {
|
||||
data, err := Asset(name)
|
||||
return string(data), err
|
||||
}
|
||||
|
||||
// MustAsset is like Asset but panics when Asset would return an error.
|
||||
// It simplifies safe initialization of global variables.
|
||||
func MustAsset(name string) []byte {
|
||||
|
@ -436,18 +450,12 @@ func MustAsset(name string) []byte {
|
|||
return a
|
||||
}
|
||||
|
||||
// MustAssetString is like AssetString but panics when Asset would return an
|
||||
// error. It simplifies safe initialization of global variables.
|
||||
func MustAssetString(name string) string {
|
||||
return string(MustAsset(name))
|
||||
}
|
||||
|
||||
// AssetInfo loads and returns the asset info for the given name.
|
||||
// It returns an error if the asset could not be found or
|
||||
// could not be loaded.
|
||||
func AssetInfo(name string) (os.FileInfo, error) {
|
||||
canonicalName := strings.Replace(name, "\\", "/", -1)
|
||||
if f, ok := _bindata[canonicalName]; ok {
|
||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||
if f, ok := _bindata[cannonicalName]; ok {
|
||||
a, err := f()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
|
||||
|
@ -457,33 +465,6 @@ func AssetInfo(name string) (os.FileInfo, error) {
|
|||
return nil, fmt.Errorf("AssetInfo %s not found", name)
|
||||
}
|
||||
|
||||
// AssetDigest returns the digest of the file with the given name. It returns an
|
||||
// error if the asset could not be found or the digest could not be loaded.
|
||||
func AssetDigest(name string) ([sha256.Size]byte, error) {
|
||||
canonicalName := strings.Replace(name, "\\", "/", -1)
|
||||
if f, ok := _bindata[canonicalName]; ok {
|
||||
a, err := f()
|
||||
if err != nil {
|
||||
return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s can't read by error: %v", name, err)
|
||||
}
|
||||
return a.digest, nil
|
||||
}
|
||||
return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s not found", name)
|
||||
}
|
||||
|
||||
// Digests returns a map of all known files and their checksums.
|
||||
func Digests() (map[string][sha256.Size]byte, error) {
|
||||
mp := make(map[string][sha256.Size]byte, len(_bindata))
|
||||
for name := range _bindata {
|
||||
a, err := _bindata[name]()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mp[name] = a.digest
|
||||
}
|
||||
return mp, nil
|
||||
}
|
||||
|
||||
// AssetNames returns the names of the assets.
|
||||
func AssetNames() []string {
|
||||
names := make([]string, 0, len(_bindata))
|
||||
|
@ -495,27 +476,25 @@ func AssetNames() []string {
|
|||
|
||||
// _bindata is a table, holding each asset generator, mapped to its name.
|
||||
var _bindata = map[string]func() (*asset, error){
|
||||
"1640111208_dummy.up.sql": _1640111208_dummyUpSql,
|
||||
"1642666031_add_removed_clock_to_bookmarks.up.sql": _1642666031_add_removed_clock_to_bookmarksUpSql,
|
||||
"1643644541_gif_api_key_setting.up.sql": _1643644541_gif_api_key_settingUpSql,
|
||||
"1644188994_recent_stickers.up.sql": _1644188994_recent_stickersUpSql,
|
||||
"1646659233_add_address_to_dapp_permisssion.up.sql": _1646659233_add_address_to_dapp_permisssionUpSql,
|
||||
"1646841105_add_emoji_account.up.sql": _1646841105_add_emoji_accountUpSql,
|
||||
"1647278782_display_name.up.sql": _1647278782_display_nameUpSql,
|
||||
"1647862838_reset_last_backup.up.sql": _1647862838_reset_last_backupUpSql,
|
||||
"1647871652_add_settings_sync_clock_table.up.sql": _1647871652_add_settings_sync_clock_tableUpSql,
|
||||
"1647880168_add_torrent_config.up.sql": _1647880168_add_torrent_configUpSql,
|
||||
"1647882837_add_communities_settings_table.up.sql": _1647882837_add_communities_settings_tableUpSql,
|
||||
"1647956635_add_waku_messages_table.up.sql": _1647956635_add_waku_messages_tableUpSql,
|
||||
"1648554928_network_test.up.sql": _1648554928_network_testUpSql,
|
||||
"1640111208_dummy.up.sql": _1640111208_dummyUpSql,
|
||||
"1642666031_add_removed_clock_to_bookmarks.up.sql": _1642666031_add_removed_clock_to_bookmarksUpSql,
|
||||
"1643644541_gif_api_key_setting.up.sql": _1643644541_gif_api_key_settingUpSql,
|
||||
"1644188994_recent_stickers.up.sql": _1644188994_recent_stickersUpSql,
|
||||
"1646659233_add_address_to_dapp_permisssion.up.sql": _1646659233_add_address_to_dapp_permisssionUpSql,
|
||||
"1646841105_add_emoji_account.up.sql": _1646841105_add_emoji_accountUpSql,
|
||||
"1647278782_display_name.up.sql": _1647278782_display_nameUpSql,
|
||||
"1647862838_reset_last_backup.up.sql": _1647862838_reset_last_backupUpSql,
|
||||
"1647871652_add_settings_sync_clock_table.up.sql": _1647871652_add_settings_sync_clock_tableUpSql,
|
||||
"1647880168_add_torrent_config.up.sql": _1647880168_add_torrent_configUpSql,
|
||||
"1647882837_add_communities_settings_table.up.sql": _1647882837_add_communities_settings_tableUpSql,
|
||||
"1647956635_add_waku_messages_table.up.sql": _1647956635_add_waku_messages_tableUpSql,
|
||||
"1648554928_network_test.up.sql": _1648554928_network_testUpSql,
|
||||
"1648826780_add_derived_from_accounts.up.sql": _1648826780_add_derived_from_accountsUpSql,
|
||||
"1649164719_add_community_archives_info_table.up.sql": _1649164719_add_community_archives_info_tableUpSql,
|
||||
"1649174829_add_visitble_token.up.sql": _1649174829_add_visitble_tokenUpSql,
|
||||
"doc.go": docGo,
|
||||
"1649174829_add_visitble_token.up.sql": _1649174829_add_visitble_tokenUpSql,
|
||||
"doc.go": docGo,
|
||||
}
|
||||
|
||||
// AssetDebug is true if the assets were built with the debug flag enabled.
|
||||
const AssetDebug = false
|
||||
|
||||
// AssetDir returns the file names below a certain
|
||||
// directory embedded in the file by go-bindata.
|
||||
// For example if you run go-bindata on data/... and data contains the
|
||||
|
@ -525,15 +504,15 @@ const AssetDebug = false
|
|||
// img/
|
||||
// a.png
|
||||
// b.png
|
||||
// then AssetDir("data") would return []string{"foo.txt", "img"},
|
||||
// AssetDir("data/img") would return []string{"a.png", "b.png"},
|
||||
// AssetDir("foo.txt") and AssetDir("notexist") would return an error, and
|
||||
// then AssetDir("data") would return []string{"foo.txt", "img"}
|
||||
// AssetDir("data/img") would return []string{"a.png", "b.png"}
|
||||
// AssetDir("foo.txt") and AssetDir("notexist") would return an error
|
||||
// AssetDir("") will return []string{"data"}.
|
||||
func AssetDir(name string) ([]string, error) {
|
||||
node := _bintree
|
||||
if len(name) != 0 {
|
||||
canonicalName := strings.Replace(name, "\\", "/", -1)
|
||||
pathList := strings.Split(canonicalName, "/")
|
||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||
pathList := strings.Split(cannonicalName, "/")
|
||||
for _, p := range pathList {
|
||||
node = node.Children[p]
|
||||
if node == nil {
|
||||
|
@ -555,27 +534,27 @@ type bintree struct {
|
|||
Func func() (*asset, error)
|
||||
Children map[string]*bintree
|
||||
}
|
||||
|
||||
var _bintree = &bintree{nil, map[string]*bintree{
|
||||
"1640111208_dummy.up.sql": {_1640111208_dummyUpSql, map[string]*bintree{}},
|
||||
"1642666031_add_removed_clock_to_bookmarks.up.sql": {_1642666031_add_removed_clock_to_bookmarksUpSql, map[string]*bintree{}},
|
||||
"1643644541_gif_api_key_setting.up.sql": {_1643644541_gif_api_key_settingUpSql, map[string]*bintree{}},
|
||||
"1644188994_recent_stickers.up.sql": {_1644188994_recent_stickersUpSql, map[string]*bintree{}},
|
||||
"1646659233_add_address_to_dapp_permisssion.up.sql": {_1646659233_add_address_to_dapp_permisssionUpSql, map[string]*bintree{}},
|
||||
"1646841105_add_emoji_account.up.sql": {_1646841105_add_emoji_accountUpSql, map[string]*bintree{}},
|
||||
"1647278782_display_name.up.sql": {_1647278782_display_nameUpSql, map[string]*bintree{}},
|
||||
"1647862838_reset_last_backup.up.sql": {_1647862838_reset_last_backupUpSql, map[string]*bintree{}},
|
||||
"1647871652_add_settings_sync_clock_table.up.sql": {_1647871652_add_settings_sync_clock_tableUpSql, map[string]*bintree{}},
|
||||
"1647880168_add_torrent_config.up.sql": {_1647880168_add_torrent_configUpSql, map[string]*bintree{}},
|
||||
"1647882837_add_communities_settings_table.up.sql": {_1647882837_add_communities_settings_tableUpSql, map[string]*bintree{}},
|
||||
"1647956635_add_waku_messages_table.up.sql": {_1647956635_add_waku_messages_tableUpSql, map[string]*bintree{}},
|
||||
"1648554928_network_test.up.sql": {_1648554928_network_testUpSql, map[string]*bintree{}},
|
||||
"1649164719_add_community_archives_info_table.up.sql": {_1649164719_add_community_archives_info_tableUpSql, map[string]*bintree{}},
|
||||
"1649174829_add_visitble_token.up.sql": {_1649174829_add_visitble_tokenUpSql, map[string]*bintree{}},
|
||||
"doc.go": {docGo, map[string]*bintree{}},
|
||||
"1640111208_dummy.up.sql": &bintree{_1640111208_dummyUpSql, map[string]*bintree{}},
|
||||
"1642666031_add_removed_clock_to_bookmarks.up.sql": &bintree{_1642666031_add_removed_clock_to_bookmarksUpSql, map[string]*bintree{}},
|
||||
"1643644541_gif_api_key_setting.up.sql": &bintree{_1643644541_gif_api_key_settingUpSql, map[string]*bintree{}},
|
||||
"1644188994_recent_stickers.up.sql": &bintree{_1644188994_recent_stickersUpSql, map[string]*bintree{}},
|
||||
"1646659233_add_address_to_dapp_permisssion.up.sql": &bintree{_1646659233_add_address_to_dapp_permisssionUpSql, map[string]*bintree{}},
|
||||
"1646841105_add_emoji_account.up.sql": &bintree{_1646841105_add_emoji_accountUpSql, map[string]*bintree{}},
|
||||
"1647278782_display_name.up.sql": &bintree{_1647278782_display_nameUpSql, map[string]*bintree{}},
|
||||
"1647862838_reset_last_backup.up.sql": &bintree{_1647862838_reset_last_backupUpSql, map[string]*bintree{}},
|
||||
"1647871652_add_settings_sync_clock_table.up.sql": &bintree{_1647871652_add_settings_sync_clock_tableUpSql, map[string]*bintree{}},
|
||||
"1647880168_add_torrent_config.up.sql": &bintree{_1647880168_add_torrent_configUpSql, map[string]*bintree{}},
|
||||
"1647882837_add_communities_settings_table.up.sql": &bintree{_1647882837_add_communities_settings_tableUpSql, map[string]*bintree{}},
|
||||
"1647956635_add_waku_messages_table.up.sql": &bintree{_1647956635_add_waku_messages_tableUpSql, map[string]*bintree{}},
|
||||
"1648554928_network_test.up.sql": &bintree{_1648554928_network_testUpSql, map[string]*bintree{}},
|
||||
"1648826780_add_derived_from_accounts.up.sql": &bintree{_1648826780_add_derived_from_accountsUpSql, map[string]*bintree{}},
|
||||
"1649164719_add_community_archives_info_table.up.sql": &bintree{_1649164719_add_community_archives_info_tableUpSql, map[string]*bintree{}},
|
||||
"1649174829_add_visitble_token.up.sql": &bintree{_1649174829_add_visitble_tokenUpSql, map[string]*bintree{}},
|
||||
"doc.go": &bintree{docGo, map[string]*bintree{}},
|
||||
}}
|
||||
|
||||
// RestoreAsset restores an asset under the given directory.
|
||||
// RestoreAsset restores an asset under the given directory
|
||||
func RestoreAsset(dir, name string) error {
|
||||
data, err := Asset(name)
|
||||
if err != nil {
|
||||
|
@ -593,10 +572,14 @@ func RestoreAsset(dir, name string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
||||
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RestoreAssets restores an asset under the given directory recursively.
|
||||
// RestoreAssets restores an asset under the given directory recursively
|
||||
func RestoreAssets(dir, name string) error {
|
||||
children, err := AssetDir(name)
|
||||
// File
|
||||
|
@ -614,6 +597,7 @@ func RestoreAssets(dir, name string) error {
|
|||
}
|
||||
|
||||
func _filePath(dir, name string) string {
|
||||
canonicalName := strings.Replace(name, "\\", "/", -1)
|
||||
return filepath.Join(append([]string{dir}, strings.Split(canonicalName, "/")...)...)
|
||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE accounts ADD COLUMN derived_from TEXT NOT NULL DEFAULT "";
|
||||
UPDATE accounts SET derived_from = "";
|
File diff suppressed because it is too large
Load Diff
|
@ -16,17 +16,18 @@ const (
|
|||
)
|
||||
|
||||
type Account struct {
|
||||
Address types.Address `json:"address"`
|
||||
Wallet bool `json:"wallet"`
|
||||
Chat bool `json:"chat"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Storage string `json:"storage,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
PublicKey types.HexBytes `json:"public-key,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Emoji string `json:"emoji"`
|
||||
Color string `json:"color"`
|
||||
Hidden bool `json:"hidden"`
|
||||
Address types.Address `json:"address"`
|
||||
Wallet bool `json:"wallet"`
|
||||
Chat bool `json:"chat"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Storage string `json:"storage,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
PublicKey types.HexBytes `json:"public-key,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Emoji string `json:"emoji"`
|
||||
Color string `json:"color"`
|
||||
Hidden bool `json:"hidden"`
|
||||
DerivedFrom string `json:"derived-from,omitempty"`
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -70,7 +71,7 @@ func (db Database) Close() error {
|
|||
}
|
||||
|
||||
func (db *Database) GetAccounts() ([]Account, error) {
|
||||
rows, err := db.db.Query("SELECT address, wallet, chat, type, storage, pubkey, path, name, emoji, color, hidden FROM accounts ORDER BY created_at")
|
||||
rows, err := db.db.Query("SELECT address, wallet, chat, type, storage, pubkey, path, name, emoji, color, hidden, derived_from FROM accounts ORDER BY created_at")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -81,7 +82,7 @@ func (db *Database) GetAccounts() ([]Account, error) {
|
|||
acc := Account{}
|
||||
err := rows.Scan(
|
||||
&acc.Address, &acc.Wallet, &acc.Chat, &acc.Type, &acc.Storage,
|
||||
&pubkey, &acc.Path, &acc.Name, &acc.Emoji, &acc.Color, &acc.Hidden)
|
||||
&pubkey, &acc.Path, &acc.Name, &acc.Emoji, &acc.Color, &acc.Hidden, &acc.DerivedFrom)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -95,13 +96,13 @@ func (db *Database) GetAccounts() ([]Account, error) {
|
|||
}
|
||||
|
||||
func (db *Database) GetAccountByAddress(address types.Address) (rst *Account, err error) {
|
||||
row := db.db.QueryRow("SELECT address, wallet, chat, type, storage, pubkey, path, name, emoji, color, hidden FROM accounts WHERE address = ? COLLATE NOCASE", address)
|
||||
row := db.db.QueryRow("SELECT address, wallet, chat, type, storage, pubkey, path, name, emoji, color, hidden, derived_from FROM accounts WHERE address = ? COLLATE NOCASE", address)
|
||||
|
||||
acc := &Account{}
|
||||
pubkey := []byte{}
|
||||
err = row.Scan(
|
||||
&acc.Address, &acc.Wallet, &acc.Chat, &acc.Type, &acc.Storage,
|
||||
&pubkey, &acc.Path, &acc.Name, &acc.Emoji, &acc.Color, &acc.Hidden)
|
||||
&pubkey, &acc.Path, &acc.Name, &acc.Emoji, &acc.Color, &acc.Hidden, &acc.DerivedFrom)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -133,7 +134,7 @@ func (db *Database) SaveAccounts(accounts []Account) (err error) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
update, err = tx.Prepare("UPDATE accounts SET wallet = ?, chat = ?, type = ?, storage = ?, pubkey = ?, path = ?, name = ?, emoji = ?, color = ?, hidden = ?, updated_at = datetime('now') WHERE address = ?")
|
||||
update, err = tx.Prepare("UPDATE accounts SET wallet = ?, chat = ?, type = ?, storage = ?, pubkey = ?, path = ?, name = ?, emoji = ?, color = ?, hidden = ?, derived_from = ?, updated_at = datetime('now') WHERE address = ?")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -143,7 +144,7 @@ func (db *Database) SaveAccounts(accounts []Account) (err error) {
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, err = update.Exec(acc.Wallet, acc.Chat, acc.Type, acc.Storage, acc.PublicKey, acc.Path, acc.Name, acc.Emoji, acc.Color, acc.Hidden, acc.Address)
|
||||
_, err = update.Exec(acc.Wallet, acc.Chat, acc.Type, acc.Storage, acc.PublicKey, acc.Path, acc.Name, acc.Emoji, acc.Color, acc.Hidden, acc.DerivedFrom, acc.Address)
|
||||
if err != nil {
|
||||
switch err.Error() {
|
||||
case uniqueChatConstraint:
|
||||
|
|
|
@ -32,6 +32,12 @@ type API struct {
|
|||
feed *event.Feed
|
||||
}
|
||||
|
||||
type DerivedAddress struct {
|
||||
Address common.Address `json:"address"`
|
||||
Path string `json:"path"`
|
||||
HasActivity bool `json:"hasActivity"`
|
||||
}
|
||||
|
||||
func (api *API) SaveAccounts(ctx context.Context, accounts []accounts.Account) error {
|
||||
log.Info("[AccountsAPI::SaveAccounts]")
|
||||
err := api.db.SaveAccounts(accounts)
|
||||
|
@ -69,41 +75,19 @@ func (api *API) AddAccountWithMnemonic(
|
|||
color string,
|
||||
emoji string,
|
||||
) error {
|
||||
mnemonicNoExtraSpaces := strings.Join(strings.Fields(mnemonic), " ")
|
||||
return api.addAccountWithMnemonic(ctx, mnemonic, password, name, color, emoji, pathWalletRoot)
|
||||
}
|
||||
|
||||
err := api.verifyPassword(password)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
generatedAccountInfo, err := api.manager.AccountsGenerator().ImportMnemonic(mnemonicNoExtraSpaces, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
accountInfos, err := api.manager.AccountsGenerator().StoreDerivedAccounts(generatedAccountInfo.ID, password, []string{pathDefaultWallet})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
addressExists, err := api.db.AddressExists(types.Address(common.HexToAddress(accountInfos[pathWalletRoot].Address)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if addressExists {
|
||||
return errors.New("account already exists")
|
||||
}
|
||||
|
||||
account := accounts.Account{
|
||||
Address: types.Address(common.HexToAddress(accountInfos[pathDefaultWallet].Address)),
|
||||
PublicKey: types.HexBytes(accountInfos[pathDefaultWallet].PublicKey),
|
||||
Type: "seed",
|
||||
Name: name,
|
||||
Emoji: emoji,
|
||||
Color: color,
|
||||
Path: pathDefaultWallet,
|
||||
}
|
||||
return api.SaveAccounts(ctx, []accounts.Account{account})
|
||||
func (api *API) AddAccountWithMnemonicAndPath(
|
||||
ctx context.Context,
|
||||
mnemonic string,
|
||||
password string,
|
||||
name string,
|
||||
color string,
|
||||
emoji string,
|
||||
path string,
|
||||
) error {
|
||||
return api.addAccountWithMnemonic(ctx, mnemonic, password, name, color, emoji, path)
|
||||
}
|
||||
|
||||
func (api *API) AddAccountWithPrivateKey(
|
||||
|
@ -157,27 +141,166 @@ func (api *API) GenerateAccount(
|
|||
color string,
|
||||
emoji string,
|
||||
) error {
|
||||
err := api.verifyPassword(password)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
address, err := api.db.GetWalletRoodAddress()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
info, err := api.manager.AccountsGenerator().LoadAccount(address.Hex(), password)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
latestDerivedPath, err := api.db.GetLatestDerivedPath()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
newDerivedPath := latestDerivedPath + 1
|
||||
path := fmt.Sprint("m/", newDerivedPath)
|
||||
path := fmt.Sprint(pathWalletRoot, "/", newDerivedPath)
|
||||
|
||||
err = api.generateAccount(ctx, password, name, color, emoji, path, address.Hex())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = api.db.SaveSettingField(settings.LatestDerivedPath, newDerivedPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (api *API) GenerateAccountWithDerivedPath(
|
||||
ctx context.Context,
|
||||
password string,
|
||||
name string,
|
||||
color string,
|
||||
emoji string,
|
||||
path string,
|
||||
derivedFrom string,
|
||||
) error {
|
||||
return api.generateAccount(ctx, password, name, color, emoji, path, derivedFrom)
|
||||
}
|
||||
|
||||
func (api *API) GetDerivedAddressesForPath(password string, derivedFrom string, path string, pageSize int, pageNumber int) ([]*DerivedAddress, error) {
|
||||
info, err := api.manager.AccountsGenerator().LoadAccount(derivedFrom, password)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return api.getDerivedAddresses(info.ID, path, pageSize, pageNumber)
|
||||
}
|
||||
|
||||
func (api *API) GetDerivedAddressesForMenominicWithPath(mnemonic string, path string, pageSize int, pageNumber int) ([]*DerivedAddress, error) {
|
||||
mnemonicNoExtraSpaces := strings.Join(strings.Fields(mnemonic), " ")
|
||||
|
||||
info, err := api.manager.AccountsGenerator().ImportMnemonic(mnemonicNoExtraSpaces, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return api.getDerivedAddresses(info.ID, path, pageSize, pageNumber)
|
||||
}
|
||||
|
||||
func (api *API) verifyPassword(password string) error {
|
||||
address, err := api.db.GetChatAddress()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = api.manager.VerifyAccountPassword(api.config.KeyStoreDir, address.Hex(), password)
|
||||
return err
|
||||
}
|
||||
|
||||
func (api *API) getDerivedAddresses(id string, path string, pageSize int, pageNumber int) ([]*DerivedAddress, error) {
|
||||
derivedAddresses := make([]*DerivedAddress, 0)
|
||||
|
||||
if pageNumber <= 0 || pageSize <= 0 {
|
||||
return nil, fmt.Errorf("pageSize and pageNumber should be greater than 0")
|
||||
}
|
||||
|
||||
var startIndex = ((pageNumber - 1) * pageSize)
|
||||
var endIndex = (pageNumber * pageSize)
|
||||
|
||||
for i := startIndex; i < endIndex; i++ {
|
||||
derivedPath := fmt.Sprint(path, "/", i)
|
||||
|
||||
info, err := api.manager.AccountsGenerator().DeriveAddresses(id, []string{derivedPath})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
address := &DerivedAddress{
|
||||
Address: common.HexToAddress(info[derivedPath].Address),
|
||||
Path: derivedPath,
|
||||
HasActivity: false,
|
||||
}
|
||||
|
||||
derivedAddresses = append(derivedAddresses, address)
|
||||
}
|
||||
return derivedAddresses, nil
|
||||
}
|
||||
|
||||
func (api *API) addAccountWithMnemonic(
|
||||
ctx context.Context,
|
||||
mnemonic string,
|
||||
password string,
|
||||
name string,
|
||||
color string,
|
||||
emoji string,
|
||||
path string,
|
||||
) error {
|
||||
mnemonicNoExtraSpaces := strings.Join(strings.Fields(mnemonic), " ")
|
||||
|
||||
err := api.verifyPassword(password)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
generatedAccountInfo, err := api.manager.AccountsGenerator().ImportMnemonic(mnemonicNoExtraSpaces, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = api.manager.AccountsGenerator().StoreAccount(generatedAccountInfo.ID, password)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
accountinfos, err := api.manager.AccountsGenerator().StoreDerivedAccounts(generatedAccountInfo.ID, password, []string{path})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
account := accounts.Account{
|
||||
Address: types.Address(common.HexToAddress(accountinfos[path].Address)),
|
||||
PublicKey: types.HexBytes(accountinfos[path].PublicKey),
|
||||
Type: "seed",
|
||||
Name: name,
|
||||
Emoji: emoji,
|
||||
Color: color,
|
||||
Path: path,
|
||||
DerivedFrom: generatedAccountInfo.Address,
|
||||
}
|
||||
return api.SaveAccounts(ctx, []accounts.Account{account})
|
||||
}
|
||||
|
||||
func (api *API) generateAccount(
|
||||
ctx context.Context,
|
||||
password string,
|
||||
name string,
|
||||
color string,
|
||||
emoji string,
|
||||
path string,
|
||||
address string,
|
||||
) error {
|
||||
err := api.verifyPassword(password)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
info, err := api.manager.AccountsGenerator().LoadAccount(address, password)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
infos, err := api.manager.AccountsGenerator().DeriveAddresses(info.ID, []string{path})
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -189,28 +312,15 @@ func (api *API) GenerateAccount(
|
|||
}
|
||||
|
||||
acc := accounts.Account{
|
||||
Address: types.Address(common.HexToAddress(infos[path].Address)),
|
||||
PublicKey: types.HexBytes(infos[path].PublicKey),
|
||||
Type: "generated",
|
||||
Name: name,
|
||||
Emoji: emoji,
|
||||
Color: color,
|
||||
Path: fmt.Sprint(pathWalletRoot, "/", newDerivedPath),
|
||||
}
|
||||
|
||||
err = api.db.SaveSettingField(settings.LatestDerivedPath, newDerivedPath)
|
||||
if err != nil {
|
||||
return err
|
||||
Address: types.Address(common.HexToAddress(infos[path].Address)),
|
||||
PublicKey: types.HexBytes(infos[path].PublicKey),
|
||||
Type: "generated",
|
||||
Name: name,
|
||||
Emoji: emoji,
|
||||
Color: color,
|
||||
Path: path,
|
||||
DerivedFrom: address,
|
||||
}
|
||||
|
||||
return api.SaveAccounts(ctx, []accounts.Account{acc})
|
||||
}
|
||||
|
||||
func (api *API) verifyPassword(password string) error {
|
||||
address, err := api.db.GetChatAddress()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = api.manager.VerifyAccountPassword(api.config.KeyStoreDir, address.Hex(), password)
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue