@@ -656,47 +656,46 @@ impl PackageTemplate {
656
656
} ;
657
657
transaction_weight + inputs_weight + witnesses_weight + output_weight
658
658
}
659
- pub ( crate ) fn finalize_package < L : Deref , Signer : Sign > ( & self , onchain_handler : & mut OnchainTxHandler < Signer > , value : u64 , destination_script : Script , logger : & L ) -> Option < Transaction >
660
- where L :: Target : Logger ,
661
- {
662
- match self . malleability {
663
- PackageMalleability :: Malleable => {
664
- let mut bumped_tx = Transaction {
665
- version : 2 ,
666
- lock_time : PackedLockTime :: ZERO ,
667
- input : vec ! [ ] ,
668
- output : vec ! [ TxOut {
669
- script_pubkey: destination_script,
670
- value,
671
- } ] ,
672
- } ;
673
- for ( outpoint, _) in self . inputs . iter ( ) {
674
- bumped_tx. input . push ( TxIn {
675
- previous_output : * outpoint,
676
- script_sig : Script :: new ( ) ,
677
- sequence : Sequence :: ENABLE_RBF_NO_LOCKTIME ,
678
- witness : Witness :: new ( ) ,
679
- } ) ;
680
- }
681
- for ( i, ( outpoint, out) ) in self . inputs . iter ( ) . enumerate ( ) {
682
- log_debug ! ( logger, "Adding claiming input for outpoint {}:{}" , outpoint. txid, outpoint. vout) ;
683
- if !out. finalize_input ( & mut bumped_tx, i, onchain_handler) { return None ; }
684
- }
685
- log_debug ! ( logger, "Finalized transaction {} ready to broadcast" , bumped_tx. txid( ) ) ;
686
- return Some ( bumped_tx) ;
687
- } ,
688
- PackageMalleability :: Untractable => {
689
- debug_assert_eq ! ( value, 0 , "value is ignored for non-malleable packages, should be zero to ensure callsites are correct" ) ;
690
- if let Some ( ( outpoint, outp) ) = self . inputs . first ( ) {
691
- if let Some ( final_tx) = outp. get_finalized_tx ( outpoint, onchain_handler) {
692
- log_debug ! ( logger, "Adding claiming input for outpoint {}:{}" , outpoint. txid, outpoint. vout) ;
693
- log_debug ! ( logger, "Finalized transaction {} ready to broadcast" , final_tx. txid( ) ) ;
694
- return Some ( final_tx) ;
695
- }
696
- return None ;
697
- } else { panic ! ( "API Error: Package must not be inputs empty" ) ; }
698
- } ,
659
+ pub ( crate ) fn finalize_malleable_package < L : Deref , Signer : Sign > (
660
+ & self , onchain_handler : & mut OnchainTxHandler < Signer > , value : u64 , destination_script : Script , logger : & L ,
661
+ ) -> Option < Transaction > where L :: Target : Logger {
662
+ debug_assert ! ( self . is_malleable( ) ) ;
663
+ let mut bumped_tx = Transaction {
664
+ version : 2 ,
665
+ lock_time : PackedLockTime :: ZERO ,
666
+ input : vec ! [ ] ,
667
+ output : vec ! [ TxOut {
668
+ script_pubkey: destination_script,
669
+ value,
670
+ } ] ,
671
+ } ;
672
+ for ( outpoint, _) in self . inputs . iter ( ) {
673
+ bumped_tx. input . push ( TxIn {
674
+ previous_output : * outpoint,
675
+ script_sig : Script :: new ( ) ,
676
+ sequence : Sequence :: ENABLE_RBF_NO_LOCKTIME ,
677
+ witness : Witness :: new ( ) ,
678
+ } ) ;
699
679
}
680
+ for ( i, ( outpoint, out) ) in self . inputs . iter ( ) . enumerate ( ) {
681
+ log_debug ! ( logger, "Adding claiming input for outpoint {}:{}" , outpoint. txid, outpoint. vout) ;
682
+ if !out. finalize_input ( & mut bumped_tx, i, onchain_handler) { return None ; }
683
+ }
684
+ log_debug ! ( logger, "Finalized transaction {} ready to broadcast" , bumped_tx. txid( ) ) ;
685
+ Some ( bumped_tx)
686
+ }
687
+ pub ( crate ) fn finalize_untractable_package < L : Deref , Signer : Sign > (
688
+ & self , onchain_handler : & mut OnchainTxHandler < Signer > , logger : & L ,
689
+ ) -> Option < Transaction > where L :: Target : Logger {
690
+ debug_assert ! ( !self . is_malleable( ) ) ;
691
+ if let Some ( ( outpoint, outp) ) = self . inputs . first ( ) {
692
+ if let Some ( final_tx) = outp. get_finalized_tx ( outpoint, onchain_handler) {
693
+ log_debug ! ( logger, "Adding claiming input for outpoint {}:{}" , outpoint. txid, outpoint. vout) ;
694
+ log_debug ! ( logger, "Finalized transaction {} ready to broadcast" , final_tx. txid( ) ) ;
695
+ return Some ( final_tx) ;
696
+ }
697
+ return None ;
698
+ } else { panic ! ( "API Error: Package must not be inputs empty" ) ; }
700
699
}
701
700
/// In LN, output claimed are time-sensitive, which means we have to spend them before reaching some timelock expiration. At in-channel
702
701
/// 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