Skip to content

Commit

Permalink
trust local mutual close for swap-in
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 committed Aug 18, 2023
1 parent fa58d67 commit 81bb01b
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 @@ -392,7 +392,12 @@ class Peer(
.filter { it.consistent }
.collect {
val currentBlockHeight = currentTipFlow.filterNotNull().first().first
swapInCommands.send(SwapInCommand.TrySwapIn(currentBlockHeight, it, 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, it, walletParams.swapInConfirmations, trustedTxs))
}
}

Expand Down

0 comments on commit 81bb01b

Please sign in to comment.