diff --git a/build.gradle.kts b/build.gradle.kts index e1285491e..80f49ee05 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -290,7 +290,6 @@ val dockerTestEnv by tasks.creating(Exec::class) { } val dockerCleanup by tasks.creating(Exec::class) { - println("Cleaning up dockers...") workingDir = projectDir.resolve("docker-local-test") commandLine("bash", "env.sh", "elx-stop", "btc-stop", "remove") } diff --git a/src/commonMain/kotlin/fr/acinq/lightning/channel/ChannelCommand.kt b/src/commonMain/kotlin/fr/acinq/lightning/channel/ChannelCommand.kt index a4086d9b4..2642b46d4 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/channel/ChannelCommand.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/channel/ChannelCommand.kt @@ -98,6 +98,7 @@ sealed class ChannelCommand { ) : Splice() { val pushAmount: MilliSatoshi = spliceIn?.pushAmount ?: 0.msat val spliceOutputs: List = spliceOut?.let { listOf(TxOut(it.amount, it.scriptPubKey)) } ?: emptyList() + val liquidityFees: LiquidityAds.Fees? = requestRemoteFunding?.fees(feerate, isChannelCreation = false) data class SpliceIn(val walletInputs: List, val pushAmount: MilliSatoshi = 0.msat) data class SpliceOut(val amount: Satoshi, val scriptPubKey: ByteVector) diff --git a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt index 99f010425..9aeac75be 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt @@ -58,7 +58,7 @@ data class Normal( is ChannelCommand.Commitment.UpdateFee -> handleCommandResult(cmd, commitments.sendFee(cmd), cmd.commit) is ChannelCommand.Commitment.Sign -> when { !commitments.changes.localHasChanges() -> { - logger.warning { "no changes to sign" } + logger.info { "no changes to sign" } Pair(this@Normal, listOf()) } commitments.remoteNextCommitInfo is Either.Left -> { @@ -511,7 +511,7 @@ data class Normal( } is SpliceAck -> when (spliceStatus) { is SpliceStatus.Requested -> { - logger.info { "our peer accepted our splice request and will contribute ${cmd.message.fundingContribution} to the funding transaction" } + logger.info { "our peer accepted our splice request with remote.amount=${cmd.message.fundingContribution} remote.push=${cmd.message.pushAmount} liquidityFees=${spliceStatus.command.liquidityFees}" } when (val liquidityPurchase = LiquidityAds.validateRemoteFunding( spliceStatus.command.requestRemoteFunding, remoteNodeId, diff --git a/src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt b/src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt index 0144026ca..c4aa97cac 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt @@ -1423,7 +1423,7 @@ class Peer( else -> { val leaseFees = cmd.fees(targetFeerate, isChannelCreation = false) val totalFees = ChannelManagementFees(miningFee = localMiningFee.min(localBalance.truncateToSatoshi()) + leaseFees.miningFee, serviceFee = leaseFees.serviceFee) - logger.info { "requesting on-the-fly splice for paymentHash=${cmd.paymentHash} feerate=$targetFeerate fee=${totalFees.total} paymentType=${paymentDetails.paymentType}" } + logger.info { "requesting on-the-fly splice for paymentHash=${cmd.paymentHash} requestedAmount=${cmd.requestedAmount} feerate=$targetFeerate fee=${totalFees.total} paymentType=${paymentDetails.paymentType}" } val spliceCommand = ChannelCommand.Commitment.Splice.Request( replyTo = CompletableDeferred(), spliceIn = null, diff --git a/src/commonMain/kotlin/fr/acinq/lightning/logging/MDCLogger.kt b/src/commonMain/kotlin/fr/acinq/lightning/logging/MDCLogger.kt index bfd07b795..4358f0a57 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/logging/MDCLogger.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/logging/MDCLogger.kt @@ -92,7 +92,10 @@ fun ChannelState.mdc(): Map { else -> {} } when(state) { - is ChannelStateWithCommitments -> put("commitments", "active=${state.commitments.active.map { it.fundingTxIndex }} inactive=${state.commitments.inactive.map { it.fundingTxIndex }}") + is ChannelStateWithCommitments -> { + put("commitments", "active=${state.commitments.active.map { it.fundingTxIndex }} inactive=${state.commitments.inactive.map { it.fundingTxIndex }}") + put("balances", "toLocal=${state.commitments.latest.localCommit.spec.toLocal} toRemote=${state.commitments.latest.localCommit.spec.toRemote} capacity=${state.commitments.latest.fundingAmount}") + } else -> {} } } diff --git a/src/commonMain/kotlin/fr/acinq/lightning/payment/IncomingPaymentHandler.kt b/src/commonMain/kotlin/fr/acinq/lightning/payment/IncomingPaymentHandler.kt index 1ad78651c..955a6934e 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/payment/IncomingPaymentHandler.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/payment/IncomingPaymentHandler.kt @@ -170,7 +170,7 @@ class IncomingPaymentHandler(val nodeParams: NodeParams, val db: PaymentsDb) { /** Main payment processing, that handles payment parts. */ private suspend fun processPaymentPart(paymentPart: PaymentPart, remoteFeatures: Features, currentBlockHeight: Int, currentFeerate: FeeratePerKw, remoteFundingRates: LiquidityAds.WillFundRates?, currentFeeCredit: MilliSatoshi): ProcessAddResult { - val logger = MDCLogger(logger.logger, staticMdc = paymentPart.mdc()) + val logger = MDCLogger(logger.logger, staticMdc = paymentPart.mdc() + ("feeCredit" to currentFeeCredit)) when (paymentPart) { is HtlcPart -> logger.info { "processing htlc part expiry=${paymentPart.htlc.cltvExpiry}" } is WillAddHtlcPart -> logger.info { "processing on-the-fly funding part amount=${paymentPart.amount} expiry=${paymentPart.htlc.expiry}" } @@ -370,6 +370,7 @@ class IncomingPaymentHandler(val nodeParams: NodeParams, val db: PaymentsDb) { // We must use the worst case fees that applies to channel creation. val fees = fundingRate.fees(currentFeerate, requestedAmount, requestedAmount, isChannelCreation = true).total val canAddToFeeCredit = Features.canUseFeature(nodeParams.features, remoteFeatures, Feature.FundingFeeCredit) && (willAddHtlcAmount + currentFeeCredit) <= liquidityPolicy.maxAllowedFeeCredit + logger.info { "on-the-fly assessment: amount=$requestedAmount feerate=$currentFeerate fees=$fees" } val rejected = when { // We never reject if we can add payments to our fee credit until making an on-chain operation becomes acceptable. canAddToFeeCredit -> null diff --git a/src/commonMain/kotlin/fr/acinq/lightning/payment/LiquidityPolicy.kt b/src/commonMain/kotlin/fr/acinq/lightning/payment/LiquidityPolicy.kt index c620176e5..359c72b2e 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/payment/LiquidityPolicy.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/payment/LiquidityPolicy.kt @@ -30,7 +30,7 @@ sealed class LiquidityPolicy { is Auto -> { val maxAbsoluteFee = if (skipAbsoluteFeeCheck && source == LiquidityEvents.Source.OffChainPayment) Long.MAX_VALUE.msat else this.maxAbsoluteFee.toMilliSatoshi() val maxRelativeFee = amount * maxRelativeFeeBasisPoints / 10_000 - logger.info { "liquidity policy check: fee=$fee maxAbsoluteFee=$maxAbsoluteFee maxRelativeFee=$maxRelativeFee policy=$this" } + logger.info { "liquidity policy check: amount=$amount liquidityTarget=${inboundLiquidityTarget ?: 0.sat} fee=$fee maxAbsoluteFee=$maxAbsoluteFee maxRelativeFee=$maxRelativeFee policy=$this" } when { fee > maxRelativeFee -> LiquidityEvents.Rejected.Reason.TooExpensive.OverRelativeFee(maxRelativeFeeBasisPoints) fee > maxAbsoluteFee -> LiquidityEvents.Rejected.Reason.TooExpensive.OverAbsoluteFee(this.maxAbsoluteFee)