@@ -731,10 +731,14 @@ 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
+ ///
737
+ /// This is used primarily by external consumers to decide when an output becomes "pinnable"
738
+ /// because the counterparty can potentially spend it. It is also used internally by
739
+ /// [`Self::get_height_timer`] to identify when an output must be claimed by, depending on the
740
+ /// type of output.
741
+ counterparty_spendable_height : u32 ,
738
742
// Determines if this package can be aggregated.
739
743
// Timelocked outputs belonging to the same transaction might have differing
740
744
// satisfying heights. Picking up the later height among the output set would be a valid
@@ -763,7 +767,7 @@ impl PackageTemplate {
763
767
/// This is an important limit for aggregation as after this height our counterparty may be
764
768
/// able to pin transactions spending this output in the mempool.
765
769
pub ( crate ) fn counterparty_spendable_height ( & self ) -> u32 {
766
- self . soonest_conf_deadline
770
+ self . counterparty_spendable_height
767
771
}
768
772
pub ( crate ) fn aggregable ( & self ) -> bool {
769
773
self . aggregable
@@ -790,7 +794,6 @@ impl PackageTemplate {
790
794
match self . malleability {
791
795
PackageMalleability :: Malleable => {
792
796
let mut split_package = None ;
793
- let timelock = self . soonest_conf_deadline ;
794
797
let aggregable = self . aggregable ;
795
798
let feerate_previous = self . feerate_previous ;
796
799
let height_timer = self . height_timer ;
@@ -799,7 +802,7 @@ impl PackageTemplate {
799
802
split_package = Some ( PackageTemplate {
800
803
inputs : vec ! [ ( outp. 0 , outp. 1 . clone( ) ) ] ,
801
804
malleability : PackageMalleability :: Malleable ,
802
- soonest_conf_deadline : timelock ,
805
+ counterparty_spendable_height : self . counterparty_spendable_height ,
803
806
aggregable,
804
807
feerate_previous,
805
808
height_timer,
@@ -836,8 +839,8 @@ impl PackageTemplate {
836
839
self . inputs . push ( ( k, v) ) ;
837
840
}
838
841
//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 ;
842
+ if self . counterparty_spendable_height > merge_from. counterparty_spendable_height {
843
+ self . counterparty_spendable_height = merge_from. counterparty_spendable_height ;
841
844
}
842
845
if self . feerate_previous > merge_from. feerate_previous {
843
846
self . feerate_previous = merge_from. feerate_previous ;
@@ -971,10 +974,10 @@ impl PackageTemplate {
971
974
match input {
972
975
PackageSolvingData :: RevokedOutput ( _) => {
973
976
// Revoked Outputs will become spendable by our counterparty at the height
974
- // where the CSV expires, which is also our `soonest_conf_deadline `.
977
+ // where the CSV expires, which is also our `counterparty_spendable_height `.
975
978
height_timer = cmp:: min (
976
979
height_timer,
977
- timer_for_target_conf ( self . soonest_conf_deadline ) ,
980
+ timer_for_target_conf ( self . counterparty_spendable_height ) ,
978
981
) ;
979
982
} ,
980
983
PackageSolvingData :: RevokedHTLCOutput ( _) => {
@@ -995,10 +998,10 @@ impl PackageTemplate {
995
998
PackageSolvingData :: HolderHTLCOutput ( outp) if outp. preimage . is_some ( ) => {
996
999
// We have the same deadline here as for `CounterpartyOfferedHTLCOutput`. Note
997
1000
// that `outp.cltv_expiry` is always 0 in this case, but
998
- // `soonest_conf_deadline ` holds the real HTLC expiry.
1001
+ // `counterparty_spendable_height ` holds the real HTLC expiry.
999
1002
height_timer = cmp:: min (
1000
1003
height_timer,
1001
- timer_for_target_conf ( self . soonest_conf_deadline ) ,
1004
+ timer_for_target_conf ( self . counterparty_spendable_height ) ,
1002
1005
) ;
1003
1006
} ,
1004
1007
PackageSolvingData :: CounterpartyReceivedHTLCOutput ( outp) => {
@@ -1100,13 +1103,13 @@ impl PackageTemplate {
1100
1103
} ) . is_some ( )
1101
1104
}
1102
1105
1103
- pub ( crate ) fn build_package ( txid : Txid , vout : u32 , input_solving_data : PackageSolvingData , soonest_conf_deadline : u32 ) -> Self {
1106
+ pub ( crate ) fn build_package ( txid : Txid , vout : u32 , input_solving_data : PackageSolvingData , counterparty_spendable_height : u32 ) -> Self {
1104
1107
let ( malleability, aggregable) = PackageSolvingData :: map_output_type_flags ( & input_solving_data) ;
1105
1108
let inputs = vec ! [ ( BitcoinOutPoint { txid, vout } , input_solving_data) ] ;
1106
1109
PackageTemplate {
1107
1110
inputs,
1108
1111
malleability,
1109
- soonest_conf_deadline ,
1112
+ counterparty_spendable_height ,
1110
1113
aggregable,
1111
1114
feerate_previous : 0 ,
1112
1115
height_timer : 0 ,
@@ -1122,7 +1125,7 @@ impl Writeable for PackageTemplate {
1122
1125
rev_outp. write ( writer) ?;
1123
1126
}
1124
1127
write_tlv_fields ! ( writer, {
1125
- ( 0 , self . soonest_conf_deadline , required) ,
1128
+ ( 0 , self . counterparty_spendable_height , required) ,
1126
1129
( 2 , self . feerate_previous, required) ,
1127
1130
// Prior to 0.1, the height at which the package's inputs were mined, but was always unused
1128
1131
( 4 , 0u32 , required) ,
@@ -1144,20 +1147,20 @@ impl Readable for PackageTemplate {
1144
1147
let ( malleability, aggregable) = if let Some ( ( _, lead_input) ) = inputs. first ( ) {
1145
1148
PackageSolvingData :: map_output_type_flags ( & lead_input)
1146
1149
} else { return Err ( DecodeError :: InvalidValue ) ; } ;
1147
- let mut soonest_conf_deadline = 0 ;
1150
+ let mut counterparty_spendable_height = 0 ;
1148
1151
let mut feerate_previous = 0 ;
1149
1152
let mut height_timer = None ;
1150
1153
let mut _height_original: Option < u32 > = None ;
1151
1154
read_tlv_fields ! ( reader, {
1152
- ( 0 , soonest_conf_deadline , required) ,
1155
+ ( 0 , counterparty_spendable_height , required) ,
1153
1156
( 2 , feerate_previous, required) ,
1154
1157
( 4 , _height_original, option) , // Written with a dummy value since 0.1
1155
1158
( 6 , height_timer, option) ,
1156
1159
} ) ;
1157
1160
Ok ( PackageTemplate {
1158
1161
inputs,
1159
1162
malleability,
1160
- soonest_conf_deadline ,
1163
+ counterparty_spendable_height ,
1161
1164
aggregable,
1162
1165
feerate_previous,
1163
1166
height_timer : height_timer. unwrap_or ( 0 ) ,
@@ -1421,7 +1424,7 @@ mod tests {
1421
1424
if let Some ( split_package) = package_one. split_package ( & BitcoinOutPoint { txid, vout : 1 } ) {
1422
1425
// Packages attributes should be identical
1423
1426
assert ! ( split_package. is_malleable( ) ) ;
1424
- assert_eq ! ( split_package. soonest_conf_deadline , package_one. soonest_conf_deadline ) ;
1427
+ assert_eq ! ( split_package. counterparty_spendable_height , package_one. counterparty_spendable_height ) ;
1425
1428
assert_eq ! ( split_package. aggregable, package_one. aggregable) ;
1426
1429
assert_eq ! ( split_package. feerate_previous, package_one. feerate_previous) ;
1427
1430
assert_eq ! ( split_package. height_timer, package_one. height_timer) ;
0 commit comments