Skip to content

Commit

Permalink
add Taro (#179)
Browse files Browse the repository at this point in the history
* add nigiri taro CLI subcommand

* add README
  • Loading branch information
tiero authored May 4, 2023
1 parent d2b3da5 commit 2f36474
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ $ 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 and a LND node.
- Use the `--ln` flag to start a Core Lightning node, a LND node and a Taro daemon.

### Stop nigiri

Expand Down Expand Up @@ -171,6 +171,8 @@ el1qqwwx9gyrcrjrhgnrnjq9dq9t4hykmr6ela46ej63dnkdkcg8veadrvg5p0xg0zd6j3aug74cv9m4
$ nigiri cln listpeers
# LND
$ nigiri lnd listpeers
# Taro
$ nigiri taro assets list
```

### Connect Core Lightning to LND
Expand Down
6 changes: 5 additions & 1 deletion cmd/nigiri/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func main() {

app.Version = formatVersion()
app.Name = "nigiri CLI"
app.Usage = "create your dockerized environment with a bitcoin and liquid node, with a block explorer and developer tools"
app.Usage = "one-click bitcoin development environment"
app.Flags = append(app.Flags, &datadirFlag)
app.Commands = append(
app.Commands,
Expand All @@ -64,6 +64,7 @@ func main() {
&logs,
&mint,
&push,
&taro,
&start,
&update,
&faucet,
Expand Down Expand Up @@ -122,6 +123,9 @@ func provisionResourcesToDatadir(datadir string) error {
if err := makeDirectoryIfNotExists(filepath.Join(datadir, "volumes", "lightningd")); err != nil {
return err
}
if err := makeDirectoryIfNotExists(filepath.Join(datadir, "volumes", "taro")); err != nil {
return err
}

// copy docker compose into the Nigiri data directory
if err := copyFromResourcesToDatadir(
Expand Down
26 changes: 25 additions & 1 deletion cmd/nigiri/resources/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ services:

lnd:
container_name: lnd
image: lightninglabs/lnd:v0.15.4-beta
image: ghcr.io/vulpemventures/lnd
user: 1000:1000
depends_on:
- bitcoin
Expand All @@ -181,6 +181,30 @@ services:
- "9735:9735" # p2p
- "10009:10009" # grpc"
- "18080:18080" # rest"

taro:
container_name: taro
image: ghcr.io/vulpemventures/taro
user: 1000:1000
depends_on:
- bitcoin
- lnd
volumes:
- ./volumes/taro:/data/.taro
- ./volumes/lnd:/data/.lnd
environment:
HOME: /data
command:
- --network=regtest
- --debuglevel=debug
- --lnd.host=lnd:10009
- --lnd.macaroonpath=/data/.lnd/data/chain/bitcoin/regtest/admin.macaroon
- --lnd.tlspath=/data/.lnd/tls.cert
restart: unless-stopped
stop_grace_period: 5m30s
ports:
- "10029:10029" # grpc
- "8089:8089" # rest"

cln:
container_name: cln
Expand Down
4 changes: 2 additions & 2 deletions cmd/nigiri/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func startAction(ctx *cli.Context) error {

if isLN {
// LND
servicesToRun = append(servicesToRun, "lnd")
servicesToRun = append(servicesToRun, "taro")
// Core Lightning Network
servicesToRun = append(servicesToRun, "cln")
}
Expand All @@ -64,7 +64,7 @@ func startAction(ctx *cli.Context) error {
// add also LN services if needed
if isLN {
// LND
servicesToRun = append(servicesToRun, "lnd")
servicesToRun = append(servicesToRun, "taro")
// Core Lightning Network
servicesToRun = append(servicesToRun, "cln")
}
Expand Down
49 changes: 49 additions & 0 deletions cmd/nigiri/taro.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package main

import (
"errors"
"os"
"os/exec"

"github.com/urfave/cli/v2"
)

var taro = cli.Command{
Name: "taro",
Usage: "invoke taro command line interface",
Action: taroAction,
}

func taroAction(ctx *cli.Context) error {

if isRunning, _ := nigiriState.GetBool("running"); !isRunning {
return errors.New("nigiri is not running")
}

network, err := nigiriState.GetString("network")
if err != nil {
return err
}

isCi, err := nigiriState.GetBool("ci")
if err != nil {
return err
}

ttyOption := "-it"
if isCi {
ttyOption = "-i"
}
rpcArgs := []string{"exec", ttyOption, "taro", "tarocli", "--network=" + network}
cmdArgs := append(rpcArgs, ctx.Args().Slice()...)
bashCmd := exec.Command("docker", cmdArgs...)
bashCmd.Stdin = os.Stdin
bashCmd.Stdout = os.Stdout
bashCmd.Stderr = os.Stderr

if err := bashCmd.Run(); err != nil {
return err
}

return nil
}

0 comments on commit 2f36474

Please sign in to comment.