@@ -1684,63 +1684,53 @@ impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for Channel<SP> where SP::Ta
1684
1684
}
1685
1685
}
1686
1686
1687
- pub(super) trait InteractivelyFunded<SP: Deref> where SP::Target: SignerProvider {
1688
- fn context(&self) -> &ChannelContext<SP>;
1689
-
1690
- fn context_mut(&mut self) -> &mut ChannelContext<SP>;
1691
-
1692
- fn interactive_tx_constructor_mut(&mut self) -> &mut Option<InteractiveTxConstructor>;
1693
-
1694
- fn dual_funding_context(&self) -> &DualFundingChannelContext;
1695
-
1696
- fn unfunded_context(&self) -> &UnfundedChannelContext;
1697
-
1698
- fn tx_add_input(&mut self, msg: &msgs::TxAddInput) -> InteractiveTxMessageSendResult {
1699
- InteractiveTxMessageSendResult(match self.interactive_tx_constructor_mut() {
1687
+ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
1688
+ pub fn tx_add_input(&mut self, msg: &msgs::TxAddInput) -> InteractiveTxMessageSendResult {
1689
+ InteractiveTxMessageSendResult(match &mut self.interactive_tx_constructor {
1700
1690
Some(ref mut tx_constructor) => tx_constructor.handle_tx_add_input(msg).map_err(
1701
- |reason| reason.into_tx_abort_msg(self.context() .channel_id())),
1691
+ |reason| reason.into_tx_abort_msg(self.context.channel_id())),
1702
1692
None => Err(msgs::TxAbort {
1703
- channel_id: self.context() .channel_id(),
1693
+ channel_id: self.context.channel_id(),
1704
1694
data: b"No interactive transaction negotiation in progress".to_vec()
1705
1695
}),
1706
1696
})
1707
1697
}
1708
1698
1709
- fn tx_add_output(&mut self, msg: &msgs::TxAddOutput)-> InteractiveTxMessageSendResult {
1710
- InteractiveTxMessageSendResult(match self.interactive_tx_constructor_mut() {
1699
+ pub fn tx_add_output(&mut self, msg: &msgs::TxAddOutput)-> InteractiveTxMessageSendResult {
1700
+ InteractiveTxMessageSendResult(match &mut self.interactive_tx_constructor {
1711
1701
Some(ref mut tx_constructor) => tx_constructor.handle_tx_add_output(msg).map_err(
1712
- |reason| reason.into_tx_abort_msg(self.context() .channel_id())),
1702
+ |reason| reason.into_tx_abort_msg(self.context.channel_id())),
1713
1703
None => Err(msgs::TxAbort {
1714
- channel_id: self.context() .channel_id(),
1704
+ channel_id: self.context.channel_id(),
1715
1705
data: b"No interactive transaction negotiation in progress".to_vec()
1716
1706
}),
1717
1707
})
1718
1708
}
1719
1709
1720
- fn tx_remove_input(&mut self, msg: &msgs::TxRemoveInput)-> InteractiveTxMessageSendResult {
1721
- InteractiveTxMessageSendResult(match self.interactive_tx_constructor_mut() {
1710
+ pub fn tx_remove_input(&mut self, msg: &msgs::TxRemoveInput)-> InteractiveTxMessageSendResult {
1711
+ InteractiveTxMessageSendResult(match &mut self.interactive_tx_constructor {
1722
1712
Some(ref mut tx_constructor) => tx_constructor.handle_tx_remove_input(msg).map_err(
1723
- |reason| reason.into_tx_abort_msg(self.context() .channel_id())),
1713
+ |reason| reason.into_tx_abort_msg(self.context.channel_id())),
1724
1714
None => Err(msgs::TxAbort {
1725
- channel_id: self.context() .channel_id(),
1715
+ channel_id: self.context.channel_id(),
1726
1716
data: b"No interactive transaction negotiation in progress".to_vec()
1727
1717
}),
1728
1718
})
1729
1719
}
1730
1720
1731
- fn tx_remove_output(&mut self, msg: &msgs::TxRemoveOutput)-> InteractiveTxMessageSendResult {
1732
- InteractiveTxMessageSendResult(match self.interactive_tx_constructor_mut() {
1721
+ pub fn tx_remove_output(&mut self, msg: &msgs::TxRemoveOutput)-> InteractiveTxMessageSendResult {
1722
+ InteractiveTxMessageSendResult(match &mut self.interactive_tx_constructor {
1733
1723
Some(ref mut tx_constructor) => tx_constructor.handle_tx_remove_output(msg).map_err(
1734
- |reason| reason.into_tx_abort_msg(self.context() .channel_id())),
1724
+ |reason| reason.into_tx_abort_msg(self.context.channel_id())),
1735
1725
None => Err(msgs::TxAbort {
1736
- channel_id: self.context() .channel_id(),
1726
+ channel_id: self.context.channel_id(),
1737
1727
data: b"No interactive transaction negotiation in progress".to_vec()
1738
1728
}),
1739
1729
})
1740
1730
}
1741
1731
1742
- fn tx_complete(&mut self, msg: &msgs::TxComplete) -> HandleTxCompleteResult {
1743
- let tx_constructor = match self.interactive_tx_constructor_mut() {
1732
+ pub fn tx_complete(&mut self, msg: &msgs::TxComplete) -> HandleTxCompleteResult {
1733
+ let tx_constructor = match &mut self.interactive_tx_constructor {
1744
1734
Some(ref mut tx_constructor) => tx_constructor,
1745
1735
None => {
1746
1736
let tx_abort = msgs::TxAbort {
@@ -1759,26 +1749,25 @@ pub(super) trait InteractivelyFunded<SP: Deref> where SP::Target: SignerProvider
1759
1749
};
1760
1750
1761
1751
if let HandleTxCompleteValue::SendTxComplete(_, ref signing_session) = tx_complete {
1762
- self.context_mut() .next_funding_txid = Some(signing_session.unsigned_tx.compute_txid());
1752
+ self.context .next_funding_txid = Some(signing_session.unsigned_tx.compute_txid());
1763
1753
};
1764
1754
1765
1755
HandleTxCompleteResult(Ok(tx_complete))
1766
1756
}
1767
1757
1768
- fn funding_tx_constructed<L: Deref>(
1758
+ pub fn funding_tx_constructed<L: Deref>(
1769
1759
&mut self, signing_session: &mut InteractiveTxSigningSession, logger: &L
1770
1760
) -> Result<(msgs::CommitmentSigned, Option<Event>), ChannelError>
1771
1761
where
1772
1762
L::Target: Logger
1773
1763
{
1774
- let our_funding_satoshis = self.dual_funding_context().our_funding_satoshis;
1775
- let transaction_number = self.unfunded_context().transaction_number();
1776
- let context = self.context_mut();
1764
+ let our_funding_satoshis = self.dual_funding_context.our_funding_satoshis;
1765
+ let transaction_number = self.unfunded_context.transaction_number();
1777
1766
1778
1767
let mut output_index = None;
1779
- let expected_spk = context.get_funding_redeemscript().to_p2wsh();
1768
+ let expected_spk = self. context.get_funding_redeemscript().to_p2wsh();
1780
1769
for (idx, outp) in signing_session.unsigned_tx.outputs().enumerate() {
1781
- if outp.script_pubkey() == &expected_spk && outp.value() == context.get_value_satoshis() {
1770
+ if outp.script_pubkey() == &expected_spk && outp.value() == self. context.get_value_satoshis() {
1782
1771
if output_index.is_some() {
1783
1772
return Err(ChannelError::Close(
1784
1773
(
@@ -1798,26 +1787,26 @@ pub(super) trait InteractivelyFunded<SP: Deref> where SP::Target: SignerProvider
1798
1787
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) },
1799
1788
)));
1800
1789
};
1801
- context.channel_transaction_parameters.funding_outpoint = Some(outpoint);
1802
- context.holder_signer.as_mut().provide_channel_parameters(&context.channel_transaction_parameters);
1790
+ self. context.channel_transaction_parameters.funding_outpoint = Some(outpoint);
1791
+ self. context.holder_signer.as_mut().provide_channel_parameters(&self. context.channel_transaction_parameters);
1803
1792
1804
- context.assert_no_commitment_advancement(transaction_number, "initial commitment_signed");
1805
- let commitment_signed = context.get_initial_commitment_signed(logger);
1793
+ self. context.assert_no_commitment_advancement(transaction_number, "initial commitment_signed");
1794
+ let commitment_signed = self. context.get_initial_commitment_signed(logger);
1806
1795
let commitment_signed = match commitment_signed {
1807
1796
Ok(commitment_signed) => {
1808
- context.funding_transaction = Some(signing_session.unsigned_tx.build_unsigned_tx());
1797
+ self. context.funding_transaction = Some(signing_session.unsigned_tx.build_unsigned_tx());
1809
1798
commitment_signed
1810
1799
},
1811
1800
Err(err) => {
1812
- context.channel_transaction_parameters.funding_outpoint = None;
1801
+ self. context.channel_transaction_parameters.funding_outpoint = None;
1813
1802
return Err(ChannelError::Close((err.to_string(), ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) })))
1814
1803
},
1815
1804
};
1816
1805
1817
1806
let funding_ready_for_sig_event = None;
1818
1807
if signing_session.local_inputs_count() == 0 {
1819
1808
debug_assert_eq!(our_funding_satoshis, 0);
1820
- if signing_session.provide_holder_witnesses(context.channel_id, Vec::new()).is_err() {
1809
+ if signing_session.provide_holder_witnesses(self. context.channel_id, Vec::new()).is_err() {
1821
1810
debug_assert!(
1822
1811
false,
1823
1812
"Zero inputs were provided & zero witnesses were provided, but a count mismatch was somehow found",
@@ -1840,33 +1829,15 @@ pub(super) trait InteractivelyFunded<SP: Deref> where SP::Target: SignerProvider
1840
1829
// </div>
1841
1830
}
1842
1831
1843
- context.channel_state = ChannelState::FundingNegotiated;
1832
+ self. context.channel_state = ChannelState::FundingNegotiated;
1844
1833
1845
1834
// Clear the interactive transaction constructor
1846
- self.interactive_tx_constructor_mut() .take();
1835
+ self.interactive_tx_constructor .take();
1847
1836
1848
1837
Ok((commitment_signed, funding_ready_for_sig_event))
1849
1838
}
1850
1839
}
1851
1840
1852
- impl<SP: Deref> InteractivelyFunded<SP> for PendingV2Channel<SP> where SP::Target: SignerProvider {
1853
- fn context(&self) -> &ChannelContext<SP> {
1854
- &self.context
1855
- }
1856
- fn context_mut(&mut self) -> &mut ChannelContext<SP> {
1857
- &mut self.context
1858
- }
1859
- fn dual_funding_context(&self) -> &DualFundingChannelContext {
1860
- &self.dual_funding_context
1861
- }
1862
- fn unfunded_context(&self) -> &UnfundedChannelContext {
1863
- &self.unfunded_context
1864
- }
1865
- fn interactive_tx_constructor_mut(&mut self) -> &mut Option<InteractiveTxConstructor> {
1866
- &mut self.interactive_tx_constructor
1867
- }
1868
- }
1869
-
1870
1841
impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
1871
1842
fn new_for_inbound_channel<'a, ES: Deref, F: Deref, L: Deref>(
1872
1843
fee_estimator: &'a LowerBoundedFeeEstimator<F>,
@@ -8810,7 +8781,7 @@ pub(super) struct PendingV2Channel<SP: Deref> where SP::Target: SignerProvider {
8810
8781
pub unfunded_context: UnfundedChannelContext,
8811
8782
pub dual_funding_context: DualFundingChannelContext,
8812
8783
/// The current interactive transaction construction session under negotiation.
8813
- interactive_tx_constructor: Option<InteractiveTxConstructor>,
8784
+ pub interactive_tx_constructor: Option<InteractiveTxConstructor>,
8814
8785
}
8815
8786
8816
8787
impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
0 commit comments