@@ -144,7 +144,6 @@ pub(crate) struct RevokedOutput {
144
144
weight : u64 ,
145
145
amount : Amount ,
146
146
on_counterparty_tx_csv : u16 ,
147
- is_counterparty_balance_on_anchors : Option < ( ) > ,
148
147
channel_parameters : Option < ChannelTransactionParameters > ,
149
148
// Added in LDK 0.1.4/0.2 and always set since.
150
149
outpoint_confirmation_height : Option < u32 > ,
@@ -154,7 +153,7 @@ impl RevokedOutput {
154
153
#[ rustfmt:: skip]
155
154
pub ( crate ) fn build (
156
155
per_commitment_point : PublicKey , per_commitment_key : SecretKey , amount : Amount ,
157
- is_counterparty_balance_on_anchors : bool , channel_parameters : ChannelTransactionParameters ,
156
+ channel_parameters : ChannelTransactionParameters ,
158
157
outpoint_confirmation_height : u32 ,
159
158
) -> Self {
160
159
let directed_params = channel_parameters. as_counterparty_broadcastable ( ) ;
@@ -170,7 +169,6 @@ impl RevokedOutput {
170
169
weight : WEIGHT_REVOKED_OUTPUT ,
171
170
amount,
172
171
on_counterparty_tx_csv,
173
- is_counterparty_balance_on_anchors : if is_counterparty_balance_on_anchors { Some ( ( ) ) } else { None } ,
174
172
channel_parameters : Some ( channel_parameters) ,
175
173
outpoint_confirmation_height : Some ( outpoint_confirmation_height) ,
176
174
}
@@ -186,7 +184,9 @@ impl_writeable_tlv_based!(RevokedOutput, {
186
184
( 8 , weight, required) ,
187
185
( 10 , amount, required) ,
188
186
( 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 ( ( ) ) ) ) ,
190
190
( 15 , channel_parameters, ( option: ReadableArgs , None ) ) , // Added in 0.2.
191
191
} ) ;
192
192
@@ -750,11 +750,17 @@ impl PackageSolvingData {
750
750
PackageSolvingData :: CounterpartyOfferedHTLCOutput ( ref outp) => outp. htlc . amount_msat / 1000 ,
751
751
PackageSolvingData :: CounterpartyReceivedHTLCOutput ( ref outp) => outp. htlc . amount_msat / 1000 ,
752
752
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) ;
754
757
outp. amount_msat / 1000
755
758
} ,
756
759
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) ;
758
764
outp. funding_amount_sats . unwrap ( )
759
765
}
760
766
} ;
@@ -768,7 +774,10 @@ impl PackageSolvingData {
768
774
PackageSolvingData :: CounterpartyOfferedHTLCOutput ( ref outp) => weight_offered_htlc ( & outp. channel_type_features ) as usize ,
769
775
PackageSolvingData :: CounterpartyReceivedHTLCOutput ( ref outp) => weight_received_htlc ( & outp. channel_type_features ) as usize ,
770
776
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) ;
772
781
if outp. preimage . is_none ( ) {
773
782
weight_offered_htlc ( & outp. channel_type_features ) as usize
774
783
} else {
@@ -988,6 +997,7 @@ impl PackageSolvingData {
988
997
match self {
989
998
PackageSolvingData :: HolderHTLCOutput ( ref outp) => {
990
999
debug_assert ! ( !outp. channel_type_features. supports_anchors_zero_fee_htlc_tx( ) ) ;
1000
+ debug_assert ! ( !outp. channel_type_features. supports_anchor_zero_fee_commitments( ) ) ;
991
1001
outp. get_maybe_signed_htlc_tx ( onchain_handler, outpoint)
992
1002
}
993
1003
PackageSolvingData :: HolderFundingOutput ( ref outp) => {
@@ -1040,14 +1050,20 @@ impl PackageSolvingData {
1040
1050
PackageMalleability :: Malleable ( AggregationCluster :: Unpinnable ) ,
1041
1051
PackageSolvingData :: CounterpartyReceivedHTLCOutput ( ..) =>
1042
1052
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
+ }
1046
1063
} else {
1047
- PackageMalleability :: Malleable ( AggregationCluster :: Pinnable )
1064
+ PackageMalleability :: Untractable
1048
1065
}
1049
1066
} ,
1050
- PackageSolvingData :: HolderHTLCOutput ( ..) => PackageMalleability :: Untractable ,
1051
1067
PackageSolvingData :: HolderFundingOutput ( ..) => PackageMalleability :: Untractable ,
1052
1068
}
1053
1069
}
@@ -1364,7 +1380,10 @@ impl PackageTemplate {
1364
1380
for ( previous_output, input) in & self . inputs {
1365
1381
match input {
1366
1382
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) ;
1368
1387
outp. get_htlc_descriptor ( onchain_handler, & previous_output) . map ( |htlc| {
1369
1388
htlcs. get_or_insert_with ( || Vec :: with_capacity ( self . inputs . len ( ) ) ) . push ( htlc) ;
1370
1389
} ) ;
@@ -1559,8 +1578,14 @@ impl PackageTemplate {
1559
1578
#[ rustfmt:: skip]
1560
1579
pub ( crate ) fn requires_external_funding ( & self ) -> bool {
1561
1580
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
+ } ,
1564
1589
_ => false ,
1565
1590
} ) . is_some ( )
1566
1591
}
@@ -1796,16 +1821,13 @@ mod tests {
1796
1821
1797
1822
#[ rustfmt:: skip]
1798
1823
macro_rules! dumb_revk_output {
1799
- ( $is_counterparty_balance_on_anchors : expr ) => {
1824
+ ( ) => {
1800
1825
{
1801
1826
let secp_ctx = Secp256k1 :: new( ) ;
1802
1827
let dumb_scalar = SecretKey :: from_slice( & <Vec <u8 >>:: from_hex( "0101010101010101010101010101010101010101010101010101010101010101" ) . unwrap( ) [ ..] ) . unwrap( ) ;
1803
1828
let dumb_point = PublicKey :: from_secret_key( & secp_ctx, & dumb_scalar) ;
1804
1829
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 ) )
1809
1831
}
1810
1832
}
1811
1833
}
@@ -2107,9 +2129,9 @@ mod tests {
2107
2129
#[ test]
2108
2130
#[ rustfmt:: skip]
2109
2131
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 ! ( ) ;
2113
2135
2114
2136
let mut package_one = PackageTemplate :: build_package ( fake_txid ( 1 ) , 0 , revk_outp_one, 1100 ) ;
2115
2137
let package_two = PackageTemplate :: build_package ( fake_txid ( 1 ) , 1 , revk_outp_two, 1100 ) ;
@@ -2141,7 +2163,7 @@ mod tests {
2141
2163
2142
2164
#[ test]
2143
2165
fn test_package_timer ( ) {
2144
- let revk_outp = dumb_revk_output ! ( false ) ;
2166
+ let revk_outp = dumb_revk_output ! ( ) ;
2145
2167
2146
2168
let mut package = PackageTemplate :: build_package ( fake_txid ( 1 ) , 0 , revk_outp, 1000 ) ;
2147
2169
assert_eq ! ( package. timer( ) , 0 ) ;
@@ -2165,7 +2187,7 @@ mod tests {
2165
2187
let weight_sans_output = ( 4 + 4 + 1 + 36 + 4 + 1 + 1 + 8 + 1 ) * WITNESS_SCALE_FACTOR as u64 + 2 ;
2166
2188
2167
2189
{
2168
- let revk_outp = dumb_revk_output ! ( false ) ;
2190
+ let revk_outp = dumb_revk_output ! ( ) ;
2169
2191
let package = PackageTemplate :: build_package ( fake_txid ( 1 ) , 0 , revk_outp, 0 ) ;
2170
2192
assert_eq ! ( package. package_weight( & ScriptBuf :: new( ) ) , weight_sans_output + WEIGHT_REVOKED_OUTPUT ) ;
2171
2193
}
0 commit comments