Skip to content

Commit

Permalink
Readme: How to pay invoices between cln and lnd (#205)
Browse files Browse the repository at this point in the history
Signed-off-by: João Bordalo <[email protected]>
  • Loading branch information
bordalix authored Jan 10, 2025
1 parent 3e8fd91 commit 452d5ed
Showing 1 changed file with 53 additions and 41 deletions.
94 changes: 53 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# 🍣 Nigiri Bitcoin
# 🍣 Nigiri Bitcoin

Nigiri provides a command line interface that manages a selection of `docker-compose` batteries included to have a ready-to-use Bitcoin `regtest` development environment. Out of the box, you get:

* **Bitcoin Node**: A Bitcoin Core node running in regtest mode
* **Electrum**: Backend and frontend explorer for quick blockchain inspection
* **Chopsticks**: A [JSON HTTP proxy](https://github.com/vulpemventures/nigiri-chopsticks) that adds handy endpoints like `/faucet` and automatic block generation
- **Bitcoin Node**: A Bitcoin Core node running in regtest mode
- **Electrum**: Backend and frontend explorer for quick blockchain inspection
- **Chopsticks**: A [JSON HTTP proxy](https://github.com/vulpemventures/nigiri-chopsticks) that adds handy endpoints like `/faucet` and automatic block generation

You can extend your setup with:
* **Ark**: A Bitcoin layer two implementation for scalable off-chain transactions
* **Elements/Liquid sidechain** with `--liquid` flag
* **Lightning Network nodes** with `--ln` flag (Core Lightning, LND, and Taproot Assets)

- **Ark**: A Bitcoin layer two implementation for scalable off-chain transactions
- **Elements/Liquid sidechain** with `--liquid` flag
- **Lightning Network nodes** with `--ln` flag (Core Lightning, LND, and Taproot Assets)

# No time to make a Nigiri yourself?
## Pre-built binary

## Pre-built binary

* Download and install `nigiri` command line interface
- Download and install `nigiri` command line interface

```
$ curl https://getnigiri.vulpem.com | bash
Expand All @@ -32,23 +32,26 @@ Windows: `%LOCALAPPDATA%\Nigiri`

Plan 9: `$home/nigiri`

* Lauch Docker daemon (Mac OSX)
- Lauch Docker daemon (Mac OSX)

```
$ open -a Docker
```
```

You may want to [Manage Docker as a non-root user](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user)

* Close and reopen your terminal, then start Bitcoin and Liquid
- Close and reopen your terminal, then start Bitcoin and Ark

```
$ nigiri start --ark
```

**That's it.**

Go to http://localhost:5000 for quickly inspect the Bitcoin blockchain.

Want more? Add Elements/Liquid, Lightning nodes, or Ark:

```bash
$ nigiri start --ark --liquid # Add Elements/Liquid sidechain
$ nigiri start --ark --ln # Add Lightning Network nodes
Expand All @@ -57,33 +60,35 @@ $ nigiri start --ark --liquid --ln # Add all features
```

**Note for users of macOS Monterey an onward**

<details>
<summary>Show more...</summary>
When trying to start Nigiri, you might get an error similar to the following:

```bash
Error response from daemon: Ports are not available: listen tcp 0.0.0.0:5000: bind: address already in use
exit status 1
```
This is due to AirPlay Receiver using port 5000, conflicting with Esplora trying to run using the very same port.
```bash
Error response from daemon: Ports are not available: listen tcp 0.0.0.0:5000: bind: address already in use
exit status 1
```

This is due to AirPlay Receiver using port 5000, conflicting with Esplora trying to run using the very same port.

There are two ways to deal with this issue:
There are two ways to deal with this issue:

1) Uncheck AirPlay Receiver in `System Preferences → Sharing → AirPlay Receiver`
2) Change Esplora’s port to something other than 5000. This can be done by changing it in [docker-compose.yml](https://github.com/vulpemventures/nigiri/blob/master/cmd/nigiri/resources/docker-compose.yml#L110) found in your data directory. If you previously tried starting Nigiri getting an error – you might have to run `nigiri stop --delete` before restarting it.
1. Uncheck AirPlay Receiver in `System Preferences → Sharing → AirPlay Receiver`
2. Change Esplora’s port to something other than 5000. This can be done by changing it in [docker-compose.yml](https://github.com/vulpemventures/nigiri/blob/master/cmd/nigiri/resources/docker-compose.yml#L110) found in your data directory. If you previously tried starting Nigiri getting an error – you might have to run `nigiri stop --delete` before restarting it.
</details>
<br />

## Tasting

At the moment bitcoind, elements and electrs are started on *regtest* network.

At the moment bitcoind, elements and electrs are started on _regtest_ network.

### Start nigiri

```bash
$ nigiri start
```

- Use the `--liquid` flag to let you do experiments with the Liquid sidechain. A liquid daemon and a block explorer are also started when passing this flag.

- Use the `--ln` flag to start a Core Lightning node, a LND node and a Tap daemon.
Expand All @@ -93,6 +98,7 @@ $ nigiri start
```bash
$ nigiri stop
```

Use the `--delete` flag to not just stop Docker containers but also to remove them and delete the config file and any new data written in volumes.

### Generate and send bitcoin to given address
Expand All @@ -111,6 +117,7 @@ $ nigiri faucet --liquid <liquid_address>
```

### Send Liquid asset to given address

```bash
$ nigiri faucet --liquid <liquid_address> <amt> <liquid_asset>
```
Expand Down Expand Up @@ -197,6 +204,14 @@ $ nigiri cln connect `nigiri lnd getinfo | jq -r .identity_pubkey`@lnd:9735

```bash
$ nigiri lnd openchannel --node_key=`nigiri cln getinfo | jq -r .id` --local_amt=100000
$ nigiri cln fundchannel `nigiri lnd getinfo | jq -r .identity_pubkey` 100000
```

### Pay invoices between cln and lnd

```bash
$ nigiri lnd payinvoice `nigiri cln invoice 21000 $(date +%s) "test" | jq -r .bolt11`
$ nigiri cln pay `nigiri lnd addinvoice 21 | jq -r .payment_request`
```

### Use the Ark CLI inside the box
Expand Down Expand Up @@ -232,47 +247,46 @@ To set a custom directory use the `--datadir` flag.
Run the `help` command to see the full list of available flags.

# Make from scratch

## Utensils

* [Docker (compose)](https://docs.docker.com/compose/)
* Go
- [Docker (compose)](https://docs.docker.com/compose/)
- Go

## Ingredients

* [Bitcoin daemon](https://bitcoin.org/en/bitcoin-core/)
* [Liquid daemon](https://blockstream.com/liquid/)
* [Electrum server](https://github.com/Blockstream/electrs)
* [Esplora](https://github.com/Blockstream/esplora)
* [Nigiri Chopsticks](https://github.com/vulpemventures/nigiri-chopsticks)
- [Bitcoin daemon](https://bitcoin.org/en/bitcoin-core/)
- [Liquid daemon](https://blockstream.com/liquid/)
- [Electrum server](https://github.com/Blockstream/electrs)
- [Esplora](https://github.com/Blockstream/esplora)
- [Nigiri Chopsticks](https://github.com/vulpemventures/nigiri-chopsticks)

## Directions

| Preparation Time: 5 min | Cooking Difficulty: Easy |
| --- | --- |
| Preparation Time: 5 min | Cooking Difficulty: Easy |
| ----------------------- | ------------------------ |

* Clone the repo:
- Clone the repo:

```bash
$ git clone https://github.com/vulpemventures/nigiri.git
```

* Enter project directory and install dependencies:
- Enter project directory and install dependencies:

```bash
$ make install
```


* Build binary
- Build binary

```
$ make build
```

Done! You should be able to find the binary in the local `./build` folder. Give it permission to execute and move/rename into your PATH.


* Clean
- Clean

Remeber to always `clean` Nigiri before running `install` to upgrade to a new version.

Expand All @@ -284,18 +298,16 @@ $ make clean

`Chopsticks` service exposes on port `3000` (and on `3001` if started with `--liquid` flag) all [Esplora's available endpoints](https://github.com/blockstream/esplora/blob/master/API.md) and extends them with the following:


### Bitcoin & Liquid

- `POST /faucet` which expects a body `{ "address": <receiving_address> }`
- `POST /faucet` which expects a body `{ "address": <receiving_address> }`
- `POST /tx` has been extended to automatically mine a block when is called.

### Liquid only

- `POST /mint` which expects a body `{"address": "ert1q90dz89u8eudeswzynl3p2jke564ejc2cnfcwuq", "quantity": 1000, "name":"VULPEM", "ticker":"VLP"}`
- `POST /mint` which expects a body `{"address": "ert1q90dz89u8eudeswzynl3p2jke564ejc2cnfcwuq", "quantity": 1000, "name":"VULPEM", "ticker":"VLP"}`
- `POST /registry` to get extra info about one or more assets like `name` and `ticker` which expects a body with an array of assets `{"assets": ["2dcf5a8834645654911964ec3602426fd3b9b4017554d3f9c19403e7fc1411d3"]}`


## Footnotes

If you really do love Sathoshi's favourite dish like us at Vulpem Ventures, check the real [recipe](https://www.allrecipes.com/recipe/228952/nigiri-sushi/) out and enjoy your own, delicious, hand made nigiri sushi.

0 comments on commit 452d5ed

Please sign in to comment.