Add --mainnet argument to the broker to send a fixed random mainnet seed to the signer for initial mainnet testing

This commit is contained in:
decentclock
2022-06-24 23:07:52 +00:00
parent 90b445ae31
commit fc442d44ba
2 changed files with 15 additions and 10 deletions

View File

@@ -6,8 +6,8 @@ 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 fn blocking_connect(tx: mpsc::Sender<ChannelRequest>) { pub fn blocking_connect(tx: mpsc::Sender<ChannelRequest>, mainnet: bool) {
let init_msg_2 = crate::init::make_init_msg().expect("could make init msg"); let init_msg_2 = crate::init::make_init_msg(mainnet).expect("could make init msg");
let (reply_tx, reply_rx) = oneshot::channel(); let (reply_tx, reply_rx) = oneshot::channel();
// Send a request to the MQTT handler to send to signer // Send a request to the MQTT handler to send to signer
let request = ChannelRequest { let request = ChannelRequest {
@@ -20,8 +20,8 @@ pub fn blocking_connect(tx: mpsc::Sender<ChannelRequest>) {
println!("REPLY {:?}", reply); println!("REPLY {:?}", reply);
} }
pub async fn _connect(tx: mpsc::Sender<ChannelRequest>) { pub async fn _connect(tx: mpsc::Sender<ChannelRequest>, mainnet: bool) {
let init_msg_2 = crate::init::make_init_msg().expect("could make init msg"); let init_msg_2 = crate::init::make_init_msg(mainnet).expect("could make init msg");
let (reply_tx, reply_rx) = oneshot::channel(); let (reply_tx, reply_rx) = oneshot::channel();
// Send a request to the MQTT handler to send to signer // Send a request to the MQTT handler to send to signer
let request = ChannelRequest { let request = ChannelRequest {
@@ -34,14 +34,18 @@ pub async fn _connect(tx: mpsc::Sender<ChannelRequest>) {
println!("REPLY {:?}", reply); println!("REPLY {:?}", reply);
} }
pub fn make_init_msg() -> anyhow::Result<Vec<u8>> { pub fn make_init_msg(mainnet: bool) -> anyhow::Result<Vec<u8>> {
let allowlist = read_allowlist() let allowlist = read_allowlist()
.into_iter() .into_iter()
.map(|s| WireString(s.as_bytes().to_vec())) .map(|s| WireString(s.as_bytes().to_vec()))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let seed = read_integration_test_seed() let seed = if mainnet {
.map(|s| Secret(s)) Some(Secret([0x8c, 0xe8, 0x62, 0xab, 0xd5, 0x6b, 0xb4, 0x6a, 0x61, 0x7f, 0xaf, 0x13, 0x50, 0xc1, 0xca, 0xf5, 0xb1, 0xee, 0x02, 0x97, 0xbf, 0xf3, 0xb8, 0xc9, 0x56, 0x63, 0x58, 0x9f, 0xec, 0x8c, 0x45, 0x79]))
.or(Some(Secret([1; 32]))); } else {
read_integration_test_seed()
.map(|s| Secret(s))
.or(Some(Secret([1; 32])))
};
// FIXME remove this // FIXME remove this
log::info!("allowlist {:?} seed {:?}", allowlist, seed); log::info!("allowlist {:?} seed {:?}", allowlist, seed);
let init = msgs::HsmdInit2 { let init = msgs::HsmdInit2 {

View File

@@ -46,7 +46,8 @@ fn main() -> anyhow::Result<()> {
) )
.arg(Arg::from("--log-io ignored dev flag")) .arg(Arg::from("--log-io ignored dev flag"))
.arg(Arg::from("--version show a dummy version")) .arg(Arg::from("--version show a dummy version"))
.arg(Arg::from("--test run a test against the embedded device")); .arg(Arg::from("--test run a test against the embedded device"))
.arg(Arg::from("--mainnet send a fixed random mainnet seed to the signer"));
let matches = app.get_matches(); let matches = app.get_matches();
if matches.is_present("version") { if matches.is_present("version") {
// Pretend to be the right version, given to us by an env var // Pretend to be the right version, given to us by an env var
@@ -69,7 +70,7 @@ fn main() -> anyhow::Result<()> {
log::info!("=> connection status: {}", status); log::info!("=> connection status: {}", status);
assert_eq!(status, true, "expected connected = true"); assert_eq!(status, true, "expected connected = true");
// runtime.block_on(async { // runtime.block_on(async {
init::blocking_connect(tx.clone()); init::blocking_connect(tx.clone(), matches.is_present("mainnet"));
log::info!("=====> sent seed!"); log::info!("=====> sent seed!");
// listen to reqs from CLN // listen to reqs from CLN