mirror of
https://github.com/stakwork/sphinx-key.git
synced 2025-12-21 17:24:23 +01:00
organize the init waiter
This commit is contained in:
@@ -1,8 +1,25 @@
|
|||||||
|
use crate::ChannelRequest;
|
||||||
|
use sphinx_key_parser as parser;
|
||||||
use sphinx_key_parser::MsgDriver;
|
use sphinx_key_parser::MsgDriver;
|
||||||
|
use tokio::sync::{mpsc, oneshot};
|
||||||
use vls_protocol::model::Secret;
|
use vls_protocol::model::Secret;
|
||||||
use vls_protocol::{msgs, serde_bolt::WireString};
|
use vls_protocol::{msgs, serde_bolt::WireString};
|
||||||
use vls_proxy::util::{read_allowlist, read_integration_test_seed};
|
use vls_proxy::util::{read_allowlist, read_integration_test_seed};
|
||||||
|
|
||||||
|
pub async fn connect(tx: mpsc::Sender<ChannelRequest>) {
|
||||||
|
let init_msg_2 = crate::init::make_init_msg().expect("could make init msg");
|
||||||
|
let (reply_tx, reply_rx) = oneshot::channel();
|
||||||
|
// Send a request to the MQTT handler to send to signer
|
||||||
|
let request = ChannelRequest {
|
||||||
|
message: init_msg_2,
|
||||||
|
reply_tx,
|
||||||
|
};
|
||||||
|
let _ = tx.send(request).await;
|
||||||
|
let res = reply_rx.await.expect("couldnt receive");
|
||||||
|
let reply = parser::response_from_bytes(res.reply, 0).expect("could parse init receive");
|
||||||
|
println!("REPLY {:?}", reply);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn make_init_msg() -> anyhow::Result<Vec<u8>> {
|
pub fn make_init_msg() -> anyhow::Result<Vec<u8>> {
|
||||||
let allowlist = read_allowlist()
|
let allowlist = read_allowlist()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ mod unix_fd;
|
|||||||
use crate::mqtt::start_broker;
|
use crate::mqtt::start_broker;
|
||||||
use crate::unix_fd::SignerLoop;
|
use crate::unix_fd::SignerLoop;
|
||||||
use clap::{App, AppSettings, Arg};
|
use clap::{App, AppSettings, Arg};
|
||||||
use sphinx_key_parser as parser;
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use tokio::sync::{mpsc, oneshot};
|
use tokio::sync::{mpsc, oneshot};
|
||||||
use vls_proxy::client::UnixClient;
|
use vls_proxy::client::UnixClient;
|
||||||
@@ -60,18 +59,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
let (tx, rx) = mpsc::channel(1000);
|
let (tx, rx) = mpsc::channel(1000);
|
||||||
let runtime = start_broker(true, rx);
|
let runtime = start_broker(true, rx);
|
||||||
runtime.block_on(async {
|
runtime.block_on(async {
|
||||||
let init_msg_2 = crate::init::make_init_msg().expect("could make init msg");
|
init::connect(tx.clone()).await;
|
||||||
let (reply_tx, reply_rx) = oneshot::channel();
|
|
||||||
// Send a request to the MQTT handler to send to signer
|
|
||||||
let request = ChannelRequest {
|
|
||||||
message: init_msg_2,
|
|
||||||
reply_tx,
|
|
||||||
};
|
|
||||||
let _ = tx.send(request).await;
|
|
||||||
let res = reply_rx.await.expect("couldnt receive");
|
|
||||||
let reply =
|
|
||||||
parser::response_from_bytes(res.reply, 0).expect("could parse init receive");
|
|
||||||
println!("REPLY {:?}", reply);
|
|
||||||
// listen to reqs from CLN
|
// listen to reqs from CLN
|
||||||
let conn = UnixConnection::new(parent_fd);
|
let conn = UnixConnection::new(parent_fd);
|
||||||
let client = UnixClient::new(conn);
|
let client = UnixClient::new(conn);
|
||||||
|
|||||||
Reference in New Issue
Block a user