@@ -1680,43 +1680,56 @@ where
1680
1680
1681
1681
fn fail_interactive_tx_negotiation<L: Deref>(
1682
1682
&mut self, error: NegotiationError, logger: &L,
1683
- ) -> msgs::TxAbort
1683
+ ) -> ( msgs::TxAbort, Option<SpliceFundingFailed>)
1684
1684
where
1685
1685
L::Target: Logger,
1686
1686
{
1687
1687
let logger = WithChannelContext::from(logger, &self.context(), None);
1688
- let NegotiationError { reason, .. } = error;
1688
+ let NegotiationError { reason, contributed_inputs, contributed_outputs } = error;
1689
1689
log_info!(logger, "Failed interactive transaction negotiation: {reason}");
1690
1690
1691
- let _interactive_tx_constructor = match &mut self.phase {
1691
+ let splice_funding_failed = match &mut self.phase {
1692
1692
ChannelPhase::Undefined => unreachable!(),
1693
1693
ChannelPhase::UnfundedOutboundV1(_) | ChannelPhase::UnfundedInboundV1(_) => None,
1694
1694
ChannelPhase::UnfundedV2(pending_v2_channel) => {
1695
- pending_v2_channel.interactive_tx_constructor.take()
1695
+ pending_v2_channel.interactive_tx_constructor.take();
1696
+ None
1697
+ },
1698
+ ChannelPhase::Funded(funded_channel) => {
1699
+ funded_channel
1700
+ .pending_splice
1701
+ .as_mut()
1702
+ .and_then(|pending_splice| pending_splice.funding_negotiation.take())
1703
+ .filter(|funding_negotiation| funding_negotiation.is_initiator())
1704
+ .map(|funding_negotiation| {
1705
+ let funding_txo = funding_negotiation
1706
+ .as_funding()
1707
+ .and_then(|funding| funding.get_funding_txo())
1708
+ .map(|txo| txo.into_bitcoin_outpoint());
1709
+
1710
+ let channel_type = funding_negotiation
1711
+ .as_funding()
1712
+ .map(|funding| funding.get_channel_type().clone());
1713
+
1714
+ SpliceFundingFailed {
1715
+ channel_id: funded_channel.context.channel_id,
1716
+ counterparty_node_id: funded_channel.context.counterparty_node_id,
1717
+ user_channel_id: funded_channel.context.user_id,
1718
+ funding_txo,
1719
+ channel_type,
1720
+ contributed_inputs,
1721
+ contributed_outputs,
1722
+ }
1723
+ })
1696
1724
},
1697
- ChannelPhase::Funded(funded_channel) => funded_channel
1698
- .pending_splice
1699
- .as_mut()
1700
- .and_then(|pending_splice| pending_splice.funding_negotiation.take())
1701
- .and_then(|funding_negotiation| {
1702
- if let FundingNegotiation::ConstructingTransaction {
1703
- interactive_tx_constructor,
1704
- ..
1705
- } = funding_negotiation
1706
- {
1707
- Some(interactive_tx_constructor)
1708
- } else {
1709
- None
1710
- }
1711
- }),
1712
1725
};
1713
1726
1714
- reason.into_tx_abort_msg(self.context().channel_id)
1727
+ ( reason.into_tx_abort_msg(self.context().channel_id), splice_funding_failed )
1715
1728
}
1716
1729
1717
1730
pub fn tx_add_input<L: Deref>(
1718
1731
&mut self, msg: &msgs::TxAddInput, logger: &L,
1719
- ) -> Result<InteractiveTxMessageSend, msgs::TxAbort>
1732
+ ) -> Result<InteractiveTxMessageSend, ( msgs::TxAbort, Option<SpliceFundingFailed>) >
1720
1733
where
1721
1734
L::Target: Logger,
1722
1735
{
@@ -1735,7 +1748,7 @@ where
1735
1748
1736
1749
pub fn tx_add_output<L: Deref>(
1737
1750
&mut self, msg: &msgs::TxAddOutput, logger: &L,
1738
- ) -> Result<InteractiveTxMessageSend, msgs::TxAbort>
1751
+ ) -> Result<InteractiveTxMessageSend, ( msgs::TxAbort, Option<SpliceFundingFailed>) >
1739
1752
where
1740
1753
L::Target: Logger,
1741
1754
{
@@ -1756,7 +1769,7 @@ where
1756
1769
1757
1770
pub fn tx_remove_input<L: Deref>(
1758
1771
&mut self, msg: &msgs::TxRemoveInput, logger: &L,
1759
- ) -> Result<InteractiveTxMessageSend, msgs::TxAbort>
1772
+ ) -> Result<InteractiveTxMessageSend, ( msgs::TxAbort, Option<SpliceFundingFailed>) >
1760
1773
where
1761
1774
L::Target: Logger,
1762
1775
{
@@ -1777,7 +1790,7 @@ where
1777
1790
1778
1791
pub fn tx_remove_output<L: Deref>(
1779
1792
&mut self, msg: &msgs::TxRemoveOutput, logger: &L,
1780
- ) -> Result<InteractiveTxMessageSend, msgs::TxAbort>
1793
+ ) -> Result<InteractiveTxMessageSend, ( msgs::TxAbort, Option<SpliceFundingFailed>) >
1781
1794
where
1782
1795
L::Target: Logger,
1783
1796
{
@@ -1798,7 +1811,7 @@ where
1798
1811
1799
1812
pub fn tx_complete<L: Deref>(
1800
1813
&mut self, msg: &msgs::TxComplete, logger: &L,
1801
- ) -> Result<(Option<InteractiveTxMessageSend>, Option<msgs::CommitmentSigned>), msgs::TxAbort>
1814
+ ) -> Result<(Option<InteractiveTxMessageSend>, Option<msgs::CommitmentSigned>), ( msgs::TxAbort, Option<SpliceFundingFailed>) >
1802
1815
where
1803
1816
L::Target: Logger,
1804
1817
{
@@ -1951,6 +1964,7 @@ where
1951
1964
interactive_tx_constructor,
1952
1965
} = funding_negotiation
1953
1966
{
1967
+ let is_initiator = interactive_tx_constructor.is_initiator();
1954
1968
let signing_session = interactive_tx_constructor.into_signing_session();
1955
1969
let commitment_signed = chan.context.funding_tx_constructed(
1956
1970
&mut funding,
@@ -1961,7 +1975,7 @@ where
1961
1975
)?;
1962
1976
1963
1977
pending_splice.funding_negotiation =
1964
- Some(FundingNegotiation::AwaitingSignatures { funding });
1978
+ Some(FundingNegotiation::AwaitingSignatures { funding, is_initiator });
1965
1979
1966
1980
return Ok(commitment_signed);
1967
1981
} else {
@@ -2563,12 +2577,14 @@ enum FundingNegotiation {
2563
2577
},
2564
2578
AwaitingSignatures {
2565
2579
funding: FundingScope,
2580
+ is_initiator: bool,
2566
2581
},
2567
2582
}
2568
2583
2569
2584
impl_writeable_tlv_based_enum_upgradable!(FundingNegotiation,
2570
2585
(0, AwaitingSignatures) => {
2571
2586
(1, funding, required),
2587
+ (3, is_initiator, required),
2572
2588
},
2573
2589
unread_variants: AwaitingAck, ConstructingTransaction
2574
2590
);
@@ -2578,7 +2594,17 @@ impl FundingNegotiation {
2578
2594
match self {
2579
2595
FundingNegotiation::AwaitingAck { .. } => None,
2580
2596
FundingNegotiation::ConstructingTransaction { funding, .. } => Some(funding),
2581
- FundingNegotiation::AwaitingSignatures { funding } => Some(funding),
2597
+ FundingNegotiation::AwaitingSignatures { funding, .. } => Some(funding),
2598
+ }
2599
+ }
2600
+
2601
+ fn is_initiator(&self) -> bool {
2602
+ match self {
2603
+ FundingNegotiation::AwaitingAck { context } => context.is_initiator,
2604
+ FundingNegotiation::ConstructingTransaction { interactive_tx_constructor, .. } => {
2605
+ interactive_tx_constructor.is_initiator()
2606
+ },
2607
+ FundingNegotiation::AwaitingSignatures { is_initiator, .. } => *is_initiator,
2582
2608
}
2583
2609
}
2584
2610
}
@@ -6749,6 +6775,25 @@ pub struct SpliceFundingNegotiated {
6749
6775
pub channel_type: ChannelTypeFeatures,
6750
6776
}
6751
6777
6778
+ /// Information about a splice funding negotiation that has failed.
6779
+ /// This is returned from channel operations and converted to an Event::SpliceFailed in ChannelManager.
6780
+ pub struct SpliceFundingFailed {
6781
+ /// The channel_id of the channel for which the splice failed.
6782
+ pub channel_id: ChannelId,
6783
+ /// The counterparty's node_id.
6784
+ pub counterparty_node_id: PublicKey,
6785
+ /// The user_channel_id value.
6786
+ pub user_channel_id: u128,
6787
+ /// The outpoint of the channel's splice funding transaction, if one was created.
6788
+ pub funding_txo: Option<bitcoin::OutPoint>,
6789
+ /// The features that this channel will operate with, if available.
6790
+ pub channel_type: Option<ChannelTypeFeatures>,
6791
+ /// Input outpoints contributed to the splice transaction.
6792
+ pub contributed_inputs: Vec<bitcoin::OutPoint>,
6793
+ /// Outputs contributed to the splice transaction.
6794
+ pub contributed_outputs: Vec<bitcoin::TxOut>,
6795
+ }
6796
+
6752
6797
pub struct SpliceFundingPromotion {
6753
6798
pub funding_txo: OutPoint,
6754
6799
pub monitor_update: Option<ChannelMonitorUpdate>,
@@ -8641,7 +8686,7 @@ where
8641
8686
8642
8687
if let Some(pending_splice) = self.pending_splice.as_mut() {
8643
8688
self.context.channel_state.clear_quiescent();
8644
- if let Some(FundingNegotiation::AwaitingSignatures { mut funding }) =
8689
+ if let Some(FundingNegotiation::AwaitingSignatures { mut funding, .. }) =
8645
8690
pending_splice.funding_negotiation.take()
8646
8691
{
8647
8692
funding.funding_transaction = Some(funding_tx);
@@ -9555,7 +9600,7 @@ where
9555
9600
.as_ref()
9556
9601
.and_then(|pending_splice| pending_splice.funding_negotiation.as_ref())
9557
9602
.and_then(|funding_negotiation| {
9558
- if let FundingNegotiation::AwaitingSignatures { funding } = &funding_negotiation {
9603
+ if let FundingNegotiation::AwaitingSignatures { funding, .. } = &funding_negotiation {
9559
9604
Some(funding)
9560
9605
} else {
9561
9606
None
0 commit comments