Skip to content

Commit

Permalink
Trust local mutual close for swap-in (#517)
Browse files Browse the repository at this point in the history
Instead of explicitly providing txids, we can look at local channel data
to extract mutual close txids, because either the tx is unconfirmed and
the channel data will still be in `Closing` state, otherwise the tx is
confirmed and the utxo can be used immediately anyway.

This is an alternative to #516.
  • Loading branch information
pm47 authored Aug 18, 2023
1 parent ca32ad7 commit e3d1bc5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,12 @@ class Peer(
swapInWallet.walletStateFlow.combine(currentTipFlow.filterNotNull()) { walletState, currentTip -> currentTip.first to walletState }
.filter { (_, walletState) -> walletState.consistent }
.collect { (currentBlockHeight, walletState) ->
swapInCommands.send(SwapInCommand.TrySwapIn(currentBlockHeight, walletState, walletParams.swapInConfirmations, trustedSwapInTxs))
// Local mutual close txs can be used as zero-conf inputs for swap-in
val mutualCloseTxs = channels.values
.filterIsInstance<Closing>()
.flatMap { state -> state.mutualClosePublished.map { closingTx -> closingTx.tx.txid } }
val trustedTxs = trustedSwapInTxs + mutualCloseTxs
swapInCommands.send(SwapInCommand.TrySwapIn(currentBlockHeight, walletState, walletParams.swapInConfirmations, trustedTxs))
}
}

Expand Down

0 comments on commit e3d1bc5

Please sign in to comment.