Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove py based glcli and publish rs based glcli #569

Merged
merged 4 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
239 changes: 139 additions & 100 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions gitlab/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Gitlab Pipelines
There are 5 Greenlight packaged binaries/libraries that are published - 2 Python packages and 3 Rust crates.
There are 5 Greenlight packaged binaries/libraries that are published - 1 Python packages and 4 Rust crates.

The builds are triggered by certain tag formats. Make sure to include a patch as well since the Rust compiler requires that (applicable to `gl-client-py` as well).

Expand All @@ -11,9 +11,9 @@ If a tagged release doesn't work, it can be retried by adding an `_N` suffix aft

### PyPI
* gl-client-py - `glclientpy_YYYYMMDD-x.x.x`
* greenlight-cli - `glcli_YYYYMMDD-x.x.x`

### crates.io
* gl-client - `glclient_YYYYMMDD-x.x.x`
* gl-plugin - `glplugin_YYYYMMDD-x.x.x`
* gl-signerproxy - `glsignerproxy_YYYYMMDD-x.x.x`
* gl-cli -`glcli_YYYYMMDD-x.x.x`
7 changes: 7 additions & 0 deletions gitlab/build-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ build_gl_signerproxy:
- if: $CI_COMMIT_TAG =~ /glsignerproxy_\d{8}(_[1-9][0-9]?)?\-.*/
variables:
PKG_NAME: gl-signerproxy

build_gl_cli:
extends: .build_rust_prep
rules:
- if: $CI_COMMIT_TAG =~ /glcli_\d{8}(_[1-9][0-9]?)?\-.*/
variables:
PKG_NAME: gl-cli
20 changes: 0 additions & 20 deletions gitlab/build-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,3 @@ build_gl_client_py:
expire_in: 2 weeks
paths:
- "target/wheels/*"

build_glcli:
extends: .build_setup
when: manual
rules:
- if: $CI_COMMIT_TAG =~ /glcli_\d{8}(_[1-9][0-9]?)?\-.*/
before_script:
- export NEW_VER=$(echo ${CI_COMMIT_TAG} | cut -d'-' -f2)
- sed -i "s/^version = \".*\"/version = \"$NEW_VER\"/" tools/glcli/pyproject.toml
- . $HOME/.cargo/env # sh doesn't have the correct PATH
script:
- cd tools/glcli
- poetry config pypi-token.pypi ${PYPI_TOKEN}
- poetry build
- poetry publish
- ls -lh dist
artifacts:
expire_in: 2 weeks
paths:
- "tools/glcli/dist/*"
27 changes: 18 additions & 9 deletions libs/gl-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
[package]
name = "glcli"
authors = ["Peter Neuroth <[email protected]>"]
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
authors = ["Peter Neuroth <[email protected]>"]
description = "A command-line interface for running a Greenlight signer and operating a Greenlight node"
homepage = "https://blockstream.github.io/greenlight/"
repository = "https://github.com/Blockstream/greenlight"
documentation = "https://blockstream.github.io/greenlight/"
keywords = ["lightning", "greenlight", "cli", "bitcoin", "blockchain"]
categories = ["command-line-utlis", "cryptography::cryptocurrencies"]
license = "MIT"
reademe = "README.md"

[dependencies]
clap = { version = "4.5.4", features = ["derive"] }
dirs = "5.0.1"
env_logger = "0.11.3"
clap = { version = "4.5", features = ["derive"] }
dirs = "6.0"
env_logger = "0.11"
futures = "0.3"
gl-client = { path = "../gl-client" }
gl-client = { version = "0.3", path = "../gl-client" }
hex = "0.4"
thiserror = "1.0.59"
tokio = "1.37.0"
thiserror = "2.0.11"
tokio = "1.43.0"
vls-core.workspace = true

[badges]
maintenance = { status = "actively-developed" }
143 changes: 143 additions & 0 deletions libs/gl-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# glcli

`glcli` is a command-line interface for running a __Greenlight signer__ and
operating a __Greenlight_node__. It is built on top of the `gl-client` library.

## Features

`glcli` is not yet feature-complete but already provides a basic set of
commands necessary for everyday node operations. Planned future enhancements
include additional commands and broader integration.

* __Scheduler__: Interact with Greenlight's scheduler to provision and start nodes.
* __Signer__: Run and interact with a local signer.
* __Node__: Operate and control a lightning node hosted on Greenlight.

## Installation

Since `glcli` is not yet published on __crates.io__, you can install it locally
using
```bash
cargo install --path=.
```
Run this command from the `glcli` directory.

### Prerequisites

Ensure __Rust__ is installed on your system. If it is not installed, you can set
it up using [Rustup]("https://rustup.rs/"):
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

### Build and Install Locally

Navigate to the `glcli` directory and use __Cargo__ to install `glcli` into
your `CARGO_HOME` (which defaults to `$HOME/.cargo/`):
```bash
cargo install --path=.
```
Ensure that `CARGO_HOME/bin` is in your `PATH`.

## Usage

After installation, run:
```bash
glcli --help
```
This will display an overview of the available commands.

By default, `glcli` stores application data in the system's default data
directory:
* __Linux__: `$XDG_DATA_HOME` or `$HOME/.local/share`
* __macOS__: `$HOME`/Library/Application Support

To specify a custom data directory, use the `--data-dir` or `-d` option. For
example:
```bash
glcli -d "${HOME}/.greenlight_node_1" node getinfo
```

### Register a Node

Before you can operate a Greenlight node you have to register one. Currently,
you need an _invite code_ or a
[developer certificate]("https://blockstream.github.io/greenlight/getting-started/certs/")
to register a new node. `glcli` currently supports registration via an
_invite code_ using the `--invite-code` option:
```bash
glcli scheduler register --invite-code=<YOUR_INVITE_CODE>
```

### Run a Local Signer

To operate your node, you need to attach a local signer to your Greenlight node.
The signer is responsible for handling cryptographic signing operations,
ensuring transaction security and validating requests before granting
signatures locally.

Start a local signer and attach it to Greenlight by running:
```bash
glcli signer run
```

The signer now listens for incomming requests.

### Operate a Greenlight Node

_(Optional scheduling)_: When executing a `node` command, `glcli` will
automatically start the node by calling Greenlight's scheduler if necessary.
However, you can manually schedule your node in advance by running:
```bash
glcli scheduler schedule
```

Once provisioned, you can interact with your node using `node` subcommands. For
example to check the node's operational state:
```bash
glcli node getinfo
```

## Advanced Bitcoin Network Configuration

Greenlight supports running nodes on the `bitcoin` and `signet` networks,
defaulting to `bitcoin`. To register a Greenlight node on `signet`, use the
`--network` option:
```bash
glcli --network="signet" scheduler register
```
Include the `--network` option in all susequent commands for this node. For
example:
```bash
glcli --network="signet" signer run
```
```bash
glcli --network="signet" node getinfo
```

_Please note that we __do not__ support `testnet` at the moment. Please open an
issue describing your use case if you need support for other networks._

## Development
### Build `glcli`
```bash
cargo build
```
### Run Tests
```bash
cargo test
```

## Contributing
`glcli` is under active development and currently lacks many major commands from
[Core-Lightning]("https://github.com/ElementsProject/lightning") such as
`listinvoices`, `fundchannel`, `close` and `sendpay`. Contributions to
add these and other missing commands are welcome. If you need a command
that is not yet available, feel free to submit a pull request or open an issue
describing your use case.

If you encounter any bugs, please report them via an issue or contribute a fix
through a pull request.

## License
`glcli` is licensed under the __MIT License__
7 changes: 0 additions & 7 deletions tools/glcli/.gitignore

This file was deleted.

20 changes: 0 additions & 20 deletions tools/glcli/Makefile

This file was deleted.

34 changes: 0 additions & 34 deletions tools/glcli/README.md

This file was deleted.

Loading
Loading