From d5eb32d2d8ef44bd3bc9b22855443cdd048f720d Mon Sep 17 00:00:00 2001 From: Evan Feenstra Date: Thu, 15 Sep 2022 14:15:36 -0700 Subject: [PATCH] vls error response --- signer/src/lib.rs | 2 +- sphinx-key/Cargo.lock | 13 +++++++++++++ sphinx-key/src/core/events.rs | 5 ++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/signer/src/lib.rs b/signer/src/lib.rs index 5f7d1ae..fff6438 100644 --- a/signer/src/lib.rs +++ b/signer/src/lib.rs @@ -20,7 +20,7 @@ pub use vls_protocol_signer::vls_protocol; pub use derive::node_keys as derive_node_keys; pub use policy::{get_allowlist, make_policy, set_allowlist, set_policy}; -pub use sphinx_key_parser::{control, topics, MsgDriver}; +pub use sphinx_key_parser::{control, error::Error as ParserError, topics, MsgDriver}; pub use sphinx_key_persister::FsPersister; pub struct InitResponse { pub root_handler: RootHandler, diff --git a/sphinx-key/Cargo.lock b/sphinx-key/Cargo.lock index 09a2339..9a67d02 100644 --- a/sphinx-key/Cargo.lock +++ b/sphinx-key/Cargo.lock @@ -1993,6 +1993,18 @@ dependencies = [ "secp256k1", ] +[[package]] +name = "sphinx-glyph" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf0527b300544e9fe193611f1be1f76e3b25f5ceab4217347429c2912b60093e" +dependencies = [ + "anyhow", + "rmp-serde", + "serde", + "sphinx-auther", +] + [[package]] name = "sphinx-key" version = "0.1.0" @@ -2025,6 +2037,7 @@ dependencies = [ "serde", "serde_bolt", "sphinx-auther", + "sphinx-glyph", "vls-protocol", ] diff --git a/sphinx-key/src/core/events.rs b/sphinx-key/src/core/events.rs index 88420ea..6196087 100644 --- a/sphinx-key/src/core/events.rs +++ b/sphinx-key/src/core/events.rs @@ -4,7 +4,7 @@ use crate::core::control::{controller_from_seed, FlashPersister}; use sphinx_key_signer::control::{Config, ControlMessage, ControlResponse, Policy}; use sphinx_key_signer::lightning_signer::bitcoin::Network; use sphinx_key_signer::vls_protocol::model::PubKey; -use sphinx_key_signer::{self, make_init_msg, topics, InitResponse, RootHandler}; +use sphinx_key_signer::{self, make_init_msg, topics, InitResponse, ParserError, RootHandler}; use std::sync::{mpsc, Arc, Mutex}; use embedded_svc::httpd::Result; @@ -104,7 +104,10 @@ pub fn make_event_loop( .expect("could not publish VLS response"); } Err(e) => { + let err_msg = ParserError::new(1, &e.to_string()); log::error!("HANDLE FAILED {:?}", e); + mqtt.publish(topics::ERROR, QOS, false, &err_msg.to_vec()[..]) + .expect("could not publish VLS error"); // panic!("HANDLE FAILED {:?}", e); } };