Skip to content

Commit

Permalink
Rename liquidityPurchased_opt -> liquidityLease_opt
Browse files Browse the repository at this point in the history
We keep the channel event unchanged though, since it contains
more than a liquidity lease.
  • Loading branch information
t-bast committed Dec 13, 2023
1 parent f20753c commit ca93f88
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
channelParams = d.commitments.params,
purpose = InteractiveTxBuilder.SpliceTx(parentCommitment, d.commitments.changes),
localPushAmount = spliceAck.pushAmount, remotePushAmount = msg.pushAmount,
liquidityPurchased_opt = liquidityLease_opt.map(_.lease),
liquidityLease_opt = liquidityLease_opt.map(_.lease),
wallet
))
txBuilder ! InteractiveTxBuilder.Start(self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ trait ChannelOpenDualFunded extends DualFundingHandlers with ErrorHandlers {
nodeParams, fundingParams,
channelParams, purpose,
localPushAmount = accept.pushAmount, remotePushAmount = open.pushAmount,
liquidityPurchased_opt = liquidityLease_opt.map(_.lease),
liquidityLease_opt = liquidityLease_opt.map(_.lease),
wallet))
txBuilder ! InteractiveTxBuilder.Start(self)
goto(WAIT_FOR_DUAL_FUNDING_CREATED) using DATA_WAIT_FOR_DUAL_FUNDING_CREATED(channelId, channelParams, open.secondPerCommitmentPoint, accept.pushAmount, open.pushAmount, txBuilder, deferred = None, replyTo_opt = None) sending accept
Expand Down Expand Up @@ -563,7 +563,7 @@ trait ChannelOpenDualFunded extends DualFundingHandlers with ErrorHandlers {
channelParams = d.commitments.params,
purpose = InteractiveTxBuilder.PreviousTxRbf(d.commitments.active.head, d.commitments.changes, 0 msat, 0 msat, previousTransactions = d.allFundingTxs.map(_.sharedTx)),
localPushAmount = d.localPushAmount, remotePushAmount = d.remotePushAmount,
liquidityPurchased_opt = liquidityLease_opt.map(_.lease),
liquidityLease_opt = liquidityLease_opt.map(_.lease),
wallet))
txBuilder ! InteractiveTxBuilder.Start(self)
val toSend = Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ object InteractiveTxBuilder {
purpose: Purpose,
localPushAmount: MilliSatoshi,
remotePushAmount: MilliSatoshi,
liquidityPurchased_opt: Option[LiquidityAds.Lease],
liquidityLease_opt: Option[LiquidityAds.Lease],
wallet: OnChainChannelFunder)(implicit ec: ExecutionContext): Behavior[Command] = {
Behaviors.setup { context =>
// The stash is used to buffer messages that arrive while we're funding the transaction.
Expand All @@ -368,7 +368,7 @@ object InteractiveTxBuilder {
Behaviors.receiveMessagePartial {
case Start(replyTo) =>
// The initiator of the interactive-tx is the liquidity buyer (if liquidity ads is used).
val liquidityFee = liquidityPurchased_opt.map(l => if (fundingParams.isInitiator) l.fees.total else -l.fees.total).getOrElse(0 sat)
val liquidityFee = liquidityLease_opt.map(l => if (fundingParams.isInitiator) l.fees.total else -l.fees.total).getOrElse(0 sat)
// Note that pending HTLCs are ignored: splices only affect the main outputs.
val nextLocalBalance = purpose.previousLocalBalance + fundingParams.localContribution - localPushAmount + remotePushAmount - liquidityFee
val nextRemoteBalance = purpose.previousRemoteBalance + fundingParams.remoteContribution - remotePushAmount + localPushAmount + liquidityFee
Expand All @@ -379,7 +379,7 @@ object InteractiveTxBuilder {
replyTo ! LocalFailure(InvalidFundingBalances(channelParams.channelId, fundingParams.fundingAmount, nextLocalBalance, nextRemoteBalance))
Behaviors.stopped
} else {
val actor = new InteractiveTxBuilder(replyTo, sessionId, nodeParams, channelParams, fundingParams, purpose, localPushAmount, remotePushAmount, liquidityPurchased_opt, wallet, stash, context)
val actor = new InteractiveTxBuilder(replyTo, sessionId, nodeParams, channelParams, fundingParams, purpose, localPushAmount, remotePushAmount, liquidityLease_opt, wallet, stash, context)
actor.start()
}
case Abort => Behaviors.stopped
Expand All @@ -402,7 +402,7 @@ private class InteractiveTxBuilder(replyTo: ActorRef[InteractiveTxBuilder.Respon
purpose: Purpose,
localPushAmount: MilliSatoshi,
remotePushAmount: MilliSatoshi,
liquidityPurchased_opt: Option[LiquidityAds.Lease],
liquidityLease_opt: Option[LiquidityAds.Lease],
wallet: OnChainChannelFunder,
stash: StashBuffer[InteractiveTxBuilder.Command],
context: ActorContext[InteractiveTxBuilder.Command])(implicit ec: ExecutionContext) {
Expand Down Expand Up @@ -758,7 +758,7 @@ private class InteractiveTxBuilder(replyTo: ActorRef[InteractiveTxBuilder.Respon
val fundingTx = completeTx.buildUnsignedTx()
val fundingOutputIndex = fundingTx.txOut.indexWhere(_.publicKeyScript == fundingPubkeyScript)
// The initiator of the interactive-tx is the liquidity buyer (if liquidity ads is used).
val liquidityFee = liquidityPurchased_opt.map(l => if (fundingParams.isInitiator) l.fees.total else -l.fees.total).getOrElse(0 sat)
val liquidityFee = liquidityLease_opt.map(l => if (fundingParams.isInitiator) l.fees.total else -l.fees.total).getOrElse(0 sat)
Funding.makeCommitTxs(keyManager, channelParams,
fundingAmount = fundingParams.fundingAmount,
toLocal = completeTx.sharedOutput.localAmount - localPushAmount + remotePushAmount - liquidityFee,
Expand Down Expand Up @@ -790,7 +790,7 @@ private class InteractiveTxBuilder(replyTo: ActorRef[InteractiveTxBuilder.Respon
Behaviors.receiveMessagePartial {
case SignTransactionResult(signedTx) =>
log.info(s"interactive-tx txid=${signedTx.txId} partially signed with {} local inputs, {} remote inputs, {} local outputs and {} remote outputs", signedTx.tx.localInputs.length, signedTx.tx.remoteInputs.length, signedTx.tx.localOutputs.length, signedTx.tx.remoteOutputs.length)
liquidityPurchased_opt.foreach { lease =>
liquidityLease_opt.foreach { lease =>
val purchase = LiquidityPurchase(
fundingTxId = signedTx.txId,
fundingTxIndex = purpose.fundingTxIndex,
Expand Down

0 comments on commit ca93f88

Please sign in to comment.