@@ -21,19 +21,21 @@ use crate::ln::channel::ANCHOR_OUTPUT_VALUE_SATOSHI;
2121use  crate :: ln:: chan_utils; 
2222use  crate :: ln:: chan_utils:: { 
2323	ANCHOR_INPUT_WITNESS_WEIGHT ,  HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT , 
24- 	HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT ,  ChannelTransactionParameters ,   HTLCOutputInCommitment 
24+ 	HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT ,  HTLCOutputInCommitment 
2525} ; 
26- use  crate :: ln:: PaymentPreimage ; 
2726use  crate :: prelude:: * ; 
28- use  crate :: sign:: { EcdsaChannelSigner ,  SignerProvider ,  WriteableEcdsaChannelSigner ,  P2WPKH_WITNESS_WEIGHT } ; 
27+ use  crate :: sign:: { 
28+ 	ChannelDerivationParameters ,  HTLCDescriptor ,  EcdsaChannelSigner ,  SignerProvider , 
29+ 	WriteableEcdsaChannelSigner ,  P2WPKH_WITNESS_WEIGHT 
30+ } ; 
2931use  crate :: sync:: Mutex ; 
3032use  crate :: util:: logger:: Logger ; 
3133
32- use  bitcoin:: { OutPoint ,  PackedLockTime ,  PubkeyHash ,  Sequence ,  Script ,  Transaction ,  Txid ,   TxIn ,  TxOut ,  Witness ,  WPubkeyHash } ; 
34+ use  bitcoin:: { OutPoint ,  PackedLockTime ,  PubkeyHash ,  Sequence ,  Script ,  Transaction ,  TxIn ,  TxOut ,  Witness ,  WPubkeyHash } ; 
3335use  bitcoin:: blockdata:: constants:: WITNESS_SCALE_FACTOR ; 
3436use  bitcoin:: consensus:: Encodable ; 
3537use  bitcoin:: secp256k1; 
36- use  bitcoin:: secp256k1:: { PublicKey ,   Secp256k1 } ; 
38+ use  bitcoin:: secp256k1:: Secp256k1 ; 
3739use  bitcoin:: secp256k1:: ecdsa:: Signature ; 
3840
3941const  EMPTY_SCRIPT_SIG_WEIGHT :  u64  = 1  /* empty script_sig */  *  WITNESS_SCALE_FACTOR  as  u64 ; 
@@ -42,26 +44,6 @@ const BASE_INPUT_SIZE: u64 = 32 /* txid */ + 4 /* vout */ + 4 /* sequence */;
4244
4345const  BASE_INPUT_WEIGHT :  u64  = BASE_INPUT_SIZE  *  WITNESS_SCALE_FACTOR  as  u64 ; 
4446
45- /// The parameters required to derive a channel signer via [`SignerProvider`]. 
46- #[ derive( Clone ,  Debug ,  PartialEq ,  Eq ) ]  
47- pub  struct  ChannelDerivationParameters  { 
48- 	/// The value in satoshis of the channel we're attempting to spend the anchor output of. 
49- pub  value_satoshis :  u64 , 
50- 	/// The unique identifier to re-derive the signer for the associated channel. 
51- pub  keys_id :  [ u8 ;  32 ] , 
52- 	/// The necessary channel parameters that need to be provided to the re-derived signer through 
53- /// [`ChannelSigner::provide_channel_parameters`]. 
54- /// 
55- /// [`ChannelSigner::provide_channel_parameters`]: crate::sign::ChannelSigner::provide_channel_parameters 
56- pub  transaction_parameters :  ChannelTransactionParameters , 
57- } 
58- 
59- impl_writeable_tlv_based ! ( ChannelDerivationParameters ,  { 
60-     ( 0 ,  value_satoshis,  required) , 
61-     ( 2 ,  keys_id,  required) , 
62-     ( 4 ,  transaction_parameters,  required) , 
63- } ) ; 
64- 
6547/// A descriptor used to sign for a commitment transaction's anchor output. 
6648#[ derive( Clone ,  Debug ,  PartialEq ,  Eq ) ]  
6749pub  struct  AnchorDescriptor  { 
@@ -120,133 +102,6 @@ impl AnchorDescriptor {
120102	} 
121103} 
122104
123- /// A descriptor used to sign for a commitment transaction's HTLC output. 
124- #[ derive( Clone ,  Debug ,  PartialEq ,  Eq ) ]  
125- pub  struct  HTLCDescriptor  { 
126- 	/// The parameters required to derive the signer for the HTLC input. 
127- pub  channel_derivation_parameters :  ChannelDerivationParameters , 
128- 	/// The txid of the commitment transaction in which the HTLC output lives. 
129- pub  commitment_txid :  Txid , 
130- 	/// The number of the commitment transaction in which the HTLC output lives. 
131- pub  per_commitment_number :  u64 , 
132- 	/// The key tweak corresponding to the number of the commitment transaction in which the HTLC 
133- /// output lives. This tweak is applied to all the basepoints for both parties in the channel to 
134- /// arrive at unique keys per commitment. 
135- /// 
136- /// See <https://github.com/lightning/bolts/blob/master/03-transactions.md#keys> for more info. 
137- pub  per_commitment_point :  PublicKey , 
138- 	/// The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs 
139- /// originating from a channel supporting anchor outputs, otherwise it is the same as the 
140- /// commitment transaction's feerate. 
141- pub  feerate_per_kw :  u32 , 
142- 	/// The details of the HTLC as it appears in the commitment transaction. 
143- pub  htlc :  HTLCOutputInCommitment , 
144- 	/// The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be 
145- /// taken. 
146- pub  preimage :  Option < PaymentPreimage > , 
147- 	/// The counterparty's signature required to spend the HTLC output. 
148- pub  counterparty_sig :  Signature 
149- } 
150- 
151- impl_writeable_tlv_based ! ( HTLCDescriptor ,  { 
152- 	( 0 ,  channel_derivation_parameters,  required) , 
153- 	( 1 ,  feerate_per_kw,  ( default_value,  0 ) ) , 
154- 	( 2 ,  commitment_txid,  required) , 
155- 	( 4 ,  per_commitment_number,  required) , 
156- 	( 6 ,  per_commitment_point,  required) , 
157- 	( 8 ,  htlc,  required) , 
158- 	( 10 ,  preimage,  option) , 
159- 	( 12 ,  counterparty_sig,  required) , 
160- } ) ; 
161- 
162- impl  HTLCDescriptor  { 
163- 	/// Returns the outpoint of the HTLC output in the commitment transaction. This is the outpoint 
164- /// being spent by the HTLC input in the HTLC transaction. 
165- pub  fn  outpoint ( & self )  -> OutPoint  { 
166- 		OutPoint  { 
167- 			txid :  self . commitment_txid , 
168- 			vout :  self . htlc . transaction_output_index . unwrap ( ) , 
169- 		} 
170- 	} 
171- 
172- 	/// Returns the UTXO to be spent by the HTLC input, which can be obtained via 
173- /// [`Self::unsigned_tx_input`]. 
174- pub  fn  previous_utxo < C :  secp256k1:: Signing  + secp256k1:: Verification > ( & self ,  secp :  & Secp256k1 < C > )  -> TxOut  { 
175- 		TxOut  { 
176- 			script_pubkey :  self . witness_script ( secp) . to_v0_p2wsh ( ) , 
177- 			value :  self . htlc . amount_msat  / 1000 , 
178- 		} 
179- 	} 
180- 
181- 	/// Returns the unsigned transaction input spending the HTLC output in the commitment 
182- /// transaction. 
183- pub  fn  unsigned_tx_input ( & self )  -> TxIn  { 
184- 		chan_utils:: build_htlc_input ( 
185- 			& self . commitment_txid ,  & self . htlc ,  & self . channel_derivation_parameters . transaction_parameters . channel_type_features 
186- 		) 
187- 	} 
188- 
189- 	/// Returns the delayed output created as a result of spending the HTLC output in the commitment 
190- /// transaction. 
191- pub  fn  tx_output < C :  secp256k1:: Signing  + secp256k1:: Verification > ( & self ,  secp :  & Secp256k1 < C > )  -> TxOut  { 
192- 		let  channel_params = self . channel_derivation_parameters . transaction_parameters . as_holder_broadcastable ( ) ; 
193- 		let  broadcaster_keys = channel_params. broadcaster_pubkeys ( ) ; 
194- 		let  counterparty_keys = channel_params. countersignatory_pubkeys ( ) ; 
195- 		let  broadcaster_delayed_key = chan_utils:: derive_public_key ( 
196- 			secp,  & self . per_commitment_point ,  & broadcaster_keys. delayed_payment_basepoint 
197- 		) ; 
198- 		let  counterparty_revocation_key = chan_utils:: derive_public_revocation_key ( 
199- 			secp,  & self . per_commitment_point ,  & counterparty_keys. revocation_basepoint 
200- 		) ; 
201- 		chan_utils:: build_htlc_output ( 
202- 			self . feerate_per_kw ,  channel_params. contest_delay ( ) ,  & self . htlc , 
203- 			channel_params. channel_type_features ( ) ,  & broadcaster_delayed_key,  & counterparty_revocation_key
204- 		) 
205- 	} 
206- 
207- 	/// Returns the witness script of the HTLC output in the commitment transaction. 
208- pub  fn  witness_script < C :  secp256k1:: Signing  + secp256k1:: Verification > ( & self ,  secp :  & Secp256k1 < C > )  -> Script  { 
209- 		let  channel_params = self . channel_derivation_parameters . transaction_parameters . as_holder_broadcastable ( ) ; 
210- 		let  broadcaster_keys = channel_params. broadcaster_pubkeys ( ) ; 
211- 		let  counterparty_keys = channel_params. countersignatory_pubkeys ( ) ; 
212- 		let  broadcaster_htlc_key = chan_utils:: derive_public_key ( 
213- 			secp,  & self . per_commitment_point ,  & broadcaster_keys. htlc_basepoint 
214- 		) ; 
215- 		let  counterparty_htlc_key = chan_utils:: derive_public_key ( 
216- 			secp,  & self . per_commitment_point ,  & counterparty_keys. htlc_basepoint 
217- 		) ; 
218- 		let  counterparty_revocation_key = chan_utils:: derive_public_revocation_key ( 
219- 			secp,  & self . per_commitment_point ,  & counterparty_keys. revocation_basepoint 
220- 		) ; 
221- 		chan_utils:: get_htlc_redeemscript_with_explicit_keys ( 
222- 			& self . htlc ,  channel_params. channel_type_features ( ) ,  & broadcaster_htlc_key,  & counterparty_htlc_key, 
223- 			& counterparty_revocation_key, 
224- 		) 
225- 	} 
226- 
227- 	/// Returns the fully signed witness required to spend the HTLC output in the commitment 
228- /// transaction. 
229- pub  fn  tx_input_witness ( & self ,  signature :  & Signature ,  witness_script :  & Script )  -> Witness  { 
230- 		chan_utils:: build_htlc_input_witness ( 
231- 			signature,  & self . counterparty_sig ,  & self . preimage ,  witness_script, 
232- 			& self . channel_derivation_parameters . transaction_parameters . channel_type_features 
233- 		) 
234- 	} 
235- 
236- 	/// Derives the channel signer required to sign the HTLC input. 
237- pub  fn  derive_channel_signer < S :  WriteableEcdsaChannelSigner ,  SP :  Deref > ( & self ,  signer_provider :  & SP )  -> S 
238- 	where 
239- 		SP :: Target :  SignerProvider < Signer  = S > 
240- 	{ 
241- 		let  mut  signer = signer_provider. derive_channel_signer ( 
242- 			self . channel_derivation_parameters . value_satoshis , 
243- 			self . channel_derivation_parameters . keys_id , 
244- 		) ; 
245- 		signer. provide_channel_parameters ( & self . channel_derivation_parameters . transaction_parameters ) ; 
246- 		signer
247- 	} 
248- } 
249- 
250105/// Represents the different types of transactions, originating from LDK, to be bumped. 
251106#[ derive( Clone ,  Debug ,  PartialEq ,  Eq ) ]  
252107pub  enum  BumpTransactionEvent  { 
@@ -342,7 +197,6 @@ pub enum BumpTransactionEvent {
342197/// 
343198/// [`EcdsaChannelSigner`]: crate::sign::EcdsaChannelSigner 
344199/// [`EcdsaChannelSigner::sign_holder_htlc_transaction`]: crate::sign::EcdsaChannelSigner::sign_holder_htlc_transaction 
345- /// [`HTLCDescriptor::tx_input_witness`]: HTLCDescriptor::tx_input_witness 
346200HTLCResolution  { 
347201		/// The unique identifier for the claim of the HTLCs in the confirmed commitment 
348202/// transaction. 
0 commit comments