cargo clippy

This commit is contained in:
irriden
2023-11-15 17:48:30 +00:00
parent 5bef7ab78e
commit 90d43c4e70
33 changed files with 207 additions and 253 deletions

10
broker/Cargo.lock generated
View File

@@ -1691,7 +1691,7 @@ dependencies = [
[[package]]
name = "lss-connector"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs?rev=1b6b89123171e621617125e8ab59faa246aa2ee3#1b6b89123171e621617125e8ab59faa246aa2ee3"
source = "git+https://github.com/stakwork/sphinx-rs?rev=55c4b00dc079d21353904fec45b10c7f09ec8f85#55c4b00dc079d21353904fec45b10c7f09ec8f85"
dependencies = [
"anyhow",
"lightning-storage-server",
@@ -2693,7 +2693,7 @@ dependencies = [
[[package]]
name = "rmp-utils"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs?rev=1b6b89123171e621617125e8ab59faa246aa2ee3#1b6b89123171e621617125e8ab59faa246aa2ee3"
source = "git+https://github.com/stakwork/sphinx-rs?rev=55c4b00dc079d21353904fec45b10c7f09ec8f85#55c4b00dc079d21353904fec45b10c7f09ec8f85"
dependencies = [
"anyhow",
"log",
@@ -3268,7 +3268,7 @@ dependencies = [
[[package]]
name = "sphinx-auther"
version = "0.1.12"
source = "git+https://github.com/stakwork/sphinx-rs?rev=1b6b89123171e621617125e8ab59faa246aa2ee3#1b6b89123171e621617125e8ab59faa246aa2ee3"
source = "git+https://github.com/stakwork/sphinx-rs?rev=55c4b00dc079d21353904fec45b10c7f09ec8f85#55c4b00dc079d21353904fec45b10c7f09ec8f85"
dependencies = [
"anyhow",
"base64 0.21.2",
@@ -3280,7 +3280,7 @@ dependencies = [
[[package]]
name = "sphinx-glyph"
version = "0.1.2"
source = "git+https://github.com/stakwork/sphinx-rs?rev=1b6b89123171e621617125e8ab59faa246aa2ee3#1b6b89123171e621617125e8ab59faa246aa2ee3"
source = "git+https://github.com/stakwork/sphinx-rs?rev=55c4b00dc079d21353904fec45b10c7f09ec8f85#55c4b00dc079d21353904fec45b10c7f09ec8f85"
dependencies = [
"anyhow",
"hex",
@@ -3326,7 +3326,7 @@ dependencies = [
[[package]]
name = "sphinx-signer"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs?rev=1b6b89123171e621617125e8ab59faa246aa2ee3#1b6b89123171e621617125e8ab59faa246aa2ee3"
source = "git+https://github.com/stakwork/sphinx-rs?rev=55c4b00dc079d21353904fec45b10c7f09ec8f85#55c4b00dc079d21353904fec45b10c7f09ec8f85"
dependencies = [
"anyhow",
"bip39",

View File

@@ -39,8 +39,8 @@ vls-proxy = { git = "https://gitlab.com/lightning-signer/validating-li
# vls-protocol-client = { path = "../../vls/vls-protocol-client" }
# vls-proxy = { path = "../../vls/vls-proxy" }
lss-connector = { git = "https://github.com/stakwork/sphinx-rs", rev = "1b6b89123171e621617125e8ab59faa246aa2ee3" }
sphinx-signer = { git = "https://github.com/stakwork/sphinx-rs", rev = "1b6b89123171e621617125e8ab59faa246aa2ee3" }
lss-connector = { git = "https://github.com/stakwork/sphinx-rs", rev = "55c4b00dc079d21353904fec45b10c7f09ec8f85" }
sphinx-signer = { git = "https://github.com/stakwork/sphinx-rs", rev = "55c4b00dc079d21353904fec45b10c7f09ec8f85" }
# lss-connector = { path = "../../sphinx-rs/lss-connector" }
# sphinx-signer = { path = "../../sphinx-rs/signer" }

View File

@@ -45,7 +45,7 @@ pub fn current_client_and_synced() -> (Option<String>, bool) {
let c = cs.current.clone();
let mut b = false;
if let Some(ref client) = c {
b = cs.clients.get(client).unwrap_or(&false).clone();
b = *cs.clients.get(client).unwrap_or(&false);
}
(c, b)
}

View File

@@ -15,9 +15,7 @@ pub fn log_errors(mut error_rx: tokio::sync::broadcast::Receiver<Vec<u8>>) {
.open(err_log_path)
{
while let Ok(err_msg) = error_rx.recv().await {
let mut log = format!("[{}]: ", chrono::Utc::now().to_string())
.as_bytes()
.to_vec();
let mut log = format!("[{}]: ", chrono::Utc::now()).as_bytes().to_vec();
log.extend_from_slice(&err_msg);
log.extend_from_slice(b"\n");
if let Err(e) = file.write_all(&log) {

View File

@@ -43,7 +43,7 @@ pub fn handle_message(
let res_bytes = loop {
let (cid, is_synced) = current_client_and_synced();
if let None = cid {
if cid.is_none() {
log::info!("no client yet... retry");
thread::sleep(Duration::from_millis(96));
continue;

View File

@@ -77,7 +77,7 @@ async fn connect_dance(
let lss_conn = new_broker.as_ref().xor(lss_conn).ok_or(anyhow!(
"should never happen, either we use the newly initialized, or the one passed in"
))?;
let _ = dance_step_2(cid, lss_conn, mqtt_tx, &ir).await?;
dance_step_2(cid, lss_conn, mqtt_tx, &ir).await?;
// only some when lss_conn is none
Ok(new_broker)
}

View File

@@ -51,12 +51,10 @@ async fn rocket() -> _ {
env::var("GREENLIGHT_VERSION").expect("set GREENLIGHT_VERSION to match c-lightning");
println!("{}", version);
panic!("end")
} else if matches.is_present("test") {
run_test::run_test()
} else {
if matches.is_present("test") {
run_test::run_test()
} else {
run_main(parent_fd)
}
run_main(parent_fd)
}
}
@@ -111,7 +109,7 @@ fn run_main(parent_fd: i32) -> rocket::Rocket<rocket::Build> {
let cln_client = UnixClient::new(UnixConnection::new(parent_fd));
// TODO pass status_rx into SignerLoop?
let mut signer_loop = SignerLoop::new(cln_client, mqtt_tx.clone(), lss_tx.clone());
let mut signer_loop = SignerLoop::new(cln_client, mqtt_tx.clone(), lss_tx);
// spawn CLN listener
std::thread::spawn(move || {
signer_loop.start(Some(settings.network));
@@ -145,15 +143,8 @@ pub fn broker_setup(
// broker
log::info!("=> start broker on network: {}", settings.network);
start_broker(
settings,
mqtt_rx,
init_rx,
status_tx,
error_tx.clone(),
auth_tx,
)
.expect("BROKER FAILED TO START");
start_broker(settings, mqtt_rx, init_rx, status_tx, error_tx, auth_tx)
.expect("BROKER FAILED TO START");
// client connections state
std::thread::spawn(move || {

View File

@@ -27,7 +27,7 @@ pub fn start_broker(
let _ = link_tx.subscribe(format!("+/{}", topics::HELLO));
let _ = link_tx.subscribe(format!("+/{}", topics::BYE));
let auth_sender_ = auth_sender.clone();
let auth_sender_ = auth_sender;
std::thread::spawn(move || {
broker
.start(Some(auth_sender_))
@@ -83,13 +83,13 @@ pub fn start_broker(
// receive replies back from glyph
let _sub_task = std::thread::spawn(move || {
while let Ok(message) = link_rx.recv() {
if let None = message {
if message.is_none() {
continue;
}
match message.unwrap() {
Notification::Forward(f) => {
let topic_res = std::str::from_utf8(&f.publish.topic);
if let Err(_) = topic_res {
if topic_res.is_err() {
continue;
}
@@ -99,7 +99,7 @@ pub fn start_broker(
continue;
}
let ts: Vec<&str> = topic.split("/").collect();
let ts: Vec<&str> = topic.split('/').collect();
if ts.len() != 2 {
continue;
}
@@ -117,10 +117,8 @@ pub fn start_broker(
if let Err(e) = init_tx.send((cid, topic_end, pld)) {
log::error!("failed to pub to init_tx! {:?}", e);
}
} else {
if let Err(e) = msg_tx.send((cid, topic_end, pld)) {
log::error!("failed to pub to msg_tx! {:?}", e);
}
} else if let Err(e) = msg_tx.send((cid, topic_end, pld)) {
log::error!("failed to pub to msg_tx! {:?}", e);
}
}
}
@@ -150,11 +148,11 @@ fn pub_and_wait(
loop {
log::debug!("looping in pub_and_wait");
let reply = pub_timeout(&msg.cid, &msg.topic, &msg.message, &msg_rx, link_tx);
let reply = pub_timeout(&msg.cid, &msg.topic, &msg.message, msg_rx, link_tx);
if let Some(reply) = reply {
log::debug!("MQTT got this response: {:?}", reply);
if let Err(_) = msg.reply_tx.send(reply) {
if msg.reply_tx.send(reply).is_err() {
log::warn!("could not send on reply_tx");
}
break;
@@ -164,7 +162,7 @@ fn pub_and_wait(
if let Some(max) = retries {
log::debug!("counter: {}, retries: {}", counter, max);
if counter == max {
if let Err(_) = msg.reply_tx.send(ChannelReply::empty()) {
if msg.reply_tx.send(ChannelReply::empty()).is_err() {
log::warn!("could not send on reply_tx");
}
break;
@@ -190,7 +188,7 @@ fn pub_timeout(
// and receive from the correct client (or timeout to next)
let dur = Duration::from_secs(10);
if let Ok((cid, topic_end, reply)) = msg_rx.recv_timeout(dur) {
if &cid == client_id {
if cid == client_id {
return Some(ChannelReply::new(topic_end, reply));
} else {
log::warn!("Mismatched client id!");
@@ -226,7 +224,7 @@ pub fn check_auth(
Ok(t) => match t.recover() {
Ok(pubkey) => {
// pubkey must match signature
if &pubkey.to_string() == username {
if pubkey.to_string() == username {
if let Some(pk) = already_pubkey {
// if there is an existing pubkey then new client must match
(pk == username, None)

View File

@@ -33,13 +33,13 @@ pub async fn control(
}
let (request, reply_rx) = ChannelRequest::new(cid, topics::CONTROL, message);
// send to ESP
let _ = sender.send(request).await.map_err(|_| Error::Fail)?;
sender.send(request).await.map_err(|_| Error::Fail)?;
// wait for reply
let reply = reply_rx.await.map_err(|_| Error::Fail)?;
if reply.is_empty() {
return Err(Error::Fail);
}
Ok(hex::encode(reply.reply).to_string())
Ok(hex::encode(reply.reply))
}
#[get("/errors")]
@@ -98,13 +98,12 @@ impl<'r, 'o: 'r> Responder<'r, 'o> for Error {
// log `self` to your favored error tracker, e.g.
// sentry::capture_error(&self);
println!("ERROR {:?}", self);
match self {
// in our simplistic example, we're happy to respond with the default 500 responder in all cases
_ => Status::InternalServerError.respond_to(req),
}
// in our simplistic example, we're happy to respond with the default 500 responder in all cases
Status::InternalServerError.respond_to(req)
}
}
#[allow(clippy::upper_case_acronyms)]
pub struct CORS;
#[rocket::async_trait]

View File

@@ -23,13 +23,7 @@ pub fn run_test() -> rocket::Rocket<rocket::Build> {
crate::error_log::log_errors(error_rx);
// block until connection
crate::broker_setup(
settings,
mqtt_rx,
init_rx,
conn_tx.clone(),
error_tx.clone(),
);
crate::broker_setup(settings, mqtt_rx, init_rx, conn_tx, error_tx.clone());
log::info!("=> off to the races!");
let tx_ = mqtt_tx.clone();

View File

@@ -110,7 +110,7 @@ pub fn setup_logging(who: &str, level_arg: &str) {
}
fn read_network_setting(table: &Value) -> Option<Network> {
if let None = table.get("network") {
if table.get("network").is_none() {
log::info!("Network not specified, setting to default regtest");
None
} else {
@@ -129,7 +129,7 @@ fn read_network_setting(table: &Value) -> Option<Network> {
}
fn read_mqtt_port_setting(table: &Value) -> Option<u16> {
if let None = table.get("mqtt_port") {
if table.get("mqtt_port").is_none() {
log::info!("Broker mqtt port not specified, setting to default 1883");
None
} else {
@@ -149,7 +149,7 @@ fn read_mqtt_port_setting(table: &Value) -> Option<u16> {
}
fn read_http_port_setting(table: &Value) -> Option<u16> {
if let None = table.get("http_port") {
if table.get("http_port").is_none() {
log::info!("Broker http port not specified, setting to default 8000");
None
} else {
@@ -169,7 +169,7 @@ fn read_http_port_setting(table: &Value) -> Option<u16> {
}
fn read_ws_port_setting(table: &Value) -> Option<u16> {
if let None = table.get("ws_port") {
if table.get("ws_port").is_none() {
log::info!("Broker ws port not specified, setting to default 8083");
None
} else {

View File

@@ -1,28 +1,28 @@
pub(crate) struct RGB {
pub(crate) struct Rgb {
pub(crate) r: u8,
pub(crate) g: u8,
pub(crate) b: u8,
}
pub(crate) const BLUE: RGB = RGB {
pub(crate) const BLUE: Rgb = Rgb {
r: 00,
g: 00,
b: 255,
};
pub(crate) const GREEN: RGB = RGB {
pub(crate) const GREEN: Rgb = Rgb {
r: 00,
g: 255,
b: 00,
};
pub(crate) const ORANGE: RGB = RGB {
pub(crate) const ORANGE: Rgb = Rgb {
r: 255,
g: 55,
b: 00,
};
pub(crate) const WHITE: RGB = RGB {
pub(crate) const WHITE: Rgb = Rgb {
r: 255,
g: 255,
b: 255,

View File

@@ -16,30 +16,30 @@ pub(crate) fn setup(peripherals: Peripherals) -> Result<TxRmtDriver<'static>, Fa
let led = peripherals.led;
let channel = peripherals.channel;
let config = TransmitConfig::new().clock_divider(1);
let tx = TxRmtDriver::new(channel, led, &config).map_err(|e| FactoryError::EspError(e))?;
let tx = TxRmtDriver::new(channel, led, &config).map_err(FactoryError::Esp)?;
Ok(tx)
}
pub(crate) fn setup_complete(led_tx: &mut TxRmtDriver) -> Result<(), FactoryError> {
neopixel(BLUE, led_tx).map_err(|e| FactoryError::EspError(e))?;
neopixel(BLUE, led_tx).map_err(FactoryError::Esp)?;
FreeRtos::delay_ms(10);
Ok(())
}
pub(crate) fn update_launch(led_tx: &mut TxRmtDriver) -> Result<(), FactoryError> {
neopixel(ORANGE, led_tx).map_err(|e| FactoryError::EspError(e))?;
neopixel(ORANGE, led_tx).map_err(FactoryError::Esp)?;
FreeRtos::delay_ms(10);
Ok(())
}
pub(crate) fn update_complete(led_tx: &mut TxRmtDriver) -> Result<(), FactoryError> {
neopixel(GREEN, led_tx).map_err(|e| FactoryError::EspError(e))?;
neopixel(GREEN, led_tx).map_err(FactoryError::Esp)?;
FreeRtos::delay_ms(10);
Ok(())
}
pub(crate) fn main_app_launch(led_tx: &mut TxRmtDriver) -> Result<(), FactoryError> {
neopixel(WHITE, led_tx).map_err(|e| FactoryError::EspError(e))?;
neopixel(WHITE, led_tx).map_err(FactoryError::Esp)?;
FreeRtos::delay_ms(10);
Ok(())
}
@@ -48,7 +48,7 @@ fn ns(nanos: u64) -> Duration {
Duration::from_nanos(nanos)
}
fn neopixel(rgb: RGB, tx: &mut TxRmtDriver) -> Result<(), EspError> {
fn neopixel(rgb: Rgb, tx: &mut TxRmtDriver) -> Result<(), EspError> {
// e.g. rgb: (1,2,4)
// G R B
// 7 0 7 0 7 0

View File

@@ -15,9 +15,9 @@ use esp_println::println;
#[derive(Debug)]
pub(crate) enum FactoryError {
SdCardError(Error<SdCardError>),
OtaError(EspError),
EspError(EspError),
SdCard(Error<SdCardError>),
Ota(EspError),
Esp(EspError),
}
#[no_mangle]
@@ -52,7 +52,7 @@ fn main() -> Result<(), FactoryError> {
fn assign_peripherals() -> Result<(sdcard::Peripherals, led::Peripherals), FactoryError> {
// this function here must be called only once
let peripherals = Peripherals::take().map_err(|e| FactoryError::EspError(e))?;
let peripherals = Peripherals::take().map_err(FactoryError::Esp)?;
let sd_card_peripherals = sdcard::Peripherals {
spi: peripherals.spi2,
sck: peripherals.pins.gpio6,

View File

@@ -13,14 +13,14 @@ const BUFFER_LEN: usize = 1024;
pub(crate) fn update_present(volume_mgr: &mut Manager) -> Result<bool, FactoryError> {
let volume0 = volume_mgr
.get_volume(VolumeIdx(0))
.map_err(|e| FactoryError::SdCardError(e))?;
.map_err(FactoryError::SdCard)?;
let root_dir = volume_mgr
.open_root_dir(&volume0)
.map_err(|e| FactoryError::SdCardError(e))?;
.map_err(FactoryError::SdCard)?;
let ret = match volume_mgr.find_directory_entry(&volume0, &root_dir, FILE) {
Ok(_) => Ok(true),
Err(FileNotFound) => Ok(false),
Err(e) => Err(FactoryError::SdCardError(e)),
Err(e) => Err(FactoryError::SdCard(e)),
};
volume_mgr.close_dir(&volume0, root_dir);
ret
@@ -29,33 +29,30 @@ pub(crate) fn update_present(volume_mgr: &mut Manager) -> Result<bool, FactoryEr
pub(crate) fn write_update(volume_mgr: &mut Manager) -> Result<(), FactoryError> {
let mut volume0 = volume_mgr
.get_volume(VolumeIdx(0))
.map_err(|e| FactoryError::SdCardError(e))?;
.map_err(FactoryError::SdCard)?;
let root_dir = volume_mgr
.open_root_dir(&volume0)
.map_err(|e| FactoryError::SdCardError(e))?;
.map_err(FactoryError::SdCard)?;
let mut my_file = volume_mgr
.open_file_in_dir(&mut volume0, &root_dir, FILE, Mode::ReadOnly)
.map_err(|e| FactoryError::SdCardError(e))?;
.map_err(FactoryError::SdCard)?;
let mut ota = EspOta::new().map_err(|e| FactoryError::OtaError(e))?;
let mut ota = ota
.initiate_update()
.map_err(|e| FactoryError::OtaError(e))?;
let mut ota = EspOta::new().map_err(FactoryError::Ota)?;
let mut ota = ota.initiate_update().map_err(FactoryError::Ota)?;
let mut buffer = [0u8; BUFFER_LEN];
while !my_file.eof() {
let r = volume_mgr
.read(&volume0, &mut my_file, &mut buffer)
.map_err(|e| FactoryError::SdCardError(e))?;
ota.write(&buffer[..r])
.map_err(|e| FactoryError::OtaError(e))?;
.map_err(FactoryError::SdCard)?;
ota.write(&buffer[..r]).map_err(FactoryError::Ota)?;
}
ota.complete().map_err(|e| FactoryError::OtaError(e))?;
ota.complete().map_err(FactoryError::Ota)?;
volume_mgr
.close_file(&volume0, my_file)
.map_err(|e| FactoryError::SdCardError(e))?;
.map_err(FactoryError::SdCard)?;
volume_mgr.close_dir(&volume0, root_dir);
Ok(())
}
@@ -65,5 +62,5 @@ pub(crate) fn set_boot_main_app() -> Result<(), FactoryError> {
let partition = esp_ota_get_next_update_partition(ptr::null());
esp_ota_set_boot_partition(partition)
})
.map_err(|e| FactoryError::OtaError(e))
.map_err(FactoryError::Ota)
}

View File

@@ -46,13 +46,13 @@ pub(crate) fn setup(peripherals: Peripherals) -> Result<Manager<'static>, Factor
Some(peripherals.miso),
&DriverConfig::default(),
)
.map_err(|e| FactoryError::EspError(e))?;
.map_err(FactoryError::Esp)?;
let mut spi_config = SpiConfig::new();
spi_config.duplex = Duplex::Full;
spi_config = spi_config.baudrate(24.MHz().into());
let spi = SpiDeviceDriver::new(driver, Option::<Gpio10>::None, &spi_config)
.map_err(|e| FactoryError::EspError(e))?;
let sdmmc_cs = PinDriver::output(peripherals.cs).map_err(|e| FactoryError::EspError(e))?;
.map_err(FactoryError::Esp)?;
let sdmmc_cs = PinDriver::output(peripherals.cs).map_err(FactoryError::Esp)?;
let sdcard = SdCard::new(spi, sdmmc_cs, Ets {});
let volume_mgr = VolumeManager::new(sdcard, SdMmcClock {});
Ok(volume_mgr)

12
sphinx-key/Cargo.lock generated
View File

@@ -1161,7 +1161,7 @@ checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
[[package]]
name = "lss-connector"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=1b6b89123171e621617125e8ab59faa246aa2ee3#1b6b89123171e621617125e8ab59faa246aa2ee3"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=55c4b00dc079d21353904fec45b10c7f09ec8f85#55c4b00dc079d21353904fec45b10c7f09ec8f85"
dependencies = [
"anyhow",
"log",
@@ -1530,7 +1530,7 @@ dependencies = [
[[package]]
name = "rmp-utils"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=1b6b89123171e621617125e8ab59faa246aa2ee3#1b6b89123171e621617125e8ab59faa246aa2ee3"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=55c4b00dc079d21353904fec45b10c7f09ec8f85#55c4b00dc079d21353904fec45b10c7f09ec8f85"
dependencies = [
"anyhow",
"log",
@@ -1728,7 +1728,7 @@ dependencies = [
[[package]]
name = "sphinx-auther"
version = "0.1.12"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=1b6b89123171e621617125e8ab59faa246aa2ee3#1b6b89123171e621617125e8ab59faa246aa2ee3"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=55c4b00dc079d21353904fec45b10c7f09ec8f85#55c4b00dc079d21353904fec45b10c7f09ec8f85"
dependencies = [
"anyhow",
"base64",
@@ -1740,7 +1740,7 @@ dependencies = [
[[package]]
name = "sphinx-crypter"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=1b6b89123171e621617125e8ab59faa246aa2ee3#1b6b89123171e621617125e8ab59faa246aa2ee3"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=55c4b00dc079d21353904fec45b10c7f09ec8f85#55c4b00dc079d21353904fec45b10c7f09ec8f85"
dependencies = [
"anyhow",
"chacha20poly1305",
@@ -1751,7 +1751,7 @@ dependencies = [
[[package]]
name = "sphinx-glyph"
version = "0.1.2"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=1b6b89123171e621617125e8ab59faa246aa2ee3#1b6b89123171e621617125e8ab59faa246aa2ee3"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=55c4b00dc079d21353904fec45b10c7f09ec8f85#55c4b00dc079d21353904fec45b10c7f09ec8f85"
dependencies = [
"anyhow",
"hex",
@@ -1783,7 +1783,7 @@ dependencies = [
[[package]]
name = "sphinx-signer"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=1b6b89123171e621617125e8ab59faa246aa2ee3#1b6b89123171e621617125e8ab59faa246aa2ee3"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=55c4b00dc079d21353904fec45b10c7f09ec8f85#55c4b00dc079d21353904fec45b10c7f09ec8f85"
dependencies = [
"anyhow",
"bip39",

View File

@@ -21,9 +21,9 @@ serde_urlencoded = "0.7.1"
url = "2"
# sphinx-rs
lss-connector = { git = "https://github.com/stakwork/sphinx-rs.git", default-features = false, rev = "1b6b89123171e621617125e8ab59faa246aa2ee3" }
sphinx-crypter = { git = "https://github.com/stakwork/sphinx-rs.git", rev = "1b6b89123171e621617125e8ab59faa246aa2ee3" }
sphinx-signer = { git = "https://github.com/stakwork/sphinx-rs.git", optional = true, rev = "1b6b89123171e621617125e8ab59faa246aa2ee3" }
lss-connector = { git = "https://github.com/stakwork/sphinx-rs.git", default-features = false, rev = "55c4b00dc079d21353904fec45b10c7f09ec8f85" }
sphinx-crypter = { git = "https://github.com/stakwork/sphinx-rs.git", rev = "55c4b00dc079d21353904fec45b10c7f09ec8f85" }
sphinx-signer = { git = "https://github.com/stakwork/sphinx-rs.git", optional = true, rev = "55c4b00dc079d21353904fec45b10c7f09ec8f85" }
# local
# lss-connector = { path = "../../sphinx-rs/lss-connector", default-features = false }
# sphinx-crypter = { path = "../../sphinx-rs/crypter" }

View File

@@ -10,10 +10,7 @@ use esp_idf_svc::hal::gpio::Gpio9;
use esp_idf_svc::hal::peripheral::Peripheral;
use esp_idf_svc::hal::peripherals::Peripherals;
use esp_idf_svc::nvs::EspDefaultNvsPartition;
use esp_idf_svc::nvs::EspNvs;
use esp_idf_svc::nvs::*;
use esp_idf_svc::sys as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported
use log;
use status::Status;
use std::sync::mpsc;
use std::sync::{Arc, Mutex};
@@ -42,7 +39,7 @@ fn main() -> anyhow::Result<()> {
// BUTTON thread
let default_nvs = EspDefaultNvsPartition::take()?;
let flash_per = FlashPersister::new(default_nvs.clone());
let flash_per = FlashPersister::new(default_nvs);
let flash_arc = Arc::new(Mutex::new(flash_per));
while let Err(e) =
periph::button::button_loop(unsafe { Gpio9::new() }, led_tx.clone(), flash_arc.clone())

View File

@@ -16,6 +16,7 @@ pub struct Params {
pub config: String,
}
#[allow(clippy::type_complexity)]
pub fn config_server(
mutex: Arc<(Mutex<Option<(Config, Option<[u8; 32]>)>>, Condvar)>,
has_stored_seed: bool,
@@ -34,7 +35,7 @@ pub fn config_server(
})?
.fn_handler("/config", Method::Post, move |request| {
let params =
serde_urlencoded::from_str::<Params>(request.uri().split_once("?").unwrap().1)?;
serde_urlencoded::from_str::<Params>(request.uri().split_once('?').unwrap().1)?;
let dto = serde_json::from_str::<ConfigDTO>(&params.config)?;
let conf_seed_tuple = decrypt_seed(dto, sk1)?;
if !has_stored_seed && conf_seed_tuple.1.is_none() {

View File

@@ -53,90 +53,83 @@ pub fn make_client(
info!("MQTT Listening for messages");
let mut inflight = Vec::new();
let mut inflight_topic = "".to_string();
loop {
match connection.next() {
Some(msg) => match msg {
Err(e) => match e.to_string().as_ref() {
"ESP_FAIL" => {
error!("ESP_FAIL msg!");
}
_ => error!("Unknown error: {}", e),
},
Ok(msg) => match msg {
Event::BeforeConnect => info!("RECEIVED BeforeConnect MESSAGE"),
Event::Connected(_flag) => {
info!("RECEIVED Connected MESSAGE");
tx.send(CoreEvent::Connected)
.expect("couldnt send Event::Connected");
}
Event::Disconnected => {
warn!("RECEIVED Disconnected MESSAGE");
tx.send(CoreEvent::Disconnected)
.expect("couldnt send Event::Disconnected");
}
Event::Subscribed(_mes_id) => info!("RECEIVED Subscribed MESSAGE"),
Event::Unsubscribed(_mes_id) => info!("RECEIVED Unsubscribed MESSAGE"),
Event::Published(_mes_id) => info!("RECEIVED Published MESSAGE"),
Event::Received(msg) => {
let incoming_message: Option<(String, Vec<u8>)> = match msg.details() {
Details::Complete => {
if let Some(topic) = msg.topic() {
Some((topic.to_string(), msg.data().to_vec()))
} else {
None
}
}
Details::InitialChunk(chunk_info) => {
if let Some(topic) = msg.topic() {
inflight = Vec::with_capacity(chunk_info.total_data_size);
inflight_topic = topic.to_string();
inflight.extend_from_slice(msg.data());
None
} else {
None
}
}
Details::SubsequentChunk(chunk_data) => {
while let Some(msg) = connection.next() {
match msg {
Err(e) => match e.to_string().as_ref() {
"ESP_FAIL" => {
error!("ESP_FAIL msg!");
}
_ => error!("Unknown error: {}", e),
},
Ok(msg) => match msg {
Event::BeforeConnect => info!("RECEIVED BeforeConnect MESSAGE"),
Event::Connected(_flag) => {
info!("RECEIVED Connected MESSAGE");
tx.send(CoreEvent::Connected)
.expect("couldnt send Event::Connected");
}
Event::Disconnected => {
warn!("RECEIVED Disconnected MESSAGE");
tx.send(CoreEvent::Disconnected)
.expect("couldnt send Event::Disconnected");
}
Event::Subscribed(_mes_id) => info!("RECEIVED Subscribed MESSAGE"),
Event::Unsubscribed(_mes_id) => info!("RECEIVED Unsubscribed MESSAGE"),
Event::Published(_mes_id) => info!("RECEIVED Published MESSAGE"),
Event::Received(msg) => {
let incoming_message: Option<(String, Vec<u8>)> = match msg.details() {
Details::Complete => msg
.topic()
.map(|topic| (topic.to_string(), msg.data().to_vec())),
Details::InitialChunk(chunk_info) => {
if let Some(topic) = msg.topic() {
inflight = Vec::with_capacity(chunk_info.total_data_size);
inflight_topic = topic.to_string();
inflight.extend_from_slice(msg.data());
if inflight.len() == chunk_data.total_data_size {
let ret = Some((inflight_topic, inflight));
inflight_topic = String::new();
inflight = Vec::new();
ret
} else {
None
}
}
};
drop(msg);
if let Some((topic, data)) = incoming_message {
if topic.ends_with(topics::VLS) {
tx.send(CoreEvent::VlsMessage(data))
.expect("couldnt send Event::VlsMessage");
} else if topic.ends_with(topics::LSS_MSG)
|| topic.ends_with(topics::INIT_1_MSG)
|| topic.ends_with(topics::INIT_2_MSG)
|| topic.ends_with(topics::LSS_CONFLICT)
{
log::debug!("received data len {}", data.len());
tx.send(CoreEvent::LssMessage(data))
.expect("couldnt send Event::LssMessage");
} else if topic.ends_with(topics::CONTROL) {
tx.send(CoreEvent::Control(data))
.expect("couldnt send Event::Control");
None
} else {
log::warn!("unrecognized topic {}", topic);
None
}
}
Details::SubsequentChunk(chunk_data) => {
inflight.extend_from_slice(msg.data());
if inflight.len() == chunk_data.total_data_size {
let ret = Some((inflight_topic, inflight));
inflight_topic = String::new();
inflight = Vec::new();
ret
} else {
None
}
}
};
drop(msg);
if let Some((topic, data)) = incoming_message {
if topic.ends_with(topics::VLS) {
tx.send(CoreEvent::VlsMessage(data))
.expect("couldnt send Event::VlsMessage");
} else if topic.ends_with(topics::LSS_MSG)
|| topic.ends_with(topics::INIT_1_MSG)
|| topic.ends_with(topics::INIT_2_MSG)
|| topic.ends_with(topics::LSS_CONFLICT)
{
log::debug!("received data len {}", data.len());
tx.send(CoreEvent::LssMessage(data))
.expect("couldnt send Event::LssMessage");
} else if topic.ends_with(topics::CONTROL) {
tx.send(CoreEvent::Control(data))
.expect("couldnt send Event::Control");
} else {
log::warn!("unrecognized topic {}", topic);
}
}
Event::Deleted(_mes_id) => info!("RECEIVED Deleted MESSAGE"),
},
}
Event::Deleted(_mes_id) => info!("RECEIVED Deleted MESSAGE"),
},
None => break,
}
}
//info!("MQTT connection loop exit");
})?;
} // match
} // while let
//info!("MQTT connection loop exit");
})?; // spawn
Ok(client)
}

View File

@@ -15,7 +15,7 @@ pub fn sync_time_timeout() -> Result<()> {
} else if counter == 30 {
break Err(anyhow!("SNTP setup timed out"));
}
counter = counter + 1;
counter += 1;
thread::sleep(Duration::from_secs(1));
}
}

View File

@@ -115,9 +115,5 @@ pub fn start_config_server_and_wait(
// drop(wifi);
// thread::sleep(Duration::from_secs(1));
println!("===> config! {:?}", config_seed_tuple.0);
Ok((
wifi,
config_seed_tuple.0.clone(),
config_seed_tuple.1.clone(),
))
Ok((wifi, config_seed_tuple.0.clone(), config_seed_tuple.1))
}

View File

@@ -49,8 +49,8 @@ impl ControlPersist for FlashPersister {
.0
.get_raw(FlashKey::Config.as_str(), &mut buf)?
.ok_or(anyhow!("no existing config"))?;
let mut bytes = Bytes::new(&existing);
Ok(deserialize_config(&mut bytes)?)
let mut bytes = Bytes::new(existing);
deserialize_config(&mut bytes)
}
fn write_config(&mut self, conf: Config) -> Result<()> {
let mut bb = ByteBuf::new();
@@ -97,8 +97,8 @@ impl ControlPersist for FlashPersister {
.0
.get_raw(FlashKey::Policy.as_str(), &mut buf)?
.ok_or(anyhow!("no existing policy"))?;
let mut bytes = Bytes::new(&existing);
Ok(deserialize_policy(&mut bytes, None)?)
let mut bytes = Bytes::new(existing);
deserialize_policy(&mut bytes, None)
}
fn write_policy(&mut self, pol: Policy) -> Result<()> {
let mut bb = ByteBuf::new();
@@ -118,7 +118,7 @@ impl ControlPersist for FlashPersister {
.ok_or(anyhow!("no existing velocity"))?;
let mut bytes = Bytes::new(existing);
let desvel = deserialize_velocity(&mut bytes, None)?;
Ok(desvel.context(anyhow::anyhow!("no velocity"))?)
desvel.context(anyhow::anyhow!("no velocity"))
}
fn write_velocity(&mut self, vel: Velocity) -> Result<()> {
let mut bb = ByteBuf::new();

View File

@@ -60,6 +60,7 @@ fn mqtt_pub(
// the main event loop
#[cfg(not(feature = "pingpong"))]
#[allow(clippy::too_many_arguments)]
pub fn make_event_loop(
mut mqtt: EspMqttClient<ConnState<MessageImpl, EspError>>,
rx: mpsc::Receiver<Event>,
@@ -79,23 +80,20 @@ pub fn make_event_loop(
while let Ok(event) = rx.recv() {
log::info!("BROKER IP AND PORT: {}", config.broker);
// wait for a Connection first.
match event {
Event::Connected => {
mqtt_sub(&mut mqtt, &client_id, topics::SIGNER_SUBS);
break;
}
_ => (),
if let Event::Connected = event {
mqtt_sub(&mut mqtt, &client_id, topics::SIGNER_SUBS);
break;
}
}
let kvv_store = FsKVVStore::new(&ROOT_STORE, signer_id.clone(), None).0;
let kvv_store = FsKVVStore::new(ROOT_STORE, *signer_id, None).0;
let fs_persister = CloudKVVStore::new(kvv_store);
let _ = fs_persister.enter();
let initial_allowlist = match fs_persister.get_nodes() {
Ok(ns) => {
if !ns.is_empty() {
match fs_persister.get_node_allowlist(&node_id) {
match fs_persister.get_node_allowlist(node_id) {
Ok(al) => al,
Err(_) => {
log::warn!("no allowlist found in fs persister!");
@@ -164,7 +162,7 @@ pub fn make_event_loop(
current_status = update_led(current_status, Status::Signing, &led_tx);
let state1 = approver.control().get_state();
//log::info!("FULL MSG {:?}", &msg_bytes);
let _ret = match sphinx_signer::root::handle_with_lss(
match sphinx_signer::root::handle_with_lss(
&root_handler,
&lss_signer,
msg_bytes,
@@ -317,7 +315,7 @@ fn handle_control_response(
}
}
ControlMessage::UpdateAllowlist(al) => {
if let Err(e) = sphinx_signer::policy::set_allowlist(&root_handler, &al) {
if let Err(e) = sphinx_signer::policy::set_allowlist(root_handler, &al) {
log::error!("set allowlist failed {:?}", e);
control_res =
ControlResponse::Error(format!("set allowlist failed {:?}", e))
@@ -325,7 +323,7 @@ fn handle_control_response(
}
// overwrite the real Allowlist response, loaded from Node
ControlMessage::QueryAllowlist => {
match sphinx_signer::policy::get_allowlist(&root_handler) {
match sphinx_signer::policy::get_allowlist(root_handler) {
Ok(al) => control_res = ControlResponse::AllowlistCurrent(al),
Err(e) => {
log::error!("read allowlist failed {:?}", e);
@@ -335,7 +333,7 @@ fn handle_control_response(
}
}
ControlMessage::Ota(params) => {
if let Err(e) = validate_ota_message(params.clone()) {
if let Err(e) = validate_ota_message(params) {
log::error!("OTA update cannot launch {:?}", e.to_string());
control_res =
ControlResponse::Error(format!("OTA update cannot launch {:?}", e))

View File

@@ -77,7 +77,7 @@ fn main() -> Result<()> {
exist
);
led_tx.send(Status::ConnectingToWifi).unwrap();
let _wifi = match start_wifi_client(peripherals.modem, default_nvs.clone(), &exist) {
let _wifi = match start_wifi_client(peripherals.modem, default_nvs, &exist) {
Ok(wifi) => wifi,
Err(e) => {
log::error!("Could not setup wifi: {}", e);
@@ -106,7 +106,7 @@ fn main() -> Result<()> {
if let Ok(()) = make_and_launch_client(
exist.clone(),
seed,
id.clone(),
id,
&policy,
&velocity,
led_tx.clone(),
@@ -124,11 +124,7 @@ fn main() -> Result<()> {
println!("=============> START SERVER NOW AND WAIT <==============");
let stored_seed = flash.read_seed().ok();
drop(flash);
match start_config_server_and_wait(
peripherals.modem,
default_nvs.clone(),
stored_seed.is_some(),
) {
match start_config_server_and_wait(peripherals.modem, default_nvs, stored_seed.is_some()) {
Ok((_wifi, config, seed_opt)) => {
let mut flash = flash_arc.lock().unwrap();
flash.write_config(config).expect("could not store config");
@@ -177,12 +173,11 @@ fn make_and_launch_client(
let ctrlr = controller_from_seed(&network, &seed[..], flash);
let pubkey = ctrlr.pubkey();
let pubkey_str = hex::encode(&pubkey.serialize());
let pubkey_str = hex::encode(pubkey.serialize());
let token = ctrlr.make_auth_token().expect("couldnt make auth token");
log::info!("PUBKEY {} TOKEN {}", &pubkey_str, &token);
let mqtt_client =
conn::mqtt::make_client(&config.broker, &signer_id, &pubkey_str, &token, tx.clone())?;
let mqtt_client = conn::mqtt::make_client(&config.broker, &signer_id, &pubkey_str, &token, tx)?;
// let mqtt_client = conn::mqtt::start_listening(mqtt, connection, tx)?;
// this blocks forever... the "main thread"

View File

@@ -48,7 +48,7 @@ pub fn button_loop(
up_times = 0;
}
if !pressed {
up_times = up_times + 1;
up_times += 1;
// back to start after waiting for a button release
if machine.state == Status::Waiting {
@@ -70,10 +70,8 @@ pub fn button_loop(
}
// if stayed up, advance
if PAUSE * up_times > MILLIS {
if machine.state == Status::Reset1 {
machine.update_status(Status::Reset2a);
}
if PAUSE * up_times > MILLIS && machine.state == Status::Reset1 {
machine.update_status(Status::Reset2a);
}
// if stays up for much longer, reset
@@ -89,7 +87,7 @@ pub fn button_loop(
low_times = 0;
}
if pressed {
low_times = low_times + 1;
low_times += 1;
// if button press while in reset1, wait for a release, and reset
if machine.state == Status::Reset1 {

View File

@@ -100,9 +100,7 @@ impl Led {
// Set low
let mut signal = FixedLengthSignal::<24>::new();
for i in 0..24 {
let bit = 2_u32.pow(i) & 0x000000 != 0;
let (high_pulse, low_pulse) = if bit { (t1h, t1l) } else { (t0h, t0l) };
signal.set(i as usize, &(high_pulse, low_pulse)).unwrap();
signal.set(i as usize, &(t0h, t0l)).unwrap();
}
tx.start_blocking(&signal).unwrap();
}

View File

@@ -14,7 +14,7 @@ use std::io::Write;
use std::ptr;
use std::string::String;
const C_MOUNT_POINT: &'static [u8] = b"/sdcard\0";
const C_MOUNT_POINT: &[u8] = b"/sdcard\0";
const SPI_HOST_SLOT: spi_host_device_t = spi_host_device_t_SPI2_HOST;
const SPI_GPIO_MOSI: gpio_num_t = 7;
@@ -84,7 +84,7 @@ pub fn mount_sd_card() -> anyhow::Result<()> {
if let Err(error) = esp!(unsafe {
spi_bus_initialize(
SPI_HOST_SLOT as u32,
SPI_HOST_SLOT,
&bus_cfg,
esp_idf_svc::sys::spi_common_dma_t_SPI_DMA_CH_AUTO,
)

41
tester/Cargo.lock generated
View File

@@ -261,7 +261,7 @@ checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42"
[[package]]
name = "bolt-derive"
version = "0.2.0"
source = "git+https://gitlab.com/irriden/validating-lightning-signer.git?rev=ce04684b312c95fa7a62329ff198092a50e9a088#ce04684b312c95fa7a62329ff198092a50e9a088"
source = "git+https://gitlab.com/lightning-signer/validating-lightning-signer.git?rev=19447b1e5d2956aa72aeca4229da7a96c5eaf208#19447b1e5d2956aa72aeca4229da7a96c5eaf208"
dependencies = [
"proc-macro2",
"quote",
@@ -668,8 +668,8 @@ dependencies = [
[[package]]
name = "fsdb"
version = "0.1.17"
source = "git+https://github.com/Evanfeenstra/fsdb.git?rev=634125776c14be45ab0618f2fa2b7f1aff4adb85#634125776c14be45ab0618f2fa2b7f1aff4adb85"
version = "0.1.18"
source = "git+https://github.com/Evanfeenstra/fsdb.git?rev=7d0db454133bf37b16d9cf5500111491e67c81e5#7d0db454133bf37b16d9cf5500111491e67c81e5"
dependencies = [
"rmp-serde",
"serde",
@@ -1151,7 +1151,7 @@ dependencies = [
[[package]]
name = "lss-connector"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=af50ee91e3600b7b4862e8f00772601c8a342110#af50ee91e3600b7b4862e8f00772601c8a342110"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=55c4b00dc079d21353904fec45b10c7f09ec8f85#55c4b00dc079d21353904fec45b10c7f09ec8f85"
dependencies = [
"anyhow",
"log",
@@ -1702,7 +1702,7 @@ dependencies = [
[[package]]
name = "rmp-utils"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=af50ee91e3600b7b4862e8f00772601c8a342110#af50ee91e3600b7b4862e8f00772601c8a342110"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=55c4b00dc079d21353904fec45b10c7f09ec8f85#55c4b00dc079d21353904fec45b10c7f09ec8f85"
dependencies = [
"anyhow",
"log",
@@ -2014,11 +2014,11 @@ dependencies = [
[[package]]
name = "serde_with"
version = "2.3.3"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe"
checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23"
dependencies = [
"base64 0.13.1",
"base64 0.21.2",
"chrono",
"hex",
"serde",
@@ -2029,9 +2029,9 @@ dependencies = [
[[package]]
name = "serde_with_macros"
version = "2.3.3"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f"
checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788"
dependencies = [
"darling",
"proc-macro2",
@@ -2085,7 +2085,7 @@ dependencies = [
[[package]]
name = "sphinx-auther"
version = "0.1.12"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=af50ee91e3600b7b4862e8f00772601c8a342110#af50ee91e3600b7b4862e8f00772601c8a342110"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=55c4b00dc079d21353904fec45b10c7f09ec8f85#55c4b00dc079d21353904fec45b10c7f09ec8f85"
dependencies = [
"anyhow",
"base64 0.21.2",
@@ -2097,7 +2097,7 @@ dependencies = [
[[package]]
name = "sphinx-crypter"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=af50ee91e3600b7b4862e8f00772601c8a342110#af50ee91e3600b7b4862e8f00772601c8a342110"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=55c4b00dc079d21353904fec45b10c7f09ec8f85#55c4b00dc079d21353904fec45b10c7f09ec8f85"
dependencies = [
"anyhow",
"chacha20poly1305",
@@ -2108,7 +2108,7 @@ dependencies = [
[[package]]
name = "sphinx-glyph"
version = "0.1.2"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=af50ee91e3600b7b4862e8f00772601c8a342110#af50ee91e3600b7b4862e8f00772601c8a342110"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=55c4b00dc079d21353904fec45b10c7f09ec8f85#55c4b00dc079d21353904fec45b10c7f09ec8f85"
dependencies = [
"anyhow",
"hex",
@@ -2147,7 +2147,7 @@ dependencies = [
[[package]]
name = "sphinx-signer"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=af50ee91e3600b7b4862e8f00772601c8a342110#af50ee91e3600b7b4862e8f00772601c8a342110"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=55c4b00dc079d21353904fec45b10c7f09ec8f85#55c4b00dc079d21353904fec45b10c7f09ec8f85"
dependencies = [
"anyhow",
"bip39",
@@ -2538,9 +2538,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
[[package]]
name = "txoo"
version = "0.6.1"
version = "0.6.2-beta.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b35482e5bf458fa43996535afbca884b2562ab6419e20686340bb19f5305b30"
checksum = "74fb0ae52e565a5e1364ed50933a2a884f2e6330e8ffe9ac32ec6c4084bd3a3a"
dependencies = [
"bitcoin",
"log",
@@ -2671,7 +2671,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "vls-core"
version = "0.10.0"
source = "git+https://gitlab.com/irriden/validating-lightning-signer.git?rev=ce04684b312c95fa7a62329ff198092a50e9a088#ce04684b312c95fa7a62329ff198092a50e9a088"
source = "git+https://gitlab.com/lightning-signer/validating-lightning-signer.git?rev=19447b1e5d2956aa72aeca4229da7a96c5eaf208#19447b1e5d2956aa72aeca4229da7a96c5eaf208"
dependencies = [
"anyhow",
"bitcoin",
@@ -2695,7 +2695,7 @@ dependencies = [
[[package]]
name = "vls-persist"
version = "0.10.0"
source = "git+https://gitlab.com/irriden/validating-lightning-signer.git?rev=ce04684b312c95fa7a62329ff198092a50e9a088#ce04684b312c95fa7a62329ff198092a50e9a088"
source = "git+https://gitlab.com/lightning-signer/validating-lightning-signer.git?rev=19447b1e5d2956aa72aeca4229da7a96c5eaf208#19447b1e5d2956aa72aeca4229da7a96c5eaf208"
dependencies = [
"hex",
"log",
@@ -2708,7 +2708,7 @@ dependencies = [
[[package]]
name = "vls-protocol"
version = "0.10.0"
source = "git+https://gitlab.com/irriden/validating-lightning-signer.git?rev=ce04684b312c95fa7a62329ff198092a50e9a088#ce04684b312c95fa7a62329ff198092a50e9a088"
source = "git+https://gitlab.com/lightning-signer/validating-lightning-signer.git?rev=19447b1e5d2956aa72aeca4229da7a96c5eaf208#19447b1e5d2956aa72aeca4229da7a96c5eaf208"
dependencies = [
"as-any",
"bitcoin-consensus-derive",
@@ -2716,12 +2716,13 @@ dependencies = [
"hex",
"log",
"serde_bolt",
"txoo",
]
[[package]]
name = "vls-protocol-signer"
version = "0.10.0"
source = "git+https://gitlab.com/irriden/validating-lightning-signer.git?rev=ce04684b312c95fa7a62329ff198092a50e9a088#ce04684b312c95fa7a62329ff198092a50e9a088"
source = "git+https://gitlab.com/lightning-signer/validating-lightning-signer.git?rev=19447b1e5d2956aa72aeca4229da7a96c5eaf208#19447b1e5d2956aa72aeca4229da7a96c5eaf208"
dependencies = [
"bit-vec",
"log",

View File

@@ -24,8 +24,8 @@ serde_json = "1.0"
tokio = { version = "1.4.0", features = ["rt", "rt-multi-thread", "macros"] }
urlencoding = "2.1.0"
sphinx-crypter = { git = "https://github.com/stakwork/sphinx-rs.git", rev = "af50ee91e3600b7b4862e8f00772601c8a342110" }
sphinx-signer = { git = "https://github.com/stakwork/sphinx-rs.git", rev = "af50ee91e3600b7b4862e8f00772601c8a342110" }
sphinx-crypter = { git = "https://github.com/stakwork/sphinx-rs.git", rev = "55c4b00dc079d21353904fec45b10c7f09ec8f85" }
sphinx-signer = { git = "https://github.com/stakwork/sphinx-rs.git", rev = "55c4b00dc079d21353904fec45b10c7f09ec8f85" }
# sphinx-crypter = { path = "../../sphinx-rs/crypter" }
# sphinx-signer = { path = "../../sphinx-rs/signer" }

View File

@@ -100,7 +100,7 @@ async fn main() -> anyhow::Result<()> {
serde_json::to_string(&config)?
};
let conf_encoded = urlencoding::encode(&conf_string).to_owned();
let conf_encoded = urlencoding::encode(&conf_string).into_owned();
println!("Posting seed");
let res2 = client
.post(format!("{}/{}={}", url, "config?config", conf_encoded))

View File

@@ -42,7 +42,7 @@ fn ecdh(keys: &State<Keys>) -> String {
#[post("/config?<config>")]
fn config(keys: &State<Keys>, config: &str) -> String {
// println!("============> {:?}", config);
let dto = serde_json::from_str::<ConfigBody>(&config).expect("failed to parse");
let dto = serde_json::from_str::<ConfigBody>(config).expect("failed to parse");
let conf = decrypt_seed(dto, keys.sk).expect("couldnt decrypt seed");
println!("SEED: ===========> {:?}", hex::encode(conf.seed));
"{\"success\":true}".to_string()
@@ -62,7 +62,7 @@ pub fn decrypt_seed(dto: ConfigBody, sk1: SecretKey) -> anyhow::Result<Config> {
ssid: dto.ssid,
pass: dto.pass,
network: dto.network,
seed: seed,
seed,
})
}