Skip to content

Commit bc71a7a

Browse files
committed
f - correctly emit SpliceFailed when funding_tx_constructed fails
1 parent 44697a4 commit bc71a7a

File tree

1 file changed

+16
-38
lines changed

1 file changed

+16
-38
lines changed

lightning/src/ln/channel.rs

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,56 +1722,34 @@ where
17221722
let NegotiationError { reason, .. } = error;
17231723
log_info!(logger, "Failed interactive transaction negotiation: {reason}");
17241724

1725-
let mut splice_failed = None;
1726-
1727-
let _interactive_tx_constructor = match &mut self.phase {
1725+
let splice_funding_failed = match &mut self.phase {
17281726
ChannelPhase::Undefined => unreachable!(),
17291727
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => None,
17301728
ChannelPhase::UnfundedV2(pending_v2_channel) => {
1731-
pending_v2_channel.interactive_tx_constructor.take()
1729+
pending_v2_channel.interactive_tx_constructor.take();
1730+
None
17321731
},
17331732
ChannelPhase::Funded(funded_channel) => {
1734-
if let Some(pending_splice) = funded_channel.pending_splice.as_mut() {
1735-
if pending_splice.funding_negotiation.is_some() {
1736-
let funding_negotiation = pending_splice.funding_negotiation.take();
1737-
1738-
let (funding_txo, channel_type, contributed_inputs, contributed_outputs) =
1739-
if let Some(FundingNegotiation::ConstructingTransaction { funding, interactive_tx_constructor: _ }) = &funding_negotiation {
1740-
(
1741-
funding.get_funding_txo().map(|txo| txo.into_bitcoin_outpoint()),
1742-
Some(funding.get_channel_type().clone()),
1743-
Vec::new(), // TODO: Extract contributed inputs from interactive_tx_constructor
1744-
Vec::new(), // TODO: Extract contributed outputs from interactive_tx_constructor
1745-
)
1746-
} else {
1747-
(None, None, Vec::new(), Vec::new())
1748-
};
1749-
1750-
splice_failed = Some(SpliceFundingFailed {
1733+
funded_channel
1734+
.pending_splice
1735+
.as_mut()
1736+
.and_then(|pending_splice| pending_splice.funding_negotiation.take())
1737+
.map(|funding_negotiation| {
1738+
let funding = funding_negotiation.as_funding();
1739+
SpliceFundingFailed {
17511740
channel_id: funded_channel.context.channel_id,
17521741
counterparty_node_id: funded_channel.context.counterparty_node_id,
17531742
user_channel_id: funded_channel.context.user_id,
1754-
funding_txo,
1755-
channel_type,
1756-
contributed_inputs,
1757-
contributed_outputs,
1758-
});
1759-
1760-
if let Some(FundingNegotiation::ConstructingTransaction { interactive_tx_constructor, .. }) = funding_negotiation {
1761-
Some(interactive_tx_constructor)
1762-
} else {
1763-
None
1743+
funding_txo: funding.as_ref().and_then(|funding| funding.get_funding_txo()).map(|txo| txo.into_bitcoin_outpoint()),
1744+
channel_type: funding.as_ref().map(|funding| funding.get_channel_type().clone()),
1745+
contributed_inputs: Vec::new(),
1746+
contributed_outputs: Vec::new(),
17641747
}
1765-
} else {
1766-
None
1767-
}
1768-
} else {
1769-
None
1770-
}
1748+
})
17711749
},
17721750
};
17731751

1774-
(reason.into_tx_abort_msg(self.context().channel_id), splice_failed)
1752+
(reason.into_tx_abort_msg(self.context().channel_id), splice_funding_failed)
17751753
}
17761754

17771755
pub fn tx_add_input<L: Deref>(

0 commit comments

Comments
 (0)