From: Wilmer Paulino Date: Wed, 14 Sep 2022 23:18:33 +0000 (-0700) Subject: Track whether HolderFundingOutput originated from an anchor channel X-Git-Tag: v0.0.112~11^2~8 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=492b24059ea278e7d99d68f5a7422ccd5abec7eb;p=rust-lightning Track whether HolderFundingOutput originated from an anchor channel --- diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index ae315f9e6..d6c14c68c 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -2884,7 +2884,7 @@ impl ChannelMonitorImpl { 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)); diff --git a/lightning/src/chain/package.rs b/lightning/src/chain/package.rs index a2922d27d..3b6ebb422 100644 --- a/lightning/src/chain/package.rs +++ b/lightning/src/chain/package.rs @@ -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.