[lbry] align port settings between lbcd, lbcctl, and lbcwallet

This commit is contained in:
Roy Lee 2021-09-06 10:48:23 -07:00
parent 202374ebd8
commit 36554814e8
5 changed files with 54 additions and 36 deletions

View file

@ -45,6 +45,7 @@ func errContext(err error, context string) error {
var opts = struct { var opts = struct {
TestNet3 bool `long:"testnet" description:"Use the test bitcoin network (version 3)"` TestNet3 bool `long:"testnet" description:"Use the test bitcoin network (version 3)"`
SimNet bool `long:"simnet" description:"Use the simulation bitcoin network"` SimNet bool `long:"simnet" description:"Use the simulation bitcoin network"`
RegTest bool `long:"regtest" description:"Use the regression test network"`
RPCConnect string `short:"c" long:"connect" description:"Hostname[:port] of wallet RPC server"` RPCConnect string `short:"c" long:"connect" description:"Hostname[:port] of wallet RPC server"`
RPCUsername string `short:"u" long:"rpcuser" description:"Wallet RPC username"` RPCUsername string `short:"u" long:"rpcuser" description:"Wallet RPC username"`
RPCCertificateFile string `long:"cafile" description:"Wallet RPC TLS certificate"` RPCCertificateFile string `long:"cafile" description:"Wallet RPC TLS certificate"`
@ -55,6 +56,7 @@ var opts = struct {
}{ }{
TestNet3: false, TestNet3: false,
SimNet: false, SimNet: false,
RegTest: false,
RPCConnect: "localhost", RPCConnect: "localhost",
RPCUsername: "", RPCUsername: "",
RPCCertificateFile: filepath.Join(walletDataDirectory, "rpc.cert"), RPCCertificateFile: filepath.Join(walletDataDirectory, "rpc.cert"),
@ -89,6 +91,8 @@ func init() {
activeNet = &netparams.TestNet3Params activeNet = &netparams.TestNet3Params
} else if opts.SimNet { } else if opts.SimNet {
activeNet = &netparams.SimNetParams activeNet = &netparams.SimNetParams
} else if opts.RegTest {
activeNet = &netparams.RegTestParams
} }
if opts.RPCConnect == "" { if opts.RPCConnect == "" {

View file

@ -51,9 +51,10 @@ type config struct {
Create bool `long:"create" description:"Create the wallet if it does not exist"` Create bool `long:"create" description:"Create the wallet if it does not exist"`
CreateTemp bool `long:"createtemp" description:"Create a temporary simulation wallet (pass=password) in the data directory indicated; must call with --datadir"` CreateTemp bool `long:"createtemp" description:"Create a temporary simulation wallet (pass=password) in the data directory indicated; must call with --datadir"`
AppDataDir *cfgutil.ExplicitString `short:"A" long:"appdata" description:"Application data directory for wallet config, databases and logs"` AppDataDir *cfgutil.ExplicitString `short:"A" long:"appdata" description:"Application data directory for wallet config, databases and logs"`
TestNet3 bool `long:"testnet" description:"Use the test Bitcoin network (version 3) (default mainnet)"` TestNet3 bool `long:"testnet" description:"Use the test Bitcoin network (version 3) (default client port: 19244, server port: 19245)"`
SimNet bool `long:"simnet" description:"Use the simulation test network (default mainnet)"` Regtest bool `long:"regtest" description:"Use the regression test network (default client port: 29244, server port: 29245)"`
SigNet bool `long:"signet" description:"Use the signet test network (default mainnet)"` SimNet bool `long:"simnet" description:"Use the simulation test network (default client port: 39244, server port: 39245)"`
SigNet bool `long:"signet" description:"Use the signet test network (default client port: 49244, server port: 49245)"`
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"` 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"`
SigNetSeedNode []string `long:"signetseednode" description:"Specify a seed node for the signet network instead of using the global default signet network seed nodes"` SigNetSeedNode []string `long:"signetseednode" description:"Specify a seed node for the signet network instead of using the global default signet network seed nodes"`
NoInitialLoad bool `long:"noinitialload" description:"Defer wallet creation/opening on startup and enable loading wallets over RPC"` NoInitialLoad bool `long:"noinitialload" description:"Defer wallet creation/opening on startup and enable loading wallets over RPC"`
@ -66,7 +67,7 @@ type config struct {
WalletPass string `long:"walletpass" default-mask:"-" description:"The public wallet password -- Only required if the wallet was created with one"` WalletPass string `long:"walletpass" default-mask:"-" description:"The public wallet password -- Only required if the wallet was created with one"`
// RPC client options // RPC client options
RPCConnect string `short:"c" long:"rpcconnect" description:"Hostname/IP and port of lbcd RPC server to connect to (default localhost:8334, testnet: localhost:18334, simnet: localhost:18556)"` RPCConnect string `short:"c" long:"rpcconnect" description:"Hostname/IP and port of lbcd RPC server to connect to (default localhost:9245, testnet: localhost:19245, regtest: localhost:29245 simnet: localhost:39245)"`
CAFile *cfgutil.ExplicitString `long:"cafile" description:"File containing root certificates to authenticate a TLS connections with lbcd"` CAFile *cfgutil.ExplicitString `long:"cafile" description:"File containing root certificates to authenticate a TLS connections with lbcd"`
DisableClientTLS bool `long:"noclienttls" description:"Disable TLS for the RPC client -- NOTE: This is only allowed if the RPC client is connecting to localhost"` DisableClientTLS bool `long:"noclienttls" description:"Disable TLS for the RPC client -- NOTE: This is only allowed if the RPC client is connecting to localhost"`
LbcdUsername string `long:"lbcdusername" description:"Username for lbcd authentication"` LbcdUsername string `long:"lbcdusername" description:"Username for lbcd authentication"`
@ -95,7 +96,7 @@ type config struct {
RPCKey *cfgutil.ExplicitString `long:"rpckey" description:"File containing the certificate key"` RPCKey *cfgutil.ExplicitString `long:"rpckey" description:"File containing the certificate key"`
OneTimeTLSKey bool `long:"onetimetlskey" description:"Generate a new TLS certpair at startup, but only write the certificate to disk"` OneTimeTLSKey bool `long:"onetimetlskey" description:"Generate a new TLS certpair at startup, but only write the certificate to disk"`
DisableServerTLS bool `long:"noservertls" description:"Disable TLS for the RPC server -- NOTE: This is only allowed if the RPC server is bound to localhost"` DisableServerTLS bool `long:"noservertls" description:"Disable TLS for the RPC server -- NOTE: This is only allowed if the RPC server is bound to localhost"`
LegacyRPCListeners []string `long:"rpclisten" description:"Listen for legacy RPC connections on this interface/port (default port: 8332, testnet: 18332, simnet: 18554)"` LegacyRPCListeners []string `long:"rpclisten" description:"Listen for legacy RPC connections on this interface/port (default port: 9244, testnet: 19244, regtest: 29244, simnet: 29244)"`
LegacyRPCMaxClients int64 `long:"rpcmaxclients" description:"Max number of legacy RPC clients for standard connections"` LegacyRPCMaxClients int64 `long:"rpcmaxclients" description:"Max number of legacy RPC clients for standard connections"`
LegacyRPCMaxWebsockets int64 `long:"rpcmaxwebsockets" description:"Max number of legacy RPC websocket connections"` LegacyRPCMaxWebsockets int64 `long:"rpcmaxwebsockets" description:"Max number of legacy RPC websocket connections"`
Username string `short:"u" long:"username" description:"Username for legacy RPC and lbcd authentication (if lbcdusername is unset)"` Username string `short:"u" long:"username" description:"Username for legacy RPC and lbcd authentication (if lbcdusername is unset)"`
@ -362,6 +363,10 @@ func loadConfig() (*config, []string, error) {
activeNet = &netparams.TestNet3Params activeNet = &netparams.TestNet3Params
numNets++ numNets++
} }
if cfg.Regtest {
activeNet = &netparams.RegTestParams
numNets++
}
if cfg.SimNet { if cfg.SimNet {
activeNet = &netparams.SimNetParams activeNet = &netparams.SimNetParams
numNets++ numNets++

View file

@ -21,32 +21,40 @@ type Params struct {
// on the main network (wire.MainNet). // on the main network (wire.MainNet).
var MainNetParams = Params{ var MainNetParams = Params{
Params: &chaincfg.MainNetParams, Params: &chaincfg.MainNetParams,
RPCClientPort: "8334", RPCClientPort: "9245",
RPCServerPort: "8332", RPCServerPort: "9244",
} }
// TestNet3Params contains parameters specific running lbcwallet and // TestNet3Params contains parameters specific running lbcwallet and
// on the test network (version 3) (wire.TestNet3). // on the test network (version 3) (wire.TestNet3).
var TestNet3Params = Params{ var TestNet3Params = Params{
Params: &chaincfg.TestNet3Params, Params: &chaincfg.TestNet3Params,
RPCClientPort: "18334", RPCClientPort: "19245",
RPCServerPort: "18332", RPCServerPort: "19244",
}
// RegNetParams contains parameters specific to the regression test network
// (wire.RegNet).
var RegTestParams = Params{
Params: &chaincfg.RegressionNetParams,
RPCClientPort: "29245",
RPCServerPort: "29244",
} }
// SimNetParams contains parameters specific to the simulation test network // SimNetParams contains parameters specific to the simulation test network
// (wire.SimNet). // (wire.SimNet).
var SimNetParams = Params{ var SimNetParams = Params{
Params: &chaincfg.SimNetParams, Params: &chaincfg.SimNetParams,
RPCClientPort: "18556", RPCClientPort: "39245",
RPCServerPort: "18554", RPCServerPort: "39244",
} }
// SigNetParams contains parameters specific to the signet test network // SigNetParams contains parameters specific to the signet test network
// (wire.SigNet). // (wire.SigNet).
var SigNetParams = Params{ var SigNetParams = Params{
Params: &chaincfg.SigNetParams, Params: &chaincfg.SigNetParams,
RPCClientPort: "38334", RPCClientPort: "49245",
RPCServerPort: "38332", RPCServerPort: "49244",
} }
// SigNetWire is a helper function that either returns the given chain // SigNetWire is a helper function that either returns the given chain

View file

@ -19,12 +19,13 @@ lbcwallet itself.
The rest of this document provides short examples of how to quickly get started The rest of this document provides short examples of how to quickly get started
by implementing a basic client that fetches the balance of the default account by implementing a basic client that fetches the balance of the default account
(account 0) from a testnet3 wallet listening on `localhost:18332` in several (account 0) from a testnet3 wallet listening on `localhost:19244` in several
different languages: different languages:
- [Client usage](#client-usage)
- [Go](#go) - [Go](#go)
- [C++](#cpp) - [C++](#c)
- [C#](#csharp) - [C#](#c-1)
- [Node.js](#nodejs) - [Node.js](#nodejs)
- [Python](#python) - [Python](#python)
@ -68,7 +69,7 @@ func main() {
fmt.Println(err) fmt.Println(err)
return return
} }
conn, err := grpc.Dial("localhost:18332", grpc.WithTransportCredentials(creds)) conn, err := grpc.Dial("localhost:19244", grpc.WithTransportCredentials(creds))
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
@ -163,7 +164,7 @@ auto main() -> int {
.pem_root_certs = read_file(wallet_tls_cert_file), .pem_root_certs = read_file(wallet_tls_cert_file),
}; };
auto creds = grpc::SslCredentials(cred_options); auto creds = grpc::SslCredentials(cred_options);
auto channel = grpc::CreateChannel("localhost:18332", creds); auto channel = grpc::CreateChannel("localhost:19244", creds);
auto stub = walletrpc::WalletService::NewStub(channel); auto stub = walletrpc::WalletService::NewStub(channel);
grpc::ClientContext context{}; grpc::ClientContext context{};
@ -251,7 +252,7 @@ namespace Example
var walletAppData = Portability.LocalAppData(Environment.OSVersion.Platform, "lbcwallet"); var walletAppData = Portability.LocalAppData(Environment.OSVersion.Platform, "lbcwallet");
var walletTlsCertFile = Path.Combine(walletAppData, "rpc.cert"); var walletTlsCertFile = Path.Combine(walletAppData, "rpc.cert");
var cert = await FileUtils.ReadFileAsync(walletTlsCertFile); var cert = await FileUtils.ReadFileAsync(walletTlsCertFile);
var channel = new Channel("localhost:18332", new SslCredentials(cert)); var channel = new Channel("localhost:19244", new SslCredentials(cert));
try try
{ {
var c = WalletService.NewClient(channel); var c = WalletService.NewClient(channel);
@ -367,7 +368,7 @@ if (os.platform == 'win32') {
var cert = fs.readFileSync(certPath); var cert = fs.readFileSync(certPath);
var creds = grpc.credentials.createSsl(cert); var creds = grpc.credentials.createSsl(cert);
var client = new walletrpc.WalletService('localhost:18332', creds); var client = new walletrpc.WalletService('localhost:19244', creds);
var request = { var request = {
account_number: 0, account_number: 0,
@ -426,7 +427,7 @@ def main():
with open(cert_file_path, 'r') as f: with open(cert_file_path, 'r') as f:
cert = f.read() cert = f.read()
creds = implementations.ssl_client_credentials(cert, None, None) creds = implementations.ssl_client_credentials(cert, None, None)
channel = implementations.secure_channel('localhost', 18332, creds) channel = implementations.secure_channel('localhost', 19244, creds)
stub = walletrpc.beta_create_WalletService_stub(channel) stub = walletrpc.beta_create_WalletService_stub(channel)
request = walletrpc.BalanceRequest(account_number = 0, required_confirmations = 1) request = walletrpc.BalanceRequest(account_number = 0, required_confirmations = 1)

View file

@ -27,8 +27,8 @@
; proxyuser= ; proxyuser=
; proxypass= ; proxypass=
; The server and port used for websocket connections. ; The server and port used for lbcd websocket connections.
; rpcconnect=localhost:18334 ; rpcconnect=localhost:19245
; File containing root certificates to authenticate a TLS connections with ; File containing root certificates to authenticate a TLS connections with
; cafile=~/.lbcwallet/.cert ; cafile=~/.lbcwallet/.cert
@ -61,11 +61,11 @@
; rpclisten= ; all interfaces on default port ; rpclisten= ; all interfaces on default port
; rpclisten=0.0.0.0 ; all ipv4 interfaces on default port ; rpclisten=0.0.0.0 ; all ipv4 interfaces on default port
; rpclisten=:: ; all ipv6 interfaces on default port ; rpclisten=:: ; all ipv6 interfaces on default port
; rpclisten=:8332 ; all interfaces on port 8332 ; rpclisten=:9244 ; all interfaces on port 9244
; rpclisten=0.0.0.0:8332 ; all ipv4 interfaces on port 8332 ; rpclisten=0.0.0.0:9244 ; all ipv4 interfaces on port 9244
; rpclisten=[::]:8332 ; all ipv6 interfaces on port 8332 ; rpclisten=[::]:9244 ; all ipv6 interfaces on port 9244
; rpclisten=127.0.0.1:8332 ; only ipv4 localhost on port 8332 (this is a default) ; rpclisten=127.0.0.1:9244 ; only ipv4 localhost on port 9244 (this is a default)
; rpclisten=[::1]:8332 ; only ipv6 localhost on port 8332 (this is a default) ; rpclisten=[::1]:9244 ; only ipv6 localhost on port 9244 (this is a default)
; rpclisten=127.0.0.1:8337 ; only ipv4 localhost on non-standard port 8337 ; rpclisten=127.0.0.1:8337 ; only ipv4 localhost on non-standard port 8337
; rpclisten=:8337 ; all interfaces on non-standard port 8337 ; rpclisten=:8337 ; all interfaces on non-standard port 8337
; rpclisten=0.0.0.0:8337 ; all ipv4 interfaces on non-standard port 8337 ; rpclisten=0.0.0.0:8337 ; all ipv4 interfaces on non-standard port 8337
@ -86,16 +86,16 @@
; RPC settings (both client and server) ; RPC settings (both client and server)
; ------------------------------------------------------------------------------ ; ------------------------------------------------------------------------------
; Username and password to authenticate to a RPC server and authenticate ; Username and password to authenticate to lbcd a RPC server and authenticate
; new client connections ; new client connections
; username= ; username=
; password= ; password=
; Alternative username and password for . If set, these will be used ; Alternative username and password for lbcd. If set, these will be used
; instead of the username and password set above for authentication to a ; instead of the username and password set above for authentication to a
; RPC server. ; lbcd RPC server.
; username= ; lbcdusername=
; password= ; lbcdpassword=
; ------------------------------------------------------------------------------ ; ------------------------------------------------------------------------------