Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit 622bbf3

Browse files
Remove the fedimint remainder sweep functionality
1 parent 8f50ea2 commit 622bbf3

File tree

1 file changed

+9
-40
lines changed

1 file changed

+9
-40
lines changed

mutiny-core/src/lib.rs

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ impl<S: MutinyStorage> MutinyWallet<S> {
12271227

12281228
// If no amount, figure out the amount to send over
12291229
let current_balance = fedimint_client.get_balance().await?;
1230-
log_info!(
1230+
log_debug!(
12311231
self.logger,
12321232
"current fedimint client balance: {}",
12331233
current_balance
@@ -1269,46 +1269,15 @@ impl<S: MutinyStorage> MutinyWallet<S> {
12691269
.await?;
12701270
final_result.fees = first_invoice_res.fees_paid;
12711271

1272-
// pay_invoice returns invoice if Succeeded or Err if something else
1273-
// it's safe to assume that it went through and we can check remaining balance
12741272
let remaining_balance = fedimint_client.get_balance().await?;
1275-
log_debug!(
1276-
self.logger,
1277-
"remaining fedimint balance: {}",
1278-
remaining_balance
1279-
);
1280-
if remaining_balance > 1 {
1281-
// the fee for existing channel is voltage 1 sat + base fee + ppm
1282-
let remaining_balance_minus_fee = max_spendable_amount(remaining_balance - 1, fees);
1283-
if remaining_balance_minus_fee.is_none() {
1284-
return Ok(final_result);
1285-
}
1286-
let remaining_balance_minus_fee = remaining_balance_minus_fee.unwrap();
1287-
1288-
let inv = self
1289-
.node_manager
1290-
.create_invoice(remaining_balance_minus_fee)
1291-
.await?;
1292-
1293-
match fedimint_client
1294-
.pay_invoice(inv.bolt11.expect("create inv had one job"), vec![])
1295-
.await
1296-
{
1297-
Ok(r) => {
1298-
log_debug!(self.logger, "paid remaining balance");
1299-
final_result.amount += remaining_balance_minus_fee;
1300-
final_result.fees = final_result.fees.map_or(r.fees_paid, |val| {
1301-
r.fees_paid
1302-
.map(|add_val| val + add_val)
1303-
.map_or(Some(val), |_| None)
1304-
});
1305-
}
1306-
Err(e) => {
1307-
// Don't want to return this error since it's just "incomplete",
1308-
// and just not the full amount.
1309-
log_warn!(self.logger, "error paying remaining balance: {}", e)
1310-
}
1311-
}
1273+
if remaining_balance > 0 {
1274+
// there was a remainder when there shouldn't have been
1275+
// for now just log this, it is probably just a millisat/1 sat difference
1276+
log_warn!(
1277+
self.logger,
1278+
"remaining fedimint balance: {}",
1279+
remaining_balance
1280+
);
13121281
}
13131282

13141283
Ok(final_result)

0 commit comments

Comments
 (0)