@@ -387,6 +387,17 @@ impl PackageSolvingData {
387
387
_ => { panic ! ( "API Error!" ) ; }
388
388
}
389
389
}
390
+ fn absolute_tx_timelock ( & self , input_height : u32 ) -> u32 {
391
+ let amt = match self {
392
+ PackageSolvingData :: RevokedOutput ( _) => input_height + 1 ,
393
+ PackageSolvingData :: RevokedHTLCOutput ( _) => input_height + 1 ,
394
+ PackageSolvingData :: CounterpartyOfferedHTLCOutput ( ref outp) => input_height + 1 ,
395
+ PackageSolvingData :: CounterpartyReceivedHTLCOutput ( ref outp) => std:: cmp:: max ( outp. htlc . cltv_expiry , input_height + 1 ) ,
396
+ PackageSolvingData :: HolderHTLCOutput ( ref outp) => std:: cmp:: max ( outp. cltv_expiry , input_height + 1 ) ,
397
+ PackageSolvingData :: HolderFundingOutput ( _) => input_height + 1 ,
398
+ } ;
399
+ amt
400
+ }
390
401
}
391
402
392
403
impl Writeable for PackageSolvingData {
@@ -598,6 +609,13 @@ impl PackageTemplate {
598
609
}
599
610
amounts
600
611
}
612
+ pub ( crate ) fn package_timelock ( & self ) -> u32 {
613
+ let mut max_locktime = 0 ;
614
+ for ( _, outp) in self . inputs . iter ( ) {
615
+ max_locktime = std:: cmp:: max ( max_locktime, outp. absolute_tx_timelock ( self . height_original ) ) ;
616
+ }
617
+ max_locktime
618
+ }
601
619
pub ( crate ) fn package_weight ( & self , destination_script : & Script ) -> usize {
602
620
let mut inputs_weight = 0 ;
603
621
let mut witnesses_weight = 2 ; // count segwit flags
0 commit comments