-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from lndk-org/cli-pay-offer
Cli: add pay offer command
- Loading branch information
Showing
8 changed files
with
272 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# LNDK-CLI | ||
|
||
For now, you can use `lndk-cli` separately from `lndk` meaning you don't need to have a `lndk` binary running for `lndk-cli` to work. | ||
|
||
## Installation | ||
|
||
To use the `lndk-cli` to pay a BOLT 12 offer, follow these instructions: | ||
- To install lndk-cli: | ||
`cargo install --bin=lndk-cli --path .` | ||
- With the above command, `lndk-cli` will be installed to `~/.cargo/bin`. So make sure `~/.cargo/bin` is on your PATH so we can properly run `lndk-cli`. | ||
- Run `lndk-cli -h` to make sure it's working. You'll see output similar to: | ||
|
||
``` | ||
A cli for interacting with lndk | ||
Usage: lndk-cli [OPTIONS] <COMMAND> | ||
Commands: | ||
decode Decodes a bech32-encoded offer string into a BOLT 12 offer | ||
pay-offer PayOffer pays a BOLT 12 offer, provided as a 'lno'-prefaced offer string | ||
help Print this message or the help of the given subcommand(s) | ||
Options: | ||
-n, --network <NETWORK> Global variables [default: regtest] | ||
-t, --tls-cert <TLS_CERT> [default: /$HOME/.lnd/tls.cert] | ||
-m, --macaroon <MACAROON> [default: /$HOME/.lnd/data/chain/bitcoin/regtest/admin.macaroon] | ||
-a, --address <ADDRESS> [default: https://localhost:10009] | ||
-h, --help Print help | ||
``` | ||
|
||
## Commands | ||
|
||
Once `lndk-cli` is installed, you can use it to pay an offer. | ||
|
||
Since `lndk-cli` needs to connect to lnd, you'll need to provide lnd credentials to the binary. If your credentials are not in the default location, you'll need to specify them manually. | ||
|
||
If your credentials are in the default location, paying an offer looks like: | ||
|
||
`lndk-cli pay-offer <OFFER_STRING> <AMOUNT_MSATS>` | ||
|
||
If your credentials are not in the default location, an example command looks like: | ||
|
||
`lndk-cli -- --network=mainnet --tls-cert=/credentials/tls.cert --macaroon=/credentials/custom.macaroon --address=https://localhost:10019 pay-offer <OFFER_STRING> <AMOUNT_MSATS>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
## Eclair testing instructions | ||
|
||
These instructions assume you already have bitcoind and lnd nodes set up on regtest. | ||
|
||
The network we'll build will look like this: | ||
|
||
`LND --> Eclair --> Eclair2` | ||
|
||
Eclair2 will create an offer and we'll make sure lnd can pay the offer with the help of lndk. | ||
|
||
For Eclair to create an offer to pay, we need to install the tipjar plugin. Pull down this branch (https://github.com/ACINQ/eclair-plugins/pull/6/files) and build `eclair-plugins`: | ||
|
||
`mvn package -DskipTests` | ||
|
||
The resulting jar will be located at `eclair-plugins/bolt12-tip-jar/target/bolt12-tip-jar-0.9.1-SNAPSHOT.jar` | ||
|
||
Set up two eclair directories, for example at `~/eclair1` and `~/eclair2` with the following configuration within (at `eclair.conf`): | ||
|
||
``` | ||
eclair { | ||
chain=regtest | ||
server { | ||
port=9995 | ||
public-ips = [ "https://localhost" ] | ||
} | ||
bitcoind { | ||
rpcuser="PASSWORD" | ||
rpcpassword="PASSWORD" | ||
rpcport=18443 | ||
zmqblock="tcp://127.0.0.1:28334" | ||
zmqtx="tcp://127.0.0.1:29335" | ||
} | ||
api { | ||
enabled = true | ||
port = 8181 | ||
password = "testing2" | ||
} | ||
features { | ||
option_route_blinding = optional | ||
} | ||
tip-jar { | ||
description = "donation to eclair" | ||
default-amount-msat = 100000000 // Amount to use if the invoice request does not specify an amount | ||
max-final-expiry-delta = 1000 // How long (in blocks) the route to pay the invoice will be valid | ||
} | ||
} | ||
``` | ||
|
||
Just: | ||
- Set the correct bitcoind values. | ||
- Make sure that `server.port` and `api.port` are different for each Eclair node. | ||
|
||
Install the dependencies for Eclair and install Eclair with `mvn package -DskipTests`. After unzipping the eclair bin (located in `target`), run two eclair nodes, each pointing to the appropriate datadirs we set above, and load in the tipjar plugin: | ||
|
||
`./eclair-node.sh /eclair-plugins/bolt12-tip-jar/target/bolt12-tip-jar-0.9.1-SNAPSHOT.jar -Declair.datadir="~/eclair1` | ||
|
||
`./eclair-node.sh ../../../../../eclair-plugins/bolt12-tip-jar/target/bolt12-tip-jar-0.9.1-SNAPSHOT.jar -Declair.datadir="~/eclair2` | ||
|
||
Using [Eclair's API](https://acinq.github.io/eclair), open two channels: 1) from LND to Eclair1, 2) from Eclair1 to Eclair2. Mine several blocks using bitcoind and make sure those channels are confirmed. | ||
|
||
Have Eclair2 create an offer with: | ||
|
||
`eclair-cli tipjarshowoffer` | ||
|
||
Then pay the offer. Run `lndk-cli pay-offer` using the instructions above. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters