From 36554814e893c679361b9c2d5a58b243460e0f06 Mon Sep 17 00:00:00 2001 From: Roy Lee Date: Mon, 6 Sep 2021 10:48:23 -0700 Subject: [PATCH] [lbry] align port settings between lbcd, lbcctl, and lbcwallet --- cmd/sweepaccount/main.go | 4 ++++ config.go | 15 ++++++++++----- netparams/params.go | 24 ++++++++++++++++-------- rpc/documentation/clientusage.md | 23 ++++++++++++----------- sample-lbcwallet.conf | 24 ++++++++++++------------ 5 files changed, 54 insertions(+), 36 deletions(-) diff --git a/cmd/sweepaccount/main.go b/cmd/sweepaccount/main.go index c40b7a9..1828697 100644 --- a/cmd/sweepaccount/main.go +++ b/cmd/sweepaccount/main.go @@ -45,6 +45,7 @@ func errContext(err error, context string) error { var opts = struct { TestNet3 bool `long:"testnet" description:"Use the test bitcoin network (version 3)"` 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"` RPCUsername string `short:"u" long:"rpcuser" description:"Wallet RPC username"` RPCCertificateFile string `long:"cafile" description:"Wallet RPC TLS certificate"` @@ -55,6 +56,7 @@ var opts = struct { }{ TestNet3: false, SimNet: false, + RegTest: false, RPCConnect: "localhost", RPCUsername: "", RPCCertificateFile: filepath.Join(walletDataDirectory, "rpc.cert"), @@ -89,6 +91,8 @@ func init() { activeNet = &netparams.TestNet3Params } else if opts.SimNet { activeNet = &netparams.SimNetParams + } else if opts.RegTest { + activeNet = &netparams.RegTestParams } if opts.RPCConnect == "" { diff --git a/config.go b/config.go index b379192..9d4bde1 100644 --- a/config.go +++ b/config.go @@ -51,9 +51,10 @@ type config struct { 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"` 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)"` - SimNet bool `long:"simnet" description:"Use the simulation test network (default mainnet)"` - SigNet bool `long:"signet" description:"Use the signet test network (default mainnet)"` + TestNet3 bool `long:"testnet" description:"Use the test Bitcoin network (version 3) (default client port: 19244, server port: 19245)"` + Regtest bool `long:"regtest" description:"Use the regression test network (default client port: 29244, server port: 29245)"` + 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"` 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"` @@ -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"` // 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"` 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"` @@ -95,7 +96,7 @@ type config struct { 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"` 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"` 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)"` @@ -362,6 +363,10 @@ func loadConfig() (*config, []string, error) { activeNet = &netparams.TestNet3Params numNets++ } + if cfg.Regtest { + activeNet = &netparams.RegTestParams + numNets++ + } if cfg.SimNet { activeNet = &netparams.SimNetParams numNets++ diff --git a/netparams/params.go b/netparams/params.go index 1dadfda..e575049 100644 --- a/netparams/params.go +++ b/netparams/params.go @@ -21,32 +21,40 @@ type Params struct { // on the main network (wire.MainNet). var MainNetParams = Params{ Params: &chaincfg.MainNetParams, - RPCClientPort: "8334", - RPCServerPort: "8332", + RPCClientPort: "9245", + RPCServerPort: "9244", } // TestNet3Params contains parameters specific running lbcwallet and // on the test network (version 3) (wire.TestNet3). var TestNet3Params = Params{ Params: &chaincfg.TestNet3Params, - RPCClientPort: "18334", - RPCServerPort: "18332", + RPCClientPort: "19245", + 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 // (wire.SimNet). var SimNetParams = Params{ Params: &chaincfg.SimNetParams, - RPCClientPort: "18556", - RPCServerPort: "18554", + RPCClientPort: "39245", + RPCServerPort: "39244", } // SigNetParams contains parameters specific to the signet test network // (wire.SigNet). var SigNetParams = Params{ Params: &chaincfg.SigNetParams, - RPCClientPort: "38334", - RPCServerPort: "38332", + RPCClientPort: "49245", + RPCServerPort: "49244", } // SigNetWire is a helper function that either returns the given chain diff --git a/rpc/documentation/clientusage.md b/rpc/documentation/clientusage.md index ef96c76..3ef1f22 100644 --- a/rpc/documentation/clientusage.md +++ b/rpc/documentation/clientusage.md @@ -19,14 +19,15 @@ lbcwallet itself. 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 -(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: -- [Go](#go) -- [C++](#cpp) -- [C#](#csharp) -- [Node.js](#nodejs) -- [Python](#python) +- [Client usage](#client-usage) + - [Go](#go) + - [C++](#c) + - [C#](#c-1) + - [Node.js](#nodejs) + - [Python](#python) Unless otherwise stated under the language example, it is assumed that gRPC is already already installed. The gRPC installation procedure @@ -68,7 +69,7 @@ func main() { fmt.Println(err) return } - conn, err := grpc.Dial("localhost:18332", grpc.WithTransportCredentials(creds)) + conn, err := grpc.Dial("localhost:19244", grpc.WithTransportCredentials(creds)) if err != nil { fmt.Println(err) return @@ -163,7 +164,7 @@ auto main() -> int { .pem_root_certs = read_file(wallet_tls_cert_file), }; 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); grpc::ClientContext context{}; @@ -251,7 +252,7 @@ namespace Example var walletAppData = Portability.LocalAppData(Environment.OSVersion.Platform, "lbcwallet"); var walletTlsCertFile = Path.Combine(walletAppData, "rpc.cert"); 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 { var c = WalletService.NewClient(channel); @@ -367,7 +368,7 @@ if (os.platform == 'win32') { var cert = fs.readFileSync(certPath); var creds = grpc.credentials.createSsl(cert); -var client = new walletrpc.WalletService('localhost:18332', creds); +var client = new walletrpc.WalletService('localhost:19244', creds); var request = { account_number: 0, @@ -426,7 +427,7 @@ def main(): with open(cert_file_path, 'r') as f: cert = f.read() 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) request = walletrpc.BalanceRequest(account_number = 0, required_confirmations = 1) diff --git a/sample-lbcwallet.conf b/sample-lbcwallet.conf index 27f858b..d30eda4 100644 --- a/sample-lbcwallet.conf +++ b/sample-lbcwallet.conf @@ -27,8 +27,8 @@ ; proxyuser= ; proxypass= -; The server and port used for websocket connections. -; rpcconnect=localhost:18334 +; The server and port used for lbcd websocket connections. +; rpcconnect=localhost:19245 ; File containing root certificates to authenticate a TLS connections with ; cafile=~/.lbcwallet/.cert @@ -61,11 +61,11 @@ ; rpclisten= ; all interfaces on default port ; rpclisten=0.0.0.0 ; all ipv4 interfaces on default port ; rpclisten=:: ; all ipv6 interfaces on default port -; rpclisten=:8332 ; all interfaces on port 8332 -; rpclisten=0.0.0.0:8332 ; all ipv4 interfaces on port 8332 -; rpclisten=[::]:8332 ; all ipv6 interfaces on port 8332 -; rpclisten=127.0.0.1:8332 ; only ipv4 localhost on port 8332 (this is a default) -; rpclisten=[::1]:8332 ; only ipv6 localhost on port 8332 (this is a default) +; rpclisten=:9244 ; all interfaces on port 9244 +; rpclisten=0.0.0.0:9244 ; all ipv4 interfaces on port 9244 +; rpclisten=[::]:9244 ; all ipv6 interfaces on port 9244 +; rpclisten=127.0.0.1:9244 ; only ipv4 localhost on port 9244 (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=:8337 ; all 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) ; ------------------------------------------------------------------------------ -; 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 ; username= ; 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 -; RPC server. -; username= -; password= +; lbcd RPC server. +; lbcdusername= +; lbcdpassword= ; ------------------------------------------------------------------------------