From a7e4dad6ee5aecdb1bd3c903c5c98aa4fbb62bc7 Mon Sep 17 00:00:00 2001 From: Bastien Teinturier <31281497+t-bast@users.noreply.github.com> Date: Tue, 22 Oct 2024 14:38:20 +0200 Subject: [PATCH] Remove support for `push_amount` (#697) With the updated on-the-fly funding protocol, we're using liquidity ads instead of an unofficial `push_amount` TLV. We can thus remove usage of `push_amount`s everywhere, which simplifies the codebase. --- .../acinq/lightning/channel/ChannelCommand.kt | 6 +- .../fr/acinq/lightning/channel/Helpers.kt | 9 --- .../acinq/lightning/channel/InteractiveTx.kt | 18 ++--- .../acinq/lightning/channel/states/Normal.kt | 16 +--- .../channel/states/WaitForAcceptChannel.kt | 4 - .../channel/states/WaitForFundingConfirmed.kt | 16 +--- .../channel/states/WaitForFundingCreated.kt | 7 -- .../channel/states/WaitForFundingSigned.kt | 4 - .../lightning/channel/states/WaitForInit.kt | 2 - .../channel/states/WaitForOpenChannel.kt | 7 +- .../kotlin/fr/acinq/lightning/io/Peer.kt | 5 -- .../serialization/v4/Deserialization.kt | 56 ++++++++++---- .../serialization/v4/Serialization.kt | 15 +--- .../fr/acinq/lightning/wire/ChannelTlv.kt | 13 ---- .../acinq/lightning/wire/LightningMessages.kt | 14 +--- .../channel/CommitmentsTestsCommon.kt | 51 +------------ .../channel/InteractiveTxTestsCommon.kt | 31 +++----- .../fr/acinq/lightning/channel/TestsHelper.kt | 15 ++-- .../channel/states/ClosingTestsCommon.kt | 4 +- .../channel/states/NegotiatingTestsCommon.kt | 12 +-- .../channel/states/NormalTestsCommon.kt | 73 ++++++++----------- .../channel/states/OfflineTestsCommon.kt | 6 +- .../channel/states/SpliceTestsCommon.kt | 27 +++---- .../channel/states/SyncingTestsCommon.kt | 2 +- .../states/WaitForAcceptChannelTestsCommon.kt | 23 ++---- .../states/WaitForChannelReadyTestsCommon.kt | 43 +---------- .../WaitForFundingConfirmedTestsCommon.kt | 19 +---- .../WaitForFundingCreatedTestsCommon.kt | 45 +++--------- .../states/WaitForFundingSignedTestsCommon.kt | 33 ++------- .../states/WaitForOpenChannelTestsCommon.kt | 19 ++--- .../fr/acinq/lightning/io/peer/PeerTest.kt | 6 +- .../OutgoingPaymentHandlerTestsCommon.kt | 2 +- .../fr/acinq/lightning/tests/TestConstants.kt | 2 - .../wire/LightningCodecsTestsCommon.kt | 8 +- 34 files changed, 166 insertions(+), 447 deletions(-) diff --git a/src/commonMain/kotlin/fr/acinq/lightning/channel/ChannelCommand.kt b/src/commonMain/kotlin/fr/acinq/lightning/channel/ChannelCommand.kt index 8180ea4a1..951ceb106 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/channel/ChannelCommand.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/channel/ChannelCommand.kt @@ -10,7 +10,6 @@ import fr.acinq.lightning.channel.states.ClosingFeerates import fr.acinq.lightning.channel.states.PersistedChannelState import fr.acinq.lightning.crypto.KeyManager import fr.acinq.lightning.utils.UUID -import fr.acinq.lightning.utils.msat import fr.acinq.lightning.wire.FailureMessage import fr.acinq.lightning.wire.LightningMessage import fr.acinq.lightning.wire.LiquidityAds @@ -27,7 +26,6 @@ sealed class ChannelCommand { data class Initiator( val replyTo: CompletableDeferred, val fundingAmount: Satoshi, - val pushAmount: MilliSatoshi, val walletInputs: List, val commitTxFeerate: FeeratePerKw, val fundingTxFeerate: FeeratePerKw, @@ -46,7 +44,6 @@ sealed class ChannelCommand { val replyTo: CompletableDeferred, val temporaryChannelId: ByteVector32, val fundingAmount: Satoshi, - val pushAmount: MilliSatoshi, val walletInputs: List, val localParams: LocalParams, val channelConfig: ChannelConfig, @@ -98,11 +95,10 @@ sealed class ChannelCommand { val feerate: FeeratePerKw, val origins: List ) : 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 SpliceIn(val walletInputs: List) data class SpliceOut(val amount: Satoshi, val scriptPubKey: ByteVector) } } diff --git a/src/commonMain/kotlin/fr/acinq/lightning/channel/Helpers.kt b/src/commonMain/kotlin/fr/acinq/lightning/channel/Helpers.kt index 7609cee77..4c55be458 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/channel/Helpers.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/channel/Helpers.kt @@ -72,11 +72,6 @@ object Helpers { return Either.Left(InvalidChainHash(open.temporaryChannelId, local = nodeParams.chainHash, remote = open.chainHash)) } - // BOLT #2: The receiving node MUST fail the channel if: push_msat is greater than funding_satoshis * 1000. - if (open.pushAmount > open.fundingAmount) { - return Either.Left(InvalidPushAmount(open.temporaryChannelId, open.pushAmount, open.fundingAmount.toMilliSatoshi())) - } - // BOLT #2: The receiving node MUST fail the channel if: to_self_delay is unreasonably large. if (open.toSelfDelay > Channel.MAX_TO_SELF_DELAY || open.toSelfDelay > nodeParams.maxToLocalDelayBlocks) { return Either.Left(ToSelfDelayTooHigh(open.temporaryChannelId, open.toSelfDelay, nodeParams.maxToLocalDelayBlocks)) @@ -122,10 +117,6 @@ object Helpers { return Either.Left(InvalidFundingAmount(accept.temporaryChannelId, accept.fundingAmount)) } - if (accept.pushAmount > accept.fundingAmount) { - return Either.Left(InvalidPushAmount(accept.temporaryChannelId, accept.pushAmount, accept.fundingAmount.toMilliSatoshi())) - } - if (accept.maxAcceptedHtlcs > Channel.MAX_ACCEPTED_HTLCS) { return Either.Left(InvalidMaxAcceptedHtlcs(accept.temporaryChannelId, accept.maxAcceptedHtlcs, Channel.MAX_ACCEPTED_HTLCS)) } diff --git a/src/commonMain/kotlin/fr/acinq/lightning/channel/InteractiveTx.kt b/src/commonMain/kotlin/fr/acinq/lightning/channel/InteractiveTx.kt index 4c6ba4c1a..a1280ecf1 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/channel/InteractiveTx.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/channel/InteractiveTx.kt @@ -270,11 +270,9 @@ data class FundingContributions(val inputs: List, v swapInKeys: KeyManager.SwapInOnChainKeys, params: InteractiveTxParams, walletInputs: List, - localPushAmount: MilliSatoshi, - remotePushAmount: MilliSatoshi, liquidityPurchase: LiquidityAds.Purchase? ): Either { - return create(channelKeys, swapInKeys, params, null, walletInputs, listOf(), localPushAmount, remotePushAmount, liquidityPurchase) + return create(channelKeys, swapInKeys, params, null, walletInputs, listOf(), liquidityPurchase) } /** @@ -290,8 +288,6 @@ data class FundingContributions(val inputs: List, v sharedUtxo: Pair?, walletInputs: List, localOutputs: List, - localPushAmount: MilliSatoshi, - remotePushAmount: MilliSatoshi, liquidityPurchase: LiquidityAds.Purchase?, changePubKey: PublicKey? = null ): Either { @@ -310,9 +306,9 @@ data class FundingContributions(val inputs: List, v val liquidityFees = params.liquidityFees(liquidityPurchase) val nextLocalBalanceBeforePush = (sharedUtxo?.second?.toLocal ?: 0.msat) + params.localContribution.toMilliSatoshi() - val nextLocalBalanceAfterPush = (sharedUtxo?.second?.toLocal ?: 0.msat) + params.localContribution.toMilliSatoshi() - localPushAmount + remotePushAmount - liquidityFees + val nextLocalBalanceAfterPush = (sharedUtxo?.second?.toLocal ?: 0.msat) + params.localContribution.toMilliSatoshi() - liquidityFees val nextRemoteBalanceBeforePush = (sharedUtxo?.second?.toRemote ?: 0.msat) + params.remoteContribution.toMilliSatoshi() - val nextRemoteBalanceAfterPush = (sharedUtxo?.second?.toRemote ?: 0.msat) + params.remoteContribution.toMilliSatoshi() + localPushAmount - remotePushAmount + liquidityFees + val nextRemoteBalanceAfterPush = (sharedUtxo?.second?.toRemote ?: 0.msat) + params.remoteContribution.toMilliSatoshi() + liquidityFees if (nextLocalBalanceAfterPush < 0.msat || nextRemoteBalanceAfterPush < 0.msat) { return Either.Left(FundingContributionFailure.InvalidFundingBalances(params.fundingAmount, nextLocalBalanceAfterPush, nextRemoteBalanceAfterPush)) } @@ -1091,8 +1087,6 @@ data class InteractiveTxSigningSession( fundingParams: InteractiveTxParams, fundingTxIndex: Long, sharedTx: SharedTransaction, - localPushAmount: MilliSatoshi, - remotePushAmount: MilliSatoshi, liquidityPurchase: LiquidityAds.Purchase?, localCommitmentIndex: Long, remoteCommitmentIndex: Long, @@ -1109,8 +1103,8 @@ data class InteractiveTxSigningSession( channelParams.channelId, channelParams.localParams, channelParams.remoteParams, fundingAmount = sharedTx.sharedOutput.amount, - toLocal = sharedTx.sharedOutput.localAmount - localPushAmount + remotePushAmount - liquidityFees, - toRemote = sharedTx.sharedOutput.remoteAmount - remotePushAmount + localPushAmount + liquidityFees, + toLocal = sharedTx.sharedOutput.localAmount - liquidityFees, + toRemote = sharedTx.sharedOutput.remoteAmount + liquidityFees, localHtlcs = localHtlcs, localCommitmentIndex = localCommitmentIndex, remoteCommitmentIndex = remoteCommitmentIndex, @@ -1203,8 +1197,6 @@ sealed class SpliceStatus { data class InProgress( val replyTo: CompletableDeferred?, val spliceSession: InteractiveTxSession, - val localPushAmount: MilliSatoshi, - val remotePushAmount: MilliSatoshi, val liquidityPurchase: LiquidityAds.Purchase?, val origins: List ) : QuiescentSpliceStatus() 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 c141be8f1..ad0e24621 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/Normal.kt @@ -419,10 +419,9 @@ data class Normal( lockTime = currentBlockHeight.toLong(), feerate = spliceStatus.command.feerate, fundingPubkey = channelKeys().fundingPubKey(parentCommitment.fundingTxIndex + 1), - pushAmount = spliceStatus.command.pushAmount, requestFunding = spliceStatus.command.requestRemoteFunding, ) - logger.info { "initiating splice with local.amount=${spliceInit.fundingContribution} local.push=${spliceInit.pushAmount}" } + logger.info { "initiating splice with local.amount=${spliceInit.fundingContribution}" } Pair(this@Normal.copy(spliceStatus = SpliceStatus.Requested(spliceStatus.command, spliceInit)), listOf(ChannelAction.Message.Send(spliceInit))) } } else { @@ -453,12 +452,11 @@ data class Normal( } is SpliceStatus.NonInitiatorQuiescent -> if (commitments.isQuiescent()) { - logger.info { "accepting splice with remote.amount=${cmd.message.fundingContribution} remote.push=${cmd.message.pushAmount}" } + logger.info { "accepting splice with remote.amount=${cmd.message.fundingContribution}" } val parentCommitment = commitments.active.first() val spliceAck = SpliceAck( channelId, fundingContribution = 0.sat, // only remote contributes to the splice - pushAmount = 0.msat, fundingPubkey = channelKeys().fundingPubKey(parentCommitment.fundingTxIndex + 1), willFund = null, ) @@ -489,8 +487,6 @@ data class Normal( spliceStatus = SpliceStatus.InProgress( replyTo = null, session, - localPushAmount = 0.msat, - remotePushAmount = cmd.message.pushAmount, liquidityPurchase = null, origins = listOf() ) @@ -511,7 +507,7 @@ data class Normal( } is SpliceAck -> when (spliceStatus) { is SpliceStatus.Requested -> { - logger.info { "our peer accepted our splice request with remote.amount=${cmd.message.fundingContribution} remote.push=${cmd.message.pushAmount} liquidityFees=${spliceStatus.command.liquidityFees}" } + logger.info { "our peer accepted our splice request with remote.amount=${cmd.message.fundingContribution} liquidityFees=${spliceStatus.command.liquidityFees}" } when (val liquidityPurchase = LiquidityAds.validateRemoteFunding( spliceStatus.command.requestRemoteFunding, remoteNodeId, @@ -550,8 +546,6 @@ data class Normal( sharedUtxo = Pair(sharedInput, SharedFundingInputBalances(toLocal = parentCommitment.localCommit.spec.toLocal, toRemote = parentCommitment.localCommit.spec.toRemote, toHtlcs = parentCommitment.localCommit.spec.htlcs.map { it.add.amountMsat }.sum())), walletInputs = spliceStatus.command.spliceIn?.walletInputs ?: emptyList(), localOutputs = spliceStatus.command.spliceOutputs, - localPushAmount = spliceStatus.spliceInit.pushAmount, - remotePushAmount = cmd.message.pushAmount, liquidityPurchase = liquidityPurchase.value, changePubKey = null // we don't want a change output: we're spending every funds available )) { @@ -579,8 +573,6 @@ data class Normal( spliceStatus = SpliceStatus.InProgress( replyTo = spliceStatus.command.replyTo, interactiveTxSession, - localPushAmount = spliceStatus.spliceInit.pushAmount, - remotePushAmount = cmd.message.pushAmount, liquidityPurchase = liquidityPurchase.value, origins = spliceStatus.command.origins, ) @@ -617,8 +609,6 @@ data class Normal( spliceStatus.spliceSession.fundingParams, fundingTxIndex = parentCommitment.fundingTxIndex + 1, interactiveTxAction.sharedTx, - localPushAmount = spliceStatus.localPushAmount, - remotePushAmount = spliceStatus.remotePushAmount, liquidityPurchase = spliceStatus.liquidityPurchase, localCommitmentIndex = parentCommitment.localCommit.index, remoteCommitmentIndex = parentCommitment.remoteCommit.index, diff --git a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForAcceptChannel.kt b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForAcceptChannel.kt index db1287933..007e519c0 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForAcceptChannel.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForAcceptChannel.kt @@ -72,8 +72,6 @@ data class WaitForAcceptChannel( keyManager.swapInOnChainWallet, fundingParams, init.walletInputs, - lastSent.pushAmount, - accept.pushAmount, liquidityPurchase.value )) { is Either.Left -> { @@ -100,8 +98,6 @@ data class WaitForAcceptChannel( init.localParams, remoteParams, interactiveTxSession, - lastSent.pushAmount, - accept.pushAmount, lastSent.commitmentFeerate, accept.firstPerCommitmentPoint, accept.secondPerCommitmentPoint, diff --git a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForFundingConfirmed.kt b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForFundingConfirmed.kt index 2026b4b24..7667c4e68 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForFundingConfirmed.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForFundingConfirmed.kt @@ -2,21 +2,17 @@ package fr.acinq.lightning.channel.states import fr.acinq.bitcoin.TxId import fr.acinq.bitcoin.utils.Either -import fr.acinq.lightning.MilliSatoshi import fr.acinq.lightning.ShortChannelId import fr.acinq.lightning.blockchain.BITCOIN_FUNDING_DEPTHOK import fr.acinq.lightning.blockchain.WatchConfirmed import fr.acinq.lightning.blockchain.WatchEventConfirmed import fr.acinq.lightning.channel.* import fr.acinq.lightning.utils.msat -import fr.acinq.lightning.utils.toMilliSatoshi import fr.acinq.lightning.wire.* /** We wait for the channel funding transaction to confirm. */ data class WaitForFundingConfirmed( override val commitments: Commitments, - val localPushAmount: MilliSatoshi, - val remotePushAmount: MilliSatoshi, val waitingSinceBlock: Long, // how many blocks have we been waiting for the funding tx to confirm val deferred: ChannelReady?, // We can have at most one ongoing RBF attempt. @@ -85,12 +81,6 @@ data class WaitForFundingConfirmed( if (cmd.message.feerate < minNextFeerate) { logger.info { "rejecting rbf attempt: the new feerate must be at least $minNextFeerate (proposed=${cmd.message.feerate})" } Pair(this@WaitForFundingConfirmed.copy(rbfStatus = RbfStatus.RbfAborted), listOf(ChannelAction.Message.Send(TxAbort(channelId, InvalidRbfFeerate(channelId, cmd.message.feerate, minNextFeerate).message)))) - } else if (cmd.message.fundingContribution.toMilliSatoshi() < remotePushAmount) { - logger.info { "rejecting rbf attempt: invalid amount pushed (fundingAmount=${cmd.message.fundingContribution}, pushAmount=$remotePushAmount)" } - Pair( - this@WaitForFundingConfirmed.copy(rbfStatus = RbfStatus.RbfAborted), - listOf(ChannelAction.Message.Send(TxAbort(channelId, InvalidPushAmount(channelId, remotePushAmount, cmd.message.fundingContribution.toMilliSatoshi()).message))) - ) } else { logger.info { "our peer wants to raise the feerate of the funding transaction (previous=${latestFundingTx.fundingParams.targetFeerate} target=${cmd.message.feerate})" } val fundingParams = InteractiveTxParams( @@ -136,7 +126,7 @@ data class WaitForFundingConfirmed( latestFundingTx.fundingParams.dustLimit, rbfStatus.command.targetFeerate ) - when (val contributions = FundingContributions.create(channelKeys(), keyManager.swapInOnChainWallet, fundingParams, rbfStatus.command.walletInputs, 0.msat, 0.msat, null)) { + when (val contributions = FundingContributions.create(channelKeys(), keyManager.swapInOnChainWallet, fundingParams, rbfStatus.command.walletInputs, null)) { is Either.Left -> { logger.warning { "error creating funding contributions: ${contributions.value}" } Pair(this@WaitForFundingConfirmed.copy(rbfStatus = RbfStatus.RbfAborted), listOf(ChannelAction.Message.Send(TxAbort(channelId, ChannelFundingError(channelId).message)))) @@ -175,8 +165,6 @@ data class WaitForFundingConfirmed( rbfSession1.fundingParams, fundingTxIndex = replacedCommitment.fundingTxIndex, interactiveTxAction.sharedTx, - localPushAmount, - remotePushAmount, liquidityPurchase = null, localCommitmentIndex = replacedCommitment.localCommit.index, remoteCommitmentIndex = replacedCommitment.remoteCommit.index, @@ -321,8 +309,6 @@ data class WaitForFundingConfirmed( val watchConfirmed = WatchConfirmed(channelId, action.commitment.fundingTxId, action.commitment.commitInput.txOut.publicKeyScript, fundingMinDepth.toLong(), BITCOIN_FUNDING_DEPTHOK) val nextState = WaitForFundingConfirmed( commitments.add(action.commitment).copy(remoteChannelData = remoteChannelData), - localPushAmount, - remotePushAmount, waitingSinceBlock, deferred, RbfStatus.None diff --git a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForFundingCreated.kt b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForFundingCreated.kt index 92b14d2ca..535543b39 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForFundingCreated.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForFundingCreated.kt @@ -3,7 +3,6 @@ package fr.acinq.lightning.channel.states import fr.acinq.bitcoin.ByteVector32 import fr.acinq.bitcoin.PublicKey import fr.acinq.bitcoin.utils.Either -import fr.acinq.lightning.MilliSatoshi import fr.acinq.lightning.blockchain.fee.FeeratePerKw import fr.acinq.lightning.channel.* import fr.acinq.lightning.wire.* @@ -35,8 +34,6 @@ data class WaitForFundingCreated( val localParams: LocalParams, val remoteParams: RemoteParams, val interactiveTxSession: InteractiveTxSession, - val localPushAmount: MilliSatoshi, - val remotePushAmount: MilliSatoshi, val commitTxFeerate: FeeratePerKw, val remoteFirstPerCommitmentPoint: PublicKey, val remoteSecondPerCommitmentPoint: PublicKey, @@ -64,8 +61,6 @@ data class WaitForFundingCreated( interactiveTxSession.fundingParams, fundingTxIndex = 0, interactiveTxAction.sharedTx, - localPushAmount, - remotePushAmount, liquidityPurchase, localCommitmentIndex = 0, remoteCommitmentIndex = 0, @@ -97,8 +92,6 @@ data class WaitForFundingCreated( val nextState = WaitForFundingSigned( channelParams, session, - localPushAmount, - remotePushAmount, remoteSecondPerCommitmentPoint, liquidityPurchase, channelOrigin diff --git a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForFundingSigned.kt b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForFundingSigned.kt index 8857c36b0..7e8ed19d9 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForFundingSigned.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForFundingSigned.kt @@ -38,8 +38,6 @@ import kotlin.math.absoluteValue data class WaitForFundingSigned( val channelParams: ChannelParams, val signingSession: InteractiveTxSigningSession, - val localPushAmount: MilliSatoshi, - val remotePushAmount: MilliSatoshi, val remoteSecondPerCommitmentPoint: PublicKey, val liquidityPurchase: LiquidityAds.Purchase?, val channelOrigin: Origin?, @@ -166,8 +164,6 @@ data class WaitForFundingSigned( logger.info { "will wait for $fundingMinDepth confirmations" } val nextState = WaitForFundingConfirmed( commitments, - localPushAmount, - remotePushAmount, currentBlockHeight.toLong(), null, RbfStatus.None diff --git a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForInit.kt b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForInit.kt index db8b5f520..a29d5fcbd 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForInit.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForInit.kt @@ -21,7 +21,6 @@ data object WaitForInit : ChannelState() { cmd.replyTo, cmd.temporaryChannelId, cmd.fundingAmount, - cmd.pushAmount, cmd.walletInputs, cmd.localParams, cmd.channelConfig, @@ -56,7 +55,6 @@ data object WaitForInit : ChannelState() { buildSet { add(ChannelTlv.ChannelTypeTlv(cmd.channelType)) cmd.requestRemoteFunding?.let { add(ChannelTlv.RequestFundingTlv(it)) } - if (cmd.pushAmount > 0.msat) add(ChannelTlv.PushAmountTlv(cmd.pushAmount)) } ) ) diff --git a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForOpenChannel.kt b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForOpenChannel.kt index d27e313c5..0ff314252 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForOpenChannel.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/channel/states/WaitForOpenChannel.kt @@ -4,7 +4,6 @@ import fr.acinq.bitcoin.ByteVector32 import fr.acinq.bitcoin.Satoshi import fr.acinq.bitcoin.utils.Either import fr.acinq.lightning.ChannelEvents -import fr.acinq.lightning.MilliSatoshi import fr.acinq.lightning.blockchain.electrum.WalletState import fr.acinq.lightning.channel.* import fr.acinq.lightning.channel.Helpers.Funding.computeChannelId @@ -25,7 +24,6 @@ data class WaitForOpenChannel( val replyTo: CompletableDeferred, val temporaryChannelId: ByteVector32, val fundingAmount: Satoshi, - val pushAmount: MilliSatoshi, val walletInputs: List, val localParams: LocalParams, val channelConfig: ChannelConfig, @@ -72,7 +70,6 @@ data class WaitForOpenChannel( buildSet { add(ChannelTlv.ChannelTypeTlv(channelType)) willFund?.let { add(ChannelTlv.ProvideFundingTlv(it.willFund)) } - if (pushAmount > 0.msat) add(ChannelTlv.PushAmountTlv(pushAmount)) } ), ) @@ -93,7 +90,7 @@ data class WaitForOpenChannel( val remoteFundingPubkey = open.fundingPubkey val dustLimit = open.dustLimit.max(localParams.dustLimit) val fundingParams = InteractiveTxParams(channelId, false, fundingAmount, open.fundingAmount, remoteFundingPubkey, open.lockTime, dustLimit, open.fundingFeerate) - when (val fundingContributions = FundingContributions.create(channelKeys, keyManager.swapInOnChainWallet, fundingParams, walletInputs, accept.pushAmount, open.pushAmount, null)) { + when (val fundingContributions = FundingContributions.create(channelKeys, keyManager.swapInOnChainWallet, fundingParams, walletInputs, null)) { is Either.Left -> { logger.error { "could not fund channel: ${fundingContributions.value}" } replyTo.complete(ChannelFundingResponse.Failure.FundingFailure(fundingContributions.value)) @@ -107,8 +104,6 @@ data class WaitForOpenChannel( localParams.copy(paysCommitTxFees = open.channelFlags.nonInitiatorPaysCommitFees), remoteParams, interactiveTxSession, - pushAmount, - open.pushAmount, open.commitmentFeerate, open.firstPerCommitmentPoint, open.secondPerCommitmentPoint, diff --git a/src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt b/src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt index e930ecd73..ba7833d6e 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt @@ -41,7 +41,6 @@ sealed class PeerCommand /** Open a channel, consuming all the spendable utxos in the wallet state provided. */ data class OpenChannel( val fundingAmount: Satoshi, - val pushAmount: MilliSatoshi, val walletInputs: List, val commitTxFeerate: FeeratePerKw, val fundingTxFeerate: FeeratePerKw, @@ -1077,7 +1076,6 @@ class Peer( replyTo = CompletableDeferred(), temporaryChannelId = msg.temporaryChannelId, fundingAmount = 0.sat, - pushAmount = 0.msat, walletInputs = listOf(), localParams = localParams, channelConfig = channelConfig, @@ -1258,7 +1256,6 @@ class Peer( ChannelCommand.Init.Initiator( replyTo = CompletableDeferred(), fundingAmount = cmd.fundingAmount, - pushAmount = cmd.pushAmount, walletInputs = cmd.walletInputs, commitTxFeerate = cmd.commitTxFeerate, fundingTxFeerate = cmd.fundingTxFeerate, @@ -1363,7 +1360,6 @@ class Peer( val initCommand = ChannelCommand.Init.Initiator( replyTo = CompletableDeferred(), fundingAmount = localFundingAmount, - pushAmount = 0.msat, walletInputs = cmd.walletInputs, commitTxFeerate = currentFeerates.commitmentFeerate, fundingTxFeerate = currentFeerates.fundingFeerate, @@ -1480,7 +1476,6 @@ class Peer( ChannelCommand.Init.Initiator( replyTo = CompletableDeferred(), fundingAmount = 0.sat, // we don't have funds to contribute - pushAmount = 0.msat, walletInputs = listOf(), commitTxFeerate = currentFeerates.commitmentFeerate, fundingTxFeerate = fundingFeerate, diff --git a/src/commonMain/kotlin/fr/acinq/lightning/serialization/v4/Deserialization.kt b/src/commonMain/kotlin/fr/acinq/lightning/serialization/v4/Deserialization.kt index 630a42600..5492af611 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/serialization/v4/Deserialization.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/serialization/v4/Deserialization.kt @@ -33,7 +33,7 @@ object Deserialization { private fun Input.readPersistedChannelState(): PersistedChannelState = when (val discriminator = read()) { 0x08 -> readLegacyWaitForFundingConfirmed() 0x09 -> readLegacyWaitForFundingLocked() - 0x00 -> readWaitForFundingConfirmed() + 0x00 -> readWaitForFundingConfirmedWithPushAmount() 0x01 -> readWaitForChannelReady() 0x02 -> readNormalLegacy() 0x03 -> readShuttingDown() @@ -43,7 +43,9 @@ object Deserialization { 0x07 -> readClosed() 0x0a -> readWaitForFundingSignedLegacy() 0x0b -> readNormal() - 0x0c -> readWaitForFundingSigned() + 0x0c -> readWaitForFundingSignedWithPushAmount() + 0x0d -> readWaitForFundingSigned() + 0x0e -> readWaitForFundingConfirmed() else -> error("unknown discriminator $discriminator for class ${PersistedChannelState::class}") } @@ -67,27 +69,51 @@ object Deserialization { private fun Input.readWaitForFundingSigned() = WaitForFundingSigned( channelParams = readChannelParams(), signingSession = readInteractiveTxSigningSession(), - localPushAmount = readNumber().msat, - remotePushAmount = readNumber().msat, remoteSecondPerCommitmentPoint = readPublicKey(), liquidityPurchase = readNullable { readLiquidityPurchase() }, channelOrigin = readNullable { readChannelOrigin() } ) - private fun Input.readWaitForFundingSignedLegacy() = WaitForFundingSigned( - channelParams = readChannelParams(), - signingSession = readInteractiveTxSigningSession(), - localPushAmount = readNumber().msat, - remotePushAmount = readNumber().msat, - remoteSecondPerCommitmentPoint = readPublicKey(), - liquidityPurchase = null, - channelOrigin = readNullable { readChannelOrigin() } - ) + private fun Input.readWaitForFundingSignedWithPushAmount(): WaitForFundingSigned { + val channelParams = readChannelParams() + val signingSession = readInteractiveTxSigningSession() + // We previously included a local_push_amount and a remote_push_amount. + readNumber() + readNumber() + val remoteSecondPerCommitmentPoint = readPublicKey() + val liquidityPurchase = readNullable { readLiquidityPurchase() } + val channelOrigin = readNullable { readChannelOrigin() } + return WaitForFundingSigned(channelParams, signingSession, remoteSecondPerCommitmentPoint, liquidityPurchase, channelOrigin) + } + + private fun Input.readWaitForFundingSignedLegacy(): WaitForFundingSigned { + val channelParams = readChannelParams() + val signingSession = readInteractiveTxSigningSession() + // We previously included a local_push_amount and a remote_push_amount. + readNumber() + readNumber() + val remoteSecondPerCommitmentPoint = readPublicKey() + val channelOrigin = readNullable { readChannelOrigin() } + return WaitForFundingSigned(channelParams, signingSession, remoteSecondPerCommitmentPoint, liquidityPurchase = null, channelOrigin) + } + + private fun Input.readWaitForFundingConfirmedWithPushAmount(): WaitForFundingConfirmed { + val commitments = readCommitments() + // We previously included a local_push_amount and a remote_push_amount. + readNumber() + readNumber() + val waitingSinceBlock = readNumber() + val deferred = readNullable { readLightningMessage() as ChannelReady } + val rbfStatus = when (val discriminator = read()) { + 0x00 -> RbfStatus.None + 0x01 -> RbfStatus.WaitingForSigs(readInteractiveTxSigningSession()) + else -> error("unknown discriminator $discriminator for class ${RbfStatus::class}") + } + return WaitForFundingConfirmed(commitments, waitingSinceBlock, deferred, rbfStatus) + } private fun Input.readWaitForFundingConfirmed() = WaitForFundingConfirmed( commitments = readCommitments(), - localPushAmount = readNumber().msat, - remotePushAmount = readNumber().msat, waitingSinceBlock = readNumber(), deferred = readNullable { readLightningMessage() as ChannelReady }, rbfStatus = when (val discriminator = read()) { diff --git a/src/commonMain/kotlin/fr/acinq/lightning/serialization/v4/Serialization.kt b/src/commonMain/kotlin/fr/acinq/lightning/serialization/v4/Serialization.kt index 2ad8be1b4..637fdfc10 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/serialization/v4/Serialization.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/serialization/v4/Serialization.kt @@ -1,7 +1,6 @@ package fr.acinq.lightning.serialization.v4 import fr.acinq.bitcoin.* -import fr.acinq.bitcoin.crypto.musig2.IndividualNonce import fr.acinq.bitcoin.io.ByteArrayOutput import fr.acinq.bitcoin.io.Output import fr.acinq.bitcoin.utils.Either @@ -50,9 +49,6 @@ object Serialization { is LegacyWaitForFundingLocked -> { write(0x09); writeLegacyWaitForFundingLocked(o) } - is WaitForFundingConfirmed -> { - write(0x00); writeWaitForFundingConfirmed(o) - } is WaitForChannelReady -> { write(0x01); writeWaitForChannelReady(o) } @@ -75,7 +71,10 @@ object Serialization { write(0x07); writeClosed(o) } is WaitForFundingSigned -> { - write(0x0c); writeWaitForFundingSigned(o) + write(0x0d); writeWaitForFundingSigned(o) + } + is WaitForFundingConfirmed -> { + write(0x0e); writeWaitForFundingConfirmed(o) } } @@ -99,8 +98,6 @@ object Serialization { private fun Output.writeWaitForFundingSigned(o: WaitForFundingSigned) = o.run { writeChannelParams(channelParams) writeInteractiveTxSigningSession(signingSession) - writeNumber(localPushAmount.toLong()) - writeNumber(remotePushAmount.toLong()) writePublicKey(remoteSecondPerCommitmentPoint) writeNullable(liquidityPurchase) { writeLiquidityPurchase(it) } writeNullable(channelOrigin) { writeChannelOrigin(it) } @@ -108,8 +105,6 @@ object Serialization { private fun Output.writeWaitForFundingConfirmed(o: WaitForFundingConfirmed) = o.run { writeCommitments(commitments) - writeNumber(localPushAmount.toLong()) - writeNumber(remotePushAmount.toLong()) writeNumber(waitingSinceBlock) writeNullable(deferred) { writeLightningMessage(it) } when (rbfStatus) { @@ -720,8 +715,6 @@ object Serialization { private fun Output.writeTxId(o: TxId) = write(o.value.toByteArray()) - private fun Output.writePublicNonce(o: IndividualNonce) = write(o.toByteArray()) - private fun Output.writeDelimited(o: ByteArray) { writeNumber(o.size) write(o) diff --git a/src/commonMain/kotlin/fr/acinq/lightning/wire/ChannelTlv.kt b/src/commonMain/kotlin/fr/acinq/lightning/wire/ChannelTlv.kt index 75b2d7dfd..227c7c5e5 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/wire/ChannelTlv.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/wire/ChannelTlv.kt @@ -100,19 +100,6 @@ sealed class ChannelTlv : Tlv { override fun read(input: Input): FeeCreditUsedTlv = FeeCreditUsedTlv(LightningCodecs.tu64(input).msat) } } - - /** Amount that will be offered by the initiator of a dual-funded channel to the non-initiator. */ - data class PushAmountTlv(val amount: MilliSatoshi) : ChannelTlv() { - override val tag: Long get() = PushAmountTlv.tag - - override fun write(out: Output) = LightningCodecs.writeTU64(amount.toLong(), out) - - companion object : TlvValueReader { - const val tag: Long = 0x47000007 - - override fun read(input: Input): PushAmountTlv = PushAmountTlv(LightningCodecs.tu64(input).msat) - } - } } sealed class ChannelReadyTlv : Tlv { diff --git a/src/commonMain/kotlin/fr/acinq/lightning/wire/LightningMessages.kt b/src/commonMain/kotlin/fr/acinq/lightning/wire/LightningMessages.kt index cceec2df5..608e0715e 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/wire/LightningMessages.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/wire/LightningMessages.kt @@ -678,7 +678,6 @@ data class OpenDualFundedChannel( val tlvStream: TlvStream = TlvStream.empty() ) : ChannelMessage, HasTemporaryChannelId, HasChainHash { val channelType: ChannelType? get() = tlvStream.get()?.channelType - val pushAmount: MilliSatoshi get() = tlvStream.get()?.amount ?: 0.msat val requestFunding: LiquidityAds.RequestFunding? get() = tlvStream.get()?.request override val type: Long get() = OpenDualFundedChannel.type @@ -717,7 +716,6 @@ data class OpenDualFundedChannel( ChannelTlv.ChannelTypeTlv.tag to ChannelTlv.ChannelTypeTlv.Companion as TlvValueReader, ChannelTlv.RequireConfirmedInputsTlv.tag to ChannelTlv.RequireConfirmedInputsTlv as TlvValueReader, ChannelTlv.RequestFundingTlv.tag to ChannelTlv.RequestFundingTlv as TlvValueReader, - ChannelTlv.PushAmountTlv.tag to ChannelTlv.PushAmountTlv.Companion as TlvValueReader, ) override fun read(input: Input): OpenDualFundedChannel { @@ -789,7 +787,6 @@ data class AcceptDualFundedChannel( val channelType: ChannelType? get() = tlvStream.get()?.channelType val willFund: LiquidityAds.WillFund? get() = tlvStream.get()?.willFund val feeCreditUsed: MilliSatoshi = tlvStream.get()?.amount ?: 0.msat - val pushAmount: MilliSatoshi get() = tlvStream.get()?.amount ?: 0.msat override val type: Long get() = AcceptDualFundedChannel.type @@ -822,7 +819,6 @@ data class AcceptDualFundedChannel( ChannelTlv.RequireConfirmedInputsTlv.tag to ChannelTlv.RequireConfirmedInputsTlv as TlvValueReader, ChannelTlv.ProvideFundingTlv.tag to ChannelTlv.ProvideFundingTlv as TlvValueReader, ChannelTlv.FeeCreditUsedTlv.tag to ChannelTlv.FeeCreditUsedTlv as TlvValueReader, - ChannelTlv.PushAmountTlv.tag to ChannelTlv.PushAmountTlv.Companion as TlvValueReader, ) override fun read(input: Input): AcceptDualFundedChannel = AcceptDualFundedChannel( @@ -960,9 +956,8 @@ data class SpliceInit( override val type: Long get() = SpliceInit.type val requireConfirmedInputs: Boolean = tlvStream.get()?.let { true } ?: false val requestFunding: LiquidityAds.RequestFunding? = tlvStream.get()?.request - val pushAmount: MilliSatoshi = tlvStream.get()?.amount ?: 0.msat - constructor(channelId: ByteVector32, fundingContribution: Satoshi, pushAmount: MilliSatoshi, feerate: FeeratePerKw, lockTime: Long, fundingPubkey: PublicKey, requestFunding: LiquidityAds.RequestFunding?) : this( + constructor(channelId: ByteVector32, fundingContribution: Satoshi, feerate: FeeratePerKw, lockTime: Long, fundingPubkey: PublicKey, requestFunding: LiquidityAds.RequestFunding?) : this( channelId, fundingContribution, feerate, @@ -970,7 +965,6 @@ data class SpliceInit( fundingPubkey, TlvStream( setOfNotNull( - if (pushAmount > 0.msat) ChannelTlv.PushAmountTlv(pushAmount) else null, requestFunding?.let { ChannelTlv.RequestFundingTlv(it) }, ) ) @@ -992,7 +986,6 @@ data class SpliceInit( private val readers = mapOf( ChannelTlv.RequireConfirmedInputsTlv.tag to ChannelTlv.RequireConfirmedInputsTlv as TlvValueReader, ChannelTlv.RequestFundingTlv.tag to ChannelTlv.RequestFundingTlv as TlvValueReader, - ChannelTlv.PushAmountTlv.tag to ChannelTlv.PushAmountTlv.Companion as TlvValueReader, ) override fun read(input: Input): SpliceInit = SpliceInit( @@ -1016,15 +1009,13 @@ data class SpliceAck( val requireConfirmedInputs: Boolean = tlvStream.get()?.let { true } ?: false val willFund: LiquidityAds.WillFund? = tlvStream.get()?.willFund val feeCreditUsed: MilliSatoshi = tlvStream.get()?.amount ?: 0.msat - val pushAmount: MilliSatoshi = tlvStream.get()?.amount ?: 0.msat - constructor(channelId: ByteVector32, fundingContribution: Satoshi, pushAmount: MilliSatoshi, fundingPubkey: PublicKey, willFund: LiquidityAds.WillFund?) : this( + constructor(channelId: ByteVector32, fundingContribution: Satoshi, fundingPubkey: PublicKey, willFund: LiquidityAds.WillFund?) : this( channelId, fundingContribution, fundingPubkey, TlvStream( setOfNotNull( - if (pushAmount > 0.msat) ChannelTlv.PushAmountTlv(pushAmount) else null, willFund?.let { ChannelTlv.ProvideFundingTlv(it) } )) ) @@ -1044,7 +1035,6 @@ data class SpliceAck( ChannelTlv.RequireConfirmedInputsTlv.tag to ChannelTlv.RequireConfirmedInputsTlv as TlvValueReader, ChannelTlv.ProvideFundingTlv.tag to ChannelTlv.ProvideFundingTlv as TlvValueReader, ChannelTlv.FeeCreditUsedTlv.tag to ChannelTlv.FeeCreditUsedTlv.Companion as TlvValueReader, - ChannelTlv.PushAmountTlv.tag to ChannelTlv.PushAmountTlv.Companion as TlvValueReader, ) override fun read(input: Input): SpliceAck = SpliceAck( diff --git a/src/commonTest/kotlin/fr/acinq/lightning/channel/CommitmentsTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/channel/CommitmentsTestsCommon.kt index c0035f0a7..f2cb0b9a9 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/channel/CommitmentsTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/channel/CommitmentsTestsCommon.kt @@ -46,7 +46,7 @@ class CommitmentsTestsCommon : LightningTestSuite(), LoggingContext { @Test fun `correct values for availableForSend - availableForReceive -- success case`() { - val (alice, bob) = reachNormal() + val (alice, bob) = reachNormal(aliceFundingAmount = 800_000.sat, bobFundingAmount = 200_000.sat) val aliceKeys = alice.ctx.keyManager.channelKeys(alice.commitments.params.localParams.fundingKeyPath) val bobKeys = bob.ctx.keyManager.channelKeys(bob.commitments.params.localParams.fundingKeyPath) @@ -135,7 +135,7 @@ class CommitmentsTestsCommon : LightningTestSuite(), LoggingContext { @Test fun `correct values for availableForSend - availableForReceive -- failure case`() { - val (alice, bob) = reachNormal() + val (alice, bob) = reachNormal(aliceFundingAmount = 800_000.sat, bobFundingAmount = 200_000.sat) val aliceKeys = alice.ctx.keyManager.channelKeys(alice.commitments.params.localParams.fundingKeyPath) val bobKeys = bob.ctx.keyManager.channelKeys(bob.commitments.params.localParams.fundingKeyPath) @@ -224,7 +224,7 @@ class CommitmentsTestsCommon : LightningTestSuite(), LoggingContext { @Test fun `correct values for availableForSend - availableForReceive -- multiple htlcs`() { - val (alice, bob) = reachNormal() + val (alice, bob) = reachNormal(aliceFundingAmount = 800_000.sat, bobFundingAmount = 200_000.sat) val aliceKeys = alice.ctx.keyManager.channelKeys(alice.commitments.params.localParams.fundingKeyPath) val bobKeys = bob.ctx.keyManager.channelKeys(bob.commitments.params.localParams.fundingKeyPath) @@ -531,50 +531,5 @@ class CommitmentsTestsCommon : LightningTestSuite(), LoggingContext { remotePerCommitmentSecrets = ShaChain.init, ) } - - fun makeCommitments(toLocal: MilliSatoshi, toRemote: MilliSatoshi, localNodeId: PublicKey, remoteNodeId: PublicKey): Commitments { - val localParams = LocalParams( - localNodeId, KeyPath("42"), 0.sat, Long.MAX_VALUE, 1.msat, CltvExpiryDelta(144), 50, isChannelOpener = true, paysCommitTxFees = true, ByteVector.empty, Features.empty - ) - val remoteParams = RemoteParams( - remoteNodeId, 0.sat, Long.MAX_VALUE, 1.msat, CltvExpiryDelta(144), 50, randomKey().publicKey(), randomKey().publicKey(), randomKey().publicKey(), randomKey().publicKey(), Features.empty - ) - val fundingAmount = (toLocal + toRemote).truncateToSatoshi() - val dummyFundingScript = Scripts.multiSig2of2(randomKey().publicKey(), randomKey().publicKey()) - val dummyFundingTx = Transaction(2, listOf(TxIn(OutPoint(TxId(randomBytes32()), 1), 0)), listOf(TxOut(fundingAmount, Script.pay2wsh(dummyFundingScript))), 0) - val commitmentInput = Transactions.InputInfo(OutPoint(dummyFundingTx, 0), dummyFundingTx.txOut[0], dummyFundingScript) - val localCommitTx = Transactions.TransactionWithInputInfo.CommitTx(commitmentInput, Transaction(2, listOf(), listOf(), 0)) - return Commitments( - ChannelParams( - channelId = randomBytes32(), - channelConfig = ChannelConfig.standard, - channelFeatures = ChannelFeatures(ChannelType.SupportedChannelType.AnchorOutputs.features), - localParams = localParams, - remoteParams = remoteParams, - channelFlags = ChannelFlags(announceChannel = false, nonInitiatorPaysCommitFees = false), - ), - CommitmentChanges( - LocalChanges(listOf(), listOf(), listOf()), - RemoteChanges(listOf(), listOf(), listOf()), - localNextHtlcId = 1, - remoteNextHtlcId = 1, - ), - active = listOf( - Commitment( - fundingTxIndex = 0, - remoteFundingPubkey = randomKey().publicKey(), - LocalFundingStatus.ConfirmedFundingTx(dummyFundingTx, 500.sat, TxSignatures(randomBytes32(), TxId(randomBytes32()), listOf())), - RemoteFundingStatus.Locked, - LocalCommit(0, CommitmentSpec(setOf(), FeeratePerKw(0.sat), toLocal, toRemote), PublishableTxs(localCommitTx, listOf())), - RemoteCommit(0, CommitmentSpec(setOf(), FeeratePerKw(0.sat), toRemote, toLocal), TxId(randomBytes32()), randomKey().publicKey()), - nextRemoteCommit = null - ) - ), - inactive = emptyList(), - payments = mapOf(), - remoteNextCommitInfo = Either.Right(randomKey().publicKey()), - remotePerCommitmentSecrets = ShaChain.init, - ) - } } } \ No newline at end of file diff --git a/src/commonTest/kotlin/fr/acinq/lightning/channel/InteractiveTxTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/channel/InteractiveTxTestsCommon.kt index 253494187..cb266c319 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/channel/InteractiveTxTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/channel/InteractiveTxTestsCommon.kt @@ -785,7 +785,7 @@ class InteractiveTxTestsCommon : LightningTestSuite() { val fundingParams = InteractiveTxParams(randomBytes32(), true, 150_000.sat, 50_000.sat, pubKey, 0, 660.sat, FeeratePerKw(2500.sat)) run { val previousTx = Transaction(2, listOf(), listOf(TxOut(293.sat, Script.pay2wpkh(pubKey))), 0) - val result = FundingContributions.create(channelKeys, swapInKeys, fundingParams, listOf(WalletState.Utxo(previousTx.txid, 0, 0, previousTx, WalletState.AddressMeta.Single)), 0.msat, 0.msat, null).left + val result = FundingContributions.create(channelKeys, swapInKeys, fundingParams, listOf(WalletState.Utxo(previousTx.txid, 0, 0, previousTx, WalletState.AddressMeta.Single)), null).left assertNotNull(result) assertIs(result) } @@ -793,7 +793,7 @@ class InteractiveTxTestsCommon : LightningTestSuite() { val txIn = (1..1000).map { TxIn(OutPoint(TxId(randomBytes32()), 3), ByteVector.empty, 0, Script.witnessPay2wpkh(pubKey, Transactions.PlaceHolderSig)) } val txOut = (1..1000).map { i -> TxOut(1000.sat * i, Script.pay2wpkh(pubKey)) } val previousTx = Transaction(2, txIn, txOut, 0) - val result = FundingContributions.create(channelKeys, swapInKeys, fundingParams, listOf(WalletState.Utxo(previousTx.txid, 53, 0, previousTx, WalletState.AddressMeta.Single)), 0.msat, 0.msat, null).left + val result = FundingContributions.create(channelKeys, swapInKeys, fundingParams, listOf(WalletState.Utxo(previousTx.txid, 53, 0, previousTx, WalletState.AddressMeta.Single)), null).left assertNotNull(result) assertIs(result) } @@ -803,7 +803,7 @@ class InteractiveTxTestsCommon : LightningTestSuite() { WalletState.Utxo(previousTx.txid, 0, 0, previousTx, WalletState.AddressMeta.Single), WalletState.Utxo(previousTx.txid, 1, 0, previousTx, WalletState.AddressMeta.Single), ) - val result = FundingContributions.create(channelKeys, swapInKeys, fundingParams, walletInputs, 0.msat, 0.msat, null).left + val result = FundingContributions.create(channelKeys, swapInKeys, fundingParams, walletInputs, null).left assertNotNull(result) assertIs(result) } @@ -820,25 +820,14 @@ class InteractiveTxTestsCommon : LightningTestSuite() { run { // If we don't contribute any funds, we cannot pay the liquidity lease. val purchase = LiquidityAds.Purchase.Standard(100_000.sat, fees, paymentDetails) - val result = FundingContributions.create(channelKeys, swapInKeys, fundingParams, listOf(), 0.msat, 0.msat, purchase).left + val result = FundingContributions.create(channelKeys, swapInKeys, fundingParams, listOf(), purchase).left assertNotNull(result) assertIs(result) } - run { - // If our peer pushes enough funds on our side to pay liquidity fees, we're fine. - val purchase = LiquidityAds.Purchase.Standard(100_000.sat, fees, paymentDetails) - val result = FundingContributions.create(channelKeys, swapInKeys, fundingParams, listOf(), 0.msat, 10_000_000.msat, purchase).right - assertNotNull(result) - assertTrue(result.inputs.isEmpty()) - assertEquals(1, result.outputs.size) - val sharedOutput = result.outputs.first() - assertIs(sharedOutput) - assertEquals(fundingParams.fundingAmount, sharedOutput.amount) - } run { // If we have enough fee credit to pay liquidity fees, we're fine. val purchase = LiquidityAds.Purchase.WithFeeCredit(100_000.sat, fees, 5_000_000.msat, paymentDetails) - val result = FundingContributions.create(channelKeys, swapInKeys, fundingParams, listOf(), 0.msat, 0.msat, purchase).right + val result = FundingContributions.create(channelKeys, swapInKeys, fundingParams, listOf(), purchase).right assertNotNull(result) assertTrue(result.inputs.isEmpty()) assertEquals(1, result.outputs.size) @@ -1318,10 +1307,10 @@ class InteractiveTxTestsCommon : LightningTestSuite() { val fundingParamsA = InteractiveTxParams(channelId, true, fundingAmountA, fundingAmountB, fundingPubkeyB, lockTime, dustLimit, targetFeerate) val fundingParamsB = InteractiveTxParams(channelId, false, fundingAmountB, fundingAmountA, fundingPubkeyA, lockTime, dustLimit, targetFeerate) val walletA = createWallet(swapInKeysA, utxosA, legacyUtxosA) - val contributionsA = FundingContributions.create(channelKeysA, swapInKeysA, fundingParamsA, null, walletA, listOf(), 0.msat, 0.msat, null, randomKey().publicKey()) + val contributionsA = FundingContributions.create(channelKeysA, swapInKeysA, fundingParamsA, null, walletA, listOf(), null, randomKey().publicKey()) assertNotNull(contributionsA.right) val walletB = createWallet(swapInKeysB, utxosB, legacyUtxosB) - val contributionsB = FundingContributions.create(channelKeysB, swapInKeysB, fundingParamsB, null, walletB, listOf(), 0.msat, 0.msat, null, randomKey().publicKey()) + val contributionsB = FundingContributions.create(channelKeysB, swapInKeysB, fundingParamsB, null, walletB, listOf(), null, randomKey().publicKey()) assertNotNull(contributionsB.right) return Fixture(channelId, TestConstants.Alice.keyManager, channelKeysA, localParamsA, fundingParamsA, contributionsA.right!!, TestConstants.Bob.keyManager, channelKeysB, localParamsB, fundingParamsB, contributionsB.right!!) } @@ -1354,7 +1343,7 @@ class InteractiveTxTestsCommon : LightningTestSuite() { val sharedInputA = SharedFundingInput.Multisig2of2(inputInfo, fundingTxIndex, channelKeysB.fundingPubKey(fundingTxIndex)) val nextFundingPubkeyB = channelKeysB.fundingPubKey(fundingTxIndex + 1) val fundingParamsA = InteractiveTxParams(channelId, true, fundingContributionA, fundingContributionB, sharedInputA, nextFundingPubkeyB, outputsA, lockTime, dustLimit, targetFeerate) - return FundingContributions.create(channelKeysA, swapInKeysA, fundingParamsA, Pair(sharedInputA, SharedFundingInputBalances(balanceA, balanceB, 0.msat)), listOf(), outputsA, 0.msat, 0.msat, null, randomKey().publicKey()) + return FundingContributions.create(channelKeysA, swapInKeysA, fundingParamsA, Pair(sharedInputA, SharedFundingInputBalances(balanceA, balanceB, 0.msat)), listOf(), outputsA, null, randomKey().publicKey()) } private fun createSpliceFixture( @@ -1393,10 +1382,10 @@ class InteractiveTxTestsCommon : LightningTestSuite() { val fundingParamsA = InteractiveTxParams(channelId, true, fundingContributionA, fundingContributionB, sharedInputA, nextFundingPubkeyB, outputsA, lockTime, dustLimit, targetFeerate) val fundingParamsB = InteractiveTxParams(channelId, false, fundingContributionB, fundingContributionA, sharedInputB, nextFundingPubkeyA, outputsB, lockTime, dustLimit, targetFeerate) val walletA = createWallet(swapInKeysA, utxosA) - val contributionsA = FundingContributions.create(channelKeysA, swapInKeysA, fundingParamsA, Pair(sharedInputA, SharedFundingInputBalances(balanceA, balanceB, 0.msat)), walletA, outputsA, 0.msat, 0.msat, null, randomKey().publicKey()) + val contributionsA = FundingContributions.create(channelKeysA, swapInKeysA, fundingParamsA, Pair(sharedInputA, SharedFundingInputBalances(balanceA, balanceB, 0.msat)), walletA, outputsA, null, randomKey().publicKey()) assertNotNull(contributionsA.right) val walletB = createWallet(swapInKeysB, utxosB) - val contributionsB = FundingContributions.create(channelKeysB, swapInKeysB, fundingParamsB, Pair(sharedInputB, SharedFundingInputBalances(balanceB, balanceA, 0.msat)), walletB, outputsB, 0.msat, 0.msat, null, randomKey().publicKey()) + val contributionsB = FundingContributions.create(channelKeysB, swapInKeysB, fundingParamsB, Pair(sharedInputB, SharedFundingInputBalances(balanceB, balanceA, 0.msat)), walletB, outputsB, null, randomKey().publicKey()) assertNotNull(contributionsB.right) return Fixture(channelId, TestConstants.Alice.keyManager, channelKeysA, localParamsA, fundingParamsA, contributionsA.right!!, TestConstants.Bob.keyManager, channelKeysB, localParamsB, fundingParamsB, contributionsB.right!!) } diff --git a/src/commonTest/kotlin/fr/acinq/lightning/channel/TestsHelper.kt b/src/commonTest/kotlin/fr/acinq/lightning/channel/TestsHelper.kt index 7606a1eff..a962506bd 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/channel/TestsHelper.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/channel/TestsHelper.kt @@ -147,8 +147,6 @@ object TestsHelper { currentHeight: Int = TestConstants.defaultBlockHeight, aliceFundingAmount: Satoshi = TestConstants.aliceFundingAmount, bobFundingAmount: Satoshi = TestConstants.bobFundingAmount, - alicePushAmount: MilliSatoshi = TestConstants.alicePushAmount, - bobPushAmount: MilliSatoshi = TestConstants.bobPushAmount, requestRemoteFunding: Satoshi? = null, zeroConf: Boolean = false, channelOrigin: Origin? = null @@ -191,7 +189,6 @@ object TestsHelper { ChannelCommand.Init.Initiator( CompletableDeferred(), aliceFundingAmount, - alicePushAmount, createWallet(aliceNodeParams.keyManager, aliceFundingAmount + 3500.sat).second, FeeratePerKw.CommitmentFeerate, TestConstants.feeratePerKw, @@ -200,7 +197,12 @@ object TestsHelper { channelFlags, ChannelConfig.standard, channelType, - requestRemoteFunding?.let { LiquidityAds.RequestFunding(it, TestConstants.fundingRates.findRate(it)!!, LiquidityAds.PaymentDetails.FromChannelBalance) }, + requestRemoteFunding?.let { + when (channelOrigin) { + is Origin.OffChainPayment -> LiquidityAds.RequestFunding(it, TestConstants.fundingRates.findRate(it)!!, LiquidityAds.PaymentDetails.FromFutureHtlc(listOf(channelOrigin.paymentHash))) + else -> LiquidityAds.RequestFunding(it, TestConstants.fundingRates.findRate(it)!!, LiquidityAds.PaymentDetails.FromChannelBalance) + } + }, channelOrigin, ) ) @@ -212,7 +214,6 @@ object TestsHelper { CompletableDeferred(), temporaryChannelId, bobFundingAmount, - bobPushAmount, bobWallet, bobChannelParams, ChannelConfig.standard, @@ -232,8 +233,6 @@ object TestsHelper { currentHeight: Int = TestConstants.defaultBlockHeight, aliceFundingAmount: Satoshi = TestConstants.aliceFundingAmount, bobFundingAmount: Satoshi = TestConstants.bobFundingAmount, - alicePushAmount: MilliSatoshi = TestConstants.alicePushAmount, - bobPushAmount: MilliSatoshi = TestConstants.bobPushAmount, requestRemoteFunding: Satoshi? = null, zeroConf: Boolean = false, ): Triple, LNChannel, Transaction> { @@ -244,8 +243,6 @@ object TestsHelper { currentHeight, aliceFundingAmount, bobFundingAmount, - alicePushAmount, - bobPushAmount, requestRemoteFunding, zeroConf ) diff --git a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/ClosingTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/ClosingTestsCommon.kt index 8abcc3a5b..08c3e527d 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/ClosingTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/ClosingTestsCommon.kt @@ -136,7 +136,7 @@ class ClosingTestsCommon : LightningTestSuite() { @Test fun `recv BITCOIN_FUNDING_DEPTHOK`() { - val (alice, bob, _) = WaitForFundingConfirmedTestsCommon.init(ChannelType.SupportedChannelType.AnchorOutputs, alicePushAmount = 0.msat) + val (alice, bob, _) = WaitForFundingConfirmedTestsCommon.init(ChannelType.SupportedChannelType.AnchorOutputs) val fundingTx = alice.state.latestFundingTx.sharedTx.tx.buildUnsignedTx() run { val (aliceClosing, _) = localClose(alice) @@ -161,7 +161,7 @@ class ClosingTestsCommon : LightningTestSuite() { @Test fun `recv BITCOIN_FUNDING_DEPTHOK -- previous funding tx`() { - val (alice, bob, previousFundingTx, walletAlice) = WaitForFundingConfirmedTestsCommon.init(ChannelType.SupportedChannelType.AnchorOutputs, alicePushAmount = 0.msat) + val (alice, bob, previousFundingTx, walletAlice) = WaitForFundingConfirmedTestsCommon.init(ChannelType.SupportedChannelType.AnchorOutputs) val (alice1, bob1, fundingTx) = WaitForFundingConfirmedTestsCommon.rbf(alice, bob, walletAlice) assertNotEquals(previousFundingTx.txid, fundingTx.txid) run { diff --git a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/NegotiatingTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/NegotiatingTestsCommon.kt index 114fe4286..c1226aaf8 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/NegotiatingTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/NegotiatingTestsCommon.kt @@ -3,7 +3,6 @@ package fr.acinq.lightning.channel.states import fr.acinq.bitcoin.* import fr.acinq.lightning.Feature import fr.acinq.lightning.Lightning.randomKey -import fr.acinq.lightning.MilliSatoshi import fr.acinq.lightning.blockchain.* import fr.acinq.lightning.blockchain.fee.FeeratePerKw import fr.acinq.lightning.channel.* @@ -148,7 +147,7 @@ class NegotiatingTestsCommon : LightningTestSuite() { @Test fun `recv ClosingSigned -- theirCloseFee == ourCloseFee -- non-initiator pays commit fees`() { - val (alice, bob) = reachNormal(channelType = ChannelType.SupportedChannelType.AnchorOutputsZeroReserve, aliceFundingAmount = 200_000.sat, alicePushAmount = 0.msat, requestRemoteFunding = TestConstants.bobFundingAmount) + val (alice, bob) = reachNormal(channelType = ChannelType.SupportedChannelType.AnchorOutputsZeroReserve, aliceFundingAmount = 200_000.sat, requestRemoteFunding = TestConstants.bobFundingAmount) assertFalse(alice.commitments.params.localParams.paysCommitTxFees) assertTrue(bob.commitments.params.localParams.paysCommitTxFees) // Alice sends all of her balance to Bob. @@ -235,7 +234,7 @@ class NegotiatingTestsCommon : LightningTestSuite() { @Test fun `recv ClosingSigned -- nothing at stake`() { - val (alice, bob) = reachNormal(bobFundingAmount = 0.sat, alicePushAmount = 0.msat) + val (alice, bob) = reachNormal(bobFundingAmount = 0.sat) val alice1 = alice.updateFeerate(FeeratePerKw(5_000.sat)) val bob1 = bob.updateFeerate(FeeratePerKw(10_000.sat)) @@ -480,11 +479,8 @@ class NegotiatingTestsCommon : LightningTestSuite() { } companion object { - fun init( - channelType: ChannelType.SupportedChannelType = ChannelType.SupportedChannelType.AnchorOutputs, - alicePushAmount: MilliSatoshi = TestConstants.alicePushAmount - ): Triple, LNChannel, ClosingSigned> { - val (alice, bob) = reachNormal(channelType = channelType, alicePushAmount = alicePushAmount) + fun init(channelType: ChannelType.SupportedChannelType = ChannelType.SupportedChannelType.AnchorOutputs): Triple, LNChannel, ClosingSigned> { + val (alice, bob) = reachNormal(channelType = channelType) return mutualCloseAlice(alice, bob) } diff --git a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/NormalTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/NormalTestsCommon.kt index 2296c53cf..bce65898d 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/NormalTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/NormalTestsCommon.kt @@ -72,7 +72,7 @@ class NormalTestsCommon : LightningTestSuite() { @Test fun `recv ChannelCommand_Htlc_Add -- zero-reserve`() { - val (_, bob0) = reachNormal(ChannelType.SupportedChannelType.AnchorOutputsZeroReserve, bobFundingAmount = 10_000.sat, alicePushAmount = 0.msat) + val (_, bob0) = reachNormal(ChannelType.SupportedChannelType.AnchorOutputsZeroReserve, bobFundingAmount = 10_000.sat) assertEquals(bob0.commitments.availableBalanceForSend(), 10_000_000.msat) val add = defaultAdd.copy(amount = 10_000_000.msat, paymentHash = randomBytes32()) @@ -86,7 +86,7 @@ class NormalTestsCommon : LightningTestSuite() { @Test fun `recv ChannelCommand_Htlc_Add -- zero-conf -- zero-reserve`() { - val (_, bob0) = reachNormal(ChannelType.SupportedChannelType.AnchorOutputsZeroReserve, bobFundingAmount = 10_000.sat, alicePushAmount = 0.msat, zeroConf = true) + val (_, bob0) = reachNormal(ChannelType.SupportedChannelType.AnchorOutputsZeroReserve, bobFundingAmount = 10_000.sat, zeroConf = true) assertEquals(bob0.commitments.availableBalanceForSend(), 10_000_000.msat) val add = defaultAdd.copy(amount = 10_000_000.msat, paymentHash = randomBytes32()) @@ -164,7 +164,7 @@ class NormalTestsCommon : LightningTestSuite() { @Test fun `recv ChannelCommand_Htlc_Add -- increasing balance but still below reserve`() { - val (alice0, bob0) = reachNormal(bobFundingAmount = 0.sat, alicePushAmount = 0.msat) + val (alice0, bob0) = reachNormal(bobFundingAmount = 0.sat) assertFalse(alice0.commitments.params.channelFeatures.hasFeature(Feature.ZeroReserveChannels)) assertFalse(bob0.commitments.params.channelFeatures.hasFeature(Feature.ZeroReserveChannels)) assertEquals(0.msat, bob0.commitments.availableBalanceForSend()) @@ -186,7 +186,7 @@ class NormalTestsCommon : LightningTestSuite() { val add = defaultAdd.copy(amount = Int.MAX_VALUE.msat) val (alice1, actions) = alice0.process(add) val actualError = actions.findCommandError() - val expectError = InsufficientFunds(alice0.channelId, amount = Int.MAX_VALUE.msat, missing = 1_372_823.sat, reserve = 10_000.sat, fees = 7_140.sat) + val expectError = InsufficientFunds(alice0.channelId, amount = Int.MAX_VALUE.msat, missing = 1_322_823.sat, reserve = 10_000.sat, fees = 7_140.sat) assertEquals(expectError, actualError) assertEquals(alice0, alice1) } @@ -204,8 +204,8 @@ class NormalTestsCommon : LightningTestSuite() { @Test fun `recv ChannelCommand_Htlc_Add -- commit tx fee greater than remote initiator balance`() { - val (alice0, bob0) = reachNormal() - val (alice1, bob1) = addHtlc(774_660_000.msat, alice0, bob0).first + val (alice0, bob0) = reachNormal(bobFundingAmount = 200_000.sat) + val (alice1, bob1) = addHtlc(824_160_000.msat, alice0, bob0).first val (alice2, bob2) = crossSign(alice1, bob1) assertEquals(0.msat, alice2.state.commitments.availableBalanceForSend()) @@ -248,7 +248,7 @@ class NormalTestsCommon : LightningTestSuite() { actionsAlice2.hasOutgoingMessage() val (_, actionsAlice3) = alice2.process(defaultAdd.copy(amount = 500_000_000.msat)) val actualError = actionsAlice3.findCommandError() - val expectError = InsufficientFunds(alice0.channelId, amount = 500_000_000.msat, missing = 328_780.sat, reserve = 10_000.sat, fees = 8_860.sat) + val expectError = InsufficientFunds(alice0.channelId, amount = 500_000_000.msat, missing = 278_780.sat, reserve = 10_000.sat, fees = 8_860.sat) assertEquals(expectError, actualError) } @@ -259,7 +259,7 @@ class NormalTestsCommon : LightningTestSuite() { actionsAlice1.hasOutgoingMessage() val (alice2, actionsAlice2) = alice1.process(defaultAdd.copy(amount = 200_000_000.msat)) actionsAlice2.hasOutgoingMessage() - val (alice3, actionsAlice3) = alice2.process(defaultAdd.copy(amount = 71_120_000.msat)) + val (alice3, actionsAlice3) = alice2.process(defaultAdd.copy(amount = 121_120_000.msat)) actionsAlice3.hasOutgoingMessage() val (_, actionsAlice4) = alice3.process(defaultAdd.copy(amount = 1_000_000.msat)) val actualError = actionsAlice4.findCommandError() @@ -271,11 +271,11 @@ class NormalTestsCommon : LightningTestSuite() { fun `recv ChannelCommand_Htlc_Add -- over their max in-flight htlc value`() { val bob0 = run { val (_, bob) = reachNormal() - bob.copy(state = bob.state.copy(commitments = bob.commitments.copy(params = bob.commitments.params.copy(remoteParams = bob.commitments.params.remoteParams.copy(maxHtlcValueInFlightMsat = 150_000_000))))) + bob.copy(state = bob.state.copy(commitments = bob.commitments.copy(params = bob.commitments.params.copy(remoteParams = bob.commitments.params.remoteParams.copy(maxHtlcValueInFlightMsat = 100_000_000))))) } - val (_, actions) = bob0.process(defaultAdd.copy(amount = 151_000_000.msat)) + val (_, actions) = bob0.process(defaultAdd.copy(amount = 101_000_000.msat)) val actualError = actions.findCommandError() - val expectedError = HtlcValueTooHighInFlight(bob0.channelId, maximum = 150_000_000UL, actual = 151_000_000.msat) + val expectedError = HtlcValueTooHighInFlight(bob0.channelId, maximum = 100_000_000UL, actual = 101_000_000.msat) assertEquals(expectedError, actualError) } @@ -295,13 +295,13 @@ class NormalTestsCommon : LightningTestSuite() { fun `recv ChannelCommand_Htlc_Add -- over max in-flight htlc value with duplicate amounts`() { val bob0 = run { val (_, bob) = reachNormal() - bob.copy(state = bob.state.copy(commitments = bob.commitments.copy(params = bob.commitments.params.copy(remoteParams = bob.commitments.params.remoteParams.copy(maxHtlcValueInFlightMsat = 150_000_000))))) + bob.copy(state = bob.state.copy(commitments = bob.commitments.copy(params = bob.commitments.params.copy(remoteParams = bob.commitments.params.remoteParams.copy(maxHtlcValueInFlightMsat = 100_000_000))))) } - val (bob1, actionsBob1) = bob0.process(defaultAdd.copy(amount = 75_500_000.msat)) + val (bob1, actionsBob1) = bob0.process(defaultAdd.copy(amount = 50_500_000.msat)) actionsBob1.hasOutgoingMessage() - val (_, actionsBob2) = bob1.process(defaultAdd.copy(amount = 75_500_000.msat)) + val (_, actionsBob2) = bob1.process(defaultAdd.copy(amount = 50_500_000.msat)) val actualError = actionsBob2.findCommandError() - val expectedError = HtlcValueTooHighInFlight(bob0.channelId, maximum = 150_000_000UL, actual = 151_000_000.msat) + val expectedError = HtlcValueTooHighInFlight(bob0.channelId, maximum = 100_000_000UL, actual = 101_000_000.msat) assertEquals(expectedError, actualError) } @@ -361,7 +361,7 @@ class NormalTestsCommon : LightningTestSuite() { val failAdd = defaultAdd.copy(amount = alice0.commitments.latest.fundingAmount.toMilliSatoshi() * 2 / 3) val (_, actionsAlice3) = alice2.process(failAdd) val actualError = actionsAlice3.findCommandError() - val expectedError = InsufficientFunds(alice0.channelId, failAdd.amount, 560_393.sat, 10_000.sat, 8_000.sat) + val expectedError = InsufficientFunds(alice0.channelId, failAdd.amount, 510_393.sat, 10_000.sat, 8_000.sat) assertEquals(expectedError, actualError) } @@ -411,7 +411,7 @@ class NormalTestsCommon : LightningTestSuite() { @Test fun `recv UpdateAddHtlc -- zero-reserve`() { - val (alice0, _) = reachNormal(ChannelType.SupportedChannelType.AnchorOutputsZeroReserve, bobFundingAmount = 10_000.sat, alicePushAmount = 0.msat) + val (alice0, _) = reachNormal(ChannelType.SupportedChannelType.AnchorOutputsZeroReserve, bobFundingAmount = 10_000.sat) assertEquals(alice0.commitments.availableBalanceForReceive(), 10_000_000.msat) val add = UpdateAddHtlc(alice0.channelId, 0, 10_000_000.msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(alice0.currentBlockHeight.toLong()), TestConstants.emptyOnionPacket) val (alice1, actions1) = alice0.process(ChannelCommand.MessageReceived(add)) @@ -422,7 +422,7 @@ class NormalTestsCommon : LightningTestSuite() { @Test fun `recv UpdateAddHtlc -- zero-conf -- zero-reserve`() { - val (alice0, _) = reachNormal(ChannelType.SupportedChannelType.AnchorOutputsZeroReserve, bobFundingAmount = 10_000.sat, alicePushAmount = 0.msat, zeroConf = true) + val (alice0, _) = reachNormal(ChannelType.SupportedChannelType.AnchorOutputsZeroReserve, bobFundingAmount = 10_000.sat, zeroConf = true) assertEquals(alice0.commitments.availableBalanceForReceive(), 10_000_000.msat) val add = UpdateAddHtlc(alice0.channelId, 0, 10_000_000.msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(alice0.currentBlockHeight.toLong()), TestConstants.emptyOnionPacket) val (alice1, actions1) = alice0.process(ChannelCommand.MessageReceived(add)) @@ -431,21 +431,6 @@ class NormalTestsCommon : LightningTestSuite() { assertEquals(alice1.commitments.changes.remoteChanges.proposed, listOf(add)) } - @Test - fun `recv UpdateAddHtlc -- zero-conf -- zero-reserve -- initiator`() { - val (alice0, bob0) = reachNormal(ChannelType.SupportedChannelType.AnchorOutputsZeroReserve, aliceFundingAmount = 10_000_000.sat, bobFundingAmount = 5_000_000.sat, alicePushAmount = 9_800_000_000.msat, zeroConf = true) - assertEquals(alice0.commitments.latest.fundingAmount, 15_000_000.sat) - assertEquals(alice0.commitments.latest.localCommit.spec.toLocal, 200_000_000.msat) - // If we applied the default 1% reserve, Alice's balance couldn't go below 150 000 sats. - // Alice still needs to pay the commit tx fees, so she cannot spend her entire balance. - val (nodes1, r, htlc) = addHtlc(160_000_000.msat, alice0, bob0) - val (alice2, bob2) = crossSign(nodes1.first, nodes1.second) - val (alice3, bob3) = fulfillHtlc(htlc.id, r, alice2, bob2) - val (bob4, alice4) = crossSign(bob3, alice3) - assertEquals(alice4.commitments.latest.localCommit.spec.toLocal, 40_000_000.msat) - assertEquals(bob4.commitments.latest.localCommit.spec.toRemote, 40_000_000.msat) - } - @Test fun `recv UpdateAddHtlc -- unexpected id`() { val (_, bob0) = reachNormal() @@ -475,7 +460,7 @@ class NormalTestsCommon : LightningTestSuite() { @Test fun `recv UpdateAddHtlc -- insufficient funds`() { val (_, bob0) = reachNormal() - val add = UpdateAddHtlc(bob0.channelId, 0, 800_000_000.msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(bob0.currentBlockHeight.toLong()), TestConstants.emptyOnionPacket) + val add = UpdateAddHtlc(bob0.channelId, 0, 850_000_000.msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(bob0.currentBlockHeight.toLong()), TestConstants.emptyOnionPacket) val (bob1, actions1) = bob0.process(ChannelCommand.MessageReceived(add)) assertIs>(bob1) val error = actions1.hasOutgoingMessage() @@ -495,20 +480,20 @@ class NormalTestsCommon : LightningTestSuite() { val (bob4, actions4) = bob3.process(ChannelCommand.MessageReceived(add.copy(id = 3, amountMsat = 800_000_000.msat))) assertIs>(bob4) val error = actions4.hasOutgoingMessage() - assertEquals(error.toAscii(), InsufficientFunds(bob0.channelId, 800_000_000.msat, 64_720.sat, 10_000.sat, 9_720.sat).message) + assertEquals(error.toAscii(), InsufficientFunds(bob0.channelId, 800_000_000.msat, 14_720.sat, 10_000.sat, 9_720.sat).message) } @Test fun `recv UpdateAddHtlc -- over max in-flight htlc value`() { val alice0 = run { val (alice, _) = reachNormal() - alice.copy(state = alice.state.copy(commitments = alice.commitments.copy(params = alice.commitments.params.copy(localParams = alice.commitments.params.localParams.copy(maxHtlcValueInFlightMsat = 150_000_000))))) + alice.copy(state = alice.state.copy(commitments = alice.commitments.copy(params = alice.commitments.params.copy(localParams = alice.commitments.params.localParams.copy(maxHtlcValueInFlightMsat = 100_000_000))))) } - val add = UpdateAddHtlc(alice0.channelId, 0, 151_000_000.msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(alice0.currentBlockHeight.toLong()), TestConstants.emptyOnionPacket) + val add = UpdateAddHtlc(alice0.channelId, 0, 101_000_000.msat, randomBytes32(), CltvExpiryDelta(144).toCltvExpiry(alice0.currentBlockHeight.toLong()), TestConstants.emptyOnionPacket) val (alice1, actions1) = alice0.process(ChannelCommand.MessageReceived(add)) assertIs>(alice1) val error = actions1.hasOutgoingMessage() - assertEquals(error.toAscii(), HtlcValueTooHighInFlight(alice0.channelId, 150_000_000UL, 151_000_000.msat).message) + assertEquals(error.toAscii(), HtlcValueTooHighInFlight(alice0.channelId, 100_000_000UL, 101_000_000.msat).message) } @Test @@ -717,7 +702,7 @@ class NormalTestsCommon : LightningTestSuite() { @Test fun `recv ChannelCommand_Sign -- going above reserve`() { - val (alice0, bob0) = reachNormal(bobFundingAmount = 0.sat, alicePushAmount = 0.msat) + val (alice0, bob0) = reachNormal(bobFundingAmount = 0.sat) assertEquals(0.msat, bob0.commitments.availableBalanceForSend()) val (nodes1, preimage, htlc) = addHtlc(50_000_000.msat, alice0, bob0) val (alice1, bob1) = nodes1 @@ -1874,7 +1859,7 @@ class NormalTestsCommon : LightningTestSuite() { claimHtlcTx.txOut[0].amount }.sum() // at best we have a little less than 450 000 + 250 000 + 100 000 + 50 000 = 850 000 (because fees) - assertEquals(829_710.sat, amountClaimed) + assertEquals(879_710.sat, amountClaimed) val rcp = aliceClosing.state.remoteCommitPublished!! val watchConfirmed = actions.findWatches() @@ -1944,7 +1929,7 @@ class NormalTestsCommon : LightningTestSuite() { claimHtlcTx.txOut[0].amount }.sum() // at best we have a little less than 500 000 + 250 000 + 100 000 = 850 000 (because fees) - assertEquals(833_440.sat, amountClaimed) + assertEquals(883_440.sat, amountClaimed) val rcp = aliceClosing.state.nextRemoteCommitPublished!! val watchConfirmed = actions9.findWatches() @@ -2032,8 +2017,8 @@ class NormalTestsCommon : LightningTestSuite() { assertEquals(htlcInputs + mainPenaltyTx.txIn.first().outPoint, actions2.findWatches().map { OutPoint(it.txId, it.outputIndex.toLong()) }.toSet()) // two main outputs are 760 000 and 200 000 (minus fees) - assertEquals(748_070.sat, mainOutputTx.txOut[0].amount) - assertEquals(197_580.sat, mainPenaltyTx.txOut[0].amount) + assertEquals(798_070.sat, mainOutputTx.txOut[0].amount) + assertEquals(147_580.sat, mainPenaltyTx.txOut[0].amount) assertEquals(7_255.sat, htlcPenaltyTxs[0].txOut[0].amount) assertEquals(7_255.sat, htlcPenaltyTxs[1].txOut[0].amount) assertEquals(7_255.sat, htlcPenaltyTxs[2].txOut[0].amount) @@ -2257,7 +2242,7 @@ class NormalTestsCommon : LightningTestSuite() { @Test fun `receive Error -- nothing at stake`() { - val (_, bob0) = reachNormal(bobFundingAmount = 0.sat, alicePushAmount = 0.msat) + val (_, bob0) = reachNormal(bobFundingAmount = 0.sat) val bobCommitTx = bob0.commitments.latest.localCommit.publishableTxs.commitTx.tx val (bob1, actions) = bob0.process(ChannelCommand.MessageReceived(Error(ByteVector32.Zeroes, "oops"))) val txs = actions.filterIsInstance().map { it.tx } diff --git a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/OfflineTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/OfflineTestsCommon.kt index e1810a8fd..9761b524c 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/OfflineTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/OfflineTestsCommon.kt @@ -574,7 +574,7 @@ class OfflineTestsCommon : LightningTestSuite() { @Test fun `republish unconfirmed funding tx after restart`() { - val (alice, bob, fundingTx) = WaitForFundingConfirmedTestsCommon.init(ChannelType.SupportedChannelType.AnchorOutputs, alicePushAmount = 0.msat) + val (alice, bob, fundingTx) = WaitForFundingConfirmedTestsCommon.init(ChannelType.SupportedChannelType.AnchorOutputs) // Alice restarts: val (alice1, actionsAlice1) = LNChannel(alice.ctx, WaitForInit).process(ChannelCommand.Init.Restore(alice.state)) assertEquals(alice1.state, Offline(alice.state)) @@ -613,7 +613,7 @@ class OfflineTestsCommon : LightningTestSuite() { @Test fun `recv BITCOIN_FUNDING_DEPTHOK`() { - val (alice, bob, _) = WaitForFundingConfirmedTestsCommon.init(ChannelType.SupportedChannelType.AnchorOutputs, alicePushAmount = 0.msat) + val (alice, bob, _) = WaitForFundingConfirmedTestsCommon.init(ChannelType.SupportedChannelType.AnchorOutputs) val fundingTx = alice.state.latestFundingTx.sharedTx.tx.buildUnsignedTx() val (alice1, bob1) = disconnect(alice, bob) // outer state is Offline, we check the inner states @@ -639,7 +639,7 @@ class OfflineTestsCommon : LightningTestSuite() { @Test fun `recv BITCOIN_FUNDING_DEPTHOK -- previous funding tx`() { - val (alice, bob, previousFundingTx, walletAlice) = WaitForFundingConfirmedTestsCommon.init(ChannelType.SupportedChannelType.AnchorOutputs, alicePushAmount = 0.msat) + val (alice, bob, previousFundingTx, walletAlice) = WaitForFundingConfirmedTestsCommon.init(ChannelType.SupportedChannelType.AnchorOutputs) val (alice1, bob1) = WaitForFundingConfirmedTestsCommon.rbf(alice, bob, walletAlice) val (alice2, bob2) = disconnect(alice1, bob1) assertIs(alice2.state.state) diff --git a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/SpliceTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/SpliceTestsCommon.kt index 8996ee4e3..9c8422ba1 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/SpliceTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/SpliceTestsCommon.kt @@ -13,6 +13,7 @@ import fr.acinq.lightning.channel.TestsHelper.fulfillHtlc import fr.acinq.lightning.channel.TestsHelper.reachNormal import fr.acinq.lightning.channel.TestsHelper.useAlternativeCommitSig import fr.acinq.lightning.crypto.KeyManager +import fr.acinq.lightning.tests.TestConstants import fr.acinq.lightning.tests.utils.LightningTestSuite import fr.acinq.lightning.transactions.Transactions import fr.acinq.lightning.transactions.incomings @@ -134,8 +135,8 @@ class SpliceTestsCommon : LightningTestSuite() { val revBob2 = actionsBob7.findOutgoingMessage() val (alice7, _) = alice6.process(ChannelCommand.MessageReceived(revBob2)) assertIs>(alice7) - assertEquals(785_000_000.msat, alice7.commitments.latest.localCommit.spec.toLocal) - assertEquals(190_000_000.msat, alice7.commitments.latest.localCommit.spec.toRemote) + assertEquals(835_000_000.msat, alice7.commitments.latest.localCommit.spec.toLocal) + assertEquals(140_000_000.msat, alice7.commitments.latest.localCommit.spec.toRemote) assertEquals(1, alice7.commitments.localCommitIndex) assertEquals(2, alice7.commitments.remoteCommitIndex) assertEquals(2, bob7.commitments.localCommitIndex) @@ -154,7 +155,7 @@ class SpliceTestsCommon : LightningTestSuite() { fun `splice funds out -- would go below reserve`() { val (alice, bob) = reachNormalWithConfirmedFundingTx() val (alice1, bob1, _) = setupHtlcs(alice, bob) - val cmd = createSpliceOutRequest(760_000.sat) + val cmd = createSpliceOutRequest(810_000.sat) val (alice2, actionsAlice2) = alice1.process(cmd) val aliceStfu = actionsAlice2.findOutgoingMessage() @@ -181,8 +182,8 @@ class SpliceTestsCommon : LightningTestSuite() { val (alice4, bob4) = fulfillHtlc(0, preimage, alice3, bob3) val (_, alice5) = crossSign(bob4, alice4, commitmentsCount = 4) val fee3 = spliceFee(alice5, capacity = 1_000_000.sat - fee1 - fee2) - assertEquals(alice5.state.commitments.latest.localCommit.spec.toLocal, 800_000_000.msat - (fee1 + fee2 + fee3).toMilliSatoshi() - 15_000_000.msat) - assertEquals(alice5.state.commitments.latest.localCommit.spec.toRemote, 200_000_000.msat + 15_000_000.msat) + assertEquals(alice5.state.commitments.latest.localCommit.spec.toLocal, TestConstants.aliceFundingAmount.toMilliSatoshi() - (fee1 + fee2 + fee3).toMilliSatoshi() - 15_000_000.msat) + assertEquals(alice5.state.commitments.latest.localCommit.spec.toRemote, TestConstants.bobFundingAmount.toMilliSatoshi() + 15_000_000.msat) } @Test @@ -206,7 +207,7 @@ class SpliceTestsCommon : LightningTestSuite() { run { val willFund = fundingRates.validateRequest(bob.staticParams.nodeParams.nodePrivateKey, fundingScript, cmd.feerate, spliceInit.requestFunding!!, isChannelCreation = false, 0.msat)?.willFund assertNotNull(willFund) - val spliceAck = SpliceAck(alice.channelId, liquidityRequest.requestedAmount, 0.msat, defaultSpliceAck.fundingPubkey, willFund) + val spliceAck = SpliceAck(alice.channelId, liquidityRequest.requestedAmount, defaultSpliceAck.fundingPubkey, willFund) val (alice2, actionsAlice2) = alice1.process(ChannelCommand.MessageReceived(spliceAck)) assertIs(alice2.state) assertIs(alice2.state.spliceStatus) @@ -225,7 +226,7 @@ class SpliceTestsCommon : LightningTestSuite() { // Bob uses a different funding script than what Alice expects. val willFund = fundingRates.validateRequest(bob.staticParams.nodeParams.nodePrivateKey, ByteVector("deadbeef"), cmd.feerate, spliceInit.requestFunding!!, isChannelCreation = false, 0.msat)?.willFund assertNotNull(willFund) - val spliceAck = SpliceAck(alice.channelId, liquidityRequest.requestedAmount, 0.msat, defaultSpliceAck.fundingPubkey, willFund) + val spliceAck = SpliceAck(alice.channelId, liquidityRequest.requestedAmount, defaultSpliceAck.fundingPubkey, willFund) val (alice2, actionsAlice2) = alice1.process(ChannelCommand.MessageReceived(spliceAck)) assertIs(alice2.state) assertIs(alice2.state.spliceStatus) @@ -233,7 +234,7 @@ class SpliceTestsCommon : LightningTestSuite() { } run { // Bob doesn't fund the splice. - val spliceAck = SpliceAck(alice.channelId, liquidityRequest.requestedAmount, 0.msat, defaultSpliceAck.fundingPubkey, willFund = null) + val spliceAck = SpliceAck(alice.channelId, liquidityRequest.requestedAmount, defaultSpliceAck.fundingPubkey, willFund = null) val (alice2, actionsAlice2) = alice1.process(ChannelCommand.MessageReceived(spliceAck)) assertIs(alice2.state) assertIs(alice2.state.spliceStatus) @@ -243,7 +244,7 @@ class SpliceTestsCommon : LightningTestSuite() { @Test fun `splice to purchase inbound liquidity -- not enough funds`() { - val (alice, bob) = reachNormal(channelType = ChannelType.SupportedChannelType.AnchorOutputsZeroReserve, aliceFundingAmount = 100_000.sat, bobFundingAmount = 10_000.sat, alicePushAmount = 0.msat, bobPushAmount = 0.msat) + val (alice, bob) = reachNormal(channelType = ChannelType.SupportedChannelType.AnchorOutputsZeroReserve, aliceFundingAmount = 100_000.sat, bobFundingAmount = 10_000.sat) val fundingRate = LiquidityAds.FundingRate(100_000.sat, 10_000_000.sat, 0, 100 /* 1% */, 0.sat, 1000.sat) val fundingRates = LiquidityAds.WillFundRates(listOf(fundingRate), setOf(LiquidityAds.PaymentType.FromChannelBalance, LiquidityAds.PaymentType.FromFutureHtlc)) run { @@ -313,7 +314,7 @@ class SpliceTestsCommon : LightningTestSuite() { @Test fun `splice to purchase inbound liquidity -- not enough funds but on-the-fly funding`() { - val (alice, bob) = reachNormal(channelType = ChannelType.SupportedChannelType.AnchorOutputsZeroReserve, bobFundingAmount = 0.sat, alicePushAmount = 0.msat, bobPushAmount = 0.msat) + val (alice, bob) = reachNormal(channelType = ChannelType.SupportedChannelType.AnchorOutputsZeroReserve, bobFundingAmount = 0.sat) val fundingRate = LiquidityAds.FundingRate(0.sat, 500_000.sat, 0, 50, 0.sat, 1000.sat) val fundingRates = LiquidityAds.WillFundRates(listOf(fundingRate), setOf(LiquidityAds.PaymentType.FromChannelBalanceForFutureHtlc, LiquidityAds.PaymentType.FromFutureHtlc)) val origin = Origin.OffChainPayment(randomBytes32(), 25_000_000.msat, ChannelManagementFees(0.sat, 500.sat)) @@ -1574,7 +1575,7 @@ class SpliceTestsCommon : LightningTestSuite() { val response = replyTo.await() assertIs(response) assertEquals(response.capacity, parentCommitment.fundingAmount + spliceInit.fundingContribution) - assertEquals(response.balance, parentCommitment.localCommit.spec.toLocal + spliceInit.fundingContribution.toMilliSatoshi() - spliceInit.pushAmount) + assertEquals(response.balance, parentCommitment.localCommit.spec.toLocal + spliceInit.fundingContribution.toMilliSatoshi()) assertEquals(response.fundingTxIndex, parentCommitment.fundingTxIndex + 1) response.fundingTxId } @@ -1853,8 +1854,8 @@ class SpliceTestsCommon : LightningTestSuite() { assertIs(alice5.state) assertEquals(1_000_000.sat, alice5.state.commitments.latest.fundingAmount) - assertEquals(770_000_000.msat, alice5.state.commitments.latest.localCommit.spec.toLocal) - assertEquals(165_000_000.msat, alice5.state.commitments.latest.localCommit.spec.toRemote) + assertEquals(820_000_000.msat, alice5.state.commitments.latest.localCommit.spec.toLocal) + assertEquals(115_000_000.msat, alice5.state.commitments.latest.localCommit.spec.toRemote) val aliceToBob = listOf(Pair(preimage1, add1), Pair(preimage2, add2)) val bobToAlice = listOf(Pair(preimage3, add3), Pair(preimage4, add4)) diff --git a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/SyncingTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/SyncingTestsCommon.kt index e696c284d..e69527e5e 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/SyncingTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/SyncingTestsCommon.kt @@ -266,7 +266,7 @@ class SyncingTestsCommon : LightningTestSuite() { @Test fun `recv BITCOIN_FUNDING_DEPTHOK`() { - val (alice, bob, _) = WaitForFundingConfirmedTestsCommon.init(ChannelType.SupportedChannelType.AnchorOutputs, alicePushAmount = 0.msat) + val (alice, bob, _) = WaitForFundingConfirmedTestsCommon.init(ChannelType.SupportedChannelType.AnchorOutputs) val fundingTx = alice.state.latestFundingTx.sharedTx.tx.buildUnsignedTx() val (alice1, bob1, _) = disconnectWithBackup(alice, bob) assertIs(alice1.state.state) diff --git a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForAcceptChannelTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForAcceptChannelTestsCommon.kt index 97cdda5fc..ad9881e56 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForAcceptChannelTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForAcceptChannelTestsCommon.kt @@ -3,15 +3,16 @@ package fr.acinq.lightning.channel.states import fr.acinq.bitcoin.ByteVector32 import fr.acinq.bitcoin.Chain import fr.acinq.bitcoin.Satoshi -import fr.acinq.lightning.* +import fr.acinq.lightning.ChannelEvents +import fr.acinq.lightning.CltvExpiryDelta +import fr.acinq.lightning.Feature +import fr.acinq.lightning.Features import fr.acinq.lightning.Lightning.randomBytes64 import fr.acinq.lightning.channel.* import fr.acinq.lightning.tests.TestConstants import fr.acinq.lightning.tests.utils.LightningTestSuite import fr.acinq.lightning.tests.utils.runSuspendTest -import fr.acinq.lightning.utils.msat import fr.acinq.lightning.utils.sat -import fr.acinq.lightning.utils.toMilliSatoshi import fr.acinq.lightning.wire.* import kotlin.test.* @@ -139,16 +140,6 @@ class WaitForAcceptChannelTestsCommon : LightningTestSuite() { assertEquals(error, Error(accept.temporaryChannelId, InvalidMaxAcceptedHtlcs(accept.temporaryChannelId, invalidMaxAcceptedHtlcs, Channel.MAX_ACCEPTED_HTLCS).message)) } - @Test - fun `recv AcceptChannel -- invalid push_amount`() { - val (alice, _, accept) = init(bobFundingAmount = TestConstants.bobFundingAmount, bobPushAmount = TestConstants.bobFundingAmount.toMilliSatoshi() + 1.msat) - assertEquals(accept.pushAmount, TestConstants.bobFundingAmount.toMilliSatoshi() + 1.msat) - val (alice1, actions) = alice.process(ChannelCommand.MessageReceived(accept)) - val error = actions.findOutgoingMessage() - assertEquals(error, Error(accept.temporaryChannelId, InvalidPushAmount(accept.temporaryChannelId, accept.fundingAmount.toMilliSatoshi() + 1.msat, accept.fundingAmount.toMilliSatoshi()).message)) - assertIs>(alice1) - } - @Test fun `recv AcceptChannel -- dust limit too low`() { val (alice, _, accept) = init() @@ -200,14 +191,11 @@ class WaitForAcceptChannelTestsCommon : LightningTestSuite() { currentHeight: Int = TestConstants.defaultBlockHeight, aliceFundingAmount: Satoshi = TestConstants.aliceFundingAmount, bobFundingAmount: Satoshi = TestConstants.bobFundingAmount, - alicePushAmount: MilliSatoshi = TestConstants.alicePushAmount, - bobPushAmount: MilliSatoshi = TestConstants.bobPushAmount, requestRemoteFunding: Satoshi? = null, zeroConf: Boolean = false, ): Triple, LNChannel, AcceptDualFundedChannel> { - val (alice, bob, open) = TestsHelper.init(channelType, aliceFeatures, bobFeatures, currentHeight, aliceFundingAmount, bobFundingAmount, alicePushAmount, bobPushAmount, requestRemoteFunding, zeroConf) + val (alice, bob, open) = TestsHelper.init(channelType, aliceFeatures, bobFeatures, currentHeight, aliceFundingAmount, bobFundingAmount, requestRemoteFunding, zeroConf) assertEquals(open.fundingAmount, aliceFundingAmount) - assertEquals(open.pushAmount, alicePushAmount) assertEquals(open.channelType, channelType) requestRemoteFunding?.let { assertTrue(open.channelFlags.nonInitiatorPaysCommitFees) @@ -218,7 +206,6 @@ class WaitForAcceptChannelTestsCommon : LightningTestSuite() { val accept = actions.hasOutgoingMessage() assertEquals(open.temporaryChannelId, accept.temporaryChannelId) assertEquals(accept.fundingAmount, bobFundingAmount) - assertEquals(accept.pushAmount, bobPushAmount) assertEquals(accept.channelType, channelType) when (zeroConf) { true -> assertEquals(0, accept.minimumDepth) diff --git a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForChannelReadyTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForChannelReadyTestsCommon.kt index c5f5f8375..965cc58b5 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForChannelReadyTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForChannelReadyTestsCommon.kt @@ -4,13 +4,10 @@ import fr.acinq.bitcoin.Satoshi import fr.acinq.bitcoin.Transaction import fr.acinq.lightning.ChannelEvents import fr.acinq.lightning.Features -import fr.acinq.lightning.MilliSatoshi import fr.acinq.lightning.blockchain.* import fr.acinq.lightning.channel.* import fr.acinq.lightning.tests.TestConstants import fr.acinq.lightning.tests.utils.LightningTestSuite -import fr.acinq.lightning.utils.msat -import fr.acinq.lightning.utils.toMilliSatoshi import fr.acinq.lightning.wire.* import kotlin.test.* @@ -77,40 +74,6 @@ class WaitForChannelReadyTestsCommon : LightningTestSuite() { assertIs(actionsBob1.find().event) } - @Test - fun `recv FundingLocked -- push amount on both sides`() { - val (alice, fundingLockedAlice, bob, fundingLockedBob) = init(bobPushAmount = 25_000_000.msat) - val aliceBalance = TestConstants.aliceFundingAmount.toMilliSatoshi() - TestConstants.alicePushAmount + 25_000_000.msat - assertEquals(aliceBalance, 825_000_000.msat) - val bobBalance = TestConstants.bobFundingAmount.toMilliSatoshi() - 25_000_000.msat + TestConstants.alicePushAmount - assertEquals(bobBalance, 175_000_000.msat) - val (alice1, _) = alice.process(ChannelCommand.MessageReceived(fundingLockedBob)) - assertIs(alice1.state) - assertEquals(alice1.commitments.latest.localCommit.spec.toLocal, aliceBalance) - assertEquals(alice1.commitments.latest.localCommit.spec.toRemote, bobBalance) - val (bob1, _) = bob.process(ChannelCommand.MessageReceived(fundingLockedAlice)) - assertIs(bob1.state) - assertEquals(bob1.commitments.latest.localCommit.spec.toLocal, bobBalance) - assertEquals(bob1.commitments.latest.localCommit.spec.toRemote, aliceBalance) - } - - @Test - fun `recv FundingLocked -- push amount on both sides -- zero-conf`() { - val (alice, fundingLockedAlice, bob, fundingLockedBob) = init(bobPushAmount = 25_000_000.msat, zeroConf = true) - val aliceBalance = TestConstants.aliceFundingAmount.toMilliSatoshi() - TestConstants.alicePushAmount + 25_000_000.msat - assertEquals(aliceBalance, 825_000_000.msat) - val bobBalance = TestConstants.bobFundingAmount.toMilliSatoshi() - 25_000_000.msat + TestConstants.alicePushAmount - assertEquals(bobBalance, 175_000_000.msat) - val (alice1, _) = alice.process(ChannelCommand.MessageReceived(fundingLockedBob)) - assertIs(alice1.state) - assertEquals(alice1.commitments.latest.localCommit.spec.toLocal, aliceBalance) - assertEquals(alice1.commitments.latest.localCommit.spec.toRemote, bobBalance) - val (bob1, _) = bob.process(ChannelCommand.MessageReceived(fundingLockedAlice)) - assertIs(bob1.state) - assertEquals(bob1.commitments.latest.localCommit.spec.toLocal, bobBalance) - assertEquals(bob1.commitments.latest.localCommit.spec.toRemote, aliceBalance) - } - @Test fun `recv BITCOIN_FUNDING_SPENT -- remote commit`() { val (alice, _, bob, _) = init() @@ -199,13 +162,11 @@ class WaitForChannelReadyTestsCommon : LightningTestSuite() { currentHeight: Int = TestConstants.defaultBlockHeight, aliceFundingAmount: Satoshi = TestConstants.aliceFundingAmount, bobFundingAmount: Satoshi = TestConstants.bobFundingAmount, - alicePushAmount: MilliSatoshi = TestConstants.alicePushAmount, - bobPushAmount: MilliSatoshi = TestConstants.bobPushAmount, requestRemoteFunding: Satoshi? = null, zeroConf: Boolean = false, ): Fixture { return if (zeroConf) { - val (alice, commitAlice, bob, commitBob) = WaitForFundingSignedTestsCommon.init(channelType, aliceFeatures, bobFeatures, currentHeight, aliceFundingAmount, bobFundingAmount, alicePushAmount, bobPushAmount, requestRemoteFunding, zeroConf) + val (alice, commitAlice, bob, commitBob) = WaitForFundingSignedTestsCommon.init(channelType, aliceFeatures, bobFeatures, currentHeight, aliceFundingAmount, bobFundingAmount, requestRemoteFunding, zeroConf) val (alice1, actionsAlice1) = alice.process(ChannelCommand.MessageReceived(commitBob)) assertIs>(alice1) assertTrue(actionsAlice1.isEmpty()) @@ -222,7 +183,7 @@ class WaitForChannelReadyTestsCommon : LightningTestSuite() { actionsAlice2.has() Fixture(alice2, channelReadyAlice, bob1, channelReadyBob) } else { - val (alice, bob, fundingTx) = WaitForFundingConfirmedTestsCommon.init(channelType, aliceFeatures, bobFeatures, currentHeight, aliceFundingAmount, bobFundingAmount, alicePushAmount, bobPushAmount, requestRemoteFunding) + val (alice, bob, fundingTx) = WaitForFundingConfirmedTestsCommon.init(channelType, aliceFeatures, bobFeatures, currentHeight, aliceFundingAmount, bobFundingAmount, requestRemoteFunding) val (alice1, actionsAlice1) = alice.process(ChannelCommand.WatchReceived(WatchEventConfirmed(alice.channelId, BITCOIN_FUNDING_DEPTHOK, 42, 0, fundingTx))) assertIs>(alice1) val channelReadyAlice = actionsAlice1.findOutgoingMessage() diff --git a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForFundingConfirmedTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForFundingConfirmedTestsCommon.kt index 4d0324fee..51c66cc51 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForFundingConfirmedTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForFundingConfirmedTestsCommon.kt @@ -5,14 +5,12 @@ import fr.acinq.lightning.Feature import fr.acinq.lightning.Features import fr.acinq.lightning.Lightning.randomBytes32 import fr.acinq.lightning.Lightning.randomKey -import fr.acinq.lightning.MilliSatoshi import fr.acinq.lightning.blockchain.* import fr.acinq.lightning.blockchain.electrum.WalletState import fr.acinq.lightning.blockchain.fee.FeeratePerKw import fr.acinq.lightning.channel.* import fr.acinq.lightning.tests.TestConstants import fr.acinq.lightning.tests.utils.LightningTestSuite -import fr.acinq.lightning.utils.msat import fr.acinq.lightning.utils.sat import fr.acinq.lightning.wire.* import kotlin.test.* @@ -207,17 +205,6 @@ class WaitForFundingConfirmedTestsCommon : LightningTestSuite() { assertTrue(actions2.isEmpty()) } - @Test - fun `recv TxInitRbf -- invalid push amount`() { - val (alice, bob, _) = init(ChannelType.SupportedChannelType.AnchorOutputs) - val (bob1, actions1) = bob.process(ChannelCommand.MessageReceived(TxInitRbf(alice.state.channelId, 0, TestConstants.feeratePerKw * 1.25, TestConstants.alicePushAmount.truncateToSatoshi() - 1.sat))) - assertEquals(actions1.size, 1) - assertEquals(actions1.hasOutgoingMessage().toAscii(), InvalidPushAmount(alice.state.channelId, TestConstants.alicePushAmount, TestConstants.alicePushAmount - 1000.msat).message) - val (bob2, actions2) = bob1.process(ChannelCommand.MessageReceived(TxAbort(alice.state.channelId, "acking tx_abort"))) - assertEquals(bob2, bob) - assertTrue(actions2.isEmpty()) - } - @Test fun `recv TxInitRbf -- failed rbf attempt`() { val (alice, bob, _) = init(ChannelType.SupportedChannelType.AnchorOutputs) @@ -254,7 +241,7 @@ class WaitForFundingConfirmedTestsCommon : LightningTestSuite() { @Test fun `recv ChannelReady -- no remote contribution`() { - val (alice, bob, _) = init(ChannelType.SupportedChannelType.AnchorOutputs, bobFundingAmount = 0.sat, alicePushAmount = 0.msat) + val (alice, bob, _) = init(ChannelType.SupportedChannelType.AnchorOutputs, bobFundingAmount = 0.sat) val channelReadyAlice = ChannelReady(alice.state.channelId, randomKey().publicKey()) val channelReadyBob = ChannelReady(bob.state.channelId, randomKey().publicKey()) val (alice1, actionsAlice1) = alice.process(ChannelCommand.MessageReceived(channelReadyBob)) @@ -396,8 +383,6 @@ class WaitForFundingConfirmedTestsCommon : LightningTestSuite() { currentHeight: Int = TestConstants.defaultBlockHeight, aliceFundingAmount: Satoshi = TestConstants.aliceFundingAmount, bobFundingAmount: Satoshi = TestConstants.bobFundingAmount, - alicePushAmount: MilliSatoshi = TestConstants.alicePushAmount, - bobPushAmount: MilliSatoshi = TestConstants.bobPushAmount, requestRemoteFunding: Satoshi? = null, ): Fixture { val (alice, commitAlice, bob, commitBob, walletAlice) = WaitForFundingSignedTestsCommon.init( @@ -407,8 +392,6 @@ class WaitForFundingConfirmedTestsCommon : LightningTestSuite() { currentHeight, aliceFundingAmount, bobFundingAmount, - alicePushAmount, - bobPushAmount, requestRemoteFunding, zeroConf = false ) diff --git a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForFundingCreatedTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForFundingCreatedTestsCommon.kt index bd89f3ae4..f0e069a46 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForFundingCreatedTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForFundingCreatedTestsCommon.kt @@ -66,7 +66,7 @@ class WaitForFundingCreatedTestsCommon : LightningTestSuite() { assertEquals(bob3.state.channelParams.channelFeatures, ChannelFeatures(setOf(Feature.StaticRemoteKey, Feature.AnchorOutputs, Feature.DualFunding))) assertIs(alice.state.replyTo.await()).also { assertEquals(0, it.fundingTxIndex) } assertIs(bob.state.replyTo.await()).also { assertEquals(0, it.fundingTxIndex) } - verifyCommits(alice2.state.signingSession, bob3.state.signingSession, TestConstants.aliceFundingAmount.toMilliSatoshi() - TestConstants.alicePushAmount, TestConstants.alicePushAmount) + verifyCommits(alice2.state.signingSession, bob3.state.signingSession, TestConstants.aliceFundingAmount.toMilliSatoshi(), 0.msat) } @Test @@ -94,15 +94,15 @@ class WaitForFundingCreatedTestsCommon : LightningTestSuite() { verifyCommits( alice2.state.signingSession, bob3.state.signingSession, - TestConstants.aliceFundingAmount.toMilliSatoshi() - TestConstants.alicePushAmount, - TestConstants.bobFundingAmount.toMilliSatoshi() + TestConstants.alicePushAmount + TestConstants.aliceFundingAmount.toMilliSatoshi(), + TestConstants.bobFundingAmount.toMilliSatoshi() ) } @Test fun `complete interactive-tx protocol -- with large non-initiator contributions`() { // Alice's funding amount is below the channel reserve: this is ok as long as she can pay the commit tx fees. - val (alice, bob, inputAlice) = init(ChannelType.SupportedChannelType.AnchorOutputs, aliceFundingAmount = 10_000.sat, bobFundingAmount = 1_500_000.sat, alicePushAmount = 0.msat, bobPushAmount = 0.msat) + val (alice, bob, inputAlice) = init(ChannelType.SupportedChannelType.AnchorOutputs, aliceFundingAmount = 10_000.sat, bobFundingAmount = 1_500_000.sat) // Alice ---- tx_add_input ----> Bob val (bob1, actionsBob1) = bob.process(ChannelCommand.MessageReceived(inputAlice)) // Alice <--- tx_add_input ----- Bob @@ -127,7 +127,7 @@ class WaitForFundingCreatedTestsCommon : LightningTestSuite() { @Test fun `complete interactive-tx protocol -- zero conf -- zero reserve`() { - val (alice, bob, inputAlice) = init(ChannelType.SupportedChannelType.AnchorOutputsZeroReserve, alicePushAmount = 0.msat, zeroConf = true) + val (alice, bob, inputAlice) = init(ChannelType.SupportedChannelType.AnchorOutputsZeroReserve, zeroConf = true) // Alice ---- tx_add_input ----> Bob val (bob1, actionsBob1) = bob.process(ChannelCommand.MessageReceived(inputAlice)) // Alice <--- tx_add_input ----- Bob @@ -150,28 +150,9 @@ class WaitForFundingCreatedTestsCommon : LightningTestSuite() { verifyCommits(alice2.state.signingSession, bob3.state.signingSession, TestConstants.aliceFundingAmount.toMilliSatoshi(), TestConstants.bobFundingAmount.toMilliSatoshi()) } - @Test - fun `complete interactive-tx protocol -- initiator can't pay fees`() = runSuspendTest { - val (alice, bob, inputAlice) = init(ChannelType.SupportedChannelType.AnchorOutputs, aliceFundingAmount = 1_000_100.sat, bobFundingAmount = 0.sat, alicePushAmount = 1_000_000.sat.toMilliSatoshi()) - // Alice ---- tx_add_input ----> Bob - val (bob1, actionsBob1) = bob.process(ChannelCommand.MessageReceived(inputAlice)) - // Alice <--- tx_complete ----- Bob - val (alice1, actionsAlice1) = alice.process(ChannelCommand.MessageReceived(actionsBob1.findOutgoingMessage())) - // Alice ---- tx_add_output ----> Bob - val (bob2, actionsBob2) = bob1.process(ChannelCommand.MessageReceived(actionsAlice1.findOutgoingMessage())) - // Alice <--- tx_complete ----- Bob - val (alice2, actionsAlice2) = alice1.process(ChannelCommand.MessageReceived(actionsBob2.findOutgoingMessage())) - assertIs(alice2.state) - // Alice ---- tx_complete ----> Bob - val (bob3, actionsBob3) = bob2.process(ChannelCommand.MessageReceived(actionsAlice2.findOutgoingMessage())) - actionsBob3.hasOutgoingMessage() - assertIs(bob3.state) - assertIs(bob.state.replyTo.await()) - } - @Test fun `recv invalid interactive-tx message`() { - val (_, bob, inputAlice) = init(ChannelType.SupportedChannelType.AnchorOutputs, bobFundingAmount = 0.sat, alicePushAmount = 0.msat) + val (_, bob, inputAlice) = init(ChannelType.SupportedChannelType.AnchorOutputs, bobFundingAmount = 0.sat) run { // Invalid serial_id. val (bob1, actionsBob1) = bob.process(ChannelCommand.MessageReceived(inputAlice.copy(serialId = 1))) @@ -189,7 +170,7 @@ class WaitForFundingCreatedTestsCommon : LightningTestSuite() { @Test fun `recv CommitSig`() { - val (alice, bob, _) = init(ChannelType.SupportedChannelType.AnchorOutputs, bobFundingAmount = 0.sat, alicePushAmount = 0.msat) + val (alice, bob, _) = init(ChannelType.SupportedChannelType.AnchorOutputs, bobFundingAmount = 0.sat) run { val (alice1, actionsAlice1) = alice.process(ChannelCommand.MessageReceived(CommitSig(alice.channelId, ByteVector64.Zeroes, listOf()))) assertEquals(actionsAlice1.findOutgoingMessage().toAscii(), UnexpectedCommitSig(alice.channelId).message) @@ -204,7 +185,7 @@ class WaitForFundingCreatedTestsCommon : LightningTestSuite() { @Test fun `recv TxSignatures`() { - val (alice, bob, _) = init(ChannelType.SupportedChannelType.AnchorOutputs, bobFundingAmount = 0.sat, alicePushAmount = 0.msat) + val (alice, bob, _) = init(ChannelType.SupportedChannelType.AnchorOutputs, bobFundingAmount = 0.sat) run { val (alice1, actionsAlice1) = alice.process(ChannelCommand.MessageReceived(TxSignatures(alice.channelId, TxId(randomBytes32()), listOf()))) assertEquals(actionsAlice1.findOutgoingMessage().toAscii(), UnexpectedFundingSignatures(alice.channelId).message) @@ -219,7 +200,7 @@ class WaitForFundingCreatedTestsCommon : LightningTestSuite() { @Test fun `recv TxAbort`() { - val (alice, bob, _) = init(ChannelType.SupportedChannelType.AnchorOutputs, bobFundingAmount = 0.sat, alicePushAmount = 0.msat) + val (alice, bob, _) = init(ChannelType.SupportedChannelType.AnchorOutputs, bobFundingAmount = 0.sat) run { val (alice1, actionsAlice1) = alice.process(ChannelCommand.MessageReceived(TxAbort(alice.channelId, "changed my mind"))) assertEquals(actionsAlice1.size, 1) @@ -236,7 +217,7 @@ class WaitForFundingCreatedTestsCommon : LightningTestSuite() { @Test fun `recv TxInitRbf`() { - val (alice, bob, _) = init(ChannelType.SupportedChannelType.AnchorOutputs, bobFundingAmount = 0.sat, alicePushAmount = 0.msat) + val (alice, bob, _) = init(ChannelType.SupportedChannelType.AnchorOutputs, bobFundingAmount = 0.sat) run { val (alice1, actionsAlice1) = alice.process(ChannelCommand.MessageReceived(TxInitRbf(alice.channelId, 0, FeeratePerKw(7500.sat)))) assertEquals(actionsAlice1.size, 1) @@ -253,7 +234,7 @@ class WaitForFundingCreatedTestsCommon : LightningTestSuite() { @Test fun `recv TxAckRbf`() { - val (alice, bob, _) = init(ChannelType.SupportedChannelType.AnchorOutputs, bobFundingAmount = 0.sat, alicePushAmount = 0.msat) + val (alice, bob, _) = init(ChannelType.SupportedChannelType.AnchorOutputs, bobFundingAmount = 0.sat) run { val (alice1, actionsAlice1) = alice.process(ChannelCommand.MessageReceived(TxAckRbf(alice.channelId))) assertEquals(actionsAlice1.size, 1) @@ -306,13 +287,11 @@ class WaitForFundingCreatedTestsCommon : LightningTestSuite() { currentHeight: Int = TestConstants.defaultBlockHeight, aliceFundingAmount: Satoshi = TestConstants.aliceFundingAmount, bobFundingAmount: Satoshi = TestConstants.bobFundingAmount, - alicePushAmount: MilliSatoshi = TestConstants.alicePushAmount, - bobPushAmount: MilliSatoshi = TestConstants.bobPushAmount, requestRemoteFunding: Satoshi? = null, zeroConf: Boolean = false, channelOrigin: Origin? = null ): Fixture { - val (a, b, open) = TestsHelper.init(channelType, aliceFeatures, bobFeatures, currentHeight, aliceFundingAmount, bobFundingAmount, alicePushAmount, bobPushAmount, requestRemoteFunding, zeroConf, channelOrigin) + val (a, b, open) = TestsHelper.init(channelType, aliceFeatures, bobFeatures, currentHeight, aliceFundingAmount, bobFundingAmount, requestRemoteFunding, zeroConf, channelOrigin) val (b1, actions) = b.process(ChannelCommand.MessageReceived(open)) val accept = actions.findOutgoingMessage() assertIs>(b1) diff --git a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForFundingSignedTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForFundingSignedTestsCommon.kt index 3ce3de7f6..c8020305b 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForFundingSignedTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForFundingSignedTestsCommon.kt @@ -36,7 +36,7 @@ class WaitForFundingSignedTestsCommon : LightningTestSuite() { assertEquals(actions.size, 5) actions.hasOutgoingMessage().also { assertFalse(it.channelData.isEmpty()) } actions.findWatch().also { assertEquals(WatchConfirmed(state.channelId, commitInput.outPoint.txid, commitInput.txOut.publicKeyScript, 3, BITCOIN_FUNDING_DEPTHOK), it) } - actions.find().also { assertEquals(TestConstants.bobFundingAmount.toMilliSatoshi() + TestConstants.alicePushAmount - TestConstants.bobPushAmount, it.amountReceived) } + actions.find().also { assertEquals(TestConstants.bobFundingAmount.toMilliSatoshi(), it.amountReceived) } actions.has() actions.find().also { assertEquals(ChannelEvents.Created(state.state), it.event) } } @@ -59,7 +59,7 @@ class WaitForFundingSignedTestsCommon : LightningTestSuite() { actions.hasOutgoingMessage().also { assertFalse(it.channelData.isEmpty()) } actions.hasOutgoingMessage().also { assertEquals(ShortChannelId.peerId(bob.staticParams.nodeParams.nodeId), it.alias) } actions.findWatch().also { assertEquals(state.commitments.latest.fundingTxId, it.txId) } - actions.find().also { assertEquals(TestConstants.bobFundingAmount.toMilliSatoshi() + TestConstants.alicePushAmount - TestConstants.bobPushAmount, it.amountReceived) } + actions.find().also { assertEquals(TestConstants.bobFundingAmount.toMilliSatoshi(), it.amountReceived) } actions.has() actions.find().also { assertEquals(ChannelEvents.Created(state.state), it.event) } } @@ -68,7 +68,7 @@ class WaitForFundingSignedTestsCommon : LightningTestSuite() { @Test fun `recv CommitSig -- liquidity ads`() { - val (alice, commitSigAlice, bob, commitSigBob) = init(requestRemoteFunding = TestConstants.bobFundingAmount, alicePushAmount = 0.msat, bobPushAmount = 0.msat) + val (alice, commitSigAlice, bob, commitSigBob) = init(requestRemoteFunding = TestConstants.bobFundingAmount) val purchase = alice.process(ChannelCommand.MessageReceived(commitSigBob)).let { (state, actions) -> assertIs(state.state) assertTrue(actions.isEmpty()) @@ -93,29 +93,10 @@ class WaitForFundingSignedTestsCommon : LightningTestSuite() { } } - @Test - fun `recv CommitSig -- with channel origin -- off-chain payment`() { - val channelOrigin = Origin.OffChainPayment(randomBytes32(), 50_000_000.msat, ChannelManagementFees(500.sat, 1_000.sat)) - val (alice, _, _, commitSigBob) = init(aliceFundingAmount = 0.sat, alicePushAmount = 0.msat, bobPushAmount = 50_000_000.msat, channelOrigin = channelOrigin) - val (alice1, actionsAlice1) = alice.process(ChannelCommand.MessageReceived(commitSigBob)) - assertIs(alice1.state) - assertEquals(5, actionsAlice1.size) - actionsAlice1.hasOutgoingMessage() - actionsAlice1.has() - actionsAlice1.find().also { - assertEquals(50_000_000.msat, it.amountReceived) - assertEquals(channelOrigin, it.origin) - assertEquals(alice1.commitments.latest.fundingTxId, it.txId) - } - actionsAlice1.hasWatch() - val events = actionsAlice1.filterIsInstance().map { it.event } - assertTrue(events.any { it is ChannelEvents.Created }) - } - @Test fun `recv CommitSig -- with channel origin -- dual-swap-in`() { val channelOrigin = Origin.OnChainWallet(setOf(), 200_000_000.msat, ChannelManagementFees(750.sat, 0.sat)) - val (alice, _, _, commitSigBob) = init(aliceFundingAmount = 200_000.sat, alicePushAmount = 0.msat, bobFundingAmount = 500_000.sat, channelOrigin = channelOrigin) + val (alice, _, _, commitSigBob) = init(aliceFundingAmount = 200_000.sat, bobFundingAmount = 500_000.sat, channelOrigin = channelOrigin) val (alice1, actionsAlice1) = alice.process(ChannelCommand.MessageReceived(commitSigBob)) assertIs(alice1.state) assertEquals(actionsAlice1.size, 6) @@ -180,7 +161,7 @@ class WaitForFundingSignedTestsCommon : LightningTestSuite() { @Test fun `recv TxSignatures -- liquidity ads`() { - val (alice, commitSigAlice, bob, commitSigBob) = init(requestRemoteFunding = TestConstants.bobFundingAmount, alicePushAmount = 0.msat, bobPushAmount = 0.msat) + val (alice, commitSigAlice, bob, commitSigBob) = init(requestRemoteFunding = TestConstants.bobFundingAmount) val commitInput = alice.state.signingSession.commitInput val txSigsBob = run { val (bob1, actionsBob1) = bob.process(ChannelCommand.MessageReceived(commitSigAlice)) @@ -348,8 +329,6 @@ class WaitForFundingSignedTestsCommon : LightningTestSuite() { currentHeight: Int = TestConstants.defaultBlockHeight, aliceFundingAmount: Satoshi = TestConstants.aliceFundingAmount, bobFundingAmount: Satoshi = TestConstants.bobFundingAmount, - alicePushAmount: MilliSatoshi = TestConstants.alicePushAmount, - bobPushAmount: MilliSatoshi = TestConstants.bobPushAmount, requestRemoteFunding: Satoshi? = null, zeroConf: Boolean = false, channelOrigin: Origin? = null @@ -361,8 +340,6 @@ class WaitForFundingSignedTestsCommon : LightningTestSuite() { currentHeight, aliceFundingAmount, bobFundingAmount, - alicePushAmount, - bobPushAmount, requestRemoteFunding, zeroConf, channelOrigin diff --git a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForOpenChannelTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForOpenChannelTestsCommon.kt index f59c71124..16375836c 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForOpenChannelTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/channel/states/WaitForOpenChannelTestsCommon.kt @@ -7,8 +7,11 @@ import fr.acinq.lightning.channel.* import fr.acinq.lightning.tests.TestConstants import fr.acinq.lightning.tests.utils.LightningTestSuite import fr.acinq.lightning.tests.utils.runSuspendTest -import fr.acinq.lightning.utils.* -import fr.acinq.lightning.wire.* +import fr.acinq.lightning.utils.sat +import fr.acinq.lightning.wire.AcceptDualFundedChannel +import fr.acinq.lightning.wire.ChannelTlv +import fr.acinq.lightning.wire.Error +import fr.acinq.lightning.wire.TlvStream import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertIs @@ -19,7 +22,6 @@ class WaitForOpenChannelTestsCommon : LightningTestSuite() { @Test fun `recv OpenChannel -- without wumbo`() { val (_, bob, open) = TestsHelper.init(aliceFeatures = TestConstants.Alice.nodeParams.features.remove(Feature.Wumbo)) - assertEquals(open.pushAmount, TestConstants.alicePushAmount) assertEquals(open.tlvStream.get(), ChannelTlv.ChannelTypeTlv(ChannelType.SupportedChannelType.AnchorOutputs)) val (bob1, actions) = bob.process(ChannelCommand.MessageReceived(open)) assertIs>(bob1) @@ -34,7 +36,6 @@ class WaitForOpenChannelTestsCommon : LightningTestSuite() { @Test fun `recv OpenChannel -- wumbo`() { val (_, bob, open) = TestsHelper.init(aliceFundingAmount = 20_000_000.sat) - assertEquals(open.pushAmount, TestConstants.alicePushAmount) val (bob1, actions) = bob.process(ChannelCommand.MessageReceived(open)) assertIs>(bob1) assertEquals(3, actions.size) @@ -100,16 +101,6 @@ class WaitForOpenChannelTestsCommon : LightningTestSuite() { assertIs>(bob1) } - @Test - fun `recv OpenChannel -- invalid push_amount`() { - val (_, bob, open) = TestsHelper.init(aliceFundingAmount = TestConstants.aliceFundingAmount, alicePushAmount = TestConstants.aliceFundingAmount.toMilliSatoshi() + 1.msat) - assertEquals(open.pushAmount, TestConstants.aliceFundingAmount.toMilliSatoshi() + 1.msat) - val (bob1, actions) = bob.process(ChannelCommand.MessageReceived(open)) - val error = actions.findOutgoingMessage() - assertEquals(error, Error(open.temporaryChannelId, InvalidPushAmount(open.temporaryChannelId, open.fundingAmount.toMilliSatoshi() + 1.msat, open.fundingAmount.toMilliSatoshi()).message)) - assertIs>(bob1) - } - @Test fun `recv OpenChannel -- to_self_delay too high`() { val (_, bob, open) = TestsHelper.init() diff --git a/src/commonTest/kotlin/fr/acinq/lightning/io/peer/PeerTest.kt b/src/commonTest/kotlin/fr/acinq/lightning/io/peer/PeerTest.kt index af58cc686..5bcba2e0d 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/io/peer/PeerTest.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/io/peer/PeerTest.kt @@ -121,7 +121,7 @@ class PeerTest : LightningTestSuite() { val (alice, bob, alice2bob, bob2alice) = newPeers(this, nodeParams, walletParams, automateMessaging = false) val wallet = createWallet(nodeParams.first.keyManager, 300_000.sat).second - alice.send(OpenChannel(250_000.sat, 50_000_000.msat, wallet, FeeratePerKw(3000.sat), FeeratePerKw(2500.sat), ChannelType.SupportedChannelType.AnchorOutputsZeroReserve)) + alice.send(OpenChannel(250_000.sat, wallet, FeeratePerKw(3000.sat), FeeratePerKw(2500.sat), ChannelType.SupportedChannelType.AnchorOutputsZeroReserve)) val open = alice2bob.expect() bob.forward(open) @@ -181,7 +181,7 @@ class PeerTest : LightningTestSuite() { val (alice, bob, alice2bob, bob2alice) = newPeers(this, nodeParams, walletParams, automateMessaging = false) val wallet = createWallet(nodeParams.first.keyManager, 300_000.sat).second - alice.send(OpenChannel(250_000.sat, 50_000_000.msat, wallet, FeeratePerKw(3000.sat), FeeratePerKw(2500.sat), ChannelType.SupportedChannelType.AnchorOutputsZeroReserve)) + alice.send(OpenChannel(250_000.sat, wallet, FeeratePerKw(3000.sat), FeeratePerKw(2500.sat), ChannelType.SupportedChannelType.AnchorOutputsZeroReserve)) val open = alice2bob.expect() bob.forward(open) @@ -486,7 +486,7 @@ class PeerTest : LightningTestSuite() { @Test fun `payment between two nodes -- with disconnection`() = runSuspendTest { - val (alice0, bob0) = TestsHelper.reachNormal() + val (alice0, bob0) = TestsHelper.reachNormal(bobFundingAmount = 300_000.sat) val nodeParams = Pair(alice0.staticParams.nodeParams, bob0.staticParams.nodeParams) val walletParams = Pair( // Alice must declare Bob as her trampoline node to enable direct payments. diff --git a/src/commonTest/kotlin/fr/acinq/lightning/payment/OutgoingPaymentHandlerTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/payment/OutgoingPaymentHandlerTestsCommon.kt index ad6f5ca3c..9e555a5bc 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/payment/OutgoingPaymentHandlerTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/payment/OutgoingPaymentHandlerTestsCommon.kt @@ -460,7 +460,7 @@ class OutgoingPaymentHandlerTestsCommon : LightningTestSuite() { @Test fun `insufficient funds when retrying with higher fees`() = runSuspendTest { - val (alice, _) = TestsHelper.reachNormal(aliceFundingAmount = 100_000.sat, alicePushAmount = 0.msat, bobFundingAmount = 0.sat, bobPushAmount = 0.msat) + val (alice, _) = TestsHelper.reachNormal(aliceFundingAmount = 100_000.sat, bobFundingAmount = 0.sat) assertTrue(83_500_000.msat < alice.commitments.availableBalanceForSend()) assertTrue(alice.commitments.availableBalanceForSend() < 84_000_000.msat) val walletParams = defaultWalletParams.copy( diff --git a/src/commonTest/kotlin/fr/acinq/lightning/tests/TestConstants.kt b/src/commonTest/kotlin/fr/acinq/lightning/tests/TestConstants.kt index 4fc8c4e6c..52aef868e 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/tests/TestConstants.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/tests/TestConstants.kt @@ -19,8 +19,6 @@ object TestConstants { const val defaultBlockHeight = 400_000 val aliceFundingAmount = 850_000.sat val bobFundingAmount = 150_000.sat - val alicePushAmount = 50_000_000.msat - val bobPushAmount = 0.msat val feeratePerKw = FeeratePerKw(5000.sat) // 20 sat/byte val emptyOnionPacket = OnionRoutingPacket(0, ByteVector(ByteArray(33)), ByteVector(ByteArray(OnionRoutingPacket.PaymentPacketLength)), ByteVector32.Zeroes) diff --git a/src/commonTest/kotlin/fr/acinq/lightning/wire/LightningCodecsTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/wire/LightningCodecsTestsCommon.kt index 32c89e500..45ba39bf2 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/wire/LightningCodecsTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/wire/LightningCodecsTestsCommon.kt @@ -337,7 +337,6 @@ class LightningCodecsTestsCommon : LightningTestSuite() { val testCases = listOf( defaultOpen to defaultEncoded, defaultOpen.copy(tlvStream = TlvStream(ChannelTlv.ChannelTypeTlv(ChannelType.SupportedChannelType.AnchorOutputs))) to (defaultEncoded + ByteVector("0103101000")), - defaultOpen.copy(tlvStream = TlvStream(ChannelTlv.ChannelTypeTlv(ChannelType.SupportedChannelType.AnchorOutputs), ChannelTlv.PushAmountTlv(25_000.msat))) to (defaultEncoded + ByteVector("0103101000 fe470000070261a8")), defaultOpen.copy(tlvStream = TlvStream(ChannelTlv.ChannelTypeTlv(ChannelType.SupportedChannelType.AnchorOutputs), ChannelTlv.RequireConfirmedInputsTlv)) to (defaultEncoded + ByteVector("0103101000 0200")), defaultOpen.copy(tlvStream = TlvStream(ChannelTlv.ChannelTypeTlv(ChannelType.SupportedChannelType.AnchorOutputs), ChannelTlv.RequestFundingTlv(requestFundsFromChannelBalance))) to (defaultEncoded + ByteVector("0103101000 fd053b1e00000000000b71b00007a120004c4b40044c004b00000000000005dc0000")), defaultOpen.copy(tlvStream = TlvStream(ChannelTlv.ChannelTypeTlv(ChannelType.SupportedChannelType.AnchorOutputs), ChannelTlv.RequestFundingTlv(requestFundsFromHtlc))) to (defaultEncoded + ByteVector("0103101000 fd053b5e000000000007a120000186a00007a1200226006400001388000003e8804080417c0c91deb72606958425ea1552a045a55a250e91870231b486dcb2106734d662b36d54c6d1c2a0227cdc114d12c578c25ab6ec664eebaa440d7e493eba47")), @@ -392,7 +391,6 @@ class LightningCodecsTestsCommon : LightningTestSuite() { defaultAccept.copy(tlvStream = TlvStream(ChannelTlv.ChannelTypeTlv(ChannelType.SupportedChannelType.AnchorOutputs), ChannelTlv.ProvideFundingTlv(willFund))) to (defaultEncoded + ByteVector("0103101000 fd053b780007a120004c4b40044c004b00000000000005dc002200202ec38203f4cf37a3b377d9a55c7ae0153c643046dbdbe2ffccfb11b74420103cc57cf393f6bd534472ec08cbfbbc7268501b32f563a21cdf02a99127c4f25168249acd6509f96b2e93843c3b838ee4808c75d0a15ff71ba886fda980b8ca954f")), defaultAccept.copy(tlvStream = TlvStream(ChannelTlv.ChannelTypeTlv(ChannelType.SupportedChannelType.AnchorOutputs), ChannelTlv.FeeCreditUsedTlv(0.msat))) to (defaultEncoded + ByteVector("0103101000 fda05200")), defaultAccept.copy(tlvStream = TlvStream(ChannelTlv.ChannelTypeTlv(ChannelType.SupportedChannelType.AnchorOutputs), ChannelTlv.FeeCreditUsedTlv(1729.msat))) to (defaultEncoded + ByteVector("0103101000 fda0520206c1")), - defaultAccept.copy(tlvStream = TlvStream(ChannelTlv.ChannelTypeTlv(ChannelType.SupportedChannelType.AnchorOutputs), ChannelTlv.PushAmountTlv(1729.msat))) to (defaultEncoded + ByteVector("0103101000 fe470000070206c1")), defaultAccept.copy(tlvStream = TlvStream(ChannelTlv.ChannelTypeTlv(ChannelType.SupportedChannelType.AnchorOutputs), ChannelTlv.RequireConfirmedInputsTlv)) to (defaultEncoded + ByteVector("0103101000 0200")), defaultAccept.copy(tlvStream = TlvStream(setOf(ChannelTlv.ChannelTypeTlv(ChannelType.SupportedChannelType.AnchorOutputs)), setOf(GenericTlv(113, ByteVector("deadbeef"))))) to (defaultEncoded + ByteVector("0103101000 7104deadbeef")), ) @@ -536,15 +534,13 @@ class LightningCodecsTestsCommon : LightningTestSuite() { Stfu(channelId, false) to ByteVector("0002 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 00"), Stfu(channelId, true) to ByteVector("0002 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 01"), SpliceInit(channelId, 100_000.sat, FeeratePerKw(2500.sat), 100, fundingPubkey) to ByteVector("9088 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 00000000000186a0 000009c4 00000064 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), - SpliceInit(channelId, 150_000.sat, 25_000_000.msat, FeeratePerKw(2500.sat), 100, fundingPubkey, null) to ByteVector("9088 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 00000000000249f0 000009c4 00000064 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 fe4700000704017d7840"), SpliceInit(channelId, 0.sat, FeeratePerKw(500.sat), 0, fundingPubkey) to ByteVector("9088 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 0000000000000000 000001f4 00000000 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), SpliceInit(channelId, (-50_000).sat, FeeratePerKw(500.sat), 0, fundingPubkey) to ByteVector("9088 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ffffffffffff3cb0 000001f4 00000000 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), - SpliceInit(channelId, 100_000.sat, 0.msat, FeeratePerKw(2500.sat), 100, fundingPubkey, LiquidityAds.RequestFunding(100_000.sat, fundingRate, LiquidityAds.PaymentDetails.FromChannelBalance)) to ByteVector("9088 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 00000000000186a0 000009c4 00000064 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 fd053b1e00000000000186a0000186a0000186a00190009600000000000000000000"), + SpliceInit(channelId, 100_000.sat, FeeratePerKw(2500.sat), 100, fundingPubkey, LiquidityAds.RequestFunding(100_000.sat, fundingRate, LiquidityAds.PaymentDetails.FromChannelBalance)) to ByteVector("9088 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 00000000000186a0 000009c4 00000064 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 fd053b1e00000000000186a0000186a0000186a00190009600000000000000000000"), SpliceAck(channelId, 25_000.sat, fundingPubkey) to ByteVector("908a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 00000000000061a8 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), - SpliceAck(channelId, 40_000.sat, 10_000_000.msat, fundingPubkey, null) to ByteVector("908a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 0000000000009c40 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 fe4700000703989680"), SpliceAck(channelId, 0.sat, fundingPubkey) to ByteVector("908a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 0000000000000000 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), SpliceAck(channelId, (-25_000).sat, fundingPubkey) to ByteVector("908a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ffffffffffff9e58 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), - SpliceAck(channelId, 25_000.sat, 0.msat, fundingPubkey, LiquidityAds.WillFund(fundingRate, ByteVector("deadbeef"), ByteVector64.Zeroes)) to ByteVector("908a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 00000000000061a8 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 fd053b5a000186a0000186a00190009600000000000000000004deadbeef00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"), + SpliceAck(channelId, 25_000.sat, fundingPubkey, LiquidityAds.WillFund(fundingRate, ByteVector("deadbeef"), ByteVector64.Zeroes)) to ByteVector("908a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 00000000000061a8 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 fd053b5a000186a0000186a00190009600000000000000000004deadbeef00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"), SpliceAck(channelId, 25_000.sat, fundingPubkey, TlvStream(ChannelTlv.FeeCreditUsedTlv(0.msat))) to ByteVector("908a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 00000000000061a8 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 fda05200"), SpliceAck(channelId, 25_000.sat, fundingPubkey, TlvStream(ChannelTlv.FeeCreditUsedTlv(1729.msat))) to ByteVector("908a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 00000000000061a8 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 fda0520206c1"), SpliceLocked(channelId, fundingTxId) to ByteVector("908c aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 24e1b2c94c4e734dd5b9c5f3c910fbb6b3b436ced6382c7186056a5a23f14566"),