@@ -731,10 +731,11 @@ pub struct PackageTemplate {
731
731
// Untractable packages have been counter-signed and thus imply that we can't aggregate
732
732
// them without breaking signatures. Fee-bumping strategy will also rely on CPFP.
733
733
malleability : PackageMalleability ,
734
- // Block height after which the earlier-output belonging to this package is mature for a
735
- // competing claim by the counterparty. As our chain tip becomes nearer from the timelock,
736
- // the fee-bumping frequency will increase. See `OnchainTxHandler::get_height_timer`.
737
- soonest_conf_deadline : u32 ,
734
+ // Block height at which our counterparty can potentially claim this output as well (assuming
735
+ // they have the keys or information required to do so).
736
+ // For HTLCs we're claiming with a preimage and revoked outputs, we need to get our spend
737
+ // on-chain before this height.
738
+ counterparty_spendable_height : u32 ,
738
739
// Determines if this package can be aggregated.
739
740
// Timelocked outputs belonging to the same transaction might have differing
740
741
// satisfying heights. Picking up the later height among the output set would be a valid
@@ -763,7 +764,7 @@ impl PackageTemplate {
763
764
/// This is an important limit for aggregation as after this height our counterparty may be
764
765
/// able to pin transactions spending this output in the mempool.
765
766
pub ( crate ) fn counterparty_spendable_height ( & self ) -> u32 {
766
- self . soonest_conf_deadline
767
+ self . counterparty_spendable_height
767
768
}
768
769
pub ( crate ) fn aggregable ( & self ) -> bool {
769
770
self . aggregable
@@ -790,7 +791,6 @@ impl PackageTemplate {
790
791
match self . malleability {
791
792
PackageMalleability :: Malleable => {
792
793
let mut split_package = None ;
793
- let timelock = self . soonest_conf_deadline ;
794
794
let aggregable = self . aggregable ;
795
795
let feerate_previous = self . feerate_previous ;
796
796
let height_timer = self . height_timer ;
@@ -799,7 +799,7 @@ impl PackageTemplate {
799
799
split_package = Some ( PackageTemplate {
800
800
inputs : vec ! [ ( outp. 0 , outp. 1 . clone( ) ) ] ,
801
801
malleability : PackageMalleability :: Malleable ,
802
- soonest_conf_deadline : timelock ,
802
+ counterparty_spendable_height : self . counterparty_spendable_height ,
803
803
aggregable,
804
804
feerate_previous,
805
805
height_timer,
@@ -836,8 +836,8 @@ impl PackageTemplate {
836
836
self . inputs . push ( ( k, v) ) ;
837
837
}
838
838
//TODO: verify coverage and sanity?
839
- if self . soonest_conf_deadline > merge_from. soonest_conf_deadline {
840
- self . soonest_conf_deadline = merge_from. soonest_conf_deadline ;
839
+ if self . counterparty_spendable_height > merge_from. counterparty_spendable_height {
840
+ self . counterparty_spendable_height = merge_from. counterparty_spendable_height ;
841
841
}
842
842
if self . feerate_previous > merge_from. feerate_previous {
843
843
self . feerate_previous = merge_from. feerate_previous ;
@@ -971,10 +971,10 @@ impl PackageTemplate {
971
971
match input {
972
972
PackageSolvingData :: RevokedOutput ( _) => {
973
973
// Revoked Outputs will become spendable by our counterparty at the height
974
- // where the CSV expires, which is also our `soonest_conf_deadline `.
974
+ // where the CSV expires, which is also our `counterparty_spendable_height `.
975
975
height_timer = cmp:: min (
976
976
height_timer,
977
- timer_for_target_conf ( self . soonest_conf_deadline ) ,
977
+ timer_for_target_conf ( self . counterparty_spendable_height ) ,
978
978
) ;
979
979
} ,
980
980
PackageSolvingData :: RevokedHTLCOutput ( _) => {
@@ -995,10 +995,10 @@ impl PackageTemplate {
995
995
PackageSolvingData :: HolderHTLCOutput ( outp) if outp. preimage . is_some ( ) => {
996
996
// We have the same deadline here as for `CounterpartyOfferedHTLCOutput`. Note
997
997
// that `outp.htlc.cltv_expiry` is always 0 in this case, but
998
- // `soonest_conf_deadline ` holds the real HTLC expiry.
998
+ // `counterparty_spendable_height ` holds the real HTLC expiry.
999
999
height_timer = cmp:: min (
1000
1000
height_timer,
1001
- timer_for_target_conf ( self . soonest_conf_deadline ) ,
1001
+ timer_for_target_conf ( self . counterparty_spendable_height ) ,
1002
1002
) ;
1003
1003
} ,
1004
1004
PackageSolvingData :: CounterpartyReceivedHTLCOutput ( outp) => {
@@ -1100,13 +1100,13 @@ impl PackageTemplate {
1100
1100
} ) . is_some ( )
1101
1101
}
1102
1102
1103
- pub ( crate ) fn build_package ( txid : Txid , vout : u32 , input_solving_data : PackageSolvingData , soonest_conf_deadline : u32 ) -> Self {
1103
+ pub ( crate ) fn build_package ( txid : Txid , vout : u32 , input_solving_data : PackageSolvingData , counterparty_spendable_height : u32 ) -> Self {
1104
1104
let ( malleability, aggregable) = PackageSolvingData :: map_output_type_flags ( & input_solving_data) ;
1105
1105
let inputs = vec ! [ ( BitcoinOutPoint { txid, vout } , input_solving_data) ] ;
1106
1106
PackageTemplate {
1107
1107
inputs,
1108
1108
malleability,
1109
- soonest_conf_deadline ,
1109
+ counterparty_spendable_height ,
1110
1110
aggregable,
1111
1111
feerate_previous : 0 ,
1112
1112
height_timer : 0 ,
@@ -1122,7 +1122,7 @@ impl Writeable for PackageTemplate {
1122
1122
rev_outp. write ( writer) ?;
1123
1123
}
1124
1124
write_tlv_fields ! ( writer, {
1125
- ( 0 , self . soonest_conf_deadline , required) ,
1125
+ ( 0 , self . counterparty_spendable_height , required) ,
1126
1126
( 2 , self . feerate_previous, required) ,
1127
1127
// Prior to 0.1, the height at which the package's inputs were mined, but was always unused
1128
1128
( 4 , 0u32 , required) ,
@@ -1144,20 +1144,20 @@ impl Readable for PackageTemplate {
1144
1144
let ( malleability, aggregable) = if let Some ( ( _, lead_input) ) = inputs. first ( ) {
1145
1145
PackageSolvingData :: map_output_type_flags ( & lead_input)
1146
1146
} else { return Err ( DecodeError :: InvalidValue ) ; } ;
1147
- let mut soonest_conf_deadline = 0 ;
1147
+ let mut counterparty_spendable_height = 0 ;
1148
1148
let mut feerate_previous = 0 ;
1149
1149
let mut height_timer = None ;
1150
1150
let mut _height_original: Option < u32 > = None ;
1151
1151
read_tlv_fields ! ( reader, {
1152
- ( 0 , soonest_conf_deadline , required) ,
1152
+ ( 0 , counterparty_spendable_height , required) ,
1153
1153
( 4 , _height_original, option) , // Written with a dummy value since 0.1
1154
1154
( 2 , feerate_previous, required) ,
1155
1155
( 6 , height_timer, option) ,
1156
1156
} ) ;
1157
1157
Ok ( PackageTemplate {
1158
1158
inputs,
1159
1159
malleability,
1160
- soonest_conf_deadline ,
1160
+ counterparty_spendable_height ,
1161
1161
aggregable,
1162
1162
feerate_previous,
1163
1163
height_timer : height_timer. unwrap_or ( 0 ) ,
@@ -1421,7 +1421,7 @@ mod tests {
1421
1421
if let Some ( split_package) = package_one. split_package ( & BitcoinOutPoint { txid, vout : 1 } ) {
1422
1422
// Packages attributes should be identical
1423
1423
assert ! ( split_package. is_malleable( ) ) ;
1424
- assert_eq ! ( split_package. soonest_conf_deadline , package_one. soonest_conf_deadline ) ;
1424
+ assert_eq ! ( split_package. counterparty_spendable_height , package_one. counterparty_spendable_height ) ;
1425
1425
assert_eq ! ( split_package. aggregable, package_one. aggregable) ;
1426
1426
assert_eq ! ( split_package. feerate_previous, package_one. feerate_previous) ;
1427
1427
assert_eq ! ( split_package. height_timer, package_one. height_timer) ;
0 commit comments