Track whether HolderFundingOutput originated from an anchor channel
authorWilmer Paulino <wilmer.paulino@gmail.com>
Wed, 14 Sep 2022 23:18:33 +0000 (16:18 -0700)
committerWilmer Paulino <wilmer.paulino@gmail.com>
Tue, 18 Oct 2022 19:22:46 +0000 (12:22 -0700)
lightning/src/chain/channelmonitor.rs
lightning/src/chain/package.rs

index ae315f9e628e2f4fb68f8d3b8d5c805b894dcbd3..d6c14c68cf17e082921ef62125186398e25d81c8 100644 (file)
@@ -2884,7 +2884,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
 
                let should_broadcast = self.should_broadcast_holder_commitment_txn(logger);
                if should_broadcast {
-                       let funding_outp = HolderFundingOutput::build(self.funding_redeemscript.clone());
+                       let funding_outp = HolderFundingOutput::build(self.funding_redeemscript.clone(), self.onchain_tx_handler.opt_anchors());
                        let commitment_package = PackageTemplate::build_package(self.funding_info.0.txid.clone(), self.funding_info.0.index as u32, PackageSolvingData::HolderFundingOutput(funding_outp), self.best_block.height(), false, self.best_block.height());
                        claimable_outpoints.push(commitment_package);
                        self.pending_monitor_events.push(MonitorEvent::CommitmentTxConfirmed(self.funding_info.0));
index a2922d27d2914add018053cdcb970c3954b9d982..3b6ebb4223ce9febe42516ad41c26a4bc38efcdc 100644 (file)
@@ -286,18 +286,26 @@ impl_writeable_tlv_based!(HolderHTLCOutput, {
 #[derive(Clone, PartialEq, Eq)]
 pub(crate) struct HolderFundingOutput {
        funding_redeemscript: Script,
+       opt_anchors: Option<()>,
 }
 
+
 impl HolderFundingOutput {
-       pub(crate) fn build(funding_redeemscript: Script) -> Self {
+       pub(crate) fn build(funding_redeemscript: Script, opt_anchors: bool) -> Self {
                HolderFundingOutput {
                        funding_redeemscript,
+                       opt_anchors: if opt_anchors { Some(()) } else { None },
                }
        }
+
+       fn opt_anchors(&self) -> bool {
+               self.opt_anchors.is_some()
+       }
 }
 
 impl_writeable_tlv_based!(HolderFundingOutput, {
        (0, funding_redeemscript, required),
+       (1, opt_anchors, option),
 });
 
 /// A wrapper encapsulating all in-protocol differing outputs types.