mirror of
https://github.com/talaia-labs/rust-teos.git
synced 2026-08-13 12:33:22 +02:00
Merge pull request #248 from sr-gi/bump-rcgen
Bumps dependencies to get rid old version of ring (<0.17)
This commit is contained in:
commit
609da2dc23
9 changed files with 770 additions and 420 deletions
8
.github/workflows/build.yaml
vendored
8
.github/workflows/build.yaml
vendored
|
|
@ -25,6 +25,10 @@ jobs:
|
|||
uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: ${{ matrix.toolchain }}
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v3
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build on Rust ${{ matrix.toolchain }}
|
||||
run: |
|
||||
cargo build ${{ matrix.arguments }} --verbose --color always
|
||||
|
|
@ -42,6 +46,10 @@ jobs:
|
|||
with:
|
||||
toolchain: stable
|
||||
components: rustfmt, clippy
|
||||
- name: Install Protoc
|
||||
uses: arduino/setup-protoc@v3
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run rustfmt
|
||||
run: |
|
||||
cargo fmt --verbose --check -- --color always
|
||||
|
|
|
|||
14
.github/workflows/cln-plugin.yaml
vendored
14
.github/workflows/cln-plugin.yaml
vendored
|
|
@ -1,6 +1,6 @@
|
|||
name: CI tests for CLN watchtower-plugin
|
||||
|
||||
on:
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
|
@ -19,6 +19,9 @@ jobs:
|
|||
with:
|
||||
python-version: '3.9'
|
||||
check-latest: true
|
||||
- uses: arduino/setup-protoc@v3
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Create CLN cache
|
||||
id: cache-cln
|
||||
uses: actions/cache@v4
|
||||
|
|
@ -28,11 +31,11 @@ jobs:
|
|||
path: lightning
|
||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-v${{ env.cln_version }}
|
||||
- name: Compile CLN
|
||||
env:
|
||||
env:
|
||||
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
|
||||
if: ${{ steps.cache-cln.outputs.cache-hit != 'true' }}
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install -y gettext protobuf-compiler
|
||||
sudo apt-get update && sudo apt-get install -y gettext
|
||||
git clone https://github.com/ElementsProject/lightning.git && cd lightning && git checkout v${{ env.cln_version }}
|
||||
pip install --user poetry && poetry install
|
||||
./configure && poetry run make
|
||||
|
|
@ -46,6 +49,9 @@ jobs:
|
|||
with:
|
||||
python-version: '3.9'
|
||||
check-latest: true
|
||||
- uses: arduino/setup-protoc@v3
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Install bitcoind
|
||||
run: |
|
||||
wget https://bitcoincore.org/bin/bitcoin-core-${{ env.bitcoind_version }}/bitcoin-${{ env.bitcoind_version }}-x86_64-linux-gnu.tar.gz
|
||||
|
|
@ -64,7 +70,7 @@ jobs:
|
|||
cd lightning && sudo make install
|
||||
- name: Install teos and the plugin
|
||||
run: |
|
||||
cargo install --locked --path teos
|
||||
cargo install --locked --path teos
|
||||
cargo install --locked --path watchtower-plugin
|
||||
- name: Add test dependencies
|
||||
run: |
|
||||
|
|
|
|||
1106
Cargo.lock
generated
1106
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,5 @@
|
|||
[workspace]
|
||||
resolver = "2"
|
||||
|
||||
members = [
|
||||
"teos",
|
||||
|
|
|
|||
|
|
@ -2,18 +2,18 @@
|
|||
name = "teos-common"
|
||||
version = "0.2.0"
|
||||
authors = ["Sergi Delgado Segura <sergi.delgado.s@gmail.com>"]
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
# General
|
||||
hex = { version = "0.4.3", features = [ "serde" ] }
|
||||
prost = "0.9"
|
||||
prost = "0.12"
|
||||
rusqlite = { version = "0.26.0", features = [ "bundled", "limits" ] }
|
||||
serde = "1.0.130"
|
||||
serde_json = "1.0"
|
||||
tonic = "0.6"
|
||||
tonic = "0.11"
|
||||
|
||||
# Crypto
|
||||
rand = "0.8.4"
|
||||
|
|
@ -24,4 +24,4 @@ bitcoin = { version = "0.28.0", features = [ "use-serde" ] }
|
|||
lightning = "0.0.108"
|
||||
|
||||
[build-dependencies]
|
||||
tonic-build = "0.6"
|
||||
tonic-build = "0.11"
|
||||
|
|
@ -3,7 +3,7 @@ name = "teos"
|
|||
version = "0.2.0"
|
||||
authors = ["Sergi Delgado Segura <sergi.delgado.s@gmail.com>"]
|
||||
license = "MIT"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
default-run="teosd"
|
||||
|
||||
[[bin]]
|
||||
|
|
@ -19,15 +19,15 @@ path = "src/main.rs"
|
|||
hex = { version = "0.4.3", features = [ "serde" ] }
|
||||
home = "0.5.3"
|
||||
log = "0.4"
|
||||
prost = "0.9"
|
||||
rcgen = { version = "0.8", features = ["pem", "x509-parser"] }
|
||||
prost = "0.12"
|
||||
rcgen = { version = "0.13.1", features = ["pem", "x509-parser"] }
|
||||
rusqlite = { version = "0.26.0", features = [ "bundled", "limits" ] }
|
||||
serde = "1.0.130"
|
||||
serde_json = "1.0"
|
||||
simple_logger = "2.1.0"
|
||||
structopt = "0.3"
|
||||
toml = "0.5"
|
||||
tonic = { version = "0.6", features = [ "tls", "transport" ] }
|
||||
tonic = { version = "0.11", features = [ "tls", "transport" ] }
|
||||
tokio = { version = "1.5", features = [ "rt-multi-thread" ] }
|
||||
triggered = "0.1.2"
|
||||
warp = "0.3.5"
|
||||
|
|
@ -44,7 +44,7 @@ lightning-block-sync = { version = "0.0.108", features = [ "rpc-client" ] }
|
|||
teos-common = { path = "../teos-common" }
|
||||
|
||||
[build-dependencies]
|
||||
tonic-build = "0.6"
|
||||
tonic-build = "0.11"
|
||||
|
||||
[dev-dependencies]
|
||||
jsonrpc-http-server = "17.1.0"
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ async fn main() {
|
|||
.ca_certificate(ca_cert)
|
||||
.identity(Identity::from_pem(certificate, key));
|
||||
|
||||
let channel = Channel::from_shared(format!("http://{}:{}", conf.rpc_bind, conf.rpc_port))
|
||||
let channel = Channel::from_shared(format!("https://{}:{}", conf.rpc_bind, conf.rpc_port))
|
||||
.expect("Cannot create channel from endpoint")
|
||||
.tls_config(tls)
|
||||
.unwrap_or_else(|e| {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* https://github.com/ElementsProject/lightning/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
use rcgen::{Certificate, KeyPair, RcgenError};
|
||||
use rcgen::{Certificate, Error as RcgenError, KeyPair};
|
||||
use std::convert::TryFrom;
|
||||
use std::path::Path;
|
||||
|
||||
|
|
@ -30,21 +30,20 @@ impl From<std::io::Error> for GenCertificateFailure {
|
|||
|
||||
/// Just a wrapper around a certificate and an associated keypair.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Identity {
|
||||
struct Identity {
|
||||
pub key: Vec<u8>,
|
||||
pub certificate: Vec<u8>,
|
||||
}
|
||||
|
||||
impl TryFrom<&Identity> for Certificate {
|
||||
impl TryFrom<&Identity> for (Certificate, KeyPair) {
|
||||
type Error = RcgenError;
|
||||
|
||||
fn try_from(id: &Identity) -> Result<Certificate, RcgenError> {
|
||||
let keystr = String::from_utf8_lossy(&id.key);
|
||||
let key = KeyPair::from_pem(&keystr)?;
|
||||
let certstr = String::from_utf8_lossy(&id.certificate);
|
||||
let params = rcgen::CertificateParams::from_ca_cert_pem(&certstr, key)?;
|
||||
let cert = Certificate::from_params(params)?;
|
||||
Ok(cert)
|
||||
fn try_from(id: &Identity) -> Result<(Certificate, KeyPair), RcgenError> {
|
||||
let key = KeyPair::from_pem(&String::from_utf8_lossy(&id.key))?;
|
||||
let params =
|
||||
rcgen::CertificateParams::from_ca_cert_pem(&String::from_utf8_lossy(&id.certificate))?;
|
||||
let cert = params.self_signed(&key)?;
|
||||
Ok((cert, key))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -72,30 +71,30 @@ fn generate_or_load_identity(
|
|||
// Did we have to generate a new key? In that case we also need to regenerate the certificate.
|
||||
if !key_path.exists() || !cert_path.exists() {
|
||||
log::debug!("Generating a new keypair in {key_path:?}, it didn't exist",);
|
||||
let keypair = KeyPair::generate(&rcgen::PKCS_ECDSA_P256_SHA256)?;
|
||||
let keypair = KeyPair::generate()?;
|
||||
std::fs::write(&key_path, keypair.serialize_pem())?;
|
||||
log::debug!("Generating a new certificate for key {key_path:?} at {cert_path:?}",);
|
||||
|
||||
// Configure the certificate we want.
|
||||
let subject_alt_names = vec!["cln".to_string(), "localhost".to_string()];
|
||||
let mut params = rcgen::CertificateParams::new(subject_alt_names);
|
||||
params.key_pair = Some(keypair);
|
||||
params.alg = &rcgen::PKCS_ECDSA_P256_SHA256;
|
||||
let subject_alt_names = vec!["teos".to_string(), "localhost".to_string()];
|
||||
let mut params = rcgen::CertificateParams::new(subject_alt_names)?;
|
||||
if parent.is_none() {
|
||||
params.is_ca = rcgen::IsCa::Ca(rcgen::BasicConstraints::Unconstrained);
|
||||
} else {
|
||||
params.is_ca = rcgen::IsCa::SelfSignedOnly;
|
||||
params.is_ca = rcgen::IsCa::NoCa;
|
||||
}
|
||||
params
|
||||
.distinguished_name
|
||||
.push(rcgen::DnType::CommonName, name);
|
||||
|
||||
let cert = Certificate::from_params(params)?;
|
||||
std::fs::write(
|
||||
&cert_path,
|
||||
match parent {
|
||||
None => cert.serialize_pem()?,
|
||||
Some(ca) => cert.serialize_pem_with_signer(&Certificate::try_from(ca)?)?,
|
||||
None => params.self_signed(&keypair)?.pem(),
|
||||
Some(ca) => {
|
||||
let (ca_cert, ca_key) = <(Certificate, KeyPair)>::try_from(ca)?;
|
||||
params.signed_by(&keypair, &ca_cert, &ca_key)?.pem()
|
||||
}
|
||||
},
|
||||
)?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ name = "watchtower-plugin"
|
|||
version = "0.2.0"
|
||||
authors = ["Sergi Delgado Segura <sergi.delgado.s@gmail.com>"]
|
||||
license = "MIT"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
|
||||
[[bin]]
|
||||
name = "watchtower-client"
|
||||
|
|
@ -21,7 +21,7 @@ log = "0.4.16"
|
|||
rusqlite = { version = "0.26.0", features = [ "bundled", "limits" ] }
|
||||
serde = "1.0.130"
|
||||
serde_json = { version = "1.0", features = [ "preserve_order" ] }
|
||||
tonic = { version = "^0.5", features = [ "tls", "transport" ] }
|
||||
tonic = { version = "0.11", features = [ "tls", "transport" ] }
|
||||
tokio = { version = "1.5", features = [ "rt-multi-thread", "fs" ] }
|
||||
|
||||
# Bitcoin and Lightning
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue