@@ -636,47 +636,46 @@ impl PackageTemplate {
636
636
let output_weight = ( 8 + 1 + destination_script. len ( ) ) * WITNESS_SCALE_FACTOR ;
637
637
inputs_weight + witnesses_weight + transaction_weight + output_weight
638
638
}
639
- pub ( crate ) fn finalize_package < L : Deref , Signer : Sign > ( & self , onchain_handler : & mut OnchainTxHandler < Signer > , value : u64 , destination_script : Script , logger : & L ) -> Option < Transaction >
640
- where L :: Target : Logger ,
641
- {
642
- match self . malleability {
643
- PackageMalleability :: Malleable => {
644
- let mut bumped_tx = Transaction {
645
- version : 2 ,
646
- lock_time : PackedLockTime :: ZERO ,
647
- input : vec ! [ ] ,
648
- output : vec ! [ TxOut {
649
- script_pubkey: destination_script,
650
- value,
651
- } ] ,
652
- } ;
653
- for ( outpoint, _) in self . inputs . iter ( ) {
654
- bumped_tx. input . push ( TxIn {
655
- previous_output : * outpoint,
656
- script_sig : Script :: new ( ) ,
657
- sequence : Sequence :: ENABLE_RBF_NO_LOCKTIME ,
658
- witness : Witness :: new ( ) ,
659
- } ) ;
660
- }
661
- for ( i, ( outpoint, out) ) in self . inputs . iter ( ) . enumerate ( ) {
662
- log_debug ! ( logger, "Adding claiming input for outpoint {}:{}" , outpoint. txid, outpoint. vout) ;
663
- if !out. finalize_input ( & mut bumped_tx, i, onchain_handler) { return None ; }
664
- }
665
- log_debug ! ( logger, "Finalized transaction {} ready to broadcast" , bumped_tx. txid( ) ) ;
666
- return Some ( bumped_tx) ;
667
- } ,
668
- PackageMalleability :: Untractable => {
669
- debug_assert_eq ! ( value, 0 , "value is ignored for non-malleable packages, should be zero to ensure callsites are correct" ) ;
670
- if let Some ( ( outpoint, outp) ) = self . inputs . first ( ) {
671
- if let Some ( final_tx) = outp. get_finalized_tx ( outpoint, onchain_handler) {
672
- log_debug ! ( logger, "Adding claiming input for outpoint {}:{}" , outpoint. txid, outpoint. vout) ;
673
- log_debug ! ( logger, "Finalized transaction {} ready to broadcast" , final_tx. txid( ) ) ;
674
- return Some ( final_tx) ;
675
- }
676
- return None ;
677
- } else { panic ! ( "API Error: Package must not be inputs empty" ) ; }
678
- } ,
639
+ pub ( crate ) fn finalize_malleable_package < L : Deref , Signer : Sign > (
640
+ & self , onchain_handler : & mut OnchainTxHandler < Signer > , value : u64 , destination_script : Script , logger : & L ,
641
+ ) -> Option < Transaction > where L :: Target : Logger {
642
+ debug_assert ! ( self . is_malleable( ) ) ;
643
+ let mut bumped_tx = Transaction {
644
+ version : 2 ,
645
+ lock_time : PackedLockTime :: ZERO ,
646
+ input : vec ! [ ] ,
647
+ output : vec ! [ TxOut {
648
+ script_pubkey: destination_script,
649
+ value,
650
+ } ] ,
651
+ } ;
652
+ for ( outpoint, _) in self . inputs . iter ( ) {
653
+ bumped_tx. input . push ( TxIn {
654
+ previous_output : * outpoint,
655
+ script_sig : Script :: new ( ) ,
656
+ sequence : Sequence :: ENABLE_RBF_NO_LOCKTIME ,
657
+ witness : Witness :: new ( ) ,
658
+ } ) ;
679
659
}
660
+ for ( i, ( outpoint, out) ) in self . inputs . iter ( ) . enumerate ( ) {
661
+ log_debug ! ( logger, "Adding claiming input for outpoint {}:{}" , outpoint. txid, outpoint. vout) ;
662
+ if !out. finalize_input ( & mut bumped_tx, i, onchain_handler) { return None ; }
663
+ }
664
+ log_debug ! ( logger, "Finalized transaction {} ready to broadcast" , bumped_tx. txid( ) ) ;
665
+ Some ( bumped_tx)
666
+ }
667
+ pub ( crate ) fn finalize_untractable_package < L : Deref , Signer : Sign > (
668
+ & self , onchain_handler : & mut OnchainTxHandler < Signer > , logger : & L ,
669
+ ) -> Option < Transaction > where L :: Target : Logger {
670
+ debug_assert ! ( !self . is_malleable( ) ) ;
671
+ if let Some ( ( outpoint, outp) ) = self . inputs . first ( ) {
672
+ if let Some ( final_tx) = outp. get_finalized_tx ( outpoint, onchain_handler) {
673
+ log_debug ! ( logger, "Adding claiming input for outpoint {}:{}" , outpoint. txid, outpoint. vout) ;
674
+ log_debug ! ( logger, "Finalized transaction {} ready to broadcast" , final_tx. txid( ) ) ;
675
+ return Some ( final_tx) ;
676
+ }
677
+ return None ;
678
+ } else { panic ! ( "API Error: Package must not be inputs empty" ) ; }
680
679
}
681
680
/// In LN, output claimed are time-sensitive, which means we have to spend them before reaching some timelock expiration. At in-channel
682
681
/// output detection, we generate a first version of a claim tx and associate to it a height timer. A height timer is an absolute block
0 commit comments