diff --git a/cmd/tapcli/main.go b/cmd/tapcli/main.go index b7b7e7d21..f01f3baf6 100644 --- a/cmd/tapcli/main.go +++ b/cmd/tapcli/main.go @@ -219,7 +219,7 @@ func extractPathArgs(ctx *cli.Context) (string, string, error) { // determine the correct path to the macaroon when not specified. network := strings.ToLower(ctx.GlobalString("network")) switch network { - case "testnet", "regtest", "simnet", "signet": + case "mainnet", "testnet", "regtest", "simnet", "signet": default: return "", "", fmt.Errorf("unknown network: %v", network) } @@ -234,7 +234,9 @@ func extractPathArgs(ctx *cli.Context) (string, string, error) { // target the specified file. var macPath string if ctx.GlobalString("macaroonpath") != "" { - macPath = lncfg.CleanAndExpandPath(ctx.GlobalString("macaroonpath")) + macPath = lncfg.CleanAndExpandPath(ctx.GlobalString( + "macaroonpath", + )) } else { // Otherwise, we'll go into the path: // tapddir/data/ in order to fetch the diff --git a/tapcfg/config.go b/tapcfg/config.go index 65e0f1a0c..6dbcd9f36 100644 --- a/tapcfg/config.go +++ b/tapcfg/config.go @@ -48,9 +48,12 @@ const ( defaultLetsEncryptDirname = "letsencrypt" defaultLetsEncryptListen = ":80" + defaultNetwork = "testnet" + defaultMaxLogFiles = 3 defaultMaxLogFileSize = 10 + defaultMainnetFederationServer = "universe.lightning.finance:10029" defaultTestnetFederationServer = "testnet.universe.lightning.finance:10029" // DefaultAutogenValidity is the default validity of a self-signed @@ -69,6 +72,10 @@ const ( // proofs for asynchronous sends. fallbackHashMailAddr = "mailbox.terminal.lightning.today:443" + // fallbackUniverseAddr is the fallback address we'll use to deliver + // proofs for asynchronous sends. + fallbackUniverseAddr = defaultMainnetFederationServer + // DatabaseBackendSqlite is the name of the SQLite database backend. DatabaseBackendSqlite = "sqlite" @@ -121,8 +128,6 @@ var ( // file. DefaultConfigFile = filepath.Join(DefaultTapdDir, defaultConfigFileName) - defaultNetwork = "testnet" - defaultDataDir = filepath.Join(DefaultTapdDir, defaultDataDirname) defaultLogDir = filepath.Join(DefaultTapdDir, defaultLogDirname) @@ -154,6 +159,12 @@ var ( defaultDataDir, defaultNetwork, defaultSqliteDatabaseFileName, ) + // defaultProofCourierAddr is the default proof courier address URI + // we'll use to deliver proofs for asynchronous sends. + defaultProofCourierAddr = fmt.Sprintf( + "%s://%s", proof.UniverseRpcCourierType, fallbackUniverseAddr, + ) + // minimalCompatibleVersion is the minimum version and build tags // required in lnd to run tapd. minimalCompatibleVersion = &verrpc.Version{ @@ -175,7 +186,7 @@ var ( // ChainConfig houses the configuration options that govern which chain/network // we operate on. type ChainConfig struct { - Network string `long:"network" description:"network to run on" choice:"regtest" choice:"testnet" choice:"simnet" choice:"signet"` + Network string `long:"network" description:"network to run on" choice:"mainnet" choice:"regtest" choice:"testnet" choice:"simnet" choice:"signet"` SigNetChallenge string `long:"signetchallenge" description:"Connect to a custom signet network defined by this challenge instead of using the global default signet test network -- Can be specified multiple times"` } @@ -334,13 +345,11 @@ func DefaultConfig() Config { Port: 5432, MaxOpenConnections: 10, }, - LogWriter: build.NewRotatingLogWriter(), - Prometheus: monitoring.DefaultPrometheusConfig(), - BatchMintingInterval: defaultBatchMintingInterval, - ReOrgSafeDepth: defaultReOrgSafeDepth, - DefaultProofCourierAddr: fmt.Sprintf( - "%s://%s", proof.HashmailCourierType, fallbackHashMailAddr, - ), + LogWriter: build.NewRotatingLogWriter(), + Prometheus: monitoring.DefaultPrometheusConfig(), + BatchMintingInterval: defaultBatchMintingInterval, + ReOrgSafeDepth: defaultReOrgSafeDepth, + DefaultProofCourierAddr: defaultProofCourierAddr, HashMailCourier: &proof.HashMailCourierCfg{ ReceiverAckTimeout: defaultProofTransferReceiverAckTimeout, BackoffCfg: &proof.BackoffCfg{ @@ -541,6 +550,8 @@ func ValidateConfig(cfg Config, cfgLogger btclog.Logger) (*Config, error) { // network flags passed; assign active network params // while we're at it. switch cfg.ChainConf.Network { + case "mainnet": + cfg.ActiveNetParams = chaincfg.MainNetParams case "testnet": cfg.ActiveNetParams = chaincfg.TestNet3Params case "regtest": diff --git a/tapcfg/server.go b/tapcfg/server.go index df644bf43..e8d99f080 100644 --- a/tapcfg/server.go +++ b/tapcfg/server.go @@ -35,7 +35,7 @@ type databaseBackend interface { // genServerConfig generates a server config from the given tapd config. // // NOTE: The RPCConfig and SignalInterceptor fields must be set by the caller -// after genereting the server config. +// after generating the server config. func genServerConfig(cfg *Config, cfgLogger btclog.Logger, lndServices *lndclient.LndServices, mainErrChan chan<- error) (*tap.Config, error) { @@ -161,6 +161,46 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger, assetStore, proofFileStore, ) + federationMembers := cfg.Universe.FederationServers + switch cfg.ChainConf.Network { + case "mainnet": + cfgLogger.Infof("Configuring %v as initial Universe "+ + "federation server", defaultMainnetFederationServer) + + federationMembers = append( + federationMembers, defaultMainnetFederationServer, + ) + + case "testnet": + cfgLogger.Infof("Configuring %v as initial Universe "+ + "federation server", defaultTestnetFederationServer) + + federationMembers = append( + federationMembers, defaultTestnetFederationServer, + ) + + // For testnet, we need to overwrite the default universe proof + // courier address to use the testnet server. + if cfg.DefaultProofCourierAddr == defaultProofCourierAddr { + cfg.DefaultProofCourierAddr = fmt.Sprintf( + "%s://%s", proof.UniverseRpcCourierType, + fallbackUniverseAddr, + ) + } + + default: + // For any other network, such as regtest, we can't use a + // universe proof courier by default, as we don't know what + // server to pick. So if there is no explicit value set, we fall + // back to using the hashmail courier, which works in all cases. + if cfg.DefaultProofCourierAddr == defaultProofCourierAddr { + cfg.DefaultProofCourierAddr = fmt.Sprintf( + "%s://%s", proof.HashmailCourierType, + fallbackHashMailAddr, + ) + } + } + // If no default proof courier address is set, use the fallback hashmail // address. fallbackHashmailCourierAddr := fmt.Sprintf( @@ -185,10 +225,10 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger, } } - var proofCourierCfg *proof.CourierCfg // TODO(ffranr): This logic is leftover for integration tests which // do not yet enable a proof courier. Remove once all integration tests // support a proof courier. + var proofCourierCfg *proof.CourierCfg if cfg.HashMailCourier != nil { proofCourierCfg = &proof.CourierCfg{ ReceiverAckTimeout: cfg.HashMailCourier.ReceiverAckTimeout, @@ -234,17 +274,6 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger, SyncBatchSize: defaultUniverseSyncBatchSize, }) - federationMembers := cfg.Universe.FederationServers - switch cfg.ChainConf.Network { - case "testnet": - cfgLogger.Infof("Configuring %v as initial Universe "+ - "federation server", defaultTestnetFederationServer) - - federationMembers = append( - federationMembers, defaultTestnetFederationServer, - ) - } - runtimeID := prand.Int63() // nolint:gosec universeFederation := universe.NewFederationEnvoy( universe.FederationConfig{ diff --git a/version.go b/version.go index ea868fc8d..63bec6d3f 100644 --- a/version.go +++ b/version.go @@ -42,10 +42,10 @@ const ( AppMajor uint = 0 // AppMinor defines the minor version of this binary. - AppMinor uint = 2 + AppMinor uint = 3 // AppPatch defines the application patch for this binary. - AppPatch uint = 3 + AppPatch uint = 0 // AppPreRelease MUST only contain characters from semanticAlphabet // per the semantic versioning spec.