From 0a6e6d412e5ffeb3a917512f0e4c4fe430c87224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Granh=C3=A3o?= Date: Thu, 9 May 2024 14:48:55 +0100 Subject: [PATCH] Log LDK node data --- src/fund_migration.rs | 15 +++++++++++++++ src/lib.rs | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/fund_migration.rs b/src/fund_migration.rs index 3601075c..f62ad770 100644 --- a/src/fund_migration.rs +++ b/src/fund_migration.rs @@ -12,6 +12,7 @@ use breez_sdk_core::{BreezServices, OpenChannelFeeRequest, OpeningFeeParams}; use graphql::schema::{migrate_funds, migration_balance, MigrateFunds, MigrationBalance}; use graphql::{build_client, post_blocking}; use honey_badger::Auth; +use log::info; use num_enum::TryFromPrimitive; use perro::{MapToError, OptionToError, ResultTrait}; use reqwest::blocking::Client; @@ -121,6 +122,20 @@ pub(crate) fn migrate_funds( } } +pub(crate) fn log_fund_migration_data(seed: &[u8; 64]) -> Result<()> { + let (private_key, public_key) = derive_ldk_keys(seed)?; + let public_key = hex::encode(public_key.serialize()); + + let message = format!("I control the private key of the node {public_key}"); + let message = Message::from_hashed_data::(message.as_bytes()); + let signature = private_key.sign_ecdsa(message).serialize_der().to_string(); + + info!("Legacy LDK node pubkey: {public_key}"); + info!("Legacy LDK node signature: {signature}"); + + Ok(()) +} + fn fetch_legacy_balance(client: &Client, backend_url: &str, public_key: String) -> Result { let variables = migration_balance::Variables { node_pub_key: Some(public_key), diff --git a/src/lib.rs b/src/lib.rs index e956aa1b..cae48009 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -438,6 +438,8 @@ impl LightningNode { ) .map_runtime_error_to(RuntimeErrorCode::FailedFundMigration)?; + fund_migration::log_fund_migration_data(&strong_typed_seed)?; + let id = auth.get_wallet_pubkey_id().map_to_runtime_error( RuntimeErrorCode::AuthServiceUnavailable, "Failed to authenticate in order to get wallet pubkey id",