@@ -1714,43 +1714,56 @@ where
1714
1714
1715
1715
fn fail_interactive_tx_negotiation<L: Deref>(
1716
1716
&mut self, error: NegotiationError, logger: &L,
1717
- ) -> msgs::TxAbort
1717
+ ) -> ( msgs::TxAbort, Option<SpliceFundingFailed>)
1718
1718
where
1719
1719
L::Target: Logger,
1720
1720
{
1721
1721
let logger = WithChannelContext::from(logger, &self.context(), None);
1722
- let NegotiationError { reason, .. } = error;
1722
+ let NegotiationError { reason, contributed_inputs, contributed_outputs } = error;
1723
1723
log_info!(logger, "Failed interactive transaction negotiation: {reason}");
1724
1724
1725
- let _interactive_tx_constructor = match &mut self.phase {
1725
+ let splice_funding_failed = match &mut self.phase {
1726
1726
ChannelPhase::Undefined => unreachable!(),
1727
1727
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => None,
1728
1728
ChannelPhase::UnfundedV2(pending_v2_channel) => {
1729
- pending_v2_channel.interactive_tx_constructor.take()
1729
+ pending_v2_channel.interactive_tx_constructor.take();
1730
+ None
1731
+ },
1732
+ ChannelPhase::Funded(funded_channel) => {
1733
+ funded_channel
1734
+ .pending_splice
1735
+ .as_mut()
1736
+ .and_then(|pending_splice| pending_splice.funding_negotiation.take())
1737
+ .filter(|funding_negotiation| funding_negotiation.is_initiator())
1738
+ .map(|funding_negotiation| {
1739
+ let funding_txo = funding_negotiation
1740
+ .as_funding()
1741
+ .and_then(|funding| funding.get_funding_txo())
1742
+ .map(|txo| txo.into_bitcoin_outpoint());
1743
+
1744
+ let channel_type = funding_negotiation
1745
+ .as_funding()
1746
+ .map(|funding| funding.get_channel_type().clone());
1747
+
1748
+ SpliceFundingFailed {
1749
+ channel_id: funded_channel.context.channel_id,
1750
+ counterparty_node_id: funded_channel.context.counterparty_node_id,
1751
+ user_channel_id: funded_channel.context.user_id,
1752
+ funding_txo,
1753
+ channel_type,
1754
+ contributed_inputs,
1755
+ contributed_outputs,
1756
+ }
1757
+ })
1730
1758
},
1731
- ChannelPhase::Funded(funded_channel) => funded_channel
1732
- .pending_splice
1733
- .as_mut()
1734
- .and_then(|pending_splice| pending_splice.funding_negotiation.take())
1735
- .and_then(|funding_negotiation| {
1736
- if let FundingNegotiation::ConstructingTransaction {
1737
- interactive_tx_constructor,
1738
- ..
1739
- } = funding_negotiation
1740
- {
1741
- Some(interactive_tx_constructor)
1742
- } else {
1743
- None
1744
- }
1745
- }),
1746
1759
};
1747
1760
1748
- reason.into_tx_abort_msg(self.context().channel_id)
1761
+ ( reason.into_tx_abort_msg(self.context().channel_id), splice_funding_failed )
1749
1762
}
1750
1763
1751
1764
pub fn tx_add_input<L: Deref>(
1752
1765
&mut self, msg: &msgs::TxAddInput, logger: &L,
1753
- ) -> Result<InteractiveTxMessageSend, msgs::TxAbort>
1766
+ ) -> Result<InteractiveTxMessageSend, ( msgs::TxAbort, Option<SpliceFundingFailed>) >
1754
1767
where
1755
1768
L::Target: Logger,
1756
1769
{
@@ -1769,7 +1782,7 @@ where
1769
1782
1770
1783
pub fn tx_add_output<L: Deref>(
1771
1784
&mut self, msg: &msgs::TxAddOutput, logger: &L,
1772
- ) -> Result<InteractiveTxMessageSend, msgs::TxAbort>
1785
+ ) -> Result<InteractiveTxMessageSend, ( msgs::TxAbort, Option<SpliceFundingFailed>) >
1773
1786
where
1774
1787
L::Target: Logger,
1775
1788
{
@@ -1790,7 +1803,7 @@ where
1790
1803
1791
1804
pub fn tx_remove_input<L: Deref>(
1792
1805
&mut self, msg: &msgs::TxRemoveInput, logger: &L,
1793
- ) -> Result<InteractiveTxMessageSend, msgs::TxAbort>
1806
+ ) -> Result<InteractiveTxMessageSend, ( msgs::TxAbort, Option<SpliceFundingFailed>) >
1794
1807
where
1795
1808
L::Target: Logger,
1796
1809
{
@@ -1811,7 +1824,7 @@ where
1811
1824
1812
1825
pub fn tx_remove_output<L: Deref>(
1813
1826
&mut self, msg: &msgs::TxRemoveOutput, logger: &L,
1814
- ) -> Result<InteractiveTxMessageSend, msgs::TxAbort>
1827
+ ) -> Result<InteractiveTxMessageSend, ( msgs::TxAbort, Option<SpliceFundingFailed>) >
1815
1828
where
1816
1829
L::Target: Logger,
1817
1830
{
@@ -1832,7 +1845,7 @@ where
1832
1845
1833
1846
pub fn tx_complete<L: Deref>(
1834
1847
&mut self, msg: &msgs::TxComplete, logger: &L,
1835
- ) -> Result<(Option<InteractiveTxMessageSend>, Option<msgs::CommitmentSigned>), msgs::TxAbort>
1848
+ ) -> Result<(Option<InteractiveTxMessageSend>, Option<msgs::CommitmentSigned>), ( msgs::TxAbort, Option<SpliceFundingFailed>) >
1836
1849
where
1837
1850
L::Target: Logger,
1838
1851
{
@@ -1985,6 +1998,7 @@ where
1985
1998
interactive_tx_constructor,
1986
1999
} = funding_negotiation
1987
2000
{
2001
+ let is_initiator = interactive_tx_constructor.is_initiator();
1988
2002
let signing_session = interactive_tx_constructor.into_signing_session();
1989
2003
let commitment_signed = chan.context.funding_tx_constructed(
1990
2004
&mut funding,
@@ -1995,7 +2009,7 @@ where
1995
2009
)?;
1996
2010
1997
2011
pending_splice.funding_negotiation =
1998
- Some(FundingNegotiation::AwaitingSignatures { funding });
2012
+ Some(FundingNegotiation::AwaitingSignatures { funding, is_initiator });
1999
2013
2000
2014
return Ok(commitment_signed);
2001
2015
} else {
@@ -2596,12 +2610,14 @@ enum FundingNegotiation {
2596
2610
},
2597
2611
AwaitingSignatures {
2598
2612
funding: FundingScope,
2613
+ is_initiator: bool,
2599
2614
},
2600
2615
}
2601
2616
2602
2617
impl_writeable_tlv_based_enum_upgradable!(FundingNegotiation,
2603
2618
(0, AwaitingSignatures) => {
2604
2619
(1, funding, required),
2620
+ (3, is_initiator, required),
2605
2621
},
2606
2622
unread_variants: AwaitingAck, ConstructingTransaction
2607
2623
);
@@ -2611,7 +2627,17 @@ impl FundingNegotiation {
2611
2627
match self {
2612
2628
FundingNegotiation::AwaitingAck { .. } => None,
2613
2629
FundingNegotiation::ConstructingTransaction { funding, .. } => Some(funding),
2614
- FundingNegotiation::AwaitingSignatures { funding } => Some(funding),
2630
+ FundingNegotiation::AwaitingSignatures { funding, .. } => Some(funding),
2631
+ }
2632
+ }
2633
+
2634
+ fn is_initiator(&self) -> bool {
2635
+ match self {
2636
+ FundingNegotiation::AwaitingAck { context } => context.is_initiator,
2637
+ FundingNegotiation::ConstructingTransaction { interactive_tx_constructor, .. } => {
2638
+ interactive_tx_constructor.is_initiator()
2639
+ },
2640
+ FundingNegotiation::AwaitingSignatures { is_initiator, .. } => *is_initiator,
2615
2641
}
2616
2642
}
2617
2643
}
@@ -6802,6 +6828,25 @@ pub struct SpliceFundingNegotiated {
6802
6828
pub channel_type: ChannelTypeFeatures,
6803
6829
}
6804
6830
6831
+ /// Information about a splice funding negotiation that has failed.
6832
+ /// This is returned from channel operations and converted to an Event::SpliceFailed in ChannelManager.
6833
+ pub struct SpliceFundingFailed {
6834
+ /// The channel_id of the channel for which the splice failed.
6835
+ pub channel_id: ChannelId,
6836
+ /// The counterparty's node_id.
6837
+ pub counterparty_node_id: PublicKey,
6838
+ /// The user_channel_id value.
6839
+ pub user_channel_id: u128,
6840
+ /// The outpoint of the channel's splice funding transaction, if one was created.
6841
+ pub funding_txo: Option<bitcoin::OutPoint>,
6842
+ /// The features that this channel will operate with, if available.
6843
+ pub channel_type: Option<ChannelTypeFeatures>,
6844
+ /// Input outpoints contributed to the splice transaction.
6845
+ pub contributed_inputs: Vec<bitcoin::OutPoint>,
6846
+ /// Outputs contributed to the splice transaction.
6847
+ pub contributed_outputs: Vec<bitcoin::TxOut>,
6848
+ }
6849
+
6805
6850
pub struct SpliceFundingPromotion {
6806
6851
pub funding_txo: OutPoint,
6807
6852
pub monitor_update: Option<ChannelMonitorUpdate>,
@@ -8649,7 +8694,7 @@ where
8649
8694
8650
8695
if let Some(pending_splice) = self.pending_splice.as_mut() {
8651
8696
self.context.channel_state.clear_quiescent();
8652
- if let Some(FundingNegotiation::AwaitingSignatures { mut funding }) =
8697
+ if let Some(FundingNegotiation::AwaitingSignatures { mut funding, .. }) =
8653
8698
pending_splice.funding_negotiation.take()
8654
8699
{
8655
8700
funding.funding_transaction = Some(funding_tx);
@@ -9566,7 +9611,7 @@ where
9566
9611
.as_ref()
9567
9612
.and_then(|pending_splice| pending_splice.funding_negotiation.as_ref())
9568
9613
.and_then(|funding_negotiation| {
9569
- if let FundingNegotiation::AwaitingSignatures { funding } = &funding_negotiation {
9614
+ if let FundingNegotiation::AwaitingSignatures { funding, .. } = &funding_negotiation {
9570
9615
Some(funding)
9571
9616
} else {
9572
9617
None
0 commit comments