Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import fr.acinq.bitcoin.Satoshi
import fr.acinq.lightning.blockchain.electrum.WalletState
import fr.acinq.lightning.channel.ChannelManagementFees
import fr.acinq.lightning.channel.InteractiveTxParams
import fr.acinq.lightning.channel.SharedFundingInput
import fr.acinq.lightning.channel.states.ChannelStateWithCommitments
import fr.acinq.lightning.channel.states.Normal
import fr.acinq.lightning.channel.states.WaitForFundingCreated
Expand Down Expand Up @@ -58,7 +57,7 @@ sealed interface LiquidityEvents : NodeEvents {
sealed interface SensitiveTaskEvents : NodeEvents {
sealed class TaskIdentifier {
data class InteractiveTx(val channelId: ByteVector32, val fundingTxIndex: Long) : TaskIdentifier() {
constructor(fundingParams: InteractiveTxParams) : this(fundingParams.channelId, (fundingParams.sharedInput as? SharedFundingInput.Multisig2of2)?.fundingTxIndex?.let { it + 1 } ?: 0)
constructor(fundingParams: InteractiveTxParams) : this(fundingParams.channelId, fundingParams.sharedInput?.fundingTxIndex?.let { it + 1 } ?: 0)
}
data class IncomingMultiPartPayment(val paymentHash: ByteVector32) : TaskIdentifier()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ suspend fun IClient.computeSpliceCpfpFeerate(commitments: Commitments, targetFee
val (parentsWeight, parentsFees) = commitments.all
.takeWhile { getConfirmations(it.fundingTxId).let { confirmations -> confirmations == null || confirmations == 0 } } // we check for null in case the tx has been evicted
.fold(Pair(0, 0.sat)) { (parentsWeight, parentsFees), commitment ->
val weight = when (commitment.localFundingStatus) {
// weight will be underestimated if the transaction is not fully signed
is LocalFundingStatus.UnconfirmedFundingTx -> commitment.localFundingStatus.signedTx?.weight() ?: commitment.localFundingStatus.sharedTx.tx.buildUnsignedTx().weight()
is LocalFundingStatus.ConfirmedFundingTx -> commitment.localFundingStatus.signedTx.weight()
when (commitment.localFundingStatus) {
is LocalFundingStatus.UnconfirmedFundingTx -> {
// Note that the weight will be underestimated if the transaction is not fully signed.
val weight = commitment.localFundingStatus.signedTx?.weight() ?: commitment.localFundingStatus.sharedTx.tx.buildUnsignedTx().weight()
Pair(parentsWeight + weight, parentsFees + commitment.localFundingStatus.fee)
}
// We filtered confirmed transactions before, so this case shouldn't happen.
is LocalFundingStatus.ConfirmedFundingTx -> Pair(parentsWeight, parentsFees)
}
Pair(parentsWeight + weight, parentsFees + commitment.localFundingStatus.fee)
}
val totalWeight = parentsWeight + spliceWeight
val totalFees = Transactions.weight2fee(targetFeerate, totalWeight)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class SwapInManager(private var reservedUtxos: Set<OutPoint>, private val logger
.forEach { fundingStatus ->
when (fundingStatus) {
is LocalFundingStatus.UnconfirmedFundingTx -> addAll(fundingStatus.sharedTx.tx.localInputs.map { it.outPoint })
is LocalFundingStatus.ConfirmedFundingTx -> addAll(fundingStatus.signedTx.txIn.map { it.outPoint })
is LocalFundingStatus.ConfirmedFundingTx -> addAll(fundingStatus.spentInputs)
}
}
else -> {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ sealed class ChannelAction {
CommitTx,
HtlcSuccessTx,
HtlcTimeoutTx,
HtlcDelayedTx,
ClaimHtlcSuccessTx,
ClaimHtlcTimeoutTx,
ClaimLocalAnchorOutputTx,
ClaimRemoteAnchorOutputTx,
ClaimLocalDelayedOutputTx,
ClaimRemoteDelayedOutputTx,
MainPenaltyTx,
Expand All @@ -47,20 +46,19 @@ sealed class ChannelAction {
constructor(txinfo: Transactions.TransactionWithInputInfo) : this(
tx = txinfo.tx,
txType = when (txinfo) {
is Transactions.TransactionWithInputInfo.CommitTx -> Type.CommitTx
is Transactions.TransactionWithInputInfo.HtlcTx.HtlcSuccessTx -> Type.HtlcSuccessTx
is Transactions.TransactionWithInputInfo.HtlcTx.HtlcTimeoutTx -> Type.HtlcTimeoutTx
is Transactions.TransactionWithInputInfo.ClaimHtlcTx.ClaimHtlcSuccessTx -> Type.ClaimHtlcSuccessTx
is Transactions.TransactionWithInputInfo.ClaimHtlcTx.ClaimHtlcTimeoutTx -> Type.ClaimHtlcTimeoutTx
is Transactions.TransactionWithInputInfo.ClaimAnchorOutputTx.ClaimLocalAnchorOutputTx -> Type.ClaimLocalAnchorOutputTx
is Transactions.TransactionWithInputInfo.ClaimAnchorOutputTx.ClaimRemoteAnchorOutputTx -> Type.ClaimRemoteAnchorOutputTx
is Transactions.TransactionWithInputInfo.ClaimLocalDelayedOutputTx -> Type.ClaimLocalDelayedOutputTx
is Transactions.TransactionWithInputInfo.ClaimRemoteCommitMainOutputTx.ClaimRemoteDelayedOutputTx -> Type.ClaimRemoteDelayedOutputTx
is Transactions.TransactionWithInputInfo.MainPenaltyTx -> Type.MainPenaltyTx
is Transactions.TransactionWithInputInfo.HtlcPenaltyTx -> Type.HtlcPenaltyTx
is Transactions.TransactionWithInputInfo.ClaimHtlcDelayedOutputPenaltyTx -> Type.ClaimHtlcDelayedOutputPenaltyTx
is Transactions.TransactionWithInputInfo.ClosingTx -> Type.ClosingTx
is Transactions.TransactionWithInputInfo.SpliceTx -> Type.FundingTx
is Transactions.CommitTx -> Type.CommitTx
is Transactions.HtlcSuccessTx -> Type.HtlcSuccessTx
is Transactions.HtlcTimeoutTx -> Type.HtlcTimeoutTx
is Transactions.HtlcDelayedTx -> Type.HtlcDelayedTx
is Transactions.ClaimHtlcSuccessTx -> Type.ClaimHtlcSuccessTx
is Transactions.ClaimHtlcTimeoutTx -> Type.ClaimHtlcTimeoutTx
is Transactions.ClaimLocalDelayedOutputTx -> Type.ClaimLocalDelayedOutputTx
is Transactions.ClaimRemoteDelayedOutputTx -> Type.ClaimRemoteDelayedOutputTx
is Transactions.MainPenaltyTx -> Type.MainPenaltyTx
is Transactions.HtlcPenaltyTx -> Type.HtlcPenaltyTx
is Transactions.ClaimHtlcDelayedOutputPenaltyTx -> Type.ClaimHtlcDelayedOutputPenaltyTx
is Transactions.ClosingTx -> Type.ClosingTx
is Transactions.SpliceTx -> Type.FundingTx
}
)
// endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package fr.acinq.lightning.channel

import fr.acinq.bitcoin.*
import fr.acinq.lightning.CltvExpiry
import fr.acinq.lightning.CltvExpiryDelta
import fr.acinq.lightning.MilliSatoshi
import fr.acinq.lightning.blockchain.WatchTriggered
import fr.acinq.lightning.blockchain.electrum.WalletState
Expand All @@ -28,7 +29,12 @@ sealed class ChannelCommand {
val walletInputs: List<WalletState.Utxo>,
val commitTxFeerate: FeeratePerKw,
val fundingTxFeerate: FeeratePerKw,
val localParams: LocalParams,
val localChannelParams: LocalChannelParams,
val dustLimit: Satoshi,
val htlcMinimum: MilliSatoshi,
val maxHtlcValueInFlightMsat: Long,
val maxAcceptedHtlcs: Int,
val toRemoteDelay: CltvExpiryDelta,
val remoteInit: InitMessage,
val channelFlags: ChannelFlags,
val channelConfig: ChannelConfig,
Expand All @@ -44,7 +50,12 @@ sealed class ChannelCommand {
val temporaryChannelId: ByteVector32,
val fundingAmount: Satoshi,
val walletInputs: List<WalletState.Utxo>,
val localParams: LocalParams,
val localParams: LocalChannelParams,
val dustLimit: Satoshi,
val htlcMinimum: MilliSatoshi,
val maxHtlcValueInFlightMsat: Long,
val maxAcceptedHtlcs: Int,
val toRemoteDelay: CltvExpiryDelta,
val channelConfig: ChannelConfig,
val remoteInit: InitMessage,
val fundingRates: LiquidityAds.WillFundRates?
Expand Down
Loading