Skip to content

Commit

Permalink
Run gateway as Core-Lightning plugin
Browse files Browse the repository at this point in the history
- mint-clint-cli gets command to generate invoices
- Gateway plugin automatically generates gateway.json if it isn't
there. Removed gw_configgen bin script.
- Add route hint to invoices we generate so HTLCs reach gateway
- Gateway uses channels to manage concurrency between webserver,
plugin and background fetching
- Had to add more features to tracing dependency for the gateway
crate because Core Lightning communicates to plugins via stdin/
stdout. Logging is routed via JSON-RPC. These feature flags helped
make that work.
- Move cln-rpc to git dependency
  • Loading branch information
justinmoon committed Jul 11, 2022
1 parent 1d46f62 commit 92f832d
Show file tree
Hide file tree
Showing 25 changed files with 653 additions and 315 deletions.
117 changes: 67 additions & 50 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ resolver = "2"

[patch.crates-io]
bitcoin_hashes = { version = "0.10.0", git = 'https://github.com/fedimint/bitcoin_hashes', branch = 'minimint' }
secp256k1-zkp = { git = "https://github.com/fedimint/rust-secp256k1-zkp/", branch = "sanket-pr" }
secp256k1-zkp = { git = "https://github.com/fedimint/rust-secp256k1-zkp/", branch = "sanket-pr" }
cln-plugin = { git = "https://github.com/ElementsProject/lightning", rev = "e6442d7" }
cln-rpc = { git = "https://github.com/ElementsProject/lightning", rev = "e6442d7" }
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,12 @@ In order to test locally we need Bitcoin running in [RegTest mode](https://devel
```shell
source ./scripts/setup-tests.sh
```
This starts `bitcoind` and 2 instances of `lightningd` with a channel between them for testing Lightning.
This starts `bitcoind` and 2 instances of `lightningd` with a channel between them for testing Lightning -- one of them running a "lightning gateway" as a Core Lightning [plugin](https://lightning.readthedocs.io/PLUGINS.html).

Now we can start the federation with:
```shell
bash ./scripts/start-fed.sh
```
The federation will connect to your local Bitcoin node and bind to ports starting at `127.0.0.1:5000` listening for clients to submit transactions.

If you wish to run the Lightning gateway to test sending and receiving over the Lightning network run:
```shell
bash ./scripts/start-gateway.sh
```

In order to clean-up these processes you can either `exit` the shell or run `kill_minimint_processes`.

Expand Down Expand Up @@ -139,6 +133,25 @@ $ ln2 listinvoices test
}
```

Create our own invoice:
```shell
$ mint_client ln-invoice 1000 "description"
lnbcrt1u1p3vcp...
```

Have `ln2` pay it:

```shell
$ ln2 pay lnbcrt1u1p3vcp...
```

Have mint client check that payment succeeded, fetch coins, and display new balances:

```shell
$ mint_client wait-invoice lnbcrt1u1p3vcp...
$ mint_client fetch
$ mint_client info
```

### Other options

Expand All @@ -163,13 +176,14 @@ SUBCOMMANDS:
help Print this message or the help of the given subcommand(s)
info Display wallet info (holdings, tiers)
ln-pay Pay a lightning invoice via a gateway
ln-invoice Create a lightning invoice to receive payment via gateway
peg-in Issue tokens in exchange for a peg-in proof (not yet implemented, just
creates coins)
peg-in-address Generate a new peg-in address, funds sent to it can later be claimed
peg-out Withdraw funds from the federation
reissue Reissue tokens received from a third party to avoid double spends
spend Prepare coins to send to a third party as a payment

wait-invoice Wait for incoming invoice to be paid
```

# Contributing
Expand Down
Loading

0 comments on commit 92f832d

Please sign in to comment.