2021-06-30 13:40:54 +02:00
|
|
|
package node
|
|
|
|
|
|
|
|
|
|
import (
|
2023-12-12 08:37:57 +01:00
|
|
|
"database/sql"
|
2021-06-30 13:40:54 +02:00
|
|
|
"errors"
|
2023-04-26 23:37:18 +08:00
|
|
|
"time"
|
2021-06-30 13:40:54 +02:00
|
|
|
|
2024-10-28 21:54:17 +01:00
|
|
|
"go.uber.org/zap"
|
|
|
|
|
|
2025-12-15 12:01:03 +00:00
|
|
|
"github.com/status-im/status-go/internal/db/multiaccounts/accounts"
|
2025-10-16 17:36:49 +01:00
|
|
|
"github.com/status-im/status-go/internal/timesource"
|
2025-12-12 21:28:00 +00:00
|
|
|
nodeadapters "github.com/status-im/status-go/pkg/backend/node/adapters"
|
2025-10-28 20:53:44 +00:00
|
|
|
"github.com/status-im/status-go/pkg/featureflags"
|
2025-06-26 10:06:15 -03:00
|
|
|
"github.com/status-im/status-go/pkg/pubsub"
|
2026-08-20 21:44:51 +01:00
|
|
|
"github.com/status-im/status-go/pkg/services/eth"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/linkpreview"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/newsfeed"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/sharedurls"
|
2022-06-25 15:20:02 +08:00
|
|
|
|
2021-06-30 13:40:54 +02:00
|
|
|
"github.com/ethereum/go-ethereum/event"
|
|
|
|
|
|
|
|
|
|
"github.com/status-im/status-go/params"
|
2026-08-20 21:44:51 +01:00
|
|
|
accountssvc "github.com/status-im/status-go/pkg/services/accounts"
|
|
|
|
|
appgeneral "github.com/status-im/status-go/pkg/services/app-general"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/browsers"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/chat"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/communitytokens"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/connector"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/ens"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/gif"
|
|
|
|
|
localnotifications "github.com/status-im/status-go/pkg/services/local-notifications"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/media"
|
2026-08-26 18:05:03 +01:00
|
|
|
"github.com/status-im/status-go/pkg/services/networks"
|
2026-08-20 21:44:51 +01:00
|
|
|
"github.com/status-im/status-go/pkg/services/permissions"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/personal"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/preferences"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/rpcstats"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/stickers"
|
2026-08-19 18:03:17 +04:00
|
|
|
"github.com/status-im/status-go/pkg/services/storagestats"
|
2026-08-20 21:44:51 +01:00
|
|
|
"github.com/status-im/status-go/pkg/services/updates"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/wakuv2ext"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/wallet"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/wallet/pendingtxtracker"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/wallet/router/fees"
|
|
|
|
|
"github.com/status-im/status-go/pkg/services/wallet/thirdparty"
|
2021-06-30 13:40:54 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
// ErrWakuClearIdentitiesFailure clearing whisper identities has failed.
|
|
|
|
|
ErrWakuClearIdentitiesFailure = errors.New("failed to clear waku identities")
|
2021-07-09 15:19:33 +02:00
|
|
|
// ErrRPCClientUnavailable is returned if an RPC client can't be retrieved.
|
|
|
|
|
// This is a normal situation when a node is stopped.
|
|
|
|
|
ErrRPCClientUnavailable = errors.New("JSON-RPC client is unavailable")
|
2021-06-30 13:40:54 +02:00
|
|
|
)
|
|
|
|
|
|
2025-12-17 21:03:34 +01:00
|
|
|
func (b *StatusNode) ThirdpartyServicesEnabled() (bool, error) {
|
|
|
|
|
accDB, err := accounts.NewDB(b.appDB)
|
|
|
|
|
if err != nil {
|
|
|
|
|
b.logger.Error("failed to create accounts db", zap.Error(err))
|
|
|
|
|
return true, err
|
|
|
|
|
}
|
|
|
|
|
enabled, err := accDB.ThirdpartyServicesEnabled()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return true, err
|
|
|
|
|
}
|
|
|
|
|
return enabled, nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-19 20:50:03 +01:00
|
|
|
func (b *StatusNode) initServices(config *params.NodeConfig, mediaServer *media.Server) error {
|
2022-03-23 18:47:00 +00:00
|
|
|
accDB, err := accounts.NewDB(b.appDB)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
2023-12-12 08:37:57 +01:00
|
|
|
|
2026-08-19 20:49:00 +01:00
|
|
|
services := []StatusService{}
|
2021-06-30 13:40:54 +02:00
|
|
|
services = append(services, b.rpcStatsService())
|
2026-08-26 18:05:03 +01:00
|
|
|
services = append(services, b.networksService())
|
2024-08-29 16:03:24 +05:30
|
|
|
services = append(services, b.appgeneralService())
|
2021-06-30 13:40:54 +02:00
|
|
|
services = append(services, b.personalService())
|
2023-08-01 19:50:30 +01:00
|
|
|
services = append(services, b.pendingTrackerService(&b.walletFeed))
|
2023-04-26 23:37:18 +08:00
|
|
|
services = append(services, b.ensService(b.timeSourceNow()))
|
2025-01-16 19:22:46 +01:00
|
|
|
services = append(services, b.CommunityTokensService())
|
2022-03-23 18:47:00 +00:00
|
|
|
services = append(services, b.stickersService(accDB))
|
2022-06-08 08:38:26 -04:00
|
|
|
services = append(services, b.updatesService())
|
2025-06-26 10:06:15 -03:00
|
|
|
services = appendIf(b.appDB != nil && b.multiaccountsDB != nil, services, b.accountsService(accDB, mediaServer))
|
2021-06-30 13:40:54 +02:00
|
|
|
services = appendIf(config.BrowsersConfig.Enabled, services, b.browsersService())
|
|
|
|
|
services = appendIf(config.PermissionsConfig.Enabled, services, b.permissionsService())
|
2026-05-26 14:18:15 +02:00
|
|
|
services = appendIf(b.appDB != nil, services, b.preferencesService())
|
2026-08-19 18:03:17 +04:00
|
|
|
services = appendIf(b.appDB != nil, services, b.storageStatsService())
|
2024-06-24 16:29:40 +02:00
|
|
|
services = appendIf(config.ConnectorConfig.Enabled, services, b.connectorService())
|
2022-03-23 18:47:00 +00:00
|
|
|
services = append(services, b.gifService(accDB))
|
|
|
|
|
services = append(services, b.ChatService(accDB))
|
2025-09-09 11:27:15 +01:00
|
|
|
services = append(services, b.ethService())
|
2021-12-21 15:44:37 +00:00
|
|
|
|
2023-07-12 15:27:36 -03:00
|
|
|
// Wallet Service is used by wakuExtSrvc/wakuV2ExtSrvc
|
|
|
|
|
// Keep this initialization before the other two
|
|
|
|
|
if config.WalletConfig.Enabled {
|
2026-05-29 20:12:18 +04:00
|
|
|
err := b.createWalletService(accDB, b.appDB, b.accountsPublisher, &b.walletFeed)
|
2025-09-25 14:05:19 +02:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
services = append(services, b.walletSrvc)
|
2023-07-12 15:27:36 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CollectiblesManager needs the WakuExt service to get metadata for
|
|
|
|
|
// Community collectibles.
|
|
|
|
|
// Messenger needs the CollectiblesManager to get the list of collectibles owned
|
|
|
|
|
// by a certain account and check community entry permissions.
|
2023-10-26 03:30:18 -03:00
|
|
|
// We handle circular dependency between the two by delaying ininitalization of the CommunityCollectibleInfoProvider
|
2023-07-12 15:27:36 -03:00
|
|
|
// in the CollectiblesManager.
|
2021-06-30 13:40:54 +02:00
|
|
|
if config.WakuV2Config.Enabled {
|
|
|
|
|
wakuext, err := b.wakuV2ExtService(config)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
b.wakuV2ExtSrvc = wakuext
|
|
|
|
|
|
|
|
|
|
services = append(services, wakuext)
|
|
|
|
|
|
2023-12-14 17:50:46 +01:00
|
|
|
b.SetWalletCommunityInfoProvider(wakuext)
|
2023-06-28 07:48:33 -03:00
|
|
|
}
|
|
|
|
|
|
2021-06-30 13:40:54 +02:00
|
|
|
// We ignore for now local notifications flag as users who are upgrading have no mean to enable it
|
2022-03-23 18:47:00 +00:00
|
|
|
lns, err := b.localNotificationsService(config.NetworkID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
services = append(services, lns)
|
2021-06-30 13:40:54 +02:00
|
|
|
|
2025-12-17 21:03:34 +01:00
|
|
|
if b.NewsFeedService() != nil {
|
|
|
|
|
services = append(services, b.NewsFeedService())
|
|
|
|
|
}
|
2025-10-31 20:44:06 +00:00
|
|
|
services = append(services, b.sharedUrlsService())
|
2025-11-26 17:08:27 +01:00
|
|
|
services = append(services, b.linkPreviewService(accDB))
|
2025-10-28 20:53:44 +00:00
|
|
|
|
2025-09-09 11:27:15 +01:00
|
|
|
b.services = services
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-28 20:53:44 +00:00
|
|
|
func (b *StatusNode) runServicesMigrations() error {
|
|
|
|
|
err := newsfeed.SQLiteMigrate(b.appDB)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-19 20:49:00 +01:00
|
|
|
func (b *StatusNode) registerService(s StatusService) error {
|
2025-09-09 11:27:15 +01:00
|
|
|
for _, api := range s.APIs() {
|
|
|
|
|
b.logger.Debug("registering service api", zap.String("namespace", api.Namespace))
|
|
|
|
|
err := b.rpcServer.RegisterName(api.Namespace, api.Service)
|
|
|
|
|
if err != nil {
|
|
|
|
|
b.logger.Error("Failed to register API", zap.String("namespace", api.Namespace), zap.Error(err))
|
|
|
|
|
return err
|
|
|
|
|
}
|
2021-06-30 13:40:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (b *StatusNode) wakuV2ExtService(config *params.NodeConfig) (*wakuv2ext.Service, error) {
|
|
|
|
|
if b.wakuV2ExtSrvc == nil {
|
2025-08-11 20:29:23 +02:00
|
|
|
b.wakuV2ExtSrvc = wakuv2ext.New(*config, b.rpcClient, b.logger.Named("protocol"))
|
2021-06-30 13:40:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return b.wakuV2ExtSrvc, nil
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-06 19:12:49 +03:00
|
|
|
func (b *StatusNode) AccountService() *accountssvc.Service {
|
|
|
|
|
return b.accountsSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 20:21:14 +08:00
|
|
|
func (b *StatusNode) BrowserService() *browsers.Service {
|
|
|
|
|
return b.browsersSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-26 23:37:18 +08:00
|
|
|
func (b *StatusNode) EnsService() *ens.Service {
|
|
|
|
|
return b.ensSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-30 13:40:54 +02:00
|
|
|
func (b *StatusNode) WakuV2ExtService() *wakuv2ext.Service {
|
|
|
|
|
return b.wakuV2ExtSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-24 16:29:40 +02:00
|
|
|
func (b *StatusNode) connectorService() *connector.Service {
|
|
|
|
|
if b.connectorSrvc == nil {
|
2025-10-17 19:04:54 -03:00
|
|
|
logger := b.logger.Named("connector")
|
2026-02-16 22:01:11 +04:00
|
|
|
|
2025-09-09 11:27:15 +01:00
|
|
|
b.connectorSrvc = connector.NewService(
|
2025-10-17 19:04:54 -03:00
|
|
|
logger,
|
2025-09-09 11:27:15 +01:00
|
|
|
b.walletDB,
|
|
|
|
|
b.rpcClient,
|
2025-10-17 19:04:54 -03:00
|
|
|
fees.NewFeeManager(b.rpcClient, logger.Named("feeManager")),
|
2026-08-26 18:05:03 +01:00
|
|
|
b.networkManager,
|
2025-09-09 11:27:15 +01:00
|
|
|
&connector.Config{
|
2026-03-13 21:01:25 +04:00
|
|
|
WSEnabled: b.config.WSEnabled,
|
2026-02-16 22:01:11 +04:00
|
|
|
WSHost: b.config.WSHost,
|
|
|
|
|
WSPort: b.config.WSPort,
|
|
|
|
|
ProjectID: b.config.WalletConnectProjectID,
|
2025-09-09 11:27:15 +01:00
|
|
|
},
|
|
|
|
|
)
|
2024-06-24 16:29:40 +02:00
|
|
|
}
|
|
|
|
|
return b.connectorSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-26 18:05:03 +01:00
|
|
|
func (b *StatusNode) networksService() *networks.Service {
|
|
|
|
|
if b.networksSrvc == nil {
|
|
|
|
|
b.networksSrvc = networks.NewService(b.networkManager)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return b.networksSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-30 13:40:54 +02:00
|
|
|
func (b *StatusNode) rpcStatsService() *rpcstats.Service {
|
|
|
|
|
if b.rpcStatsSrvc == nil {
|
|
|
|
|
b.rpcStatsSrvc = rpcstats.New()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return b.rpcStatsSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-19 20:50:03 +01:00
|
|
|
func (b *StatusNode) accountsService(accDB *accounts.Database, mediaServer *media.Server) *accountssvc.Service {
|
2021-06-30 13:40:54 +02:00
|
|
|
if b.accountsSrvc == nil {
|
2022-01-24 10:29:18 +01:00
|
|
|
b.accountsSrvc = accountssvc.NewService(
|
2022-03-23 18:47:00 +00:00
|
|
|
accDB,
|
2022-01-24 10:29:18 +01:00
|
|
|
b.multiaccountsDB,
|
2025-06-30 10:24:43 +02:00
|
|
|
b.gethAccountsManager,
|
2022-01-24 10:29:18 +01:00
|
|
|
b.config,
|
2025-06-17 01:02:34 -03:00
|
|
|
b.accountsPublisher,
|
2022-06-25 15:20:02 +08:00
|
|
|
mediaServer,
|
2025-10-03 11:36:39 -04:00
|
|
|
b.logger.Named("AccountsService"),
|
2022-01-24 10:29:18 +01:00
|
|
|
)
|
2021-06-30 13:40:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return b.accountsSrvc
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (b *StatusNode) browsersService() *browsers.Service {
|
|
|
|
|
if b.browsersSrvc == nil {
|
|
|
|
|
b.browsersSrvc = browsers.NewService(browsers.NewDB(b.appDB))
|
|
|
|
|
}
|
|
|
|
|
return b.browsersSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-26 23:37:18 +08:00
|
|
|
func (b *StatusNode) ensService(timesource func() time.Time) *ens.Service {
|
2021-12-21 16:05:09 +01:00
|
|
|
if b.ensSrvc == nil {
|
2025-06-30 10:24:43 +02:00
|
|
|
b.ensSrvc = ens.NewService(b.rpcClient, b.gethAccountsManager, b.pendingTracker, b.config, b.appDB, timesource)
|
2021-12-21 16:05:09 +01:00
|
|
|
}
|
|
|
|
|
return b.ensSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-17 07:29:28 -03:00
|
|
|
func (b *StatusNode) pendingTrackerService(walletFeed *event.Feed) *pendingtxtracker.PendingTxTracker {
|
2023-08-01 19:50:30 +01:00
|
|
|
if b.pendingTracker == nil {
|
2025-10-17 07:29:28 -03:00
|
|
|
b.pendingTracker = pendingtxtracker.NewPendingTxTracker(b.walletDB, pendingtxtracker.NewBatchTxStatusFetcher(b.rpcClient, b.logger.Named("PendingTxTracker")), walletFeed, pendingtxtracker.PendingCheckInterval)
|
2024-03-12 10:15:30 +01:00
|
|
|
if b.transactor != nil {
|
|
|
|
|
b.transactor.SetPendingTracker(b.pendingTracker)
|
|
|
|
|
}
|
2023-08-01 19:50:30 +01:00
|
|
|
}
|
|
|
|
|
return b.pendingTracker
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-16 19:22:46 +01:00
|
|
|
func (b *StatusNode) CommunityTokensService() *communitytokens.Service {
|
|
|
|
|
if b.communityTokensSrvc == nil {
|
2025-06-30 10:24:43 +02:00
|
|
|
b.communityTokensSrvc = communitytokens.NewService(b.rpcClient, b.gethAccountsManager, b.config, b.appDB, &b.walletFeed, b.transactor)
|
2024-12-10 11:56:24 +01:00
|
|
|
}
|
2025-01-16 19:22:46 +01:00
|
|
|
return b.communityTokensSrvc
|
2024-12-10 11:56:24 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-23 18:47:00 +00:00
|
|
|
func (b *StatusNode) stickersService(accountDB *accounts.Database) *stickers.Service {
|
2022-02-02 18:50:55 -04:00
|
|
|
if b.stickersSrvc == nil {
|
2025-09-10 10:19:04 +01:00
|
|
|
b.stickersSrvc = stickers.NewService(accountDB, b.rpcClient, b.gethAccountsManager, b.config, b.downloader, b.mediaServer, b.pendingTracker)
|
2022-02-02 18:50:55 -04:00
|
|
|
}
|
|
|
|
|
return b.stickersSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 08:38:26 -04:00
|
|
|
func (b *StatusNode) updatesService() *updates.Service {
|
|
|
|
|
if b.updatesSrvc == nil {
|
2023-04-26 23:37:18 +08:00
|
|
|
b.updatesSrvc = updates.NewService(b.ensService(b.timeSourceNow()))
|
2022-06-08 08:38:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return b.updatesSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-23 18:47:00 +00:00
|
|
|
func (b *StatusNode) gifService(accountsDB *accounts.Database) *gif.Service {
|
2022-01-31 13:58:03 +01:00
|
|
|
if b.gifSrvc == nil {
|
2022-03-23 18:47:00 +00:00
|
|
|
b.gifSrvc = gif.NewService(accountsDB)
|
2022-01-31 13:58:03 +01:00
|
|
|
}
|
|
|
|
|
return b.gifSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-23 18:47:00 +00:00
|
|
|
func (b *StatusNode) ChatService(accountsDB *accounts.Database) *chat.Service {
|
2022-02-10 11:15:27 -04:00
|
|
|
if b.chatSrvc == nil {
|
2022-03-23 18:47:00 +00:00
|
|
|
b.chatSrvc = chat.NewService(accountsDB)
|
2022-02-10 11:15:27 -04:00
|
|
|
}
|
|
|
|
|
return b.chatSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-30 13:40:54 +02:00
|
|
|
func (b *StatusNode) permissionsService() *permissions.Service {
|
|
|
|
|
if b.permissionsSrvc == nil {
|
|
|
|
|
b.permissionsSrvc = permissions.NewService(permissions.NewDB(b.appDB))
|
|
|
|
|
}
|
|
|
|
|
return b.permissionsSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-26 14:18:15 +02:00
|
|
|
func (b *StatusNode) preferencesService() *preferences.Service {
|
|
|
|
|
if b.preferencesSrvc == nil {
|
|
|
|
|
b.preferencesSrvc = preferences.NewService(b.appDB)
|
|
|
|
|
}
|
|
|
|
|
return b.preferencesSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-29 16:03:24 +05:30
|
|
|
func (b *StatusNode) appgeneralService() *appgeneral.Service {
|
|
|
|
|
if b.appGeneralSrvc == nil {
|
|
|
|
|
b.appGeneralSrvc = appgeneral.New()
|
|
|
|
|
}
|
|
|
|
|
return b.appGeneralSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-19 18:03:17 +04:00
|
|
|
func (b *StatusNode) storageStatsService() *storagestats.Service {
|
|
|
|
|
if b.storageStatsSrvc == nil {
|
|
|
|
|
b.storageStatsSrvc = storagestats.New(b.appDB, b.walletDB, b.logger)
|
|
|
|
|
}
|
|
|
|
|
return b.storageStatsSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-25 13:00:17 +01:00
|
|
|
func (b *StatusNode) WalletService() *wallet.Service {
|
|
|
|
|
return b.walletSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-26 10:06:15 -03:00
|
|
|
func (b *StatusNode) AccountsPublisher() *pubsub.Publisher {
|
|
|
|
|
return b.accountsPublisher
|
2024-08-31 00:58:03 +05:30
|
|
|
}
|
|
|
|
|
|
2023-12-14 17:50:46 +01:00
|
|
|
func (b *StatusNode) SetWalletCommunityInfoProvider(provider thirdparty.CommunityInfoProvider) {
|
2023-09-21 09:40:58 -03:00
|
|
|
if b.walletSrvc != nil {
|
2023-12-14 17:50:46 +01:00
|
|
|
b.walletSrvc.SetWalletCommunityInfoProvider(provider)
|
2023-09-21 09:40:58 -03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-29 20:12:18 +04:00
|
|
|
func (b *StatusNode) createWalletService(accountsDB *accounts.Database, appDB *sql.DB, accountsPublisher *pubsub.Publisher, walletFeed *event.Feed) (err error) {
|
2021-06-30 13:40:54 +02:00
|
|
|
if b.walletSrvc == nil {
|
2025-09-25 14:05:19 +02:00
|
|
|
b.walletSrvc, err = wallet.NewService(
|
2025-06-30 10:24:43 +02:00
|
|
|
b.walletDB, accountsDB, appDB, b.rpcClient, accountsPublisher, b.gethAccountsManager, b.transactor, b.config,
|
2024-11-05 12:05:23 +01:00
|
|
|
b.ensService(b.timeSourceNow()).API().EnsResolver(),
|
2023-08-01 19:50:30 +01:00
|
|
|
b.pendingTracker,
|
|
|
|
|
walletFeed,
|
2025-09-10 10:19:04 +01:00
|
|
|
b.mediaServer,
|
2025-09-08 21:01:02 +02:00
|
|
|
b.tokenManager,
|
2022-09-13 09:10:59 +02:00
|
|
|
)
|
2021-06-30 13:40:54 +02:00
|
|
|
}
|
2025-09-25 14:05:19 +02:00
|
|
|
return
|
2021-06-30 13:40:54 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-09 11:27:15 +01:00
|
|
|
func (b *StatusNode) ethService() *eth.Service {
|
|
|
|
|
if b.ethSrvc == nil {
|
|
|
|
|
b.ethSrvc = eth.NewService(b.rpcClient, b.gethAccountsManager)
|
|
|
|
|
}
|
|
|
|
|
return b.ethSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-31 20:44:06 +00:00
|
|
|
func (b *StatusNode) sharedUrlsService() *sharedurls.Service {
|
|
|
|
|
if b.sharedUrlsSrvc == nil {
|
|
|
|
|
b.sharedUrlsSrvc = sharedurls.NewService(nil)
|
|
|
|
|
if extService := b.WakuV2ExtService(); extService != nil {
|
2025-12-12 21:28:00 +00:00
|
|
|
provider := nodeadapters.NewSharedUrlsMessengerAdapter(extService.Messenger())
|
2025-10-31 20:44:06 +00:00
|
|
|
b.sharedUrlsSrvc.SetDataProvider(provider)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return b.sharedUrlsSrvc
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (b *StatusNode) SharedUrlsService() *sharedurls.Service {
|
|
|
|
|
return b.sharedUrlsSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-26 17:08:27 +01:00
|
|
|
func (b *StatusNode) linkPreviewService(accDB *accounts.Database) *linkpreview.Service {
|
|
|
|
|
if b.linkPreviewSrvc == nil {
|
2025-12-12 21:28:00 +00:00
|
|
|
settingsProvider := nodeadapters.NewLinkPreviewSettingsAdapter(accDB)
|
2025-11-26 17:08:27 +01:00
|
|
|
b.linkPreviewSrvc = linkpreview.NewService(b.logger.Named("linkpreview"), settingsProvider, nil)
|
|
|
|
|
}
|
|
|
|
|
return b.linkPreviewSrvc
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (b *StatusNode) LinkPreviewService() *linkpreview.Service {
|
|
|
|
|
return b.linkPreviewSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-23 18:47:00 +00:00
|
|
|
func (b *StatusNode) localNotificationsService(network uint64) (*localnotifications.Service, error) {
|
|
|
|
|
var err error
|
2021-06-30 13:40:54 +02:00
|
|
|
if b.localNotificationsSrvc == nil {
|
2024-12-05 15:44:03 -03:00
|
|
|
b.localNotificationsSrvc, err = localnotifications.NewService(b.appDB)
|
2022-03-23 18:47:00 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
2021-06-30 13:40:54 +02:00
|
|
|
}
|
2022-03-23 18:47:00 +00:00
|
|
|
return b.localNotificationsSrvc, nil
|
2021-06-30 13:40:54 +02:00
|
|
|
}
|
|
|
|
|
|
2026-08-19 20:49:00 +01:00
|
|
|
func appendIf(condition bool, services []StatusService, service StatusService) []StatusService {
|
2021-06-30 13:40:54 +02:00
|
|
|
if !condition {
|
|
|
|
|
return services
|
|
|
|
|
}
|
|
|
|
|
return append(services, service)
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-17 07:29:28 -03:00
|
|
|
func (b *StatusNode) PendingTracker() *pendingtxtracker.PendingTxTracker {
|
2023-08-01 19:50:30 +01:00
|
|
|
return b.pendingTracker
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-30 13:40:54 +02:00
|
|
|
func (b *StatusNode) StopLocalNotifications() error {
|
|
|
|
|
if b.localNotificationsSrvc == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if b.localNotificationsSrvc.IsStarted() {
|
|
|
|
|
err := b.localNotificationsSrvc.Stop()
|
|
|
|
|
if err != nil {
|
2024-10-28 21:54:17 +01:00
|
|
|
b.logger.Error("LocalNotifications service stop failed on StopLocalNotifications", zap.Error(err))
|
2021-06-30 13:40:54 +02:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (b *StatusNode) StartLocalNotifications() error {
|
|
|
|
|
if b.localNotificationsSrvc == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if b.walletSrvc == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !b.localNotificationsSrvc.IsStarted() {
|
|
|
|
|
err := b.localNotificationsSrvc.Start()
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
2024-10-28 21:54:17 +01:00
|
|
|
b.logger.Error("LocalNotifications service start failed on StartLocalNotifications", zap.Error(err))
|
2021-06-30 13:40:54 +02:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (b *StatusNode) personalService() *personal.Service {
|
|
|
|
|
if b.personalSrvc == nil {
|
2025-06-02 16:03:24 +02:00
|
|
|
b.personalSrvc = personal.New()
|
2021-06-30 13:40:54 +02:00
|
|
|
}
|
|
|
|
|
return b.personalSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-16 17:36:49 +01:00
|
|
|
func (b *StatusNode) TimeSource() timesource.Provider {
|
2021-06-30 13:40:54 +02:00
|
|
|
if b.timeSourceSrvc == nil {
|
2025-12-17 21:03:34 +01:00
|
|
|
thirdpartyServicesEnabled, err := b.ThirdpartyServicesEnabled()
|
|
|
|
|
if err != nil {
|
|
|
|
|
b.logger.Error("failed to get if thirdparty services enabled", zap.Error(err))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if thirdpartyServicesEnabled {
|
2025-10-16 17:36:49 +01:00
|
|
|
b.timeSourceSrvc = timesource.DefaultService()
|
2025-12-17 21:03:34 +01:00
|
|
|
} else {
|
|
|
|
|
b.timeSourceSrvc = timesource.LocalService()
|
2025-10-16 17:36:49 +01:00
|
|
|
}
|
2021-06-30 13:40:54 +02:00
|
|
|
}
|
|
|
|
|
return b.timeSourceSrvc
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-26 23:37:18 +08:00
|
|
|
func (b *StatusNode) timeSourceNow() func() time.Time {
|
2025-06-11 13:52:14 +02:00
|
|
|
return b.TimeSource().Now
|
2023-04-26 23:37:18 +08:00
|
|
|
}
|
|
|
|
|
|
2025-10-28 20:53:44 +00:00
|
|
|
func (b *StatusNode) NewsFeedService() *newsfeed.Service {
|
2025-12-17 21:03:34 +01:00
|
|
|
thirdpartyServicesEnabled, err := b.ThirdpartyServicesEnabled()
|
|
|
|
|
if err != nil {
|
|
|
|
|
b.logger.Error("failed to get if thirdparty services are enabled", zap.Error(err))
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !featureflags.EnableNewsFeed || !thirdpartyServicesEnabled {
|
2025-10-28 20:53:44 +00:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if b.newsfeedSrvc == nil {
|
|
|
|
|
persistence := newsfeed.NewSQLitePersistence(b.appDB)
|
|
|
|
|
|
|
|
|
|
b.newsfeedSrvc = newsfeed.NewService(
|
|
|
|
|
b.logger.Named("newsfeed"),
|
|
|
|
|
persistence,
|
2025-11-04 09:57:35 +00:00
|
|
|
nil,
|
2025-10-28 20:53:44 +00:00
|
|
|
)
|
2025-11-04 09:57:35 +00:00
|
|
|
|
2025-11-05 14:24:03 -05:00
|
|
|
if wakuext := b.WakuV2ExtService(); wakuext != nil && wakuext.Messenger() != nil {
|
2025-12-12 21:28:00 +00:00
|
|
|
ac := nodeadapters.NewNewsFeedActivityCenterAdapter(wakuext.Messenger())
|
2025-11-04 09:57:35 +00:00
|
|
|
b.newsfeedSrvc.SetActivityCenter(ac)
|
|
|
|
|
}
|
2025-10-28 20:53:44 +00:00
|
|
|
}
|
|
|
|
|
return b.newsfeedSrvc
|
|
|
|
|
}
|