Configure with --enable-rust
. Here’s how to use:
0$ ./bitcoin-cli help
1...
2 == Lightning ==
3lnclosechannel "channel_id"
4lnconnect "node"
5lncreateinvoice "description" amount
6lnfundchannel "node_id" amount
7lngetchannels
8lngetpeers
9lnpayinvoice "invoice"
10...
Connect to ACINQ testnet node:
0$ ./bitcoin-cli lnconnect 03933884aaf1d6b108397e5efe5c86bcf2d8ca8d2f700eda99db9214fc2712b134@34.250.234.192:9735
See that we are connected:
0$ ./bitcoin-cli lngetpeers
1[
2 {
3 "id": "03933884aaf1d6b108397e5efe5c86bcf2d8ca8d2f700eda99db9214fc2712b134"
4 }
5]
Check if we have enough in our wallet:
0$ ./bitcoin-cli getbalances
1{
2 "mine": {
3 "trusted": 0.01000000,
4 "untrusted_pending": 0.00000000,
5 "immature": 0.00000000
6 }
7}
Fund a 0.001 tBTC channel with our peer:
0$ ./bitcoin-cli lnfundchannel 03933884aaf1d6b108397e5efe5c86bcf2d8ca8d2f700eda99db9214fc2712b134 0.001
1
2$ ./bitcoin-cli lngetchannels
3[
4 {
5 "id": "09e43999ea4fc33c0c8aa134727ea17ac1e2ac7e9356b1434fed9bfc8f091e1f",
6 "shortid": 0,
7 "capacity": 100000,
8 "status": "unconfirmed"
9 }
10]
Wait a couple of blocks and try again:
0$ ./bitcoin-cli lngetchannels
1[
2 {
3 "id": "09e43999ea4fc33c0c8aa134727ea17ac1e2ac7e9356b1434fed9bfc8f091e1f",
4 "shortid": 1831367457947189249,
5 "capacity": 100000,
6 "status": "confirmed"
7 }
8]
9
10$ ./bitcoin-cli getbalances
11{
12 "mine": {
13 "trusted": 0.00896940,
14 "untrusted_pending": 0.00000000,
15 "immature": 0.00000000
16 }
17}
Our channel is operational! Immediately go and purchase some beers on yalls.org:
0$ ./bitcoin-cli lnpayinvoice lntb1500n1p0yxfm6pp5098ss9punvma2xusvdez40dnrnrr7zlf2hpqm5kvnc4g9fjk7pjqdp6g9jxggrjv4skxarfdahzpuyl3kazqar0ypuk7atjyp3k7mrvv43hg6t0dccqzpgxqr23ssp5kjpejv09t6yweaf02x7ywzpdr3z8utpnyw67x9lcvfuf6f6kwdns9qy9qsqx323heyl6e54cmrxn9gnuqsef7juacsl7w7cngvrvg2vft6qtll5f7c07vx004n62uwklnhfwd62tnjzw30gt5ucsz32yz3j6uanvhqqqgpkru
Close the channel:
0$ ./bitcoin-cli lnclosechannel 09e43999ea4fc33c0c8aa134727ea17ac1e2ac7e9356b1434fed9bfc8f091e1f
Hot on the heels of rust-lightning 0.0.10 release and the LDK announcement I present you CoreLightning.
This PR is based on #17376 and it adds 4 more crates to the mix:
rust-lightning
, rust-lightning-invoice
, rust-bech32-bitcoin
and num-traits
. Peers and channels data is in lightning
. Code will be impossible to review on GitHub due to submodule mess but for now this is a one-commit PR anyway so take a look there.
Even though this is nowhere near production ready I’m excited to see it work. Credit to @TheBlueMatt and the rust-bitcoin/lightning team. Truly awesome work.
For the sake of argument let’s say everyone agrees that Lightning is a good thing and helpes Bitcoin scale. In that case I see built-in CoreLightning as useful in two ways:
- Makes it easy for the Core install-base to adopt Lightning in one fell swoop. People will be more likely to use and build on top of Lightning if it’s one upgrade away. You can use your existing wallet funds. No separate daemons or needless transactions. Institutional users such as exchanges would have no excuse not leverage Lightning.
- I feel that Core could be more of a universal client in the future. It’s somewhat industrial nowadays but I’d like 2021 to be the year of Core on the Phone :sunglasses:. I wrote about this a bit here.
Code is not very robust, it needs a lot of love in regards to making it more “rusty” and figuring how to better manage the C++/Rust FFI boundary. Before I invest any more time in this I’d like to get some guidance and concept (N)ACKs.