Skip to content

Commit

Permalink
fixup! fix: Add delay before paying jit channel open fees
Browse files Browse the repository at this point in the history
wait for outbound capacity
  • Loading branch information
holzeis committed Jul 27, 2023
1 parent b888ba0 commit 51cd76c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mobile/native/src/channel_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl ChannelFeePaymentSubscriber {
"Waiting for channel {} to be usable.",
hex::encode(channel_id)
);
Handle::current().block_on(self.wait_for_usable_channel(channel_id))
Handle::current().block_on(self.wait_for_outbound_capacity(channel_id))
})?;

tracing::debug!("Trying to pay channel opening fees of {}", transaction.fee);
Expand Down Expand Up @@ -148,20 +148,20 @@ impl ChannelFeePaymentSubscriber {
.clone()
}

async fn wait_for_usable_channel(&self, channel_id: ChannelId) -> Result<()> {
async fn wait_for_outbound_capacity(&self, channel_id: ChannelId) -> Result<()> {
tokio::time::timeout(Duration::from_secs(5), async {
loop {
let channel_details = self
.channel_manager
.get_channel_details(&channel_id)
.expect("Channel details to exist");
tracing::debug!("------> Channel Details: {:?}", channel_details);
if channel_details.is_usable {
tracing::debug!("Channel {} is usable", hex::encode(channel_id));
if channel_details.outbound_capacity_msat > 0 {
tracing::debug!("Channel {} has outbound capacity", hex::encode(channel_id));
break;
} else {
tracing::debug!(
"Channel {} is not usable yet, waiting.",
"Channel {} does not have outbound capacity yet, waiting.",
hex::encode(channel_id)
);
tokio::time::sleep(Duration::from_millis(200)).await
Expand Down

0 comments on commit 51cd76c

Please sign in to comment.