@@ -144,7 +144,6 @@ pub(crate) struct RevokedOutput {
144144 weight : u64 ,
145145 amount : Amount ,
146146 on_counterparty_tx_csv : u16 ,
147- is_counterparty_balance_on_anchors : Option < ( ) > ,
148147 channel_parameters : Option < ChannelTransactionParameters > ,
149148 // Added in LDK 0.1.4/0.2 and always set since.
150149 outpoint_confirmation_height : Option < u32 > ,
@@ -154,7 +153,7 @@ impl RevokedOutput {
154153 #[ rustfmt:: skip]
155154 pub ( crate ) fn build (
156155 per_commitment_point : PublicKey , per_commitment_key : SecretKey , amount : Amount ,
157- is_counterparty_balance_on_anchors : bool , channel_parameters : ChannelTransactionParameters ,
156+ channel_parameters : ChannelTransactionParameters ,
158157 outpoint_confirmation_height : u32 ,
159158 ) -> Self {
160159 let directed_params = channel_parameters. as_counterparty_broadcastable ( ) ;
@@ -170,7 +169,6 @@ impl RevokedOutput {
170169 weight : WEIGHT_REVOKED_OUTPUT ,
171170 amount,
172171 on_counterparty_tx_csv,
173- is_counterparty_balance_on_anchors : if is_counterparty_balance_on_anchors { Some ( ( ) ) } else { None } ,
174172 channel_parameters : Some ( channel_parameters) ,
175173 outpoint_confirmation_height : Some ( outpoint_confirmation_height) ,
176174 }
@@ -186,7 +184,9 @@ impl_writeable_tlv_based!(RevokedOutput, {
186184 ( 8 , weight, required) ,
187185 ( 10 , amount, required) ,
188186 ( 12 , on_counterparty_tx_csv, required) ,
189- ( 14 , is_counterparty_balance_on_anchors, option) ,
187+ // Unused since 0.1, this setting causes downgrades to before 0.1 to refuse to
188+ // aggregate `RevokedOutput` claims, which is the more conservative stance.
189+ ( 14 , is_counterparty_balance_on_anchors, ( legacy, ( ) , |_| Some ( ( ) ) ) ) ,
190190 ( 15 , channel_parameters, ( option: ReadableArgs , None ) ) , // Added in 0.2.
191191} ) ;
192192
@@ -750,11 +750,17 @@ impl PackageSolvingData {
750750 PackageSolvingData :: CounterpartyOfferedHTLCOutput ( ref outp) => outp. htlc . amount_msat / 1000 ,
751751 PackageSolvingData :: CounterpartyReceivedHTLCOutput ( ref outp) => outp. htlc . amount_msat / 1000 ,
752752 PackageSolvingData :: HolderHTLCOutput ( ref outp) => {
753- debug_assert ! ( outp. channel_type_features. supports_anchors_zero_fee_htlc_tx( ) ) ;
753+ let free_htlcs = outp. channel_type_features . supports_anchors_zero_fee_htlc_tx ( ) ;
754+ let free_commitments =
755+ outp. channel_type_features . supports_anchor_zero_fee_commitments ( ) ;
756+ debug_assert ! ( free_htlcs || free_commitments) ;
754757 outp. amount_msat / 1000
755758 } ,
756759 PackageSolvingData :: HolderFundingOutput ( ref outp) => {
757- debug_assert ! ( outp. channel_type_features. supports_anchors_zero_fee_htlc_tx( ) ) ;
760+ let free_htlcs = outp. channel_type_features . supports_anchors_zero_fee_htlc_tx ( ) ;
761+ let free_commitments =
762+ outp. channel_type_features . supports_anchor_zero_fee_commitments ( ) ;
763+ debug_assert ! ( free_htlcs || free_commitments) ;
758764 outp. funding_amount_sats . unwrap ( )
759765 }
760766 } ;
@@ -768,7 +774,10 @@ impl PackageSolvingData {
768774 PackageSolvingData :: CounterpartyOfferedHTLCOutput ( ref outp) => weight_offered_htlc ( & outp. channel_type_features ) as usize ,
769775 PackageSolvingData :: CounterpartyReceivedHTLCOutput ( ref outp) => weight_received_htlc ( & outp. channel_type_features ) as usize ,
770776 PackageSolvingData :: HolderHTLCOutput ( ref outp) => {
771- debug_assert ! ( outp. channel_type_features. supports_anchors_zero_fee_htlc_tx( ) ) ;
777+ let free_htlcs = outp. channel_type_features . supports_anchors_zero_fee_htlc_tx ( ) ;
778+ let free_commitments =
779+ outp. channel_type_features . supports_anchor_zero_fee_commitments ( ) ;
780+ debug_assert ! ( free_htlcs || free_commitments) ;
772781 if outp. preimage . is_none ( ) {
773782 weight_offered_htlc ( & outp. channel_type_features ) as usize
774783 } else {
@@ -988,6 +997,7 @@ impl PackageSolvingData {
988997 match self {
989998 PackageSolvingData :: HolderHTLCOutput ( ref outp) => {
990999 debug_assert ! ( !outp. channel_type_features. supports_anchors_zero_fee_htlc_tx( ) ) ;
1000+ debug_assert ! ( !outp. channel_type_features. supports_anchor_zero_fee_commitments( ) ) ;
9911001 outp. get_maybe_signed_htlc_tx ( onchain_handler, outpoint)
9921002 }
9931003 PackageSolvingData :: HolderFundingOutput ( ref outp) => {
@@ -1040,14 +1050,20 @@ impl PackageSolvingData {
10401050 PackageMalleability :: Malleable ( AggregationCluster :: Unpinnable ) ,
10411051 PackageSolvingData :: CounterpartyReceivedHTLCOutput ( ..) =>
10421052 PackageMalleability :: Malleable ( AggregationCluster :: Pinnable ) ,
1043- PackageSolvingData :: HolderHTLCOutput ( ref outp) if outp. channel_type_features . supports_anchors_zero_fee_htlc_tx ( ) => {
1044- if outp. preimage . is_some ( ) {
1045- PackageMalleability :: Malleable ( AggregationCluster :: Unpinnable )
1053+ PackageSolvingData :: HolderHTLCOutput ( ref outp) => {
1054+ let free_htlcs = outp. channel_type_features . supports_anchors_zero_fee_htlc_tx ( ) ;
1055+ let free_commits = outp. channel_type_features . supports_anchor_zero_fee_commitments ( ) ;
1056+
1057+ if free_htlcs || free_commits {
1058+ if outp. preimage . is_some ( ) {
1059+ PackageMalleability :: Malleable ( AggregationCluster :: Unpinnable )
1060+ } else {
1061+ PackageMalleability :: Malleable ( AggregationCluster :: Pinnable )
1062+ }
10461063 } else {
1047- PackageMalleability :: Malleable ( AggregationCluster :: Pinnable )
1064+ PackageMalleability :: Untractable
10481065 }
10491066 } ,
1050- PackageSolvingData :: HolderHTLCOutput ( ..) => PackageMalleability :: Untractable ,
10511067 PackageSolvingData :: HolderFundingOutput ( ..) => PackageMalleability :: Untractable ,
10521068 }
10531069 }
@@ -1364,7 +1380,10 @@ impl PackageTemplate {
13641380 for ( previous_output, input) in & self . inputs {
13651381 match input {
13661382 PackageSolvingData :: HolderHTLCOutput ( ref outp) => {
1367- debug_assert ! ( outp. channel_type_features. supports_anchors_zero_fee_htlc_tx( ) ) ;
1383+ let free_htlcs = outp. channel_type_features . supports_anchors_zero_fee_htlc_tx ( ) ;
1384+ let free_commitments =
1385+ outp. channel_type_features . supports_anchor_zero_fee_commitments ( ) ;
1386+ debug_assert ! ( free_htlcs || free_commitments) ;
13681387 outp. get_htlc_descriptor ( onchain_handler, & previous_output) . map ( |htlc| {
13691388 htlcs. get_or_insert_with ( || Vec :: with_capacity ( self . inputs . len ( ) ) ) . push ( htlc) ;
13701389 } ) ;
@@ -1559,8 +1578,14 @@ impl PackageTemplate {
15591578 #[ rustfmt:: skip]
15601579 pub ( crate ) fn requires_external_funding ( & self ) -> bool {
15611580 self . inputs . iter ( ) . find ( |input| match input. 1 {
1562- PackageSolvingData :: HolderFundingOutput ( ref outp) => outp. channel_type_features . supports_anchors_zero_fee_htlc_tx ( ) ,
1563- PackageSolvingData :: HolderHTLCOutput ( ref outp) => outp. channel_type_features . supports_anchors_zero_fee_htlc_tx ( ) ,
1581+ PackageSolvingData :: HolderFundingOutput ( ref outp) => {
1582+ outp. channel_type_features . supports_anchors_zero_fee_htlc_tx ( )
1583+ || outp. channel_type_features . supports_anchor_zero_fee_commitments ( )
1584+ } ,
1585+ PackageSolvingData :: HolderHTLCOutput ( ref outp) => {
1586+ outp. channel_type_features . supports_anchors_zero_fee_htlc_tx ( )
1587+ || outp. channel_type_features . supports_anchor_zero_fee_commitments ( )
1588+ } ,
15641589 _ => false ,
15651590 } ) . is_some ( )
15661591 }
@@ -1796,16 +1821,13 @@ mod tests {
17961821
17971822 #[ rustfmt:: skip]
17981823 macro_rules! dumb_revk_output {
1799- ( $is_counterparty_balance_on_anchors : expr ) => {
1824+ ( ) => {
18001825 {
18011826 let secp_ctx = Secp256k1 :: new( ) ;
18021827 let dumb_scalar = SecretKey :: from_slice( & <Vec <u8 >>:: from_hex( "0101010101010101010101010101010101010101010101010101010101010101" ) . unwrap( ) [ ..] ) . unwrap( ) ;
18031828 let dumb_point = PublicKey :: from_secret_key( & secp_ctx, & dumb_scalar) ;
18041829 let channel_parameters = ChannelTransactionParameters :: test_dummy( 0 ) ;
1805- PackageSolvingData :: RevokedOutput ( RevokedOutput :: build(
1806- dumb_point, dumb_scalar, Amount :: ZERO , $is_counterparty_balance_on_anchors,
1807- channel_parameters, 0 ,
1808- ) )
1830+ PackageSolvingData :: RevokedOutput ( RevokedOutput :: build( dumb_point, dumb_scalar, Amount :: ZERO , channel_parameters, 0 ) )
18091831 }
18101832 }
18111833 }
@@ -2107,9 +2129,9 @@ mod tests {
21072129 #[ test]
21082130 #[ rustfmt:: skip]
21092131 fn test_package_split_malleable ( ) {
2110- let revk_outp_one = dumb_revk_output ! ( false ) ;
2111- let revk_outp_two = dumb_revk_output ! ( false ) ;
2112- let revk_outp_three = dumb_revk_output ! ( false ) ;
2132+ let revk_outp_one = dumb_revk_output ! ( ) ;
2133+ let revk_outp_two = dumb_revk_output ! ( ) ;
2134+ let revk_outp_three = dumb_revk_output ! ( ) ;
21132135
21142136 let mut package_one = PackageTemplate :: build_package ( fake_txid ( 1 ) , 0 , revk_outp_one, 1100 ) ;
21152137 let package_two = PackageTemplate :: build_package ( fake_txid ( 1 ) , 1 , revk_outp_two, 1100 ) ;
@@ -2141,7 +2163,7 @@ mod tests {
21412163
21422164 #[ test]
21432165 fn test_package_timer ( ) {
2144- let revk_outp = dumb_revk_output ! ( false ) ;
2166+ let revk_outp = dumb_revk_output ! ( ) ;
21452167
21462168 let mut package = PackageTemplate :: build_package ( fake_txid ( 1 ) , 0 , revk_outp, 1000 ) ;
21472169 assert_eq ! ( package. timer( ) , 0 ) ;
@@ -2165,7 +2187,7 @@ mod tests {
21652187 let weight_sans_output = ( 4 + 4 + 1 + 36 + 4 + 1 + 1 + 8 + 1 ) * WITNESS_SCALE_FACTOR as u64 + 2 ;
21662188
21672189 {
2168- let revk_outp = dumb_revk_output ! ( false ) ;
2190+ let revk_outp = dumb_revk_output ! ( ) ;
21692191 let package = PackageTemplate :: build_package ( fake_txid ( 1 ) , 0 , revk_outp, 0 ) ;
21702192 assert_eq ! ( package. package_weight( & ScriptBuf :: new( ) ) , weight_sans_output + WEIGHT_REVOKED_OUTPUT ) ;
21712193 }
0 commit comments