Check that broker and signer are on the same network

This commit is contained in:
decentclock
2022-08-26 15:55:43 -06:00
parent 6f81516a60
commit d0b5c4c4c1

View File

@@ -1,5 +1,6 @@
mod randomstartingtime;
use lightning_signer::bitcoin::blockdata::constants::ChainHash;
use lightning_signer::node::NodeServices;
use lightning_signer::persist::Persist;
use lightning_signer::policy::filter::PolicyFilter;
@@ -16,6 +17,7 @@ use vls_protocol::msgs::{self, read_serial_request_header, write_serial_response
use vls_protocol::serde_bolt::WireString;
use vls_protocol_signer::handler::{Handler, RootHandler};
use vls_protocol_signer::lightning_signer::bitcoin::Network;
use vls_protocol_signer::lightning_signer::wallet::Wallet;
pub use sphinx_key_parser::MsgDriver;
pub use sphinx_key_persister::FsPersister;
@@ -95,6 +97,15 @@ pub fn handle(
_ => {}
};
if let Message::HsmdInit(ref m) = message {
if ChainHash::using_genesis_block(root_handler.node.network()).as_bytes()
!= &m.chain_params.0
{
log::error!("The network setting of CLN and VLS don't match!");
panic!("The network setting of CLN and VLS don't match!");
}
}
if do_log {
log::info!("VLS msg: {:?}", message);
}