@@ -274,8 +274,8 @@ impl PackageSolvingData {
274
274
// Note: Currently, amounts of holder outputs spending witnesses aren't used
275
275
// as we can't malleate spending package to increase their feerate. This
276
276
// should change with the remaining anchor output patchset.
277
- PackageSolvingData :: HolderHTLCOutput ( ..) => { 0 } ,
278
- PackageSolvingData :: HolderFundingOutput ( ..) => { 0 } ,
277
+ PackageSolvingData :: HolderHTLCOutput ( ..) => { debug_assert ! ( false ) ; 0 } ,
278
+ PackageSolvingData :: HolderFundingOutput ( ..) => { debug_assert ! ( false ) ; 0 } ,
279
279
} ;
280
280
amt
281
281
}
@@ -577,7 +577,9 @@ impl PackageTemplate {
577
577
}
578
578
self . height_timer = cmp:: min ( self . height_timer , merge_from. height_timer ) ;
579
579
}
580
- pub ( crate ) fn package_amount ( & self ) -> u64 {
580
+ /// Gets the amount of all outptus being spent by this package, only valid for malleable
581
+ /// packages.
582
+ fn package_amount ( & self ) -> u64 {
581
583
let mut amounts = 0 ;
582
584
for ( _, outp) in self . inputs . iter ( ) {
583
585
amounts += outp. amount ( ) ;
@@ -628,6 +630,7 @@ impl PackageTemplate {
628
630
return Some ( bumped_tx) ;
629
631
} ,
630
632
PackageMalleability :: Untractable => {
633
+ debug_assert_eq ! ( value, 0 , "value is ignored for non-malleable packages, should be zero to ensure callsites are correct" ) ;
631
634
if let Some ( ( outpoint, outp) ) = self . inputs . first ( ) {
632
635
if let Some ( final_tx) = outp. get_finalized_tx ( outpoint, onchain_handler) {
633
636
log_trace ! ( logger, "Adding claiming input for outpoint {}:{}" , outpoint. txid, outpoint. vout) ;
@@ -653,10 +656,12 @@ impl PackageTemplate {
653
656
current_height + LOW_FREQUENCY_BUMP_INTERVAL
654
657
}
655
658
/// Returns value in satoshis to be included as package outgoing output amount and feerate with which package finalization should be done.
656
- pub ( crate ) fn compute_package_output < F : Deref , L : Deref > ( & self , predicted_weight : usize , input_amounts : u64 , fee_estimator : & F , logger : & L ) -> Option < ( u64 , u64 ) >
659
+ pub ( crate ) fn compute_package_output < F : Deref , L : Deref > ( & self , predicted_weight : usize , fee_estimator : & F , logger : & L ) -> Option < ( u64 , u64 ) >
657
660
where F :: Target : FeeEstimator ,
658
661
L :: Target : Logger ,
659
662
{
663
+ debug_assert ! ( self . malleability == PackageMalleability :: Malleable , "The package output is fixed for non-malleable packages" ) ;
664
+ let input_amounts = self . package_amount ( ) ;
660
665
// If old feerate is 0, first iteration of this claim, use normal fee calculation
661
666
if self . feerate_previous != 0 {
662
667
if let Some ( ( new_fee, feerate) ) = feerate_bump ( predicted_weight, input_amounts, self . feerate_previous , fee_estimator, logger) {
0 commit comments