mirror of
https://github.com/stakwork/sphinx-key.git
synced 2025-12-17 07:14:23 +01:00
broker to new rumqttd (not working)
This commit is contained in:
89
Cargo.lock
generated
89
Cargo.lock
generated
@@ -55,14 +55,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ahash"
|
||||
version = "0.7.6"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"once_cell",
|
||||
"version_check",
|
||||
]
|
||||
checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217"
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
@@ -298,7 +293,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "bolt-derive"
|
||||
version = "0.1.0"
|
||||
source = "git+https://gitlab.com/lightning-signer/validating-lightning-signer.git#7afb0cdedb38750cc2086ce0e05dc41d93158e70"
|
||||
source = "git+https://gitlab.com/lightning-signer/validating-lightning-signer.git#9112828c14ecff3bc86bd5e23a1016210de16e85"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -939,11 +934,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.11.2"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
|
||||
checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1207,16 +1203,18 @@ checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
|
||||
|
||||
[[package]]
|
||||
name = "lightning"
|
||||
version = "0.0.110"
|
||||
source = "git+https://github.com/lightningdevkit/rust-lightning.git?rev=ea5b62fff69847941434fb51562e302eb4e7ff4b#ea5b62fff69847941434fb51562e302eb4e7ff4b"
|
||||
version = "0.0.113"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "087add70f81d2fdc6d4409bc0cef69e11ad366ef1d0068550159bd22b3ac8664"
|
||||
dependencies = [
|
||||
"bitcoin",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lightning-invoice"
|
||||
version = "0.18.0"
|
||||
source = "git+https://github.com/lightningdevkit/rust-lightning.git?rev=ea5b62fff69847941434fb51562e302eb4e7ff4b#ea5b62fff69847941434fb51562e302eb4e7ff4b"
|
||||
version = "0.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9680857590c3529cf8c7d32b04501f215f2bf1e029fdfa22f4112f66c1741e4"
|
||||
dependencies = [
|
||||
"bech32",
|
||||
"bitcoin_hashes 0.11.0",
|
||||
@@ -1225,21 +1223,6 @@ dependencies = [
|
||||
"secp256k1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lightning-signer-core"
|
||||
version = "0.1.0-5"
|
||||
source = "git+https://gitlab.com/lightning-signer/validating-lightning-signer.git#7afb0cdedb38750cc2086ce0e05dc41d93158e70"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitcoin",
|
||||
"hashbrown 0.11.2",
|
||||
"itertools",
|
||||
"lightning",
|
||||
"lightning-invoice",
|
||||
"log",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "link-cplusplus"
|
||||
version = "1.0.7"
|
||||
@@ -2162,10 +2145,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_bolt"
|
||||
version = "0.2.0"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "704720009634ab092146c0b01eb578ae8b9d88eef028398752965fd766eb38bd"
|
||||
checksum = "fd5fb14792b8d139f641e6d0e1a19eb0e3c47ec8629a2dc4e75fcbd7d77f46a8"
|
||||
dependencies = [
|
||||
"hex",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
]
|
||||
@@ -2297,8 +2281,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "sphinx-auther"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33bd24149ede6f4ec091326eacf550cfa3fc00492d4e627a045c1bd690255362"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git#fb621dce1ef8bf8ca8bc7dbfbafdbd6a4fb8d293"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64",
|
||||
@@ -2310,7 +2293,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "sphinx-crypter"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git#0f9fcc1416ec0c977d8b307c89983ed7baa3ffa8"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git#fb621dce1ef8bf8ca8bc7dbfbafdbd6a4fb8d293"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chacha20poly1305",
|
||||
@@ -2321,10 +2304,10 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "sphinx-glyph"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62fadd6d488d0e5d824acfc3e8a74599429836c9422503c2dfc84418a19bae24"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git#fb621dce1ef8bf8ca8bc7dbfbafdbd6a4fb8d293"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"hex",
|
||||
"rmp-serde",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -2360,7 +2343,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "sphinx-signer"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git#0f9fcc1416ec0c977d8b307c89983ed7baa3ffa8"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git#fb621dce1ef8bf8ca8bc7dbfbafdbd6a4fb8d293"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bip39",
|
||||
@@ -2824,26 +2807,48 @@ version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||
|
||||
[[package]]
|
||||
name = "vls-core"
|
||||
version = "0.1.0-5"
|
||||
source = "git+https://gitlab.com/lightning-signer/validating-lightning-signer.git#9112828c14ecff3bc86bd5e23a1016210de16e85"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitcoin",
|
||||
"bolt-derive",
|
||||
"hashbrown 0.8.2",
|
||||
"hex",
|
||||
"itertools",
|
||||
"lightning",
|
||||
"lightning-invoice",
|
||||
"log",
|
||||
"scopeguard",
|
||||
"serde",
|
||||
"serde_bolt",
|
||||
"serde_derive",
|
||||
"serde_with",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vls-persist"
|
||||
version = "0.1.0"
|
||||
source = "git+https://gitlab.com/lightning-signer/validating-lightning-signer.git#7afb0cdedb38750cc2086ce0e05dc41d93158e70"
|
||||
source = "git+https://gitlab.com/lightning-signer/validating-lightning-signer.git#9112828c14ecff3bc86bd5e23a1016210de16e85"
|
||||
dependencies = [
|
||||
"hex",
|
||||
"lightning-signer-core",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_with",
|
||||
"vls-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vls-protocol"
|
||||
version = "0.1.0"
|
||||
source = "git+https://gitlab.com/lightning-signer/validating-lightning-signer.git#7afb0cdedb38750cc2086ce0e05dc41d93158e70"
|
||||
source = "git+https://gitlab.com/lightning-signer/validating-lightning-signer.git#9112828c14ecff3bc86bd5e23a1016210de16e85"
|
||||
dependencies = [
|
||||
"as-any",
|
||||
"bolt-derive",
|
||||
"hex",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_bolt",
|
||||
@@ -2853,12 +2858,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "vls-protocol-signer"
|
||||
version = "0.1.0"
|
||||
source = "git+https://gitlab.com/lightning-signer/validating-lightning-signer.git#7afb0cdedb38750cc2086ce0e05dc41d93158e70"
|
||||
source = "git+https://gitlab.com/lightning-signer/validating-lightning-signer.git#9112828c14ecff3bc86bd5e23a1016210de16e85"
|
||||
dependencies = [
|
||||
"bit-vec",
|
||||
"lightning-signer-core",
|
||||
"log",
|
||||
"serde",
|
||||
"vls-core",
|
||||
"vls-protocol",
|
||||
]
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
[toolchain]
|
||||
|
||||
channel = "nightly"
|
||||
channel = "stable"
|
||||
@@ -1,4 +1,4 @@
|
||||
#![feature(once_cell)]
|
||||
// #![feature(once_cell)]
|
||||
mod chain_tracker;
|
||||
mod error_log;
|
||||
mod mqtt;
|
||||
|
||||
@@ -6,6 +6,8 @@ use rumqttd::{Alert, AlertEvent, Broker, Config, Notification};
|
||||
use sphinx_signer::sphinx_glyph::topics;
|
||||
use std::time::Duration;
|
||||
|
||||
// pub const INTERNAL_CONTROL: &str = "INTERNAL_CONTROL";
|
||||
|
||||
// must get a reply within this time, or disconnects
|
||||
const REPLY_TIMEOUT_MS: u64 = 10000;
|
||||
|
||||
@@ -20,13 +22,13 @@ pub fn start_broker(
|
||||
let client_id = expected_client_id.to_string();
|
||||
|
||||
let mut broker = Broker::new(conf);
|
||||
let mut alerts = broker
|
||||
.alerts(vec![
|
||||
let mut alerts = broker.alerts(vec![
|
||||
// "/alerts/error/+".to_string(),
|
||||
"/alerts/event/connect/+".to_string(),
|
||||
"/alerts/event/disconnect/+".to_string(),
|
||||
])?;
|
||||
let (mut link_tx, mut link_rx) = broker.link("localclient")?;
|
||||
|
||||
std::thread::spawn(move || {
|
||||
broker.start().expect("could not start broker");
|
||||
});
|
||||
@@ -51,29 +53,32 @@ pub fn start_broker(
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(40)).await;
|
||||
}
|
||||
});
|
||||
|
||||
// msg forwarding
|
||||
let (msg_tx, mut msg_rx): (mpsc::Sender<Vec<u8>>, mpsc::Receiver<Vec<u8>>) =
|
||||
mpsc::channel(1000);
|
||||
// link_tx.subscribe(INTERNAL_CONTROL)?;
|
||||
link_tx.subscribe(topics::VLS_RETURN)?;
|
||||
link_tx.subscribe(topics::CONTROL_RETURN)?;
|
||||
link_tx.subscribe(topics::ERROR)?;
|
||||
|
||||
let _sub_task = tokio::spawn(async move {
|
||||
println!("ummm....");
|
||||
while let Ok(message) = link_rx.recv() {
|
||||
println!("GOT A MSG ON LINK RX");
|
||||
if let Some(n) = message {
|
||||
match n {
|
||||
Notification::Forward(f) => {
|
||||
println!("GOT A FORWARDED MSG! FORWARD!");
|
||||
println!("GOT A FORWARDED MSG! FORWARD! {:?}", f.publish.topic);
|
||||
if f.publish.topic == topics::ERROR {
|
||||
let _ = error_sender.send(f.publish.topic.to_vec());
|
||||
} else {
|
||||
println!("send now on msg_tx {:?}", f.publish.payload.to_vec());
|
||||
if let Err(e) = msg_tx.send(f.publish.payload.to_vec()).await {
|
||||
log::error!("failed to pub to msg_tx! {:?}", e);
|
||||
}
|
||||
println!("sent on msg_tx");
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
@@ -81,21 +86,24 @@ pub fn start_broker(
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let _relay_task = tokio::spawn(async move {
|
||||
while let Some(msg) = receiver.recv().await {
|
||||
println!("YO YO YO got a receiver msg! {:?}", msg);
|
||||
if let Err(e) = link_tx.publish(msg.topic, msg.message) {
|
||||
log::error!("failed to pub to link_tx! {:?}", e);
|
||||
}
|
||||
println!("PUBBED TO LINKTX....");
|
||||
// let rep = msg_rx.recv().await;
|
||||
// println!("REPPPP {:?}", rep);
|
||||
match timeout(Duration::from_millis(REPLY_TIMEOUT_MS), msg_rx.recv()).await {
|
||||
Ok(reply) => {
|
||||
println!("send on channelreply!");
|
||||
if let Err(_) = msg.reply_tx.send(ChannelReply {
|
||||
reply: reply.unwrap(),
|
||||
}) {
|
||||
Ok(rep) => {
|
||||
println!("GOT A REPLY {:?}", rep);
|
||||
if let Some(reply) = rep {
|
||||
if let Err(_) = msg.reply_tx.send(ChannelReply { reply }) {
|
||||
log::warn!("could not send on reply_tx");
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("reply_tx timed out {:?}", e);
|
||||
let _ = status_sender.send(false).await;
|
||||
@@ -118,9 +126,10 @@ fn config(settings: Settings) -> Config {
|
||||
use std::net::{Ipv4Addr, SocketAddrV4};
|
||||
let router = rumqttd::RouterConfig {
|
||||
instant_ack: true,
|
||||
max_segment_size: 10240,
|
||||
max_segment_size: 104857600,
|
||||
max_segment_count: 10,
|
||||
max_connections: 10001,
|
||||
max_connections: 10010,
|
||||
max_read_len: 10240,
|
||||
..Default::default()
|
||||
};
|
||||
let mut servers = HashMap::new();
|
||||
|
||||
@@ -22,7 +22,6 @@ pub async fn control(sender: &State<Sender<ChannelRequest>>, msg: &str) -> Resul
|
||||
if message.len() < 65 {
|
||||
return Err(Error::Fail);
|
||||
}
|
||||
println!("/control?<msg> got hit!");
|
||||
let (request, reply_rx) = ChannelRequest::new(topics::CONTROL, message);
|
||||
// send to ESP
|
||||
let _ = sender.send(request).await.map_err(|_| Error::Fail)?;
|
||||
|
||||
@@ -6,7 +6,9 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
sphinx-signer = { git = "https://github.com/stakwork/sphinx-rs.git" }
|
||||
# sphinx-signer = { path = "../../sphinx-rs/signer" }
|
||||
sphinx-crypter = { git = "https://github.com/stakwork/sphinx-rs.git" }
|
||||
# sphinx-crypter = { path = "../../sphinx-rs/crypter" }
|
||||
anyhow = {version = "1", features = ["backtrace"]}
|
||||
log = "0.4"
|
||||
rumqttc = "0.12.0"
|
||||
|
||||
@@ -108,8 +108,10 @@ async fn run_main(
|
||||
loop {
|
||||
match eventloop.poll().await {
|
||||
Ok(event) => {
|
||||
println!("{:?}", event);
|
||||
let dummy_peer = PubKey([0; 33]);
|
||||
if let Some((topic, msg_bytes)) = incoming_bytes(event) {
|
||||
println!("MSG BYTES {:}", msg_bytes.len());
|
||||
match topic.as_str() {
|
||||
topics::VLS => {
|
||||
match sphinx_signer::root::handle(
|
||||
|
||||
Reference in New Issue
Block a user