2023-03-16 14:49:25 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/rand"
|
|
|
|
"encoding/json"
|
|
|
|
"math/big"
|
2024-03-28 15:01:44 +00:00
|
|
|
"path/filepath"
|
2023-03-16 14:49:25 +00:00
|
|
|
|
|
|
|
"github.com/status-im/status-go/account/generator"
|
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
|
|
|
"github.com/status-im/status-go/multiaccounts/settings"
|
|
|
|
"github.com/status-im/status-go/params"
|
2024-04-24 15:36:02 +00:00
|
|
|
"github.com/status-im/status-go/protocol"
|
2024-08-14 20:10:19 +00:00
|
|
|
"github.com/status-im/status-go/protocol/encryption/multidevice"
|
2023-03-16 14:49:25 +00:00
|
|
|
"github.com/status-im/status-go/protocol/identity/alias"
|
2024-04-24 15:36:02 +00:00
|
|
|
"github.com/status-im/status-go/protocol/protobuf"
|
2023-03-16 14:49:25 +00:00
|
|
|
"github.com/status-im/status-go/protocol/requests"
|
|
|
|
)
|
|
|
|
|
2024-08-14 20:10:19 +00:00
|
|
|
const (
|
|
|
|
pathWalletRoot = "m/44'/60'/0'/0"
|
|
|
|
pathEIP1581 = "m/43'/60'/1581'"
|
|
|
|
pathDefaultChat = pathEIP1581 + "/0'/0"
|
|
|
|
pathEncryption = pathEIP1581 + "/1'/0"
|
|
|
|
pathDefaultWallet = pathWalletRoot + "/0"
|
|
|
|
defaultMnemonicLength = 12
|
|
|
|
shardsTestClusterID = 16
|
|
|
|
walletAccountDefaultName = "Account 1"
|
|
|
|
|
|
|
|
DefaultKeystoreRelativePath = "keystore"
|
|
|
|
DefaultKeycardPairingDataFile = "/ethereum/mainnet_rpc/keycard/pairings.json"
|
|
|
|
DefaultDataDir = "/ethereum/mainnet_rpc"
|
|
|
|
DefaultNodeName = "StatusIM"
|
|
|
|
DefaultLogFile = "geth.log"
|
|
|
|
DefaultLogLevel = "ERROR"
|
|
|
|
DefaultMaxPeers = 20
|
|
|
|
DefaultMaxPendingPeers = 20
|
|
|
|
DefaultListenAddr = ":0"
|
|
|
|
DefaultMaxMessageDeliveryAttempts = 3
|
|
|
|
DefaultVerifyTransactionChainID = 1
|
|
|
|
DefaultCurrentNetwork = "mainnet_rpc"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
paths = []string{pathWalletRoot, pathEIP1581, pathDefaultChat, pathDefaultWallet, pathEncryption}
|
|
|
|
|
|
|
|
DefaultFleet = params.FleetStatusProd
|
|
|
|
|
|
|
|
overrideApiConfig = overrideApiConfigProd
|
|
|
|
)
|
2024-07-04 10:48:40 +00:00
|
|
|
|
2024-06-26 11:14:27 +00:00
|
|
|
func defaultSettings(keyUID string, address string, derivedAddresses map[string]generator.AccountInfo) (*settings.Settings, error) {
|
2023-03-16 14:49:25 +00:00
|
|
|
chatKeyString := derivedAddresses[pathDefaultChat].PublicKey
|
|
|
|
|
2023-03-28 14:47:58 +00:00
|
|
|
s := &settings.Settings{}
|
|
|
|
s.BackupEnabled = true
|
|
|
|
logLevel := "INFO"
|
|
|
|
s.LogLevel = &logLevel
|
2023-06-19 16:55:04 +00:00
|
|
|
s.ProfilePicturesShowTo = settings.ProfilePicturesShowToEveryone
|
|
|
|
s.ProfilePicturesVisibility = settings.ProfilePicturesVisibilityEveryone
|
2024-06-26 11:14:27 +00:00
|
|
|
s.KeyUID = keyUID
|
|
|
|
s.Address = types.HexToAddress(address)
|
2023-03-28 14:47:58 +00:00
|
|
|
s.WalletRootAddress = types.HexToAddress(derivedAddresses[pathWalletRoot].Address)
|
2023-10-13 14:31:56 +00:00
|
|
|
s.URLUnfurlingMode = settings.URLUnfurlingAlwaysAsk
|
2023-03-16 14:49:25 +00:00
|
|
|
|
|
|
|
// Set chat key & name
|
|
|
|
name, err := alias.GenerateFromPublicKeyString(chatKeyString)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-03-28 14:47:58 +00:00
|
|
|
s.Name = name
|
|
|
|
s.PublicKey = chatKeyString
|
2023-03-16 14:49:25 +00:00
|
|
|
|
2023-03-28 14:47:58 +00:00
|
|
|
s.DappsAddress = types.HexToAddress(derivedAddresses[pathDefaultWallet].Address)
|
|
|
|
s.EIP1581Address = types.HexToAddress(derivedAddresses[pathEIP1581].Address)
|
2023-03-16 14:49:25 +00:00
|
|
|
|
|
|
|
signingPhrase, err := buildSigningPhrase()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-03-28 14:47:58 +00:00
|
|
|
s.SigningPhrase = signingPhrase
|
2023-03-16 14:49:25 +00:00
|
|
|
|
2023-03-28 14:47:58 +00:00
|
|
|
s.SendPushNotifications = true
|
2024-08-14 20:10:19 +00:00
|
|
|
s.InstallationID = multidevice.GenerateInstallationID()
|
2023-03-28 14:47:58 +00:00
|
|
|
s.UseMailservers = true
|
2023-03-16 14:49:25 +00:00
|
|
|
|
2023-03-28 14:47:58 +00:00
|
|
|
s.PreviewPrivacy = true
|
2024-03-05 10:44:09 +00:00
|
|
|
s.PeerSyncingEnabled = false
|
2023-03-28 14:47:58 +00:00
|
|
|
s.Currency = "usd"
|
|
|
|
s.LinkPreviewRequestEnabled = true
|
2023-03-16 14:49:25 +00:00
|
|
|
|
|
|
|
visibleTokens := make(map[string][]string)
|
|
|
|
visibleTokens["mainnet"] = []string{"SNT"}
|
|
|
|
visibleTokensJSON, err := json.Marshal(visibleTokens)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
visibleTokenJSONRaw := json.RawMessage(visibleTokensJSON)
|
2023-03-28 14:47:58 +00:00
|
|
|
s.WalletVisibleTokens = &visibleTokenJSONRaw
|
2023-03-16 14:49:25 +00:00
|
|
|
|
|
|
|
// TODO: fix this
|
|
|
|
networks := make([]map[string]string, 0)
|
|
|
|
networksJSON, err := json.Marshal(networks)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
networkRawMessage := json.RawMessage(networksJSON)
|
2023-03-28 14:47:58 +00:00
|
|
|
s.Networks = &networkRawMessage
|
2024-08-14 20:10:19 +00:00
|
|
|
s.CurrentNetwork = DefaultCurrentNetwork
|
2023-03-16 14:49:25 +00:00
|
|
|
|
2024-01-05 11:12:53 +00:00
|
|
|
s.TokenGroupByCommunity = false
|
|
|
|
s.ShowCommunityAssetWhenSendingTokens = true
|
|
|
|
s.DisplayAssetsBelowBalance = false
|
|
|
|
|
2024-03-26 11:38:16 +00:00
|
|
|
s.TestNetworksEnabled = false
|
|
|
|
|
2024-04-24 15:36:02 +00:00
|
|
|
// Default user status
|
|
|
|
currentUserStatus, err := json.Marshal(protocol.UserStatus{
|
|
|
|
PublicKey: chatKeyString,
|
|
|
|
StatusType: int(protobuf.StatusUpdate_AUTOMATIC),
|
|
|
|
Clock: 0,
|
|
|
|
CustomText: "",
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
userRawMessage := json.RawMessage(currentUserStatus)
|
|
|
|
s.CurrentUserStatus = &userRawMessage
|
|
|
|
|
2023-03-28 14:47:58 +00:00
|
|
|
return s, nil
|
2023-03-16 14:49:25 +00:00
|
|
|
}
|
|
|
|
|
2023-09-27 17:26:10 +00:00
|
|
|
func SetDefaultFleet(nodeConfig *params.NodeConfig) error {
|
2023-12-07 13:45:53 +00:00
|
|
|
return SetFleet(DefaultFleet, nodeConfig)
|
2023-11-10 15:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func SetFleet(fleet string, nodeConfig *params.NodeConfig) error {
|
2024-04-26 14:11:49 +00:00
|
|
|
specifiedWakuV2Config := nodeConfig.WakuV2Config
|
2023-12-07 13:45:53 +00:00
|
|
|
nodeConfig.WakuV2Config = params.WakuV2Config{
|
|
|
|
Enabled: true,
|
|
|
|
EnableDiscV5: true,
|
|
|
|
DiscoveryLimit: 20,
|
|
|
|
Host: "0.0.0.0",
|
|
|
|
AutoUpdate: true,
|
2024-04-26 14:11:49 +00:00
|
|
|
// mobile may need override following options
|
2024-07-11 09:57:56 +00:00
|
|
|
LightClient: specifiedWakuV2Config.LightClient,
|
|
|
|
EnableStoreConfirmationForMessagesSent: specifiedWakuV2Config.EnableStoreConfirmationForMessagesSent,
|
2024-07-26 19:19:19 +00:00
|
|
|
EnableMissingMessageVerification: specifiedWakuV2Config.EnableMissingMessageVerification,
|
2024-07-11 09:57:56 +00:00
|
|
|
Nameserver: specifiedWakuV2Config.Nameserver,
|
2023-12-07 13:45:53 +00:00
|
|
|
}
|
|
|
|
|
2023-11-10 15:12:54 +00:00
|
|
|
clusterConfig, err := params.LoadClusterConfigFromFleet(fleet)
|
2023-09-27 17:26:10 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
nodeConfig.ClusterConfig = *clusterConfig
|
2023-12-07 13:45:53 +00:00
|
|
|
nodeConfig.ClusterConfig.Fleet = fleet
|
2024-02-22 19:32:24 +00:00
|
|
|
nodeConfig.ClusterConfig.WakuNodes = params.DefaultWakuNodes(fleet)
|
2024-05-26 23:16:26 +00:00
|
|
|
nodeConfig.ClusterConfig.DiscV5BootstrapNodes = params.DefaultDiscV5Nodes(fleet)
|
2023-12-07 13:45:53 +00:00
|
|
|
|
2024-07-29 21:19:48 +00:00
|
|
|
if fleet == params.FleetStatusProd {
|
2023-12-07 13:45:53 +00:00
|
|
|
nodeConfig.ClusterConfig.ClusterID = shardsTestClusterID
|
|
|
|
}
|
2023-09-27 17:26:10 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-07-31 06:21:11 +00:00
|
|
|
func buildWalletConfig(request *requests.WalletSecretsConfig, statusProxyEnabled bool) params.WalletConfig {
|
2024-02-02 13:55:46 +00:00
|
|
|
walletConfig := params.WalletConfig{
|
2023-04-25 12:00:17 +00:00
|
|
|
Enabled: true,
|
|
|
|
AlchemyAPIKeys: make(map[uint64]string),
|
|
|
|
}
|
|
|
|
|
2024-08-14 15:35:48 +00:00
|
|
|
if request.StatusProxyStageName != "" {
|
|
|
|
walletConfig.StatusProxyStageName = request.StatusProxyStageName
|
|
|
|
}
|
|
|
|
|
2023-04-25 12:00:17 +00:00
|
|
|
if request.OpenseaAPIKey != "" {
|
2024-02-02 13:55:46 +00:00
|
|
|
walletConfig.OpenseaAPIKey = request.OpenseaAPIKey
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
|
2023-10-12 19:40:13 +00:00
|
|
|
if request.RaribleMainnetAPIKey != "" {
|
2024-02-02 13:55:46 +00:00
|
|
|
walletConfig.RaribleMainnetAPIKey = request.RaribleMainnetAPIKey
|
2023-10-12 19:40:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if request.RaribleTestnetAPIKey != "" {
|
2024-02-02 13:55:46 +00:00
|
|
|
walletConfig.RaribleTestnetAPIKey = request.RaribleTestnetAPIKey
|
2023-10-12 19:40:13 +00:00
|
|
|
}
|
|
|
|
|
2023-04-25 12:00:17 +00:00
|
|
|
if request.InfuraToken != "" {
|
2024-02-02 13:55:46 +00:00
|
|
|
walletConfig.InfuraAPIKey = request.InfuraToken
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if request.InfuraSecret != "" {
|
2024-02-02 13:55:46 +00:00
|
|
|
walletConfig.InfuraAPIKeySecret = request.InfuraSecret
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
|
2023-10-03 11:47:27 +00:00
|
|
|
if request.AlchemyEthereumMainnetToken != "" {
|
2024-02-02 13:55:46 +00:00
|
|
|
walletConfig.AlchemyAPIKeys[mainnetChainID] = request.AlchemyEthereumMainnetToken
|
2023-10-03 11:47:27 +00:00
|
|
|
}
|
|
|
|
if request.AlchemyEthereumGoerliToken != "" {
|
2024-02-02 13:55:46 +00:00
|
|
|
walletConfig.AlchemyAPIKeys[goerliChainID] = request.AlchemyEthereumGoerliToken
|
2023-10-03 11:47:27 +00:00
|
|
|
}
|
2023-11-16 20:46:01 +00:00
|
|
|
if request.AlchemyEthereumSepoliaToken != "" {
|
2024-02-02 13:55:46 +00:00
|
|
|
walletConfig.AlchemyAPIKeys[sepoliaChainID] = request.AlchemyEthereumSepoliaToken
|
2023-11-16 20:46:01 +00:00
|
|
|
}
|
2023-04-25 12:00:17 +00:00
|
|
|
if request.AlchemyArbitrumMainnetToken != "" {
|
2024-02-02 13:55:46 +00:00
|
|
|
walletConfig.AlchemyAPIKeys[arbitrumChainID] = request.AlchemyArbitrumMainnetToken
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
if request.AlchemyArbitrumGoerliToken != "" {
|
2024-02-02 13:55:46 +00:00
|
|
|
walletConfig.AlchemyAPIKeys[arbitrumGoerliChainID] = request.AlchemyArbitrumGoerliToken
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
2023-11-16 20:46:01 +00:00
|
|
|
if request.AlchemyArbitrumSepoliaToken != "" {
|
2024-02-02 13:55:46 +00:00
|
|
|
walletConfig.AlchemyAPIKeys[arbitrumSepoliaChainID] = request.AlchemyArbitrumSepoliaToken
|
2023-11-16 20:46:01 +00:00
|
|
|
}
|
2023-04-25 12:00:17 +00:00
|
|
|
if request.AlchemyOptimismMainnetToken != "" {
|
2024-02-02 13:55:46 +00:00
|
|
|
walletConfig.AlchemyAPIKeys[optimismChainID] = request.AlchemyOptimismMainnetToken
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
|
|
|
if request.AlchemyOptimismGoerliToken != "" {
|
2024-02-02 13:55:46 +00:00
|
|
|
walletConfig.AlchemyAPIKeys[optimismGoerliChainID] = request.AlchemyOptimismGoerliToken
|
2023-04-25 12:00:17 +00:00
|
|
|
}
|
2023-11-16 20:46:01 +00:00
|
|
|
if request.AlchemyOptimismSepoliaToken != "" {
|
2024-02-02 13:55:46 +00:00
|
|
|
walletConfig.AlchemyAPIKeys[optimismSepoliaChainID] = request.AlchemyOptimismSepoliaToken
|
2023-11-16 20:46:01 +00:00
|
|
|
}
|
2024-07-30 13:48:22 +00:00
|
|
|
if request.StatusProxyMarketUser != "" {
|
|
|
|
walletConfig.StatusProxyMarketUser = request.StatusProxyMarketUser
|
|
|
|
}
|
|
|
|
if request.StatusProxyMarketPassword != "" {
|
|
|
|
walletConfig.StatusProxyMarketPassword = request.StatusProxyMarketPassword
|
|
|
|
}
|
2024-07-31 06:21:11 +00:00
|
|
|
if request.StatusProxyBlockchainUser != "" {
|
|
|
|
walletConfig.StatusProxyBlockchainUser = request.StatusProxyBlockchainUser
|
|
|
|
}
|
|
|
|
if request.StatusProxyBlockchainPassword != "" {
|
|
|
|
walletConfig.StatusProxyBlockchainPassword = request.StatusProxyBlockchainPassword
|
|
|
|
}
|
|
|
|
|
|
|
|
walletConfig.StatusProxyEnabled = statusProxyEnabled
|
2023-04-25 12:00:17 +00:00
|
|
|
|
2024-02-02 13:55:46 +00:00
|
|
|
return walletConfig
|
|
|
|
}
|
|
|
|
|
2024-07-04 10:48:40 +00:00
|
|
|
func overrideApiConfigProd(nodeConfig *params.NodeConfig, config *requests.APIConfig) {
|
2024-06-26 14:33:22 +00:00
|
|
|
nodeConfig.APIModules = config.APIModules
|
|
|
|
nodeConfig.ConnectorConfig.Enabled = config.ConnectorEnabled
|
|
|
|
|
|
|
|
nodeConfig.HTTPEnabled = config.HTTPEnabled
|
|
|
|
nodeConfig.HTTPHost = config.HTTPHost
|
|
|
|
nodeConfig.HTTPPort = config.HTTPPort
|
2024-07-04 10:48:40 +00:00
|
|
|
nodeConfig.HTTPVirtualHosts = config.HTTPVirtualHosts
|
2024-06-26 14:33:22 +00:00
|
|
|
|
|
|
|
nodeConfig.WSEnabled = config.WSEnabled
|
|
|
|
nodeConfig.WSHost = config.WSHost
|
|
|
|
nodeConfig.WSPort = config.WSPort
|
|
|
|
}
|
|
|
|
|
2024-08-14 20:10:19 +00:00
|
|
|
func DefaultNodeConfig(installationID string, request *requests.CreateAccount, opts ...params.Option) (*params.NodeConfig, error) {
|
2024-02-02 13:55:46 +00:00
|
|
|
// Set mainnet
|
|
|
|
nodeConfig := ¶ms.NodeConfig{}
|
2024-08-14 20:10:19 +00:00
|
|
|
nodeConfig.RootDataDir = request.RootDataDir
|
2024-02-02 13:55:46 +00:00
|
|
|
nodeConfig.LogEnabled = request.LogEnabled
|
2024-04-26 14:11:49 +00:00
|
|
|
nodeConfig.LogFile = DefaultLogFile
|
2024-02-02 13:55:46 +00:00
|
|
|
nodeConfig.LogDir = request.LogFilePath
|
2024-04-26 14:11:49 +00:00
|
|
|
nodeConfig.LogLevel = DefaultLogLevel
|
2024-04-22 12:33:23 +00:00
|
|
|
nodeConfig.DataDir = DefaultDataDir
|
2024-03-28 15:01:44 +00:00
|
|
|
nodeConfig.ProcessBackedupMessages = false
|
2024-06-26 11:14:27 +00:00
|
|
|
nodeConfig.KeycardPairingDataFile = DefaultKeycardPairingDataFile
|
|
|
|
if request.KeycardPairingDataFile != nil {
|
|
|
|
nodeConfig.KeycardPairingDataFile = *request.KeycardPairingDataFile
|
|
|
|
}
|
2024-02-02 13:55:46 +00:00
|
|
|
|
|
|
|
if request.LogLevel != nil {
|
|
|
|
nodeConfig.LogLevel = *request.LogLevel
|
2024-03-28 15:01:44 +00:00
|
|
|
nodeConfig.LogEnabled = true
|
|
|
|
} else {
|
|
|
|
nodeConfig.LogEnabled = false
|
|
|
|
}
|
|
|
|
|
2024-06-02 18:28:55 +00:00
|
|
|
if request.TestOverrideNetworks != nil {
|
|
|
|
nodeConfig.Networks = request.TestOverrideNetworks
|
|
|
|
} else {
|
|
|
|
nodeConfig.Networks = BuildDefaultNetworks(&request.WalletSecretsConfig)
|
|
|
|
}
|
2024-03-28 15:01:44 +00:00
|
|
|
|
|
|
|
if request.NetworkID != nil {
|
|
|
|
nodeConfig.NetworkID = *request.NetworkID
|
|
|
|
} else {
|
|
|
|
nodeConfig.NetworkID = nodeConfig.Networks[0].ChainID
|
2024-02-02 13:55:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if request.UpstreamConfig != "" {
|
|
|
|
nodeConfig.UpstreamConfig = params.UpstreamRPCConfig{
|
|
|
|
Enabled: true,
|
|
|
|
URL: request.UpstreamConfig,
|
|
|
|
}
|
2024-03-28 15:01:44 +00:00
|
|
|
} else {
|
2024-08-14 15:35:48 +00:00
|
|
|
nodeConfig.UpstreamConfig.URL = mainnet(request.WalletSecretsConfig.StatusProxyStageName).RPCURL
|
2024-03-28 15:01:44 +00:00
|
|
|
nodeConfig.UpstreamConfig.Enabled = true
|
2024-02-02 13:55:46 +00:00
|
|
|
}
|
|
|
|
|
2024-04-26 14:11:49 +00:00
|
|
|
nodeConfig.Name = DefaultNodeName
|
2024-02-02 13:55:46 +00:00
|
|
|
nodeConfig.Rendezvous = false
|
|
|
|
nodeConfig.NoDiscovery = true
|
2024-04-26 14:11:49 +00:00
|
|
|
nodeConfig.MaxPeers = DefaultMaxPeers
|
|
|
|
nodeConfig.MaxPendingPeers = DefaultMaxPendingPeers
|
2024-02-02 13:55:46 +00:00
|
|
|
|
2024-07-31 06:21:11 +00:00
|
|
|
nodeConfig.WalletConfig = buildWalletConfig(&request.WalletSecretsConfig, request.StatusProxyEnabled)
|
2024-02-02 13:55:46 +00:00
|
|
|
|
2023-03-16 14:49:25 +00:00
|
|
|
nodeConfig.LocalNotificationsConfig = params.LocalNotificationsConfig{Enabled: true}
|
|
|
|
nodeConfig.BrowsersConfig = params.BrowsersConfig{Enabled: true}
|
|
|
|
nodeConfig.PermissionsConfig = params.PermissionsConfig{Enabled: true}
|
|
|
|
nodeConfig.MailserversConfig = params.MailserversConfig{Enabled: true}
|
|
|
|
|
2024-04-26 14:11:49 +00:00
|
|
|
nodeConfig.ListenAddr = DefaultListenAddr
|
2023-12-07 13:45:53 +00:00
|
|
|
|
2024-07-11 09:57:56 +00:00
|
|
|
fleet := request.WakuV2Fleet
|
|
|
|
if fleet == "" {
|
|
|
|
fleet = DefaultFleet
|
|
|
|
}
|
|
|
|
|
|
|
|
err := SetFleet(fleet, nodeConfig)
|
2023-09-27 17:26:10 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-07-03 12:48:21 +00:00
|
|
|
if request.WakuV2LightClient {
|
|
|
|
nodeConfig.WakuV2Config.LightClient = true
|
2024-07-26 19:19:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if request.WakuV2EnableMissingMessageVerification {
|
|
|
|
nodeConfig.WakuV2Config.EnableMissingMessageVerification = true
|
2023-07-03 12:48:21 +00:00
|
|
|
}
|
|
|
|
|
2024-07-11 09:57:56 +00:00
|
|
|
if request.WakuV2EnableStoreConfirmationForMessagesSent {
|
|
|
|
nodeConfig.WakuV2Config.EnableStoreConfirmationForMessagesSent = true
|
|
|
|
}
|
|
|
|
|
2023-03-16 14:49:25 +00:00
|
|
|
if request.WakuV2Nameserver != nil {
|
|
|
|
nodeConfig.WakuV2Config.Nameserver = *request.WakuV2Nameserver
|
|
|
|
}
|
|
|
|
|
2024-05-22 22:01:54 +00:00
|
|
|
if request.TelemetryServerURL != "" {
|
|
|
|
nodeConfig.WakuV2Config.TelemetryServerURL = request.TelemetryServerURL
|
|
|
|
}
|
|
|
|
|
2023-03-16 14:49:25 +00:00
|
|
|
nodeConfig.ShhextConfig = params.ShhextConfig{
|
|
|
|
InstallationID: installationID,
|
2024-04-26 14:11:49 +00:00
|
|
|
MaxMessageDeliveryAttempts: DefaultMaxMessageDeliveryAttempts,
|
2023-03-16 14:49:25 +00:00
|
|
|
MailServerConfirmations: true,
|
2024-04-26 14:11:49 +00:00
|
|
|
VerifyTransactionChainID: DefaultVerifyTransactionChainID,
|
2023-03-16 14:49:25 +00:00
|
|
|
DataSyncEnabled: true,
|
|
|
|
PFSEnabled: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
if request.VerifyTransactionURL != nil {
|
|
|
|
nodeConfig.ShhextConfig.VerifyTransactionURL = *request.VerifyTransactionURL
|
2024-03-28 15:01:44 +00:00
|
|
|
} else {
|
2024-08-14 15:35:48 +00:00
|
|
|
nodeConfig.ShhextConfig.VerifyTransactionURL = mainnet(request.WalletSecretsConfig.StatusProxyStageName).FallbackURL
|
2023-03-16 14:49:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if request.VerifyENSURL != nil {
|
|
|
|
nodeConfig.ShhextConfig.VerifyENSURL = *request.VerifyENSURL
|
2024-03-28 15:01:44 +00:00
|
|
|
} else {
|
2024-08-14 15:35:48 +00:00
|
|
|
nodeConfig.ShhextConfig.VerifyENSURL = mainnet(request.WalletSecretsConfig.StatusProxyStageName).FallbackURL
|
2023-03-16 14:49:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if request.VerifyTransactionChainID != nil {
|
|
|
|
nodeConfig.ShhextConfig.VerifyTransactionChainID = *request.VerifyTransactionChainID
|
|
|
|
}
|
|
|
|
|
|
|
|
if request.VerifyENSContractAddress != nil {
|
|
|
|
nodeConfig.ShhextConfig.VerifyENSContractAddress = *request.VerifyENSContractAddress
|
|
|
|
}
|
|
|
|
|
2024-03-28 15:01:44 +00:00
|
|
|
if request.NetworkID != nil {
|
|
|
|
nodeConfig.NetworkID = *request.NetworkID
|
|
|
|
}
|
|
|
|
|
|
|
|
nodeConfig.TorrentConfig = params.TorrentConfig{
|
|
|
|
Enabled: false,
|
|
|
|
Port: 0,
|
2024-06-06 14:08:17 +00:00
|
|
|
DataDir: filepath.Join(nodeConfig.RootDataDir, params.ArchivesRelativePath),
|
|
|
|
TorrentDir: filepath.Join(nodeConfig.RootDataDir, params.TorrentTorrentsRelativePath),
|
2024-03-28 15:01:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if request.TorrentConfigEnabled != nil {
|
|
|
|
nodeConfig.TorrentConfig.Enabled = *request.TorrentConfigEnabled
|
|
|
|
|
|
|
|
}
|
|
|
|
if request.TorrentConfigPort != nil {
|
|
|
|
nodeConfig.TorrentConfig.Port = *request.TorrentConfigPort
|
|
|
|
}
|
2023-04-25 12:00:17 +00:00
|
|
|
|
2024-04-09 15:44:43 +00:00
|
|
|
if request.APIConfig != nil {
|
2024-06-26 14:33:22 +00:00
|
|
|
overrideApiConfig(nodeConfig, request.APIConfig)
|
2024-03-19 00:31:35 +00:00
|
|
|
}
|
|
|
|
|
2024-03-22 10:55:09 +00:00
|
|
|
for _, opt := range opts {
|
|
|
|
if err := opt(nodeConfig); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-16 14:49:25 +00:00
|
|
|
return nodeConfig, nil
|
|
|
|
}
|
|
|
|
|
2024-08-14 20:10:19 +00:00
|
|
|
func DefaultKeystorePath(rootDataDir string, keyUID string) (string, string) {
|
|
|
|
relativePath := filepath.Join(DefaultKeystoreRelativePath, keyUID)
|
|
|
|
absolutePath := filepath.Join(rootDataDir, relativePath)
|
|
|
|
return relativePath, absolutePath
|
|
|
|
}
|
|
|
|
|
2023-03-16 14:49:25 +00:00
|
|
|
func buildSigningPhrase() (string, error) {
|
|
|
|
length := big.NewInt(int64(len(dictionary)))
|
|
|
|
a, err := rand.Int(rand.Reader, length)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
b, err := rand.Int(rand.Reader, length)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
c, err := rand.Int(rand.Reader, length)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
return dictionary[a.Int64()] + " " + dictionary[b.Int64()] + " " + dictionary[c.Int64()], nil
|
2024-08-07 12:34:04 +00:00
|
|
|
}
|
2023-03-16 14:49:25 +00:00
|
|
|
|
2024-08-07 12:34:04 +00:00
|
|
|
func randomWalletEmoji() (string, error) {
|
|
|
|
count := big.NewInt(int64(len(animalsAndNatureEmojis)))
|
|
|
|
index, err := rand.Int(rand.Reader, count)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
return animalsAndNatureEmojis[index.Int64()], nil
|
2023-03-16 14:49:25 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 12:34:04 +00:00
|
|
|
var animalsAndNatureEmojis = []string{
|
|
|
|
"🐵", "🐒", "🦍", "🦧", "🦣", "🦏", "🦛", "🐪", "🐫", "🦙",
|
|
|
|
"🐃", "🐂", "🐄", "🐎", "🦄", "🦓", "🦌", "🐐", "🐏", "🐑",
|
|
|
|
"🦙", "🐘", "🦣", "🦛", "🦏", "🦒", "🐁", "🐀", "🐹", "🐰",
|
|
|
|
"🐇", "🐿️", "🦔", "🦇", "🐻", "🐻❄️", "🐨", "🐼", "🦥", "🦦",
|
|
|
|
"🦨", "🦘", "🦡", "🐾", "🐉", "🐲", "🌵", "🎄", "🌲", "🌳",
|
|
|
|
"🌴", "🌱", "🌿", "☘️", "🍀", "🎍", "🎋", "🍃", "🍂", "🍁",
|
|
|
|
"🍄", "🐚", "🪨", "🌾", "💐", "🌷", "🌹", "🥀", "🌺", "🌸",
|
|
|
|
"🌼", "🌻", "🌞", "🌝", "🌛", "🌜", "🌚", "🌕", "🌖", "🌗",
|
|
|
|
"🌘", "🌑", "🌒", "🌓", "🌔", "🌙", "🌎", "🌍", "🌏", "🪐",
|
|
|
|
"💫", "⭐", "🌟", "✨", "⚡", "☄️", "💥", "🔥", "🌪️", "🌈",
|
|
|
|
"☀️", "🌤️", "⛅", "🌥️", "☁️", "🌦️", "🌧️", "⛈️", "🌩️", "🌨️",
|
|
|
|
"❄️", "☃️", "⛄", "🌬️", "💨", "💧", "💦", "🌊",
|
2023-03-16 14:49:25 +00:00
|
|
|
}
|