@@ -731,10 +731,11 @@ pub struct PackageTemplate {
731731 // Untractable packages have been counter-signed and thus imply that we can't aggregate
732732 // them without breaking signatures. Fee-bumping strategy will also rely on CPFP.
733733 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 ,
738739 // Determines if this package can be aggregated.
739740 // Timelocked outputs belonging to the same transaction might have differing
740741 // satisfying heights. Picking up the later height among the output set would be a valid
@@ -763,7 +764,7 @@ impl PackageTemplate {
763764 /// This is an important limit for aggregation as after this height our counterparty may be
764765 /// able to pin transactions spending this output in the mempool.
765766 pub ( crate ) fn counterparty_spendable_height ( & self ) -> u32 {
766- self . soonest_conf_deadline
767+ self . counterparty_spendable_height
767768 }
768769 pub ( crate ) fn aggregable ( & self ) -> bool {
769770 self . aggregable
@@ -790,7 +791,6 @@ impl PackageTemplate {
790791 match self . malleability {
791792 PackageMalleability :: Malleable => {
792793 let mut split_package = None ;
793- let timelock = self . soonest_conf_deadline ;
794794 let aggregable = self . aggregable ;
795795 let feerate_previous = self . feerate_previous ;
796796 let height_timer = self . height_timer ;
@@ -799,7 +799,7 @@ impl PackageTemplate {
799799 split_package = Some ( PackageTemplate {
800800 inputs : vec ! [ ( outp. 0 , outp. 1 . clone( ) ) ] ,
801801 malleability : PackageMalleability :: Malleable ,
802- soonest_conf_deadline : timelock ,
802+ counterparty_spendable_height : self . counterparty_spendable_height ,
803803 aggregable,
804804 feerate_previous,
805805 height_timer,
@@ -836,8 +836,8 @@ impl PackageTemplate {
836836 self . inputs . push ( ( k, v) ) ;
837837 }
838838 //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 ;
841841 }
842842 if self . feerate_previous > merge_from. feerate_previous {
843843 self . feerate_previous = merge_from. feerate_previous ;
@@ -971,10 +971,10 @@ impl PackageTemplate {
971971 match input {
972972 PackageSolvingData :: RevokedOutput ( _) => {
973973 // 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 `.
975975 height_timer = cmp:: min (
976976 height_timer,
977- timer_for_target_conf ( self . soonest_conf_deadline ) ,
977+ timer_for_target_conf ( self . counterparty_spendable_height ) ,
978978 ) ;
979979 } ,
980980 PackageSolvingData :: RevokedHTLCOutput ( _) => {
@@ -995,10 +995,10 @@ impl PackageTemplate {
995995 PackageSolvingData :: HolderHTLCOutput ( outp) if outp. preimage . is_some ( ) => {
996996 // We have the same deadline here as for `CounterpartyOfferedHTLCOutput`. Note
997997 // that `outp.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.
999999 height_timer = cmp:: min (
10001000 height_timer,
1001- timer_for_target_conf ( self . soonest_conf_deadline ) ,
1001+ timer_for_target_conf ( self . counterparty_spendable_height ) ,
10021002 ) ;
10031003 } ,
10041004 PackageSolvingData :: CounterpartyReceivedHTLCOutput ( outp) => {
@@ -1100,13 +1100,13 @@ impl PackageTemplate {
11001100 } ) . is_some ( )
11011101 }
11021102
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 {
11041104 let ( malleability, aggregable) = PackageSolvingData :: map_output_type_flags ( & input_solving_data) ;
11051105 let inputs = vec ! [ ( BitcoinOutPoint { txid, vout } , input_solving_data) ] ;
11061106 PackageTemplate {
11071107 inputs,
11081108 malleability,
1109- soonest_conf_deadline ,
1109+ counterparty_spendable_height ,
11101110 aggregable,
11111111 feerate_previous : 0 ,
11121112 height_timer : 0 ,
@@ -1122,7 +1122,7 @@ impl Writeable for PackageTemplate {
11221122 rev_outp. write ( writer) ?;
11231123 }
11241124 write_tlv_fields ! ( writer, {
1125- ( 0 , self . soonest_conf_deadline , required) ,
1125+ ( 0 , self . counterparty_spendable_height , required) ,
11261126 ( 2 , self . feerate_previous, required) ,
11271127 // Prior to 0.1, the height at which the package's inputs were mined, but was always unused
11281128 ( 4 , 0u32 , required) ,
@@ -1144,20 +1144,20 @@ impl Readable for PackageTemplate {
11441144 let ( malleability, aggregable) = if let Some ( ( _, lead_input) ) = inputs. first ( ) {
11451145 PackageSolvingData :: map_output_type_flags ( & lead_input)
11461146 } else { return Err ( DecodeError :: InvalidValue ) ; } ;
1147- let mut soonest_conf_deadline = 0 ;
1147+ let mut counterparty_spendable_height = 0 ;
11481148 let mut feerate_previous = 0 ;
11491149 let mut height_timer = None ;
11501150 let mut _height_original: Option < u32 > = None ;
11511151 read_tlv_fields ! ( reader, {
1152- ( 0 , soonest_conf_deadline , required) ,
1152+ ( 0 , counterparty_spendable_height , required) ,
11531153 ( 4 , _height_original, option) , // Written with a dummy value since 0.1
11541154 ( 2 , feerate_previous, required) ,
11551155 ( 6 , height_timer, option) ,
11561156 } ) ;
11571157 Ok ( PackageTemplate {
11581158 inputs,
11591159 malleability,
1160- soonest_conf_deadline ,
1160+ counterparty_spendable_height ,
11611161 aggregable,
11621162 feerate_previous,
11631163 height_timer : height_timer. unwrap_or ( 0 ) ,
@@ -1421,7 +1421,7 @@ mod tests {
14211421 if let Some ( split_package) = package_one. split_package ( & BitcoinOutPoint { txid, vout : 1 } ) {
14221422 // Packages attributes should be identical
14231423 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 ) ;
14251425 assert_eq ! ( split_package. aggregable, package_one. aggregable) ;
14261426 assert_eq ! ( split_package. feerate_previous, package_one. feerate_previous) ;
14271427 assert_eq ! ( split_package. height_timer, package_one. height_timer) ;
0 commit comments