@@ -769,6 +769,37 @@ pub fn build_htlc_input_witness(
769
769
witness
770
770
}
771
771
772
+ /// Pre-anchors channel type features did not use to get serialized in the following six structs:
773
+ /// — [`ChannelTransactionParameters`]
774
+ /// — [`CommitmentTransaction`]
775
+ /// — [`CounterpartyOfferedHTLCOutput`]
776
+ /// — [`CounterpartyReceivedHTLCOutput`]
777
+ /// — [`HolderHTLCOutput`]
778
+ /// — [`HolderFundingOutput`]
779
+ ///
780
+ /// To ensure a forwards-compatible serialization, we use odd TLV fields. However, if new features
781
+ /// are used that could break security, where old signers should be prevented from handling the
782
+ /// serialized data, an optional even-field TLV will be used as a stand-in to break compatibility.
783
+ ///
784
+ /// This method determines whether or not that option needs to be set based on the chanenl type
785
+ /// features, and returns it.
786
+ ///
787
+ /// [`CounterpartyOfferedHTLCOutput`]: crate::chain::package::CounterpartyOfferedHTLCOutput
788
+ /// [`CounterpartyReceivedHTLCOutput`]: crate::chain::package::CounterpartyReceivedHTLCOutput
789
+ /// [`HolderHTLCOutput`]: crate::chain::package::HolderHTLCOutput
790
+ /// [`HolderFundingOutput`]: crate::chain::package::HolderFundingOutput
791
+ pub ( crate ) fn legacy_deserialization_prevention_marker_for_channel_type_features ( features : & ChannelTypeFeatures ) -> Option < ( ) > {
792
+ let mut legacy_version_bit_set = ChannelTypeFeatures :: only_static_remote_key ( ) ;
793
+ legacy_version_bit_set. set_scid_privacy_required ( ) ;
794
+ legacy_version_bit_set. set_zero_conf_required ( ) ;
795
+
796
+ if features. is_subset ( & legacy_version_bit_set) {
797
+ None
798
+ } else {
799
+ Some ( ( ) )
800
+ }
801
+ }
802
+
772
803
/// Gets the witnessScript for the to_remote output when anchors are enabled.
773
804
#[ inline]
774
805
pub fn get_to_countersignatory_with_anchors_redeemscript ( payment_point : & PublicKey ) -> Script {
0 commit comments