@@ -798,21 +798,16 @@ impl CommitmentTransaction {
798
798
}
799
799
800
800
/// Build the Bitcoin transaction
801
- pub fn build < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , channel_parameters : & DirectedChannelTransactionParameters , secp_ctx : & Secp256k1 < T > ) -> Result < ( bitcoin:: Transaction , Vec < HTLCOutputInCommitment > , Vec < Script > ) , ( ) > {
801
+ pub fn build < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , channel_parameters : & DirectedChannelTransactionParameters , secp_ctx : & Secp256k1 < T > ) -> Result < ( bitcoin:: Transaction , Vec < Script > ) , ( ) > {
802
802
let ( obscured_commitment_transaction_number, txins) = self . build_inputs ( channel_parameters) ;
803
803
804
804
let mut txouts = self . build_outputs ( channel_parameters, secp_ctx) ?;
805
805
806
806
let mut outputs = Vec :: with_capacity ( txouts. len ( ) ) ;
807
807
let mut scripts = Vec :: with_capacity ( txouts. len ( ) ) ;
808
- let mut htlcs = Vec :: new ( ) ;
809
- for ( idx, mut out) in txouts. drain ( ..) . enumerate ( ) {
810
- outputs. push ( out. 0 ) ;
811
- scripts. push ( ( out. 1 ) . 0 . clone ( ) ) ;
812
- if let Some ( mut htlc) = ( out. 1 ) . 1 . take ( ) {
813
- htlc. transaction_output_index = Some ( idx as u32 ) ;
814
- htlcs. push ( htlc) ;
815
- }
808
+ for ( txout, script) in txouts. drain ( ..) {
809
+ outputs. push ( txout) ;
810
+ scripts. push ( script) ;
816
811
}
817
812
818
813
Ok ( (
@@ -822,15 +817,14 @@ impl CommitmentTransaction {
822
817
input : txins,
823
818
output : outputs,
824
819
} ,
825
- htlcs,
826
820
scripts,
827
821
) )
828
822
}
829
823
830
- fn build_outputs < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , channel_parameters : & DirectedChannelTransactionParameters , secp_ctx : & Secp256k1 < T > ) -> Result < Vec < ( TxOut , ( Script , Option < HTLCOutputInCommitment > ) ) > , ( ) > {
824
+ fn build_outputs < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , channel_parameters : & DirectedChannelTransactionParameters , secp_ctx : & Secp256k1 < T > ) -> Result < Vec < ( TxOut , Script ) > , ( ) > {
831
825
let htlcs = self . htlcs . iter ( ) . map ( |h| ( h. clone ( ) , ( ) ) ) . collect ( ) ;
832
826
let mut txouts = Self :: do_build_outputs ( & self . keys , self . to_broadcaster_value_sat , self . to_countersignatory_value_sat , & htlcs, channel_parameters, secp_ctx) ?;
833
- let outs = txouts. drain ( ..) . map ( |( out, ( s, extra ) ) | ( out, ( s , extra . map ( | ( p , _ ) | p ) ) ) ) . collect ( ) ;
827
+ let outs = txouts. drain ( ..) . map ( |( out, ( s, _ ) ) | ( out, s ) ) . collect ( ) ;
834
828
Ok ( outs)
835
829
}
836
830
@@ -940,7 +934,7 @@ impl CommitmentTransaction {
940
934
///
941
935
/// Builds the transaction and computes the sighash. This can be used to verify a signature.
942
936
pub fn get_sighash < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , channel_parameters : & DirectedChannelTransactionParameters , funding_redeemscript : & Script , channel_value_satoshis : u64 , secp_ctx : & Secp256k1 < T > ) -> ( Message , Transaction ) {
943
- let ( unsigned_tx, _, _ ) = self . build ( channel_parameters, secp_ctx) . unwrap ( ) ;
937
+ let ( unsigned_tx, _) = self . build ( channel_parameters, secp_ctx) . unwrap ( ) ;
944
938
let sighash = hash_to_message ! ( & bip143:: SigHashCache :: new( & unsigned_tx)
945
939
. signature_hash( 0 , funding_redeemscript, channel_value_satoshis, SigHashType :: All ) [ ..] ) ;
946
940
( sighash, unsigned_tx)
@@ -949,7 +943,7 @@ impl CommitmentTransaction {
949
943
// TODO(devrandom): remove this and subsume the HolderCommitmentTransactionForSigning signing functionality
950
944
pub ( crate ) fn to_holder_commitment_tx < T : secp256k1:: Signing + secp256k1:: Verification > ( & self , counterparty_sig : Signature , htlcs_with_sig : Vec < ( HTLCOutputInCommitment , Option < Signature > ) > , channel_parameters : & DirectedChannelTransactionParameters , secp_ctx : & Secp256k1 < T > ) -> HolderCommitmentTransactionForSigning {
951
945
let ( broadcaster_pubkeys, countersignatory_pubkeys) = channel_parameters. pubkeys ( ) ;
952
- let ( tx, _, _ ) = self . build ( channel_parameters, secp_ctx) . unwrap ( ) ;
946
+ let ( tx, _) = self . build ( channel_parameters, secp_ctx) . unwrap ( ) ;
953
947
HolderCommitmentTransactionForSigning :: new_missing_holder_sig ( tx, counterparty_sig, & broadcaster_pubkeys. funding_pubkey , & countersignatory_pubkeys. funding_pubkey , self . keys . clone ( ) , self . feerate_per_kw , htlcs_with_sig)
954
948
}
955
949
}
0 commit comments