Skip to content

Commit

Permalink
Merge pull request #1063 from getlipa/feature/log-ldk-node-data
Browse files Browse the repository at this point in the history
Log LDK node data
  • Loading branch information
danielgranhao authored May 9, 2024
2 parents 1008f33 + 0a6e6d4 commit 67d52b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/fund_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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::<sha256::Hash>(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<u64> {
let variables = migration_balance::Variables {
node_pub_key: Some(public_key),
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 67d52b1

Please sign in to comment.