[#4200] Avoid tx watching for addresses which were not exposed
This commit is contained in:
parent
8206ffc736
commit
aee111e5ab
|
@ -29,6 +29,7 @@ type StatusBackend interface {
|
||||||
// SelectAccount(loginParams account.LoginParams) error
|
// SelectAccount(loginParams account.LoginParams) error
|
||||||
OpenAccounts() error
|
OpenAccounts() error
|
||||||
GetAccounts() ([]multiaccounts.Account, error)
|
GetAccounts() ([]multiaccounts.Account, error)
|
||||||
|
LocalPairingStarted() error
|
||||||
// SaveAccount(account multiaccounts.Account) error
|
// SaveAccount(account multiaccounts.Account) error
|
||||||
SaveAccountAndStartNodeWithKey(acc multiaccounts.Account, password string, settings settings.Settings, conf *params.NodeConfig, subaccs []*accounts.Account, keyHex string) error
|
SaveAccountAndStartNodeWithKey(acc multiaccounts.Account, password string, settings settings.Settings, conf *params.NodeConfig, subaccs []*accounts.Account, keyHex string) error
|
||||||
Recover(rpcParams personal.RecoverParams) (types.Address, error)
|
Recover(rpcParams personal.RecoverParams) (types.Address, error)
|
||||||
|
|
|
@ -1352,6 +1352,7 @@ func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, customizati
|
||||||
if mnemonic == "" {
|
if mnemonic == "" {
|
||||||
settings.Mnemonic = &info.Mnemonic
|
settings.Mnemonic = &info.Mnemonic
|
||||||
settings.OmitTransfersHistoryScan = true
|
settings.OmitTransfersHistoryScan = true
|
||||||
|
//settings.MnemonicWasNotShown = true
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeConfig, err := defaultNodeConfig(settings.InstallationID, request)
|
nodeConfig, err := defaultNodeConfig(settings.InstallationID, request)
|
||||||
|
@ -1377,6 +1378,10 @@ func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, customizati
|
||||||
Name: walletAccountDefaultName,
|
Name: walletAccountDefaultName,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if mnemonic == "" {
|
||||||
|
walletAccount.AddressWasNotShown = true
|
||||||
|
}
|
||||||
|
|
||||||
chatDerivedAccount := derivedAddresses[pathDefaultChat]
|
chatDerivedAccount := derivedAddresses[pathDefaultChat]
|
||||||
chatAccount := &accounts.Account{
|
chatAccount := &accounts.Account{
|
||||||
PublicKey: types.Hex2Bytes(chatDerivedAccount.PublicKey),
|
PublicKey: types.Hex2Bytes(chatDerivedAccount.PublicKey),
|
||||||
|
@ -2294,6 +2299,19 @@ func (b *GethStatusBackend) GetActiveAccount() (*multiaccounts.Account, error) {
|
||||||
return b.account, nil
|
return b.account, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *GethStatusBackend) LocalPairingStarted() error {
|
||||||
|
if b.account == nil {
|
||||||
|
return errors.New("master key account is nil in the GethStatusBackend")
|
||||||
|
}
|
||||||
|
|
||||||
|
accountDB, err := accounts.NewDB(b.appDB)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return accountDB.MnemonicWasShown()
|
||||||
|
}
|
||||||
|
|
||||||
func (b *GethStatusBackend) injectAccountsIntoWakuService(w types.WakuKeyManager, st *ext.Service) error {
|
func (b *GethStatusBackend) injectAccountsIntoWakuService(w types.WakuKeyManager, st *ext.Service) error {
|
||||||
chatAccount, err := b.accountManager.SelectedChatAccount()
|
chatAccount, err := b.accountManager.SelectedChatAccount()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE keypairs_accounts ADD COLUMN address_was_not_shown BOOLEAN NOT NULL DEFAULT FALSE;
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE settings ADD COLUMN mnemonic_was_not_shown BOOLEAN NOT NULL DEFAULT FALSE;
|
File diff suppressed because it is too large
Load Diff
|
@ -354,6 +354,7 @@ func SaveAccountAndLogin(accountData, password, settingsJSON, configJSON, subacc
|
||||||
|
|
||||||
if *settings.Mnemonic != "" {
|
if *settings.Mnemonic != "" {
|
||||||
settings.OmitTransfersHistoryScan = true
|
settings.OmitTransfersHistoryScan = true
|
||||||
|
settings.MnemonicWasNotShown = true
|
||||||
}
|
}
|
||||||
|
|
||||||
var conf params.NodeConfig
|
var conf params.NodeConfig
|
||||||
|
|
|
@ -58,6 +58,7 @@ type Account struct {
|
||||||
Address types.Address `json:"address"`
|
Address types.Address `json:"address"`
|
||||||
KeyUID string `json:"key-uid"`
|
KeyUID string `json:"key-uid"`
|
||||||
Wallet bool `json:"wallet"`
|
Wallet bool `json:"wallet"`
|
||||||
|
AddressWasNotShown bool `json:"address-was-not-shown,omitempty"`
|
||||||
Chat bool `json:"chat"`
|
Chat bool `json:"chat"`
|
||||||
Type AccountType `json:"type,omitempty"`
|
Type AccountType `json:"type,omitempty"`
|
||||||
Path string `json:"path,omitempty"`
|
Path string `json:"path,omitempty"`
|
||||||
|
@ -354,6 +355,7 @@ func (db *Database) processRows(rows *sql.Rows) ([]*Keypair, []*Account, error)
|
||||||
accRemoved sql.NullBool
|
accRemoved sql.NullBool
|
||||||
accProdPreferredChainIDs sql.NullString
|
accProdPreferredChainIDs sql.NullString
|
||||||
accTestPreferredChainIDs sql.NullString
|
accTestPreferredChainIDs sql.NullString
|
||||||
|
accAddressWasNotShown sql.NullBool
|
||||||
)
|
)
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
|
@ -364,7 +366,7 @@ func (db *Database) processRows(rows *sql.Rows) ([]*Keypair, []*Account, error)
|
||||||
&kpKeyUID, &kpName, &kpType, &kpDerivedFrom, &kpLastUsedDerivationIndex, &kpSyncedFrom, &kpClock, &kpRemoved,
|
&kpKeyUID, &kpName, &kpType, &kpDerivedFrom, &kpLastUsedDerivationIndex, &kpSyncedFrom, &kpClock, &kpRemoved,
|
||||||
&accAddress, &accKeyUID, &pubkey, &accPath, &accName, &accColorID, &accEmoji,
|
&accAddress, &accKeyUID, &pubkey, &accPath, &accName, &accColorID, &accEmoji,
|
||||||
&accWallet, &accChat, &accHidden, &accOperable, &accClock, &accCreatedAt, &accPosition, &accRemoved,
|
&accWallet, &accChat, &accHidden, &accOperable, &accClock, &accCreatedAt, &accPosition, &accRemoved,
|
||||||
&accProdPreferredChainIDs, &accTestPreferredChainIDs)
|
&accProdPreferredChainIDs, &accTestPreferredChainIDs, &accAddressWasNotShown)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -440,6 +442,9 @@ func (db *Database) processRows(rows *sql.Rows) ([]*Keypair, []*Account, error)
|
||||||
if accTestPreferredChainIDs.Valid {
|
if accTestPreferredChainIDs.Valid {
|
||||||
acc.TestPreferredChainIDs = accTestPreferredChainIDs.String
|
acc.TestPreferredChainIDs = accTestPreferredChainIDs.String
|
||||||
}
|
}
|
||||||
|
if accAddressWasNotShown.Valid {
|
||||||
|
acc.AddressWasNotShown = accAddressWasNotShown.Bool
|
||||||
|
}
|
||||||
if lth := len(pubkey); lth > 0 {
|
if lth := len(pubkey); lth > 0 {
|
||||||
acc.PublicKey = make(types.HexBytes, lth)
|
acc.PublicKey = make(types.HexBytes, lth)
|
||||||
copy(acc.PublicKey, pubkey)
|
copy(acc.PublicKey, pubkey)
|
||||||
|
@ -529,7 +534,8 @@ func (db *Database) getKeypairs(tx *sql.Tx, keyUID string, includeRemoved bool)
|
||||||
ka.position,
|
ka.position,
|
||||||
ka.removed,
|
ka.removed,
|
||||||
ka.prod_preferred_chain_ids,
|
ka.prod_preferred_chain_ids,
|
||||||
ka.test_preferred_chain_ids
|
ka.test_preferred_chain_ids,
|
||||||
|
ka.address_was_not_shown
|
||||||
FROM
|
FROM
|
||||||
keypairs k
|
keypairs k
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
|
@ -631,7 +637,8 @@ func (db *Database) getAccounts(tx *sql.Tx, address types.Address, includeRemove
|
||||||
ka.position,
|
ka.position,
|
||||||
ka.removed,
|
ka.removed,
|
||||||
ka.prod_preferred_chain_ids,
|
ka.prod_preferred_chain_ids,
|
||||||
ka.test_preferred_chain_ids
|
ka.test_preferred_chain_ids,
|
||||||
|
ka.address_was_not_shown
|
||||||
FROM
|
FROM
|
||||||
keypairs_accounts ka
|
keypairs_accounts ka
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
|
@ -994,9 +1001,9 @@ func (db *Database) saveOrUpdateAccounts(tx *sql.Tx, accounts []*Account, update
|
||||||
|
|
||||||
_, err = tx.Exec(`
|
_, err = tx.Exec(`
|
||||||
INSERT OR IGNORE INTO
|
INSERT OR IGNORE INTO
|
||||||
keypairs_accounts (address, key_uid, pubkey, path, wallet, chat, created_at, updated_at)
|
keypairs_accounts (address, key_uid, pubkey, path, wallet, address_was_not_shown, chat, created_at, updated_at)
|
||||||
VALUES
|
VALUES
|
||||||
(?, ?, ?, ?, ?, ?, datetime('now'), datetime('now'));
|
(?, ?, ?, ?, ?, ?, ?, datetime('now'), datetime('now'));
|
||||||
|
|
||||||
UPDATE
|
UPDATE
|
||||||
keypairs_accounts
|
keypairs_accounts
|
||||||
|
@ -1015,7 +1022,7 @@ func (db *Database) saveOrUpdateAccounts(tx *sql.Tx, accounts []*Account, update
|
||||||
WHERE
|
WHERE
|
||||||
address = ?;
|
address = ?;
|
||||||
`,
|
`,
|
||||||
acc.Address, keyUID, acc.PublicKey, acc.Path, acc.Wallet, acc.Chat,
|
acc.Address, keyUID, acc.PublicKey, acc.Path, acc.Wallet, acc.AddressWasNotShown, acc.Chat,
|
||||||
acc.Name, acc.ColorID, acc.Emoji, acc.Hidden, acc.Operable, acc.Clock, acc.Position, acc.Removed,
|
acc.Name, acc.ColorID, acc.Emoji, acc.Hidden, acc.Operable, acc.Clock, acc.Position, acc.Removed,
|
||||||
acc.ProdPreferredChainIDs, acc.TestPreferredChainIDs, acc.Address)
|
acc.ProdPreferredChainIDs, acc.TestPreferredChainIDs, acc.Address)
|
||||||
|
|
||||||
|
@ -1644,3 +1651,20 @@ func (db *Database) CheckAndDeleteExpiredKeypairsAndAccounts(time uint64) error
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *Database) AddressWasShown(address types.Address) error {
|
||||||
|
tx, err := db.db.Begin()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if err == nil {
|
||||||
|
err = tx.Commit()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_ = tx.Rollback()
|
||||||
|
}()
|
||||||
|
|
||||||
|
_, err = tx.Exec(`UPDATE keypairs_accounts SET address_was_not_shown = 0 WHERE address = ?`, address)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
|
@ -452,7 +452,11 @@ var (
|
||||||
dBColumnName: "omit_transfers_history_scan",
|
dBColumnName: "omit_transfers_history_scan",
|
||||||
valueHandler: BoolHandler,
|
valueHandler: BoolHandler,
|
||||||
}
|
}
|
||||||
|
MnemonicWasNotShown = SettingField{
|
||||||
|
reactFieldName: "mnemonic-was-not-shown?",
|
||||||
|
dBColumnName: "mnemonic_was_not_shown",
|
||||||
|
valueHandler: BoolHandler,
|
||||||
|
}
|
||||||
SettingFieldRegister = []SettingField{
|
SettingFieldRegister = []SettingField{
|
||||||
AnonMetricsShouldSend,
|
AnonMetricsShouldSend,
|
||||||
Appearance,
|
Appearance,
|
||||||
|
|
|
@ -126,10 +126,11 @@ INSERT INTO settings (
|
||||||
profile_pictures_show_to,
|
profile_pictures_show_to,
|
||||||
profile_pictures_visibility,
|
profile_pictures_visibility,
|
||||||
url_unfurling_mode,
|
url_unfurling_mode,
|
||||||
omit_transfers_history_scan
|
omit_transfers_history_scan,
|
||||||
|
mnemonic_was_not_shown
|
||||||
) VALUES (
|
) VALUES (
|
||||||
?,?,?,?,?,?,?,?,?,?,?,?,?,
|
?,?,?,?,?,?,?,?,?,?,?,?,?,
|
||||||
?,?,?,?,?,?,?,?,?,'id',?,?,?,?,?)`,
|
?,?,?,?,?,?,?,?,?,'id',?,?,?,?,?,?)`,
|
||||||
s.Address,
|
s.Address,
|
||||||
s.Currency,
|
s.Currency,
|
||||||
s.CurrentNetwork,
|
s.CurrentNetwork,
|
||||||
|
@ -157,6 +158,7 @@ INSERT INTO settings (
|
||||||
s.ProfilePicturesVisibility,
|
s.ProfilePicturesVisibility,
|
||||||
s.URLUnfurlingMode,
|
s.URLUnfurlingMode,
|
||||||
s.OmitTransfersHistoryScan,
|
s.OmitTransfersHistoryScan,
|
||||||
|
s.MnemonicWasNotShown,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -352,7 +354,7 @@ func (db *Database) GetSettings() (Settings, error) {
|
||||||
waku_bloom_filter_mode, webview_allow_permission_requests, current_user_status, send_status_updates, gif_recents,
|
waku_bloom_filter_mode, webview_allow_permission_requests, current_user_status, send_status_updates, gif_recents,
|
||||||
gif_favorites, opensea_enabled, last_backup, backup_enabled, telemetry_server_url, auto_message_enabled, gif_api_key,
|
gif_favorites, opensea_enabled, last_backup, backup_enabled, telemetry_server_url, auto_message_enabled, gif_api_key,
|
||||||
test_networks_enabled, mutual_contact_enabled, profile_migration_needed, is_sepolia_enabled, url_unfurling_mode,
|
test_networks_enabled, mutual_contact_enabled, profile_migration_needed, is_sepolia_enabled, url_unfurling_mode,
|
||||||
omit_transfers_history_scan
|
omit_transfers_history_scan, mnemonic_was_not_shown
|
||||||
FROM
|
FROM
|
||||||
settings
|
settings
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -429,6 +431,7 @@ func (db *Database) GetSettings() (Settings, error) {
|
||||||
&s.IsSepoliaEnabled,
|
&s.IsSepoliaEnabled,
|
||||||
&s.URLUnfurlingMode,
|
&s.URLUnfurlingMode,
|
||||||
&s.OmitTransfersHistoryScan,
|
&s.OmitTransfersHistoryScan,
|
||||||
|
&s.MnemonicWasNotShown,
|
||||||
)
|
)
|
||||||
|
|
||||||
return s, err
|
return s, err
|
||||||
|
@ -613,6 +616,14 @@ func (db *Database) MnemonicRemoved() (result bool, err error) {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *Database) GetMnemonicWasNotShown() (result bool, err error) {
|
||||||
|
err = db.makeSelectRow(MnemonicWasNotShown).Scan(&result)
|
||||||
|
if err == sql.ErrNoRows {
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
|
|
||||||
func (db *Database) GifAPIKey() (string, error) {
|
func (db *Database) GifAPIKey() (string, error) {
|
||||||
return db.makeSelectString(GifAPIKey)
|
return db.makeSelectString(GifAPIKey)
|
||||||
}
|
}
|
||||||
|
@ -742,3 +753,7 @@ func (db *Database) postChangesToSubscribers(change *SyncSettingField) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *Database) MnemonicWasShown() error {
|
||||||
|
return db.SaveSettingField(MnemonicWasNotShown, false)
|
||||||
|
}
|
||||||
|
|
|
@ -142,11 +142,13 @@ type Settings struct {
|
||||||
LogLevel *string `json:"log-level,omitempty"`
|
LogLevel *string `json:"log-level,omitempty"`
|
||||||
MessagesFromContactsOnly bool `json:"messages-from-contacts-only"`
|
MessagesFromContactsOnly bool `json:"messages-from-contacts-only"`
|
||||||
Mnemonic *string `json:"mnemonic,omitempty"`
|
Mnemonic *string `json:"mnemonic,omitempty"`
|
||||||
MnemonicRemoved bool `json:"mnemonic-removed?,omitempty"`
|
// NOTE(rasom): negation here because it safer/simpler to have false by default
|
||||||
OmitTransfersHistoryScan bool `json:"omit-transfers-history-scan?,omitempty"`
|
MnemonicWasNotShown bool `json:"mnemonic-was-not-shown?,omitempty"`
|
||||||
MutualContactEnabled bool `json:"mutual-contact-enabled?"`
|
MnemonicRemoved bool `json:"mnemonic-removed?,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
OmitTransfersHistoryScan bool `json:"omit-transfers-history-scan?,omitempty"`
|
||||||
Networks *json.RawMessage `json:"networks/networks"`
|
MutualContactEnabled bool `json:"mutual-contact-enabled?"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
Networks *json.RawMessage `json:"networks/networks"`
|
||||||
// NotificationsEnabled indicates whether local notifications should be enabled (android only)
|
// NotificationsEnabled indicates whether local notifications should be enabled (android only)
|
||||||
NotificationsEnabled bool `json:"notifications-enabled?,omitempty"`
|
NotificationsEnabled bool `json:"notifications-enabled?,omitempty"`
|
||||||
PhotoPath string `json:"photo-path"`
|
PhotoPath string `json:"photo-path"`
|
||||||
|
|
|
@ -46,7 +46,7 @@ func handleReceiveAccount(logger *zap.Logger, pr PayloadReceiver) http.HandlerFu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleSendAccount(logger *zap.Logger, pm PayloadMounter) http.HandlerFunc {
|
func handleSendAccount(logger *zap.Logger, pm PayloadMounter, beforeSending func()) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
signal.SendLocalPairingEvent(Event{Type: EventConnectionSuccess, Action: ActionPairingAccount})
|
signal.SendLocalPairingEvent(Event{Type: EventConnectionSuccess, Action: ActionPairingAccount})
|
||||||
w.Header().Set("Content-Type", "application/octet-stream")
|
w.Header().Set("Content-Type", "application/octet-stream")
|
||||||
|
@ -58,6 +58,7 @@ func handleSendAccount(logger *zap.Logger, pm PayloadMounter) http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beforeSending()
|
||||||
_, err = w.Write(pm.ToSend())
|
_, err = w.Write(pm.ToSend())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
signal.SendLocalPairingEvent(Event{Type: EventTransferError, Error: err.Error(), Action: ActionPairingAccount})
|
signal.SendLocalPairingEvent(Event{Type: EventTransferError, Error: err.Error(), Action: ActionPairingAccount})
|
||||||
|
@ -96,7 +97,7 @@ func handleParingSyncDeviceReceive(logger *zap.Logger, pr PayloadReceiver) http.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handlePairingSyncDeviceSend(logger *zap.Logger, pm PayloadMounter) http.HandlerFunc {
|
func handlePairingSyncDeviceSend(logger *zap.Logger, pm PayloadMounter, beforeSending func()) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
signal.SendLocalPairingEvent(Event{Type: EventConnectionSuccess, Action: ActionSyncDevice})
|
signal.SendLocalPairingEvent(Event{Type: EventConnectionSuccess, Action: ActionSyncDevice})
|
||||||
w.Header().Set("Content-Type", "application/octet-stream")
|
w.Header().Set("Content-Type", "application/octet-stream")
|
||||||
|
@ -110,6 +111,7 @@ func handlePairingSyncDeviceSend(logger *zap.Logger, pm PayloadMounter) http.Han
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beforeSending()
|
||||||
_, err = w.Write(pm.ToSend())
|
_, err = w.Write(pm.ToSend())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
signal.SendLocalPairingEvent(Event{Type: EventTransferError, Error: err.Error(), Action: ActionSyncDevice})
|
signal.SendLocalPairingEvent(Event{Type: EventTransferError, Error: err.Error(), Action: ActionSyncDevice})
|
||||||
|
@ -148,7 +150,7 @@ func handleReceiveInstallation(logger *zap.Logger, pmr PayloadMounterReceiver) h
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleSendInstallation(logger *zap.Logger, pmr PayloadMounterReceiver) http.HandlerFunc {
|
func handleSendInstallation(logger *zap.Logger, pmr PayloadMounterReceiver, beforeSending func()) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
signal.SendLocalPairingEvent(Event{Type: EventConnectionSuccess, Action: ActionPairingInstallation})
|
signal.SendLocalPairingEvent(Event{Type: EventConnectionSuccess, Action: ActionPairingInstallation})
|
||||||
w.Header().Set("Content-Type", "application/octet-stream")
|
w.Header().Set("Content-Type", "application/octet-stream")
|
||||||
|
@ -160,6 +162,7 @@ func handleSendInstallation(logger *zap.Logger, pmr PayloadMounterReceiver) http
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beforeSending()
|
||||||
_, err = w.Write(pmr.ToSend())
|
_, err = w.Write(pmr.ToSend())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
signal.SendLocalPairingEvent(Event{Type: EventTransferError, Error: err.Error(), Action: ActionPairingInstallation})
|
signal.SendLocalPairingEvent(Event{Type: EventTransferError, Error: err.Error(), Action: ActionPairingInstallation})
|
||||||
|
|
|
@ -108,6 +108,7 @@ type SenderServer struct {
|
||||||
accountMounter PayloadMounter
|
accountMounter PayloadMounter
|
||||||
rawMessageMounter PayloadMounter
|
rawMessageMounter PayloadMounter
|
||||||
installationMounter PayloadMounterReceiver
|
installationMounter PayloadMounterReceiver
|
||||||
|
backend *api.GethStatusBackend
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSenderServer returns a *SenderServer init from the given *SenderServerConfig
|
// NewSenderServer returns a *SenderServer init from the given *SenderServerConfig
|
||||||
|
@ -130,14 +131,24 @@ func NewSenderServer(backend *api.GethStatusBackend, config *SenderServerConfig)
|
||||||
accountMounter: am,
|
accountMounter: am,
|
||||||
rawMessageMounter: rmm,
|
rawMessageMounter: rmm,
|
||||||
installationMounter: imr,
|
installationMounter: imr,
|
||||||
|
backend: backend,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SenderServer) startSendingData() error {
|
func (s *SenderServer) startSendingData() error {
|
||||||
|
logger := s.GetLogger()
|
||||||
|
beforeSending := func() {
|
||||||
|
if s.backend != nil {
|
||||||
|
err := s.backend.LocalPairingStarted()
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("startSendingData backend.LocalPairingStarted()", zap.Error(err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
s.SetHandlers(server.HandlerPatternMap{
|
s.SetHandlers(server.HandlerPatternMap{
|
||||||
pairingChallenge: handlePairingChallenge(s.challengeGiver),
|
pairingChallenge: handlePairingChallenge(s.challengeGiver),
|
||||||
pairingSendAccount: middlewareChallenge(s.challengeGiver, handleSendAccount(s.GetLogger(), s.accountMounter)),
|
pairingSendAccount: middlewareChallenge(s.challengeGiver, handleSendAccount(logger, s.accountMounter, beforeSending)),
|
||||||
pairingSendSyncDevice: middlewareChallenge(s.challengeGiver, handlePairingSyncDeviceSend(s.GetLogger(), s.rawMessageMounter)),
|
pairingSendSyncDevice: middlewareChallenge(s.challengeGiver, handlePairingSyncDeviceSend(logger, s.rawMessageMounter, beforeSending)),
|
||||||
// TODO implement refactor of installation data exchange to follow the send/receive pattern of
|
// TODO implement refactor of installation data exchange to follow the send/receive pattern of
|
||||||
// the other handlers.
|
// the other handlers.
|
||||||
// https://github.com/status-im/status-go/issues/3304
|
// https://github.com/status-im/status-go/issues/3304
|
||||||
|
@ -205,6 +216,7 @@ type ReceiverServer struct {
|
||||||
accountReceiver PayloadReceiver
|
accountReceiver PayloadReceiver
|
||||||
rawMessageReceiver PayloadReceiver
|
rawMessageReceiver PayloadReceiver
|
||||||
installationReceiver PayloadMounterReceiver
|
installationReceiver PayloadMounterReceiver
|
||||||
|
backend *api.GethStatusBackend
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewReceiverServer returns a *SenderServer init from the given *ReceiverServerConfig
|
// NewReceiverServer returns a *SenderServer init from the given *ReceiverServerConfig
|
||||||
|
@ -227,19 +239,29 @@ func NewReceiverServer(backend *api.GethStatusBackend, config *ReceiverServerCon
|
||||||
accountReceiver: ar,
|
accountReceiver: ar,
|
||||||
rawMessageReceiver: rmr,
|
rawMessageReceiver: rmr,
|
||||||
installationReceiver: imr,
|
installationReceiver: imr,
|
||||||
|
backend: backend,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ReceiverServer) startReceivingData() error {
|
func (s *ReceiverServer) startReceivingData() error {
|
||||||
|
logger := s.GetLogger()
|
||||||
|
beforeSending := func() {
|
||||||
|
if s.backend != nil {
|
||||||
|
err := s.backend.LocalPairingStarted()
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("startSendingData backend.LocalPairingStarted()", zap.Error(err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
s.SetHandlers(server.HandlerPatternMap{
|
s.SetHandlers(server.HandlerPatternMap{
|
||||||
pairingChallenge: handlePairingChallenge(s.challengeGiver),
|
pairingChallenge: handlePairingChallenge(s.challengeGiver),
|
||||||
pairingReceiveAccount: handleReceiveAccount(s.GetLogger(), s.accountReceiver),
|
pairingReceiveAccount: handleReceiveAccount(logger, s.accountReceiver),
|
||||||
pairingReceiveSyncDevice: handleParingSyncDeviceReceive(s.GetLogger(), s.rawMessageReceiver),
|
pairingReceiveSyncDevice: handleParingSyncDeviceReceive(logger, s.rawMessageReceiver),
|
||||||
// TODO implement refactor of installation data exchange to follow the send/receive pattern of
|
// TODO implement refactor of installation data exchange to follow the send/receive pattern of
|
||||||
// the other handlers.
|
// the other handlers.
|
||||||
// https://github.com/status-im/status-go/issues/3304
|
// https://github.com/status-im/status-go/issues/3304
|
||||||
// send installation data back to sender
|
// send installation data back to sender
|
||||||
pairingSendInstallation: middlewareChallenge(s.challengeGiver, handleSendInstallation(s.GetLogger(), s.installationReceiver)),
|
pairingSendInstallation: middlewareChallenge(s.challengeGiver, handleSendInstallation(logger, s.installationReceiver, beforeSending)),
|
||||||
})
|
})
|
||||||
return s.Start()
|
return s.Start()
|
||||||
}
|
}
|
||||||
|
@ -301,6 +323,7 @@ func StartUpReceiverServer(backend *api.GethStatusBackend, configJSON string) (s
|
||||||
type KeystoreFilesSenderServer struct {
|
type KeystoreFilesSenderServer struct {
|
||||||
*BaseServer
|
*BaseServer
|
||||||
keystoreFilesMounter PayloadMounter
|
keystoreFilesMounter PayloadMounter
|
||||||
|
backend *api.GethStatusBackend
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewKeystoreFilesSenderServer(backend *api.GethStatusBackend, config *KeystoreFilesSenderServerConfig) (*KeystoreFilesSenderServer, error) {
|
func NewKeystoreFilesSenderServer(backend *api.GethStatusBackend, config *KeystoreFilesSenderServerConfig) (*KeystoreFilesSenderServer, error) {
|
||||||
|
@ -320,13 +343,23 @@ func NewKeystoreFilesSenderServer(backend *api.GethStatusBackend, config *Keysto
|
||||||
return &KeystoreFilesSenderServer{
|
return &KeystoreFilesSenderServer{
|
||||||
BaseServer: bs,
|
BaseServer: bs,
|
||||||
keystoreFilesMounter: kfm,
|
keystoreFilesMounter: kfm,
|
||||||
|
backend: backend,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *KeystoreFilesSenderServer) startSendingData() error {
|
func (s *KeystoreFilesSenderServer) startSendingData() error {
|
||||||
|
logger := s.GetLogger()
|
||||||
|
beforeSending := func() {
|
||||||
|
if s.backend != nil {
|
||||||
|
err := s.backend.LocalPairingStarted()
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("startSendingData backend.LocalPairingStarted()", zap.Error(err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
s.SetHandlers(server.HandlerPatternMap{
|
s.SetHandlers(server.HandlerPatternMap{
|
||||||
pairingChallenge: handlePairingChallenge(s.challengeGiver),
|
pairingChallenge: handlePairingChallenge(s.challengeGiver),
|
||||||
pairingSendAccount: middlewareChallenge(s.challengeGiver, handleSendAccount(s.GetLogger(), s.keystoreFilesMounter)),
|
pairingSendAccount: middlewareChallenge(s.challengeGiver, handleSendAccount(logger, s.keystoreFilesMounter, beforeSending)),
|
||||||
})
|
})
|
||||||
return s.Start()
|
return s.Start()
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,6 +293,10 @@ func (api *API) AddAccount(ctx context.Context, password string, account *accoun
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if account.Type == accounts.AccountTypeGenerated {
|
||||||
|
account.AddressWasNotShown = true
|
||||||
|
}
|
||||||
|
|
||||||
return api.SaveAccount(ctx, account)
|
return api.SaveAccount(ctx, account)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,3 +591,7 @@ func (api *API) DeleteAllKeycardsWithKeyUID(ctx context.Context, keyUID string)
|
||||||
func (api *API) UpdateKeycardUID(ctx context.Context, oldKeycardUID string, newKeycardUID string) error {
|
func (api *API) UpdateKeycardUID(ctx context.Context, oldKeycardUID string, newKeycardUID string) error {
|
||||||
return (*api.messenger).UpdateKeycardUID(ctx, oldKeycardUID, newKeycardUID)
|
return (*api.messenger).UpdateKeycardUID(ctx, oldKeycardUID, newKeycardUID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (api *API) AddressWasShown(address types.Address) error {
|
||||||
|
return api.db.AddressWasShown(address)
|
||||||
|
}
|
||||||
|
|
|
@ -186,3 +186,7 @@ func (api *SettingsAPI) AddOrReplaceSocialLinks(links identity.SocialLinks) erro
|
||||||
|
|
||||||
return (*api.messenger).AddOrReplaceSocialLinks(links)
|
return (*api.messenger).AddOrReplaceSocialLinks(links)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (api *SettingsAPI) MnemonicWasShown() error {
|
||||||
|
return api.db.MnemonicWasShown()
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
nodetypes "github.com/status-im/status-go/eth-node/types"
|
||||||
|
"github.com/status-im/status-go/multiaccounts/accounts"
|
||||||
"github.com/status-im/status-go/rpc/chain"
|
"github.com/status-im/status-go/rpc/chain"
|
||||||
"github.com/status-im/status-go/services/wallet/async"
|
"github.com/status-im/status-go/services/wallet/async"
|
||||||
"github.com/status-im/status-go/services/wallet/balance"
|
"github.com/status-im/status-go/services/wallet/balance"
|
||||||
|
@ -74,6 +76,7 @@ func (c *findNewBlocksCommand) Run(parent context.Context) (err error) {
|
||||||
type findBlocksCommand struct {
|
type findBlocksCommand struct {
|
||||||
account common.Address
|
account common.Address
|
||||||
db *Database
|
db *Database
|
||||||
|
accountsDB *accounts.Database
|
||||||
blockRangeDAO *BlockRangeSequentialDAO
|
blockRangeDAO *BlockRangeSequentialDAO
|
||||||
chainClient chain.ClientInterface
|
chainClient chain.ClientInterface
|
||||||
balanceCacher balance.Cacher
|
balanceCacher balance.Cacher
|
||||||
|
@ -223,8 +226,27 @@ func (c *findBlocksCommand) checkERC20Tail(parent context.Context) ([]*DBHeader,
|
||||||
return foundHeaders, nil
|
return foundHeaders, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var mnemonicCheckEnabled = false
|
||||||
|
|
||||||
func (c *findBlocksCommand) Run(parent context.Context) (err error) {
|
func (c *findBlocksCommand) Run(parent context.Context) (err error) {
|
||||||
log.Debug("start findBlocksCommand", "account", c.account, "chain", c.chainClient.NetworkID(), "noLimit", c.noLimit, "from", c.fromBlockNumber, "to", c.toBlockNumber)
|
log.Debug("start findBlocksCommand", "account", c.account, "chain", c.chainClient.NetworkID(), "noLimit", c.noLimit, "from", c.fromBlockNumber, "to", c.toBlockNumber)
|
||||||
|
mnemonicWasNotShown, err := c.accountsDB.GetMnemonicWasNotShown()
|
||||||
|
if err != nil {
|
||||||
|
c.error = err
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if mnemonicCheckEnabled && mnemonicWasNotShown {
|
||||||
|
account, err := c.accountsDB.GetAccountByAddress(nodetypes.BytesToAddress(c.account.Bytes()))
|
||||||
|
if err != nil {
|
||||||
|
c.error = err
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if account.AddressWasNotShown {
|
||||||
|
log.Info("skip findBlocksCommand, mnemonic has not been shown and the address has not been shared yet", "address", c.account)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rangeSize := big.NewInt(int64(c.defaultNodeBlockChunkSize))
|
rangeSize := big.NewInt(int64(c.defaultNodeBlockChunkSize))
|
||||||
|
|
||||||
|
@ -513,7 +535,7 @@ func loadTransfersLoop(ctx context.Context, account common.Address, blockDAO *Bl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newLoadBlocksAndTransfersCommand(account common.Address, db *Database,
|
func newLoadBlocksAndTransfersCommand(account common.Address, db *Database, accountsDB *accounts.Database,
|
||||||
blockDAO *BlockDAO, blockRangesSeqDAO *BlockRangeSequentialDAO, chainClient chain.ClientInterface, feed *event.Feed,
|
blockDAO *BlockDAO, blockRangesSeqDAO *BlockRangeSequentialDAO, chainClient chain.ClientInterface, feed *event.Feed,
|
||||||
transactionManager *TransactionManager, pendingTxManager *transactions.PendingTxTracker,
|
transactionManager *TransactionManager, pendingTxManager *transactions.PendingTxTracker,
|
||||||
tokenManager *token.Manager, balanceCacher balance.Cacher, omitHistory bool) *loadBlocksAndTransfersCommand {
|
tokenManager *token.Manager, balanceCacher balance.Cacher, omitHistory bool) *loadBlocksAndTransfersCommand {
|
||||||
|
@ -522,6 +544,7 @@ func newLoadBlocksAndTransfersCommand(account common.Address, db *Database,
|
||||||
account: account,
|
account: account,
|
||||||
db: db,
|
db: db,
|
||||||
blockRangeDAO: blockRangesSeqDAO,
|
blockRangeDAO: blockRangesSeqDAO,
|
||||||
|
accountsDB: accountsDB,
|
||||||
blockDAO: blockDAO,
|
blockDAO: blockDAO,
|
||||||
chainClient: chainClient,
|
chainClient: chainClient,
|
||||||
feed: feed,
|
feed: feed,
|
||||||
|
@ -537,6 +560,7 @@ func newLoadBlocksAndTransfersCommand(account common.Address, db *Database,
|
||||||
type loadBlocksAndTransfersCommand struct {
|
type loadBlocksAndTransfersCommand struct {
|
||||||
account common.Address
|
account common.Address
|
||||||
db *Database
|
db *Database
|
||||||
|
accountsDB *accounts.Database
|
||||||
blockRangeDAO *BlockRangeSequentialDAO
|
blockRangeDAO *BlockRangeSequentialDAO
|
||||||
blockDAO *BlockDAO
|
blockDAO *BlockDAO
|
||||||
chainClient chain.ClientInterface
|
chainClient chain.ClientInterface
|
||||||
|
@ -554,7 +578,7 @@ type loadBlocksAndTransfersCommand struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *loadBlocksAndTransfersCommand) Run(parent context.Context) error {
|
func (c *loadBlocksAndTransfersCommand) Run(parent context.Context) error {
|
||||||
log.Debug("start load all transfers command", "chain", c.chainClient.NetworkID(), "account", c.account)
|
log.Info("start load all transfers command", "chain", c.chainClient.NetworkID(), "account", c.account)
|
||||||
|
|
||||||
ctx := parent
|
ctx := parent
|
||||||
|
|
||||||
|
@ -609,7 +633,6 @@ func (c *loadBlocksAndTransfersCommand) startTransfersLoop(ctx context.Context)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *loadBlocksAndTransfersCommand) fetchHistoryBlocks(ctx context.Context, group *async.Group, fromNum, toNum *big.Int, blocksLoadedCh chan []*DBHeader) error {
|
func (c *loadBlocksAndTransfersCommand) fetchHistoryBlocks(ctx context.Context, group *async.Group, fromNum, toNum *big.Int, blocksLoadedCh chan []*DBHeader) error {
|
||||||
|
|
||||||
log.Debug("fetchHistoryBlocks start", "chainID", c.chainClient.NetworkID(), "account", c.account, "omit", c.omitHistory)
|
log.Debug("fetchHistoryBlocks start", "chainID", c.chainClient.NetworkID(), "account", c.account, "omit", c.omitHistory)
|
||||||
|
|
||||||
if c.omitHistory {
|
if c.omitHistory {
|
||||||
|
@ -633,6 +656,7 @@ func (c *loadBlocksAndTransfersCommand) fetchHistoryBlocks(ctx context.Context,
|
||||||
fbc := &findBlocksCommand{
|
fbc := &findBlocksCommand{
|
||||||
account: c.account,
|
account: c.account,
|
||||||
db: c.db,
|
db: c.db,
|
||||||
|
accountsDB: c.accountsDB,
|
||||||
blockRangeDAO: c.blockRangeDAO,
|
blockRangeDAO: c.blockRangeDAO,
|
||||||
chainClient: c.chainClient,
|
chainClient: c.chainClient,
|
||||||
balanceCacher: c.balanceCacher,
|
balanceCacher: c.balanceCacher,
|
||||||
|
@ -667,12 +691,13 @@ func (c *loadBlocksAndTransfersCommand) fetchHistoryBlocks(ctx context.Context,
|
||||||
|
|
||||||
func (c *loadBlocksAndTransfersCommand) startFetchingNewBlocks(group *async.Group, address common.Address, blocksLoadedCh chan<- []*DBHeader) {
|
func (c *loadBlocksAndTransfersCommand) startFetchingNewBlocks(group *async.Group, address common.Address, blocksLoadedCh chan<- []*DBHeader) {
|
||||||
|
|
||||||
log.Debug("startFetchingNewBlocks", "chainID", c.chainClient.NetworkID(), "account", address)
|
log.Debug("startFetchingNewBlocks", "chainID", c.chainClient.NetworkID(), "account", address, "db", c.accountsDB)
|
||||||
|
|
||||||
newBlocksCmd := &findNewBlocksCommand{
|
newBlocksCmd := &findNewBlocksCommand{
|
||||||
findBlocksCommand: &findBlocksCommand{
|
findBlocksCommand: &findBlocksCommand{
|
||||||
account: address,
|
account: address,
|
||||||
db: c.db,
|
db: c.db,
|
||||||
|
accountsDB: c.accountsDB,
|
||||||
blockRangeDAO: c.blockRangeDAO,
|
blockRangeDAO: c.blockRangeDAO,
|
||||||
chainClient: c.chainClient,
|
chainClient: c.chainClient,
|
||||||
balanceCacher: c.balanceCacher,
|
balanceCacher: c.balanceCacher,
|
||||||
|
|
|
@ -30,6 +30,7 @@ import (
|
||||||
"github.com/status-im/status-go/services/wallet/balance"
|
"github.com/status-im/status-go/services/wallet/balance"
|
||||||
"github.com/status-im/status-go/t/helpers"
|
"github.com/status-im/status-go/t/helpers"
|
||||||
|
|
||||||
|
"github.com/status-im/status-go/multiaccounts/accounts"
|
||||||
"github.com/status-im/status-go/params"
|
"github.com/status-im/status-go/params"
|
||||||
statusRpc "github.com/status-im/status-go/rpc"
|
statusRpc "github.com/status-im/status-go/rpc"
|
||||||
"github.com/status-im/status-go/rpc/network"
|
"github.com/status-im/status-go/rpc/network"
|
||||||
|
@ -942,10 +943,13 @@ func TestFindBlocksCommand(t *testing.T) {
|
||||||
Verified: true,
|
Verified: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
accDB, err := accounts.NewDB(appdb)
|
||||||
|
require.NoError(t, err)
|
||||||
fbc := &findBlocksCommand{
|
fbc := &findBlocksCommand{
|
||||||
account: common.HexToAddress("0x1234"),
|
account: common.HexToAddress("0x1234"),
|
||||||
db: wdb,
|
db: wdb,
|
||||||
blockRangeDAO: &BlockRangeSequentialDAO{wdb.client},
|
blockRangeDAO: &BlockRangeSequentialDAO{wdb.client},
|
||||||
|
accountsDB: accDB,
|
||||||
chainClient: tc,
|
chainClient: tc,
|
||||||
balanceCacher: balance.NewCacherWithTTL(5 * time.Minute),
|
balanceCacher: balance.NewCacherWithTTL(5 * time.Minute),
|
||||||
feed: &event.Feed{},
|
feed: &event.Feed{},
|
||||||
|
@ -1065,11 +1069,15 @@ func TestFetchTransfersForLoadedBlocks(t *testing.T) {
|
||||||
|
|
||||||
chainClient := newMockChainClient()
|
chainClient := newMockChainClient()
|
||||||
tracker := transactions.NewPendingTxTracker(db, chainClient, nil, &event.Feed{}, transactions.PendingCheckInterval)
|
tracker := transactions.NewPendingTxTracker(db, chainClient, nil, &event.Feed{}, transactions.PendingCheckInterval)
|
||||||
|
accDB, err := accounts.NewDB(wdb.client)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
cmd := &loadBlocksAndTransfersCommand{
|
cmd := &loadBlocksAndTransfersCommand{
|
||||||
account: common.HexToAddress("0x1234"),
|
account: common.HexToAddress("0x1234"),
|
||||||
db: wdb,
|
db: wdb,
|
||||||
blockRangeDAO: &BlockRangeSequentialDAO{wdb.client},
|
blockRangeDAO: &BlockRangeSequentialDAO{wdb.client},
|
||||||
blockDAO: &BlockDAO{db},
|
blockDAO: &BlockDAO{db},
|
||||||
|
accountsDB: accDB,
|
||||||
chainClient: tc,
|
chainClient: tc,
|
||||||
feed: &event.Feed{},
|
feed: &event.Feed{},
|
||||||
balanceCacher: balance.NewCacherWithTTL(5 * time.Minute),
|
balanceCacher: balance.NewCacherWithTTL(5 * time.Minute),
|
||||||
|
|
|
@ -110,7 +110,7 @@ func (c *Controller) CheckRecentHistory(chainIDs []uint64, accounts []common.Add
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.reactor = NewReactor(c.db, c.blockDAO, c.blockRangesSeqDAO, c.TransferFeed, c.transactionManager,
|
c.reactor = NewReactor(c.db, c.blockDAO, c.blockRangesSeqDAO, c.accountsDB, c.TransferFeed, c.transactionManager,
|
||||||
c.pendingTxManager, c.tokenManager, c.balanceCacher, omitHistory)
|
c.pendingTxManager, c.tokenManager, c.balanceCacher, omitHistory)
|
||||||
|
|
||||||
err = c.reactor.start(chainClients, accounts)
|
err = c.reactor.start(chainClients, accounts)
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
|
"github.com/status-im/status-go/multiaccounts/accounts"
|
||||||
"github.com/status-im/status-go/rpc/chain"
|
"github.com/status-im/status-go/rpc/chain"
|
||||||
"github.com/status-im/status-go/services/wallet/balance"
|
"github.com/status-im/status-go/services/wallet/balance"
|
||||||
"github.com/status-im/status-go/services/wallet/token"
|
"github.com/status-im/status-go/services/wallet/token"
|
||||||
|
@ -49,6 +50,7 @@ type Reactor struct {
|
||||||
db *Database
|
db *Database
|
||||||
blockDAO *BlockDAO
|
blockDAO *BlockDAO
|
||||||
blockRangesSeqDAO *BlockRangeSequentialDAO
|
blockRangesSeqDAO *BlockRangeSequentialDAO
|
||||||
|
accountsDB *accounts.Database
|
||||||
feed *event.Feed
|
feed *event.Feed
|
||||||
transactionManager *TransactionManager
|
transactionManager *TransactionManager
|
||||||
pendingTxManager *transactions.PendingTxTracker
|
pendingTxManager *transactions.PendingTxTracker
|
||||||
|
@ -58,11 +60,12 @@ type Reactor struct {
|
||||||
omitHistory bool
|
omitHistory bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewReactor(db *Database, blockDAO *BlockDAO, blockRangesSeqDAO *BlockRangeSequentialDAO, feed *event.Feed, tm *TransactionManager,
|
func NewReactor(db *Database, blockDAO *BlockDAO, blockRangesSeqDAO *BlockRangeSequentialDAO, accountsDB *accounts.Database, feed *event.Feed, tm *TransactionManager,
|
||||||
pendingTxManager *transactions.PendingTxTracker, tokenManager *token.Manager,
|
pendingTxManager *transactions.PendingTxTracker, tokenManager *token.Manager,
|
||||||
balanceCacher balance.Cacher, omitHistory bool) *Reactor {
|
balanceCacher balance.Cacher, omitHistory bool) *Reactor {
|
||||||
return &Reactor{
|
return &Reactor{
|
||||||
db: db,
|
db: db,
|
||||||
|
accountsDB: accountsDB,
|
||||||
blockDAO: blockDAO,
|
blockDAO: blockDAO,
|
||||||
blockRangesSeqDAO: blockRangesSeqDAO,
|
blockRangesSeqDAO: blockRangesSeqDAO,
|
||||||
feed: feed,
|
feed: feed,
|
||||||
|
@ -101,6 +104,7 @@ func (r *Reactor) createFetchStrategy(chainClients map[uint64]chain.ClientInterf
|
||||||
r.db,
|
r.db,
|
||||||
r.blockDAO,
|
r.blockDAO,
|
||||||
r.blockRangesSeqDAO,
|
r.blockRangesSeqDAO,
|
||||||
|
r.accountsDB,
|
||||||
r.feed,
|
r.feed,
|
||||||
r.transactionManager,
|
r.transactionManager,
|
||||||
r.pendingTxManager,
|
r.pendingTxManager,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
"github.com/status-im/status-go/multiaccounts/accounts"
|
||||||
"github.com/status-im/status-go/rpc/chain"
|
"github.com/status-im/status-go/rpc/chain"
|
||||||
"github.com/status-im/status-go/services/wallet/async"
|
"github.com/status-im/status-go/services/wallet/async"
|
||||||
"github.com/status-im/status-go/services/wallet/balance"
|
"github.com/status-im/status-go/services/wallet/balance"
|
||||||
|
@ -16,7 +17,7 @@ import (
|
||||||
"github.com/status-im/status-go/transactions"
|
"github.com/status-im/status-go/transactions"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewSequentialFetchStrategy(db *Database, blockDAO *BlockDAO, blockRangesSeqDAO *BlockRangeSequentialDAO, feed *event.Feed,
|
func NewSequentialFetchStrategy(db *Database, blockDAO *BlockDAO, blockRangesSeqDAO *BlockRangeSequentialDAO, accountsDB *accounts.Database, feed *event.Feed,
|
||||||
transactionManager *TransactionManager, pendingTxManager *transactions.PendingTxTracker,
|
transactionManager *TransactionManager, pendingTxManager *transactions.PendingTxTracker,
|
||||||
tokenManager *token.Manager,
|
tokenManager *token.Manager,
|
||||||
chainClients map[uint64]chain.ClientInterface,
|
chainClients map[uint64]chain.ClientInterface,
|
||||||
|
@ -29,6 +30,7 @@ func NewSequentialFetchStrategy(db *Database, blockDAO *BlockDAO, blockRangesSeq
|
||||||
db: db,
|
db: db,
|
||||||
blockDAO: blockDAO,
|
blockDAO: blockDAO,
|
||||||
blockRangesSeqDAO: blockRangesSeqDAO,
|
blockRangesSeqDAO: blockRangesSeqDAO,
|
||||||
|
accountsDB: accountsDB,
|
||||||
feed: feed,
|
feed: feed,
|
||||||
transactionManager: transactionManager,
|
transactionManager: transactionManager,
|
||||||
pendingTxManager: pendingTxManager,
|
pendingTxManager: pendingTxManager,
|
||||||
|
@ -44,6 +46,7 @@ type SequentialFetchStrategy struct {
|
||||||
db *Database
|
db *Database
|
||||||
blockDAO *BlockDAO
|
blockDAO *BlockDAO
|
||||||
blockRangesSeqDAO *BlockRangeSequentialDAO
|
blockRangesSeqDAO *BlockRangeSequentialDAO
|
||||||
|
accountsDB *accounts.Database
|
||||||
feed *event.Feed
|
feed *event.Feed
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
group *async.Group
|
group *async.Group
|
||||||
|
@ -59,7 +62,7 @@ type SequentialFetchStrategy struct {
|
||||||
func (s *SequentialFetchStrategy) newCommand(chainClient chain.ClientInterface,
|
func (s *SequentialFetchStrategy) newCommand(chainClient chain.ClientInterface,
|
||||||
account common.Address) async.Commander {
|
account common.Address) async.Commander {
|
||||||
|
|
||||||
return newLoadBlocksAndTransfersCommand(account, s.db, s.blockDAO, s.blockRangesSeqDAO, chainClient, s.feed,
|
return newLoadBlocksAndTransfersCommand(account, s.db, s.accountsDB, s.blockDAO, s.blockRangesSeqDAO, chainClient, s.feed,
|
||||||
s.transactionManager, s.pendingTxManager, s.tokenManager, s.balanceCacher, s.omitHistory)
|
s.transactionManager, s.pendingTxManager, s.tokenManager, s.balanceCacher, s.omitHistory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue