@@ -2198,7 +2198,13 @@ impl<Signer: Sign> Channel<Signer> {
21982198 & self . get_counterparty_pubkeys ( ) . funding_pubkey
21992199 }
22002200
2201- pub fn funding_created < L : Deref > ( & mut self , msg : & msgs:: FundingCreated , best_block : BestBlock , logger : & L ) -> Result < ( msgs:: FundingSigned , ChannelMonitor < Signer > , Option < msgs:: ChannelReady > ) , ChannelError > where L :: Target : Logger {
2201+ pub fn funding_created < K : Deref , L : Deref > (
2202+ & mut self , msg : & msgs:: FundingCreated , best_block : BestBlock , keys_source : & K , logger : & L
2203+ ) -> Result < ( msgs:: FundingSigned , ChannelMonitor < <K :: Target as KeysInterface >:: Signer > , Option < msgs:: ChannelReady > ) , ChannelError >
2204+ where
2205+ K :: Target : KeysInterface ,
2206+ L :: Target : Logger
2207+ {
22022208 if self . is_outbound ( ) {
22032209 return Err ( ChannelError :: Close ( "Received funding_created for an outbound channel?" . to_owned ( ) ) ) ;
22042210 }
@@ -2253,7 +2259,9 @@ impl<Signer: Sign> Channel<Signer> {
22532259 let funding_txo_script = funding_redeemscript. to_v0_p2wsh ( ) ;
22542260 let obscure_factor = get_commitment_transaction_number_obscure_factor ( & self . get_holder_pubkeys ( ) . payment_point , & self . get_counterparty_pubkeys ( ) . payment_point , self . is_outbound ( ) ) ;
22552261 let shutdown_script = self . shutdown_scriptpubkey . clone ( ) . map ( |script| script. into_inner ( ) ) ;
2256- let channel_monitor = ChannelMonitor :: new ( self . secp_ctx . clone ( ) , self . holder_signer . clone ( ) ,
2262+ let mut monitor_signer = keys_source. derive_channel_signer ( self . channel_value_satoshis , self . channel_keys_id ) ;
2263+ monitor_signer. provide_channel_parameters ( & self . channel_transaction_parameters ) ;
2264+ let channel_monitor = ChannelMonitor :: new ( self . secp_ctx . clone ( ) , monitor_signer,
22572265 shutdown_script, self . get_holder_selected_contest_delay ( ) ,
22582266 & self . destination_script , ( funding_txo, funding_txo_script. clone ( ) ) ,
22592267 & self . channel_transaction_parameters ,
@@ -2278,7 +2286,13 @@ impl<Signer: Sign> Channel<Signer> {
22782286
22792287 /// Handles a funding_signed message from the remote end.
22802288 /// If this call is successful, broadcast the funding transaction (and not before!)
2281- pub fn funding_signed < L : Deref > ( & mut self , msg : & msgs:: FundingSigned , best_block : BestBlock , logger : & L ) -> Result < ( ChannelMonitor < Signer > , Transaction , Option < msgs:: ChannelReady > ) , ChannelError > where L :: Target : Logger {
2289+ pub fn funding_signed < K : Deref , L : Deref > (
2290+ & mut self , msg : & msgs:: FundingSigned , best_block : BestBlock , keys_source : & K , logger : & L
2291+ ) -> Result < ( ChannelMonitor < <K :: Target as KeysInterface >:: Signer > , Transaction , Option < msgs:: ChannelReady > ) , ChannelError >
2292+ where
2293+ K :: Target : KeysInterface ,
2294+ L :: Target : Logger
2295+ {
22822296 if !self . is_outbound ( ) {
22832297 return Err ( ChannelError :: Close ( "Received funding_signed for an inbound channel?" . to_owned ( ) ) ) ;
22842298 }
@@ -2330,7 +2344,9 @@ impl<Signer: Sign> Channel<Signer> {
23302344 let funding_txo_script = funding_redeemscript. to_v0_p2wsh ( ) ;
23312345 let obscure_factor = get_commitment_transaction_number_obscure_factor ( & self . get_holder_pubkeys ( ) . payment_point , & self . get_counterparty_pubkeys ( ) . payment_point , self . is_outbound ( ) ) ;
23322346 let shutdown_script = self . shutdown_scriptpubkey . clone ( ) . map ( |script| script. into_inner ( ) ) ;
2333- let channel_monitor = ChannelMonitor :: new ( self . secp_ctx . clone ( ) , self . holder_signer . clone ( ) ,
2347+ let mut monitor_signer = keys_source. derive_channel_signer ( self . channel_value_satoshis , self . channel_keys_id ) ;
2348+ monitor_signer. provide_channel_parameters ( & self . channel_transaction_parameters ) ;
2349+ let channel_monitor = ChannelMonitor :: new ( self . secp_ctx . clone ( ) , monitor_signer,
23342350 shutdown_script, self . get_holder_selected_contest_delay ( ) ,
23352351 & self . destination_script , ( funding_txo, funding_txo_script) ,
23362352 & self . channel_transaction_parameters ,
@@ -7058,10 +7074,10 @@ mod tests {
70587074 } ] } ;
70597075 let funding_outpoint = OutPoint { txid : tx. txid ( ) , index : 0 } ;
70607076 let funding_created_msg = node_a_chan. get_outbound_funding_created ( tx. clone ( ) , funding_outpoint, & & logger) . unwrap ( ) ;
7061- let ( funding_signed_msg, _, _) = node_b_chan. funding_created ( & funding_created_msg, best_block, & & logger) . unwrap ( ) ;
7077+ let ( funding_signed_msg, _, _) = node_b_chan. funding_created ( & funding_created_msg, best_block, & & keys_provider , & & logger) . unwrap ( ) ;
70627078
70637079 // Node B --> Node A: funding signed
7064- let _ = node_a_chan. funding_signed ( & funding_signed_msg, best_block, & & logger) ;
7080+ let _ = node_a_chan. funding_signed ( & funding_signed_msg, best_block, & & keys_provider , & & logger) ;
70657081
70667082 // Now disconnect the two nodes and check that the commitment point in
70677083 // Node B's channel_reestablish message is sane.
0 commit comments