Skip to content

Commit

Permalink
Add more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Jan 30, 2025
1 parent 8a1cd00 commit da864b2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
20 changes: 20 additions & 0 deletions harbor-client/src/fedimint_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ pub(crate) async fn spawn_invoice_receive_subscription(
is_transfer: bool,
subscription: UpdateStreamOrOutcome<LnReceiveState>,
) {
info!(
"Spawning lightning receive subscription for operation id: {}",
operation_id.fmt_full()
);
spawn(async move {
let mut stream = subscription.into_stream();
while let Some(op_state) = stream.next().await {
Expand Down Expand Up @@ -346,6 +350,10 @@ pub(crate) async fn spawn_invoice_payment_subscription(
is_transfer: bool,
subscription: UpdateStreamOrOutcome<LnPayState>,
) {
info!(
"Spawning lightning payment subscription for operation id: {}",
operation_id.fmt_full()
);
spawn(async move {
let mut stream = subscription.into_stream();
while let Some(op_state) = stream.next().await {
Expand Down Expand Up @@ -439,6 +447,10 @@ pub(crate) async fn spawn_internal_payment_subscription(
msg_id: Uuid,
subscription: UpdateStreamOrOutcome<InternalPayState>,
) {
info!(
"Spawning internal payment subscription for operation id: {}",
operation_id.fmt_full()
);
spawn(async move {
let mut stream = subscription.into_stream();
while let Some(op_state) = stream.next().await {
Expand Down Expand Up @@ -519,6 +531,10 @@ pub(crate) async fn spawn_onchain_payment_subscription(
msg_id: Uuid,
subscription: UpdateStreamOrOutcome<WithdrawState>,
) {
info!(
"Spawning onchain payment subscription for operation id: {}",
operation_id.fmt_full()
);
spawn(async move {
let mut stream = subscription.into_stream();
while let Some(op_state) = stream.next().await {
Expand Down Expand Up @@ -583,6 +599,10 @@ pub(crate) async fn spawn_onchain_receive_subscription(
msg_id: Uuid,
subscription: UpdateStreamOrOutcome<DepositStateV2>,
) {
info!(
"Spawning onchain receive subscription for operation id: {}",
operation_id.fmt_full()
);
spawn(async move {
let mut stream = subscription.into_stream();
while let Some(op_state) = stream.next().await {
Expand Down
13 changes: 12 additions & 1 deletion harbor-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ impl HarborCore {
invoice: Bolt11Invoice,
is_transfer: bool,
) -> anyhow::Result<()> {
log::info!("Paying lightning invoice: {invoice} from federation: {federation_id}");
if invoice.amount_milli_satoshis().is_none() {
return Err(anyhow!("Invoice must have an amount"));
}
Expand Down Expand Up @@ -275,7 +276,7 @@ impl HarborCore {
}
}

log::info!("Invoice sent");
log::info!("Payment sent");

Ok(())
}
Expand All @@ -287,6 +288,7 @@ impl HarborCore {
amount: Amount,
is_transfer: bool,
) -> anyhow::Result<Bolt11Invoice> {
log::info!("Creating lightning invoice, amount: {amount} for federation: {federation_id}");
let client = self.get_client(federation_id).await.fedimint_client;
let lightning_module = client
.get_first_module::<LightningClientModule>()
Expand Down Expand Up @@ -358,6 +360,10 @@ impl HarborCore {
address: Address<NetworkUnchecked>,
sats: Option<u64>,
) -> anyhow::Result<()> {
log::info!(
"Sending onchain payment to address: {} from federation: {federation_id}",
address.clone().assume_checked()
);
let client = self.get_client(federation_id).await.fedimint_client;
let onchain = client
.get_first_module::<WalletClientModule>()
Expand Down Expand Up @@ -431,6 +437,8 @@ impl HarborCore {
return Err(anyhow!("on-chain receive is not enabled"));
}

log::info!("Generating address for federation: {federation_id}");

let client = self.get_client(federation_id).await.fedimint_client;
let onchain = client
.get_first_module::<WalletClientModule>()
Expand Down Expand Up @@ -460,6 +468,7 @@ impl HarborCore {
&self,
invite_code: InviteCode,
) -> anyhow::Result<ClientConfig> {
log::info!("Getting federation info for invite code: {invite_code}");
let download = Instant::now();
let config = {
#[cfg(all(debug_assertions, feature = "disable-tor"))]
Expand Down Expand Up @@ -489,6 +498,7 @@ impl HarborCore {
}

pub async fn add_federation(&self, invite_code: InviteCode) -> anyhow::Result<()> {
log::info!("Adding federation with invite code: {invite_code}");
let id = invite_code.federation_id();

let mut clients = self.clients.write().await;
Expand All @@ -511,6 +521,7 @@ impl HarborCore {
}

pub async fn remove_federation(&self, id: FederationId) -> anyhow::Result<()> {
log::info!("Removing federation with id: {id}");
let mut clients = self.clients.write().await;
if clients.remove(&id).is_none() {
return Err(anyhow!("Federation doesn't exist"));
Expand Down

0 comments on commit da864b2

Please sign in to comment.