From 56b916a313a3c9d286e345ff9a8aa0aff4a9f4e0 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 8 Jul 2020 17:13:14 -0700 Subject: [PATCH] lnwallet: don't publish funding TX if flag set on assembler The first channels of a batch shouldn't publish the batch TX to avoid problems if some of the funding flows can't be completed. Only the last channel of a batch should publish. We set the channel flag accordingly depending on the flag in the assembler. --- lnwallet/reservation.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lnwallet/reservation.go b/lnwallet/reservation.go index 22ef08b3a..caa8af2ae 100644 --- a/lnwallet/reservation.go +++ b/lnwallet/reservation.go @@ -287,10 +287,24 @@ func NewChannelReservation(capacity, localFundingAmt btcutil.Amount, chanType |= channeldb.SingleFunderBit } + switch a := fundingAssembler.(type) { + // The first channels of a batch shouldn't publish the batch TX + // to avoid problems if some of the funding flows can't be + // completed. Only the last channel of a batch should publish. + case chanfunding.ConditionalPublishAssembler: + if !a.ShouldPublishFundingTx() { + chanType |= channeldb.NoFundingTxBit + } + + // Normal funding flow, the assembler creates a TX from the + // internal wallet. + case chanfunding.FundingTxAssembler: + // Do nothing, a FundingTxAssembler has the transaction. + // If this intent isn't one that's able to provide us with a // funding transaction, then we'll set the chanType bit to // signal that we don't have access to one. - if _, ok := fundingAssembler.(chanfunding.FundingTxAssembler); !ok { + default: chanType |= channeldb.NoFundingTxBit }