@@ -148,7 +148,7 @@ pub trait ChannelKeys : Send {
148
148
///
149
149
/// Note that, due to rounding, there may be one "missing" satoshi, and either party may have
150
150
/// chosen to forgo their output as dust.
151
- fn sign_closing_transaction < T : secp256k1:: Signing > ( & self , channel_funding_redeemscript : & Script , closing_tx : & Transaction , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > ;
151
+ fn sign_closing_transaction < T : secp256k1:: Signing > ( & self , closing_tx : & Transaction , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > ;
152
152
153
153
/// Signs a channel announcement message with our funding key, proving it comes from one
154
154
/// of the channel participants.
@@ -223,11 +223,15 @@ impl ChannelKeys for InMemoryChannelKeys {
223
223
Ok ( ( commitment_sig, htlc_sigs) )
224
224
}
225
225
226
- fn sign_closing_transaction < T : secp256k1:: Signing > ( & self , channel_funding_redeemscript : & Script , closing_tx : & Transaction , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > {
226
+ fn sign_closing_transaction < T : secp256k1:: Signing > ( & self , closing_tx : & Transaction , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > {
227
227
if closing_tx. input . len ( ) != 1 { return Err ( ( ) ) ; }
228
228
if closing_tx. input [ 0 ] . witness . len ( ) != 0 { return Err ( ( ) ) ; }
229
229
if closing_tx. output . len ( ) > 2 { return Err ( ( ) ) ; }
230
230
231
+ let remote_channel_pubkeys = self . remote_channel_pubkeys . as_ref ( ) . expect ( "must set remote channel pubkeys before signing" ) ;
232
+ let funding_pubkey = PublicKey :: from_secret_key ( secp_ctx, & self . funding_key ) ;
233
+ let channel_funding_redeemscript = make_funding_redeemscript ( & funding_pubkey, & remote_channel_pubkeys. funding_pubkey ) ;
234
+
231
235
let sighash = hash_to_message ! ( & bip143:: SighashComponents :: new( closing_tx)
232
236
. sighash_all( & closing_tx. input[ 0 ] , & channel_funding_redeemscript, self . channel_value_satoshis) [ ..] ) ;
233
237
Ok ( secp_ctx. sign ( & sighash, & self . funding_key ) )
0 commit comments