diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 8f970e65..4b8ede93 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -17,18 +17,16 @@ At this point, you should set your `$GOPATH` environment variable, which represents the path to your workspace. By default, `$GOPATH` is set to - `~/go`. Be sure to set your `$GOPATH` every time you open a new terminal - window. - ``` - export GOPATH=~/projects/lightning - ``` - It is recommended to add `$GOPATH/bin` to your `PATH` at this point, like - so: + `~/go`. You wll also need to add `$GOPATH/bin` to your `PATH`. This ensures + that your shell will be able to detect the binaries you install. + ```bash + export GOPATH=~/projects/lightning export PATH=$PATH:$GOPATH/bin ``` - This will ensure that your shell will be able to detect the binaries that - were just installed. + We recommend placing the above in your .bashrc or in a setup + script so that you can avoid typing this every time you open a new terminal + window. * **Glide:** This project uses `Glide` to manage dependencies as well as to provide *reproducible builds*. To install `Glide`, execute the @@ -131,7 +129,7 @@ If you are doing local development, such as for the tutorial, you'll want to start both `btcd` and `lnd` in the `simnet` mode. Simnet is similar to regtest in that you'll be able to instantly mine blocks as needed to test `lnd` locally. In order to start either daemon in the `simnet` mode use `simnet` -instead of `testnet`, such as adding the `--bitcoin.simnet` flag instead of the +instead of `testnet`, adding the `--bitcoin.simnet` flag instead of the `--bitcoin.testnet` flag. Another relevant command line flag for local testing of new `lnd` developments @@ -144,7 +142,9 @@ of your `sendpayment` commands. ### Running LND If you are on testnet, run this command after `btcd` has finished syncing. -Otherwise, replace `--bitcoin.testnet` with `--bitcoin.simnet` +Otherwise, replace `--bitcoin.testnet` with `--bitcoin.simnet`. If you +installing `lnd` in preparation for the +[tutorial](//dev.lightning.community/tutorial), you may skip this step. ``` lnd --bitcoin.active --bitcoin.testnet --debuglevel=debug --bitcoin.rpcuser=kek --bitcoin.rpcpass=kek --externalip=X.X.X.X ``` diff --git a/docs/grpc/javascript.md b/docs/grpc/javascript.md index c37b0266..61b16f8e 100644 --- a/docs/grpc/javascript.md +++ b/docs/grpc/javascript.md @@ -18,8 +18,8 @@ at least somewhere reachable by your Javascript code). The `rpc.proto` file is [located in the `lnrpc` directory of the `lnd` sources](https://github.com/lightningnetwork/lnd/blob/master/lnrpc/rpc.proto). -In order to allow the auto code generated to compile the protos successfully, -you'll need to comment out the following line: +In order for the auto-generated code to compile successfully, you'll need to +comment out the following line: ``` //import "google/api/annotations.proto"; ``` @@ -31,14 +31,23 @@ Every time you work with Javascript gRPC, you will have to import `grpc`, load ```js var grpc = require('grpc'); +var fs = require("fs"); + +// Lnd cert is at ~/.lnd/tls.cert on Linux and +// ~/Library/Application Support/Lnd/tls.cert on Mac +var lndCert = fs.readFileSync("~/.lnd/tls.cert"); +var credentials = grpc.credentials.createSsl(lndCert); var lnrpcDescriptor = grpc.load("rpc.proto"); var lnrpc = lnrpcDescriptor.lnrpc; -var lightning = new lnrpc.Lightning('localhost:10009', grpc.credentials.createInsecure()); +var lightning = new lnrpc.Lightning('localhost:10009', credentials); ``` ### Examples -Let's walk through some examples of Javascript gRPC clients. +Let's walk through some examples of Javascript gRPC clients. These examples +assume that you have at least two `lnd` nodes running, the RPC location of one +of which is at the default `localhost:10009`, with an open channel between the +two nodes. #### Simple RPC @@ -78,8 +87,18 @@ call.on('data', function(invoice) { console.log("Current status" + status); }); ``` -Now, create an invoice for your node at `localhost:10009` and send a payment to -it. Your Javascript console should display the details of the recently satisfied + +Now, create an invoice for your node at `localhost:10009`and send a payment to +it from another node. +```bash +$ lncli addinvoice --value=100 +{ + "r_hash": , + "pay_req": +} +$ lncli sendpayment --pay_req= +``` +Your Javascript console should now display the details of the recently satisfied invoice. #### Bidirectional-streaming RPC diff --git a/docs/grpc/python.md b/docs/grpc/python.md index 455c7f03..9fc02dda 100644 --- a/docs/grpc/python.md +++ b/docs/grpc/python.md @@ -44,7 +44,7 @@ Python gRPC. #### Imports and Client -Everytime you use Python gRPC, you will have to import the generated rpc modeuls +Everytime you use Python gRPC, you will have to import the generated rpc modules and set up a channel and stub to your connect to your `lnd` node: ```python @@ -52,13 +52,19 @@ import rpc_pb2 as ln import rpc_pb2_grpc as lnrpc import grpc -channel = grpc.insecure_channel('localhost:10009') +# Lnd cert is at ~/.lnd/tls.cert on Linux and +# ~/Library/Application Support/Lnd/tls.cert on Mac +cert = open('~/.lnd/tls.cert').read() +creds = grpc.ssl_channel_credentials(cert) +channel = grpc.secure_channel('localhost:10009', creds) stub = lnrpc.LightningStub(channel) ``` ### Examples -Let's walk through some examples of Python gRPC clients. +Let's walk through some examples of Python gRPC clients. These examples assume +that you have at least two `lnd` nodes running, the RPC location of one of which +is at the default `localhost:10009`, with an open channel between the two nodes. #### Simple RPC @@ -75,8 +81,19 @@ request = ln.InvoiceSubscription() for invoice in stub.SubscribeInvoices(request); print invoice ``` -Now, create an invoice for your node at `localhost:10009` and send a payment to -it. Your Python console should display the details of the recently satisfied + +Now, create an invoice for your node at `localhost:10009`and send a payment to +it from another node. +```bash +$ lncli addinvoice --value=100 +{ + "r_hash": , + "pay_req": +} +$ lncli sendpayment --pay_req= +``` + +Your Python console should now display the details of the recently satisfied invoice. #### Bidirectional-streaming RPC