Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more logs to federation client #1222

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions mutiny-core/src/federation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,19 @@ impl<S: MutinyStorage> FederationClient<S> {
amount: u64,
labels: Vec<String>,
) -> Result<MutinyInvoice, MutinyError> {
log_trace!(self.logger, "calling federation.get_invoice");
let inbound = true;

let lightning_module = self
.fedimint_client
.get_first_module::<LightningClientModule>();

log_debug!(
self.logger,
"getting invoice from federation: {}",
self.fedimint_client.federation_id()
);

let desc = Description::new(String::new()).expect("empty string is valid");
let gateway = self.gateway.read().await;
let (id, invoice, _) = lightning_module
Expand All @@ -511,6 +518,8 @@ impl<S: MutinyStorage> FederationClient<S> {
.await?;
let invoice = convert_from_fedimint_invoice(&invoice);

log_debug!(self.logger, "got invoice from federation: {invoice}");

// persist the invoice
let mut stored_payment: MutinyInvoice = invoice.clone().into();
stored_payment.inbound = inbound;
Expand Down Expand Up @@ -546,21 +555,31 @@ impl<S: MutinyStorage> FederationClient<S> {
);
});

log_trace!(self.logger, "finished calling get_invoice");
Ok(invoice.into())
}

pub(crate) async fn get_new_address(
&self,
labels: Vec<String>,
) -> Result<Address, MutinyError> {
log_trace!(self.logger, "calling federation.get_new_address");
let wallet_module = self
.fedimint_client
.get_first_module::<WalletClientModule>();

log_debug!(
self.logger,
"getting new address from federation: {}",
self.fedimint_client.federation_id()
);

let (op_id, address) = wallet_module
.get_deposit_address(fedimint_core::time::now() + PEG_IN_TIMEOUT_YEAR, ())
.await?;

log_debug!(self.logger, "got new address from federation: {address}");

let address = Address::from_str(&address.to_string())
.expect("should convert")
.assume_checked();
Expand All @@ -578,6 +597,8 @@ impl<S: MutinyStorage> FederationClient<S> {
.expect("just created it");
self.subscribe_operation(operation, op_id);

log_trace!(self.logger, "finished calling get_new_address");

Ok(address)
}

Expand Down
Loading