@@ -736,10 +736,14 @@ pub struct PackageTemplate {
736736 // Untractable packages have been counter-signed and thus imply that we can't aggregate
737737 // them without breaking signatures. Fee-bumping strategy will also rely on CPFP.
738738 malleability : PackageMalleability ,
739- // Block height after which the earlier-output belonging to this package is mature for a
740- // competing claim by the counterparty. As our chain tip becomes nearer from the timelock,
741- // the fee-bumping frequency will increase. See `OnchainTxHandler::get_height_timer`.
742- soonest_conf_deadline : u32 ,
739+ /// Block height at which our counterparty can potentially claim this output as well (assuming
740+ /// they have the keys or information required to do so).
741+ ///
742+ /// This is used primarily by external consumers to decide when an output becomes "pinnable"
743+ /// because the counterparty can potentially spend it. It is also used internally by
744+ /// [`Self::get_height_timer`] to identify when an output must be claimed by, depending on the
745+ /// type of output.
746+ counterparty_spendable_height : u32 ,
743747 // Determines if this package can be aggregated.
744748 // Timelocked outputs belonging to the same transaction might have differing
745749 // satisfying heights. Picking up the later height among the output set would be a valid
@@ -768,7 +772,7 @@ impl PackageTemplate {
768772 /// This is an important limit for aggregation as after this height our counterparty may be
769773 /// able to pin transactions spending this output in the mempool.
770774 pub ( crate ) fn counterparty_spendable_height ( & self ) -> u32 {
771- self . soonest_conf_deadline
775+ self . counterparty_spendable_height
772776 }
773777 pub ( crate ) fn aggregable ( & self ) -> bool {
774778 self . aggregable
@@ -795,7 +799,6 @@ impl PackageTemplate {
795799 match self . malleability {
796800 PackageMalleability :: Malleable => {
797801 let mut split_package = None ;
798- let timelock = self . soonest_conf_deadline ;
799802 let aggregable = self . aggregable ;
800803 let feerate_previous = self . feerate_previous ;
801804 let height_timer = self . height_timer ;
@@ -804,7 +807,7 @@ impl PackageTemplate {
804807 split_package = Some ( PackageTemplate {
805808 inputs : vec ! [ ( outp. 0 , outp. 1 . clone( ) ) ] ,
806809 malleability : PackageMalleability :: Malleable ,
807- soonest_conf_deadline : timelock ,
810+ counterparty_spendable_height : self . counterparty_spendable_height ,
808811 aggregable,
809812 feerate_previous,
810813 height_timer,
@@ -841,8 +844,8 @@ impl PackageTemplate {
841844 self . inputs . push ( ( k, v) ) ;
842845 }
843846 //TODO: verify coverage and sanity?
844- if self . soonest_conf_deadline > merge_from. soonest_conf_deadline {
845- self . soonest_conf_deadline = merge_from. soonest_conf_deadline ;
847+ if self . counterparty_spendable_height > merge_from. counterparty_spendable_height {
848+ self . counterparty_spendable_height = merge_from. counterparty_spendable_height ;
846849 }
847850 if self . feerate_previous > merge_from. feerate_previous {
848851 self . feerate_previous = merge_from. feerate_previous ;
@@ -976,10 +979,10 @@ impl PackageTemplate {
976979 match input {
977980 PackageSolvingData :: RevokedOutput ( _) => {
978981 // Revoked Outputs will become spendable by our counterparty at the height
979- // where the CSV expires, which is also our `soonest_conf_deadline `.
982+ // where the CSV expires, which is also our `counterparty_spendable_height `.
980983 height_timer = cmp:: min (
981984 height_timer,
982- timer_for_target_conf ( self . soonest_conf_deadline ) ,
985+ timer_for_target_conf ( self . counterparty_spendable_height ) ,
983986 ) ;
984987 } ,
985988 PackageSolvingData :: RevokedHTLCOutput ( _) => {
@@ -1000,10 +1003,10 @@ impl PackageTemplate {
10001003 PackageSolvingData :: HolderHTLCOutput ( outp) if outp. preimage . is_some ( ) => {
10011004 // We have the same deadline here as for `CounterpartyOfferedHTLCOutput`. Note
10021005 // that `outp.cltv_expiry` is always 0 in this case, but
1003- // `soonest_conf_deadline ` holds the real HTLC expiry.
1006+ // `counterparty_spendable_height ` holds the real HTLC expiry.
10041007 height_timer = cmp:: min (
10051008 height_timer,
1006- timer_for_target_conf ( self . soonest_conf_deadline ) ,
1009+ timer_for_target_conf ( self . counterparty_spendable_height ) ,
10071010 ) ;
10081011 } ,
10091012 PackageSolvingData :: CounterpartyReceivedHTLCOutput ( outp) => {
@@ -1105,13 +1108,13 @@ impl PackageTemplate {
11051108 } ) . is_some ( )
11061109 }
11071110
1108- pub ( crate ) fn build_package ( txid : Txid , vout : u32 , input_solving_data : PackageSolvingData , soonest_conf_deadline : u32 ) -> Self {
1111+ pub ( crate ) fn build_package ( txid : Txid , vout : u32 , input_solving_data : PackageSolvingData , counterparty_spendable_height : u32 ) -> Self {
11091112 let ( malleability, aggregable) = PackageSolvingData :: map_output_type_flags ( & input_solving_data) ;
11101113 let inputs = vec ! [ ( BitcoinOutPoint { txid, vout } , input_solving_data) ] ;
11111114 PackageTemplate {
11121115 inputs,
11131116 malleability,
1114- soonest_conf_deadline ,
1117+ counterparty_spendable_height ,
11151118 aggregable,
11161119 feerate_previous : 0 ,
11171120 height_timer : 0 ,
@@ -1127,7 +1130,7 @@ impl Writeable for PackageTemplate {
11271130 rev_outp. write ( writer) ?;
11281131 }
11291132 write_tlv_fields ! ( writer, {
1130- ( 0 , self . soonest_conf_deadline , required) ,
1133+ ( 0 , self . counterparty_spendable_height , required) ,
11311134 ( 2 , self . feerate_previous, required) ,
11321135 // Prior to 0.1, the height at which the package's inputs were mined, but was always unused
11331136 ( 4 , 0u32 , required) ,
@@ -1149,20 +1152,20 @@ impl Readable for PackageTemplate {
11491152 let ( malleability, aggregable) = if let Some ( ( _, lead_input) ) = inputs. first ( ) {
11501153 PackageSolvingData :: map_output_type_flags ( & lead_input)
11511154 } else { return Err ( DecodeError :: InvalidValue ) ; } ;
1152- let mut soonest_conf_deadline = 0 ;
1155+ let mut counterparty_spendable_height = 0 ;
11531156 let mut feerate_previous = 0 ;
11541157 let mut height_timer = None ;
11551158 let mut _height_original: Option < u32 > = None ;
11561159 read_tlv_fields ! ( reader, {
1157- ( 0 , soonest_conf_deadline , required) ,
1160+ ( 0 , counterparty_spendable_height , required) ,
11581161 ( 2 , feerate_previous, required) ,
11591162 ( 4 , _height_original, option) , // Written with a dummy value since 0.1
11601163 ( 6 , height_timer, option) ,
11611164 } ) ;
11621165 Ok ( PackageTemplate {
11631166 inputs,
11641167 malleability,
1165- soonest_conf_deadline ,
1168+ counterparty_spendable_height ,
11661169 aggregable,
11671170 feerate_previous,
11681171 height_timer : height_timer. unwrap_or ( 0 ) ,
@@ -1426,7 +1429,7 @@ mod tests {
14261429 if let Some ( split_package) = package_one. split_package ( & BitcoinOutPoint { txid, vout : 1 } ) {
14271430 // Packages attributes should be identical
14281431 assert ! ( split_package. is_malleable( ) ) ;
1429- assert_eq ! ( split_package. soonest_conf_deadline , package_one. soonest_conf_deadline ) ;
1432+ assert_eq ! ( split_package. counterparty_spendable_height , package_one. counterparty_spendable_height ) ;
14301433 assert_eq ! ( split_package. aggregable, package_one. aggregable) ;
14311434 assert_eq ! ( split_package. feerate_previous, package_one. feerate_previous) ;
14321435 assert_eq ! ( split_package. height_timer, package_one. height_timer) ;
0 commit comments