@@ -1033,7 +1033,16 @@ pub trait ChannelSigner {
10331033 }
10341034 }
10351035
1036- /// Spend the holder anchor output
1036+ /// Computes the signature for a commitment transaction's anchor output used as an
1037+ /// input within `anchor_tx`, which spends the commitment transaction, at index `input`.
1038+ ///
1039+ /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
1040+ /// signature and should be retried later. Once the signer is ready to provide a signature after
1041+ /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
1042+ /// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors.
1043+ ///
1044+ /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
1045+ /// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
10371046 fn spend_holder_anchor_output (
10381047 & self , anchor_tx : & Transaction , input_idx : usize , secp_ctx : & Secp256k1 < secp256k1:: All > ,
10391048 ) -> Result < Witness , ( ) > ;
@@ -1829,10 +1838,19 @@ impl ChannelSigner for InMemorySigner {
18291838 fn spend_holder_anchor_output (
18301839 & self , anchor_tx : & Transaction , input_idx : usize , secp_ctx : & Secp256k1 < secp256k1:: All > ,
18311840 ) -> Result < Witness , ( ) > {
1832- let anchor_sig =
1833- EcdsaChannelSigner :: sign_holder_anchor_input ( self , anchor_tx, input_idx, secp_ctx) ?;
1834- let funding_pubkey = self . pubkeys ( ) . funding_pubkey ;
1835- Ok ( chan_utils:: build_anchor_input_witness ( & funding_pubkey, & anchor_sig) )
1841+ let funding_pubkey = & self . pubkeys ( ) . funding_pubkey ;
1842+ let witness_script = chan_utils:: get_anchor_redeemscript ( funding_pubkey) ;
1843+ let sighash = sighash:: SighashCache :: new ( anchor_tx)
1844+ . p2wsh_signature_hash (
1845+ input_idx,
1846+ & witness_script,
1847+ Amount :: from_sat ( ANCHOR_OUTPUT_VALUE_SATOSHI ) ,
1848+ EcdsaSighashType :: All ,
1849+ )
1850+ . unwrap ( ) ;
1851+ let sig =
1852+ sign_with_aux_rand ( secp_ctx, & hash_to_message ! ( & sighash[ ..] ) , & self . funding_key , & self ) ;
1853+ Ok ( chan_utils:: build_anchor_input_witness ( funding_pubkey, & sig) )
18361854 }
18371855}
18381856
@@ -1922,22 +1940,6 @@ impl EcdsaChannelSigner for InMemorySigner {
19221940 ) )
19231941 }
19241942
1925- fn sign_holder_anchor_input (
1926- & self , anchor_tx : & Transaction , input : usize , secp_ctx : & Secp256k1 < secp256k1:: All > ,
1927- ) -> Result < Signature , ( ) > {
1928- let witness_script =
1929- chan_utils:: get_anchor_redeemscript ( & self . holder_channel_pubkeys . funding_pubkey ) ;
1930- let sighash = sighash:: SighashCache :: new ( & * anchor_tx)
1931- . p2wsh_signature_hash (
1932- input,
1933- & witness_script,
1934- Amount :: from_sat ( ANCHOR_OUTPUT_VALUE_SATOSHI ) ,
1935- EcdsaSighashType :: All ,
1936- )
1937- . unwrap ( ) ;
1938- Ok ( sign_with_aux_rand ( secp_ctx, & hash_to_message ! ( & sighash[ ..] ) , & self . funding_key , & self ) )
1939- }
1940-
19411943 fn sign_channel_announcement_with_funding_key (
19421944 & self , msg : & UnsignedChannelAnnouncement , secp_ctx : & Secp256k1 < secp256k1:: All > ,
19431945 ) -> Result < Signature , ( ) > {
0 commit comments