mirror of
https://github.com/stakwork/sphinx-key.git
synced 2026-02-06 16:24:37 +01:00
fix MqttSignerPort, update deps, start hardware
This commit is contained in:
1539
broker/Cargo.lock
generated
1539
broker/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -16,12 +16,6 @@ impl SignerPort for MqttSignerPort {
|
||||
self.get_reply(reply_rx).await
|
||||
}
|
||||
|
||||
fn clone(&self) -> Box<dyn SignerPort> {
|
||||
Box::new(Self {
|
||||
sender: self.sender.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
fn is_ready(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
@@ -102,8 +102,8 @@ async fn run_main(parent_fd: i32) -> rocket::Rocket<rocket::Build> {
|
||||
};
|
||||
|
||||
if let Ok(btc_url) = env::var("BITCOIND_RPC_URL") {
|
||||
let signer_port = Box::new(MqttSignerPort::new(mqtt_tx.clone()));
|
||||
let port_front = SignerPortFront::new(signer_port, settings.network);
|
||||
let signer_port = MqttSignerPort::new(mqtt_tx.clone());
|
||||
let port_front = SignerPortFront::new(Arc::new(signer_port), settings.network);
|
||||
let source_factory = Arc::new(SourceFactory::new(".", settings.network));
|
||||
let frontend = Frontend::new(
|
||||
Arc::new(port_front),
|
||||
|
||||
1
sphinx-key/Cargo.lock
generated
1
sphinx-key/Cargo.lock
generated
@@ -2030,6 +2030,7 @@ dependencies = [
|
||||
"esp-idf-sys",
|
||||
"hex",
|
||||
"log",
|
||||
"lss-connector",
|
||||
"rmp-serde",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
||||
@@ -22,6 +22,7 @@ no_persist = []
|
||||
[dependencies]
|
||||
sphinx-signer = { git = "https://github.com/stakwork/sphinx-rs.git", optional = true }
|
||||
sphinx-crypter = { git = "https://github.com/stakwork/sphinx-rs.git" }
|
||||
lss-connector = { git = "https://github.com/stakwork/sphinx-rs.git", default-features = false }
|
||||
bitflags = "1.3.2"
|
||||
esp-idf-sys = { version = "0.32.1", features = ["binstart"] }
|
||||
embedded-svc = "0.24.0"
|
||||
|
||||
@@ -80,6 +80,9 @@ pub fn make_client(
|
||||
if topic.ends_with(topics::VLS) {
|
||||
tx.send(CoreEvent::VlsMessage(msg.data().to_vec()))
|
||||
.expect("couldnt send Event::VlsMessage");
|
||||
} else if topic.ends_with(topics::LSS_MSG) {
|
||||
tx.send(CoreEvent::LssMessage(msg.data().to_vec()))
|
||||
.expect("couldnt send Event::LssMessage");
|
||||
} else if topic.ends_with(topics::CONTROL) {
|
||||
tx.send(CoreEvent::Control(msg.data().to_vec()))
|
||||
.expect("couldnt send Event::Control");
|
||||
|
||||
@@ -26,6 +26,7 @@ pub enum Event {
|
||||
Connected,
|
||||
Disconnected,
|
||||
VlsMessage(Vec<u8>),
|
||||
LssMessage(Vec<u8>),
|
||||
Control(Vec<u8>),
|
||||
}
|
||||
|
||||
@@ -48,6 +49,19 @@ pub enum Status {
|
||||
|
||||
pub const ROOT_STORE: &str = "/sdcard/store";
|
||||
|
||||
fn mqtt_sub(
|
||||
mqtt: &mut EspMqttClient<ConnState<MessageImpl, EspError>>,
|
||||
client_id: &str,
|
||||
topics: &[&str],
|
||||
) {
|
||||
for top in topics {
|
||||
let topic = format!("{}/{}", client_id, top);
|
||||
log::info!("SUBSCRIBE to {}", topic);
|
||||
mqtt.subscribe(&topic, QOS)
|
||||
.expect("could not MQTT subscribe");
|
||||
}
|
||||
}
|
||||
|
||||
// the main event loop
|
||||
#[cfg(not(feature = "pingpong"))]
|
||||
pub fn make_event_loop(
|
||||
@@ -67,14 +81,8 @@ pub fn make_event_loop(
|
||||
// wait for a Connection first.
|
||||
match event {
|
||||
Event::Connected => {
|
||||
let vls_topic = format!("{}/{}", client_id, topics::VLS);
|
||||
log::info!("SUBSCRIBE to {}", vls_topic);
|
||||
mqtt.subscribe(&vls_topic, QOS)
|
||||
.expect("could not MQTT subscribe");
|
||||
let control_topic = format!("{}/{}", client_id, topics::CONTROL);
|
||||
mqtt.subscribe(&control_topic, QOS)
|
||||
.expect("could not MQTT subscribe");
|
||||
led_tx.send(Status::Connected).unwrap();
|
||||
let ts = &[topics::VLS, topics::LSS_MSG, topics::CONTROL];
|
||||
mqtt_sub(&mut mqtt, client_id, ts);
|
||||
break;
|
||||
}
|
||||
_ => (),
|
||||
@@ -95,13 +103,8 @@ pub fn make_event_loop(
|
||||
while let Ok(event) = rx.recv() {
|
||||
match event {
|
||||
Event::Connected => {
|
||||
let vls_topic = format!("{}/{}", client_id, topics::VLS);
|
||||
mqtt.subscribe(&vls_topic, QOS)
|
||||
.expect("could not MQTT subscribe");
|
||||
log::info!("SUBSCRIBE TO {}", vls_topic);
|
||||
let control_topic = format!("{}/{}", client_id, topics::CONTROL);
|
||||
mqtt.subscribe(&control_topic, QOS)
|
||||
.expect("could not MQTT subscribe");
|
||||
let ts = &[topics::VLS, topics::LSS_MSG, topics::CONTROL];
|
||||
mqtt_sub(&mut mqtt, client_id, ts);
|
||||
led_tx.send(Status::Connected).unwrap();
|
||||
}
|
||||
Event::Disconnected => {
|
||||
@@ -127,6 +130,9 @@ pub fn make_event_loop(
|
||||
}
|
||||
};
|
||||
}
|
||||
Event::LssMessage(ref msg_bytes) => {
|
||||
//
|
||||
}
|
||||
Event::Control(ref msg_bytes) => {
|
||||
log::info!("GOT A CONTROL MSG");
|
||||
let cres = ctrlr.handle(msg_bytes);
|
||||
@@ -230,10 +236,8 @@ pub fn make_event_loop(
|
||||
match event {
|
||||
Event::Connected => {
|
||||
led_tx.send(Status::ConnectedToMqtt).unwrap();
|
||||
let vls_topic = format!("{}/{}", client_id, topics::VLS);
|
||||
log::info!("SUBSCRIBE TO {}", vls_topic);
|
||||
mqtt.subscribe(&vls_topic, QOS)
|
||||
.expect("could not MQTT subscribe");
|
||||
let ts = &[topics::VLS];
|
||||
mqtt_sub(&mut mqtt, client_id, ts);
|
||||
}
|
||||
Event::VlsMessage(msg_bytes) => {
|
||||
led_tx.send(Status::Signing).unwrap();
|
||||
@@ -245,6 +249,7 @@ pub fn make_event_loop(
|
||||
mqtt.publish(&vls_return_topic, QOS, false, b)
|
||||
.expect("could not publish ping response");
|
||||
}
|
||||
Event::LssMessage(_) => (),
|
||||
Event::Disconnected => {
|
||||
led_tx.send(Status::ConnectingToMqtt).unwrap();
|
||||
log::info!("GOT A Event::Disconnected msg!");
|
||||
|
||||
@@ -1,25 +1,8 @@
|
||||
use sphinx_signer::lightning_signer::persist::{ExternalPersistHelper, SimpleEntropy};
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use anyhow::{anyhow, Result};
|
||||
use lss_connector::{secp256k1::PublicKey, LssSigner, Msg as LssMsg, Response as LssRes};
|
||||
use sphinx_signer::{self, RootHandler, RootHandlerBuilder};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ExternalPersistWithHelper {
|
||||
pub state: Arc<Mutex<BTreeMap<String, (u64, Vec<u8>)>>>,
|
||||
pub helper: ExternalPersistHelper,
|
||||
}
|
||||
|
||||
impl ExternalPersistWithHelper {
|
||||
pub async fn init_state(&self) {
|
||||
// let client = self.persist_client.lock().await;
|
||||
let entropy = SimpleEntropy::new();
|
||||
let mut helper = self.helper.clone();
|
||||
let nonce = helper.new_nonce(&entropy);
|
||||
// let (muts, server_hmac) = client.get("".to_string(), &nonce).await.unwrap();
|
||||
// let success = helper.check_hmac(&muts, server_hmac);
|
||||
// assert!(success, "server hmac mismatch on get");
|
||||
// let mut local = self.state.lock().unwrap();
|
||||
// for (key, version_value) in muts.into_iter() {
|
||||
// local.insert(key, version_value);
|
||||
// }
|
||||
}
|
||||
pub fn init_lss() -> Result<(RootHandler, LssSigner)> {
|
||||
let init = LssMsg::from_slice(&[0])?.as_init()?;
|
||||
Err(anyhow!("test"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user