@@ -736,10 +736,11 @@ 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+ // For HTLCs we're claiming with a preimage and revoked outputs, we need to get our spend
742+ // on-chain before this height.
743+ counterparty_spendable_height : u32 ,
743744 // Determines if this package can be aggregated.
744745 // Timelocked outputs belonging to the same transaction might have differing
745746 // satisfying heights. Picking up the later height among the output set would be a valid
@@ -768,7 +769,7 @@ impl PackageTemplate {
768769 /// This is an important limit for aggregation as after this height our counterparty may be
769770 /// able to pin transactions spending this output in the mempool.
770771 pub ( crate ) fn counterparty_spendable_height ( & self ) -> u32 {
771- self . soonest_conf_deadline
772+ self . counterparty_spendable_height
772773 }
773774 pub ( crate ) fn aggregable ( & self ) -> bool {
774775 self . aggregable
@@ -795,7 +796,6 @@ impl PackageTemplate {
795796 match self . malleability {
796797 PackageMalleability :: Malleable => {
797798 let mut split_package = None ;
798- let timelock = self . soonest_conf_deadline ;
799799 let aggregable = self . aggregable ;
800800 let feerate_previous = self . feerate_previous ;
801801 let height_timer = self . height_timer ;
@@ -804,7 +804,7 @@ impl PackageTemplate {
804804 split_package = Some ( PackageTemplate {
805805 inputs : vec ! [ ( outp. 0 , outp. 1 . clone( ) ) ] ,
806806 malleability : PackageMalleability :: Malleable ,
807- soonest_conf_deadline : timelock ,
807+ counterparty_spendable_height : self . counterparty_spendable_height ,
808808 aggregable,
809809 feerate_previous,
810810 height_timer,
@@ -841,8 +841,8 @@ impl PackageTemplate {
841841 self . inputs . push ( ( k, v) ) ;
842842 }
843843 //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 ;
844+ if self . counterparty_spendable_height > merge_from. counterparty_spendable_height {
845+ self . counterparty_spendable_height = merge_from. counterparty_spendable_height ;
846846 }
847847 if self . feerate_previous > merge_from. feerate_previous {
848848 self . feerate_previous = merge_from. feerate_previous ;
@@ -976,10 +976,10 @@ impl PackageTemplate {
976976 match input {
977977 PackageSolvingData :: RevokedOutput ( _) => {
978978 // Revoked Outputs will become spendable by our counterparty at the height
979- // where the CSV expires, which is also our `soonest_conf_deadline `.
979+ // where the CSV expires, which is also our `counterparty_spendable_height `.
980980 height_timer = cmp:: min (
981981 height_timer,
982- timer_for_target_conf ( self . soonest_conf_deadline ) ,
982+ timer_for_target_conf ( self . counterparty_spendable_height ) ,
983983 ) ;
984984 } ,
985985 PackageSolvingData :: RevokedHTLCOutput ( _) => {
@@ -1000,10 +1000,10 @@ impl PackageTemplate {
10001000 PackageSolvingData :: HolderHTLCOutput ( outp) if outp. preimage . is_some ( ) => {
10011001 // We have the same deadline here as for `CounterpartyOfferedHTLCOutput`. Note
10021002 // that `outp.cltv_expiry` is always 0 in this case, but
1003- // `soonest_conf_deadline ` holds the real HTLC expiry.
1003+ // `counterparty_spendable_height ` holds the real HTLC expiry.
10041004 height_timer = cmp:: min (
10051005 height_timer,
1006- timer_for_target_conf ( self . soonest_conf_deadline ) ,
1006+ timer_for_target_conf ( self . counterparty_spendable_height ) ,
10071007 ) ;
10081008 } ,
10091009 PackageSolvingData :: CounterpartyReceivedHTLCOutput ( outp) => {
@@ -1105,13 +1105,13 @@ impl PackageTemplate {
11051105 } ) . is_some ( )
11061106 }
11071107
1108- pub ( crate ) fn build_package ( txid : Txid , vout : u32 , input_solving_data : PackageSolvingData , soonest_conf_deadline : u32 ) -> Self {
1108+ pub ( crate ) fn build_package ( txid : Txid , vout : u32 , input_solving_data : PackageSolvingData , counterparty_spendable_height : u32 ) -> Self {
11091109 let ( malleability, aggregable) = PackageSolvingData :: map_output_type_flags ( & input_solving_data) ;
11101110 let inputs = vec ! [ ( BitcoinOutPoint { txid, vout } , input_solving_data) ] ;
11111111 PackageTemplate {
11121112 inputs,
11131113 malleability,
1114- soonest_conf_deadline ,
1114+ counterparty_spendable_height ,
11151115 aggregable,
11161116 feerate_previous : 0 ,
11171117 height_timer : 0 ,
@@ -1127,7 +1127,7 @@ impl Writeable for PackageTemplate {
11271127 rev_outp. write ( writer) ?;
11281128 }
11291129 write_tlv_fields ! ( writer, {
1130- ( 0 , self . soonest_conf_deadline , required) ,
1130+ ( 0 , self . counterparty_spendable_height , required) ,
11311131 ( 2 , self . feerate_previous, required) ,
11321132 // Prior to 0.1, the height at which the package's inputs were mined, but was always unused
11331133 ( 4 , 0u32 , required) ,
@@ -1149,20 +1149,20 @@ impl Readable for PackageTemplate {
11491149 let ( malleability, aggregable) = if let Some ( ( _, lead_input) ) = inputs. first ( ) {
11501150 PackageSolvingData :: map_output_type_flags ( & lead_input)
11511151 } else { return Err ( DecodeError :: InvalidValue ) ; } ;
1152- let mut soonest_conf_deadline = 0 ;
1152+ let mut counterparty_spendable_height = 0 ;
11531153 let mut feerate_previous = 0 ;
11541154 let mut height_timer = None ;
11551155 let mut _height_original: Option < u32 > = None ;
11561156 read_tlv_fields ! ( reader, {
1157- ( 0 , soonest_conf_deadline , required) ,
1157+ ( 0 , counterparty_spendable_height , required) ,
11581158 ( 4 , _height_original, option) , // Written with a dummy value since 0.1
11591159 ( 2 , feerate_previous, required) ,
11601160 ( 6 , height_timer, option) ,
11611161 } ) ;
11621162 Ok ( PackageTemplate {
11631163 inputs,
11641164 malleability,
1165- soonest_conf_deadline ,
1165+ counterparty_spendable_height ,
11661166 aggregable,
11671167 feerate_previous,
11681168 height_timer : height_timer. unwrap_or ( 0 ) ,
@@ -1426,7 +1426,7 @@ mod tests {
14261426 if let Some ( split_package) = package_one. split_package ( & BitcoinOutPoint { txid, vout : 1 } ) {
14271427 // Packages attributes should be identical
14281428 assert ! ( split_package. is_malleable( ) ) ;
1429- assert_eq ! ( split_package. soonest_conf_deadline , package_one. soonest_conf_deadline ) ;
1429+ assert_eq ! ( split_package. counterparty_spendable_height , package_one. counterparty_spendable_height ) ;
14301430 assert_eq ! ( split_package. aggregable, package_one. aggregable) ;
14311431 assert_eq ! ( split_package. feerate_previous, package_one. feerate_previous) ;
14321432 assert_eq ! ( split_package. height_timer, package_one. height_timer) ;
0 commit comments