@@ -1070,7 +1070,16 @@ pub trait ChannelSigner {
10701070 }
10711071 }
10721072
1073- /// Spend the holder anchor output
1073+ /// Computes the signature for a commitment transaction's anchor output used as an
1074+ /// input within `anchor_tx`, which spends the commitment transaction, at index `input`.
1075+ ///
1076+ /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
1077+ /// signature and should be retried later. Once the signer is ready to provide a signature after
1078+ /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
1079+ /// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors.
1080+ ///
1081+ /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
1082+ /// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
10741083 fn spend_holder_anchor_output (
10751084 & self , anchor_tx : & Transaction , input_idx : usize , secp_ctx : & Secp256k1 < secp256k1:: All > ,
10761085 ) -> Result < Witness , ( ) > ;
@@ -1855,10 +1864,19 @@ impl ChannelSigner for InMemorySigner {
18551864 fn spend_holder_anchor_output (
18561865 & self , anchor_tx : & Transaction , input_idx : usize , secp_ctx : & Secp256k1 < secp256k1:: All > ,
18571866 ) -> Result < Witness , ( ) > {
1858- let anchor_sig =
1859- EcdsaChannelSigner :: sign_holder_anchor_input ( self , anchor_tx, input_idx, secp_ctx) ?;
1860- let funding_pubkey = self . pubkeys ( ) . funding_pubkey ;
1861- Ok ( chan_utils:: build_anchor_input_witness ( & funding_pubkey, & anchor_sig) )
1867+ let funding_pubkey = & self . pubkeys ( ) . funding_pubkey ;
1868+ let witness_script = chan_utils:: get_anchor_redeemscript ( funding_pubkey) ;
1869+ let sighash = sighash:: SighashCache :: new ( anchor_tx)
1870+ . p2wsh_signature_hash (
1871+ input_idx,
1872+ & witness_script,
1873+ Amount :: from_sat ( ANCHOR_OUTPUT_VALUE_SATOSHI ) ,
1874+ EcdsaSighashType :: All ,
1875+ )
1876+ . unwrap ( ) ;
1877+ let sig =
1878+ sign_with_aux_rand ( secp_ctx, & hash_to_message ! ( & sighash[ ..] ) , & self . funding_key , & self ) ;
1879+ Ok ( chan_utils:: build_anchor_input_witness ( funding_pubkey, & sig) )
18621880 }
18631881}
18641882
@@ -1948,22 +1966,6 @@ impl EcdsaChannelSigner for InMemorySigner {
19481966 ) )
19491967 }
19501968
1951- fn sign_holder_anchor_input (
1952- & self , anchor_tx : & Transaction , input : usize , secp_ctx : & Secp256k1 < secp256k1:: All > ,
1953- ) -> Result < Signature , ( ) > {
1954- let witness_script =
1955- chan_utils:: get_anchor_redeemscript ( & self . holder_channel_pubkeys . funding_pubkey ) ;
1956- let sighash = sighash:: SighashCache :: new ( & * anchor_tx)
1957- . p2wsh_signature_hash (
1958- input,
1959- & witness_script,
1960- Amount :: from_sat ( ANCHOR_OUTPUT_VALUE_SATOSHI ) ,
1961- EcdsaSighashType :: All ,
1962- )
1963- . unwrap ( ) ;
1964- Ok ( sign_with_aux_rand ( secp_ctx, & hash_to_message ! ( & sighash[ ..] ) , & self . funding_key , & self ) )
1965- }
1966-
19671969 fn sign_channel_announcement_with_funding_key (
19681970 & self , msg : & UnsignedChannelAnnouncement , secp_ctx : & Secp256k1 < secp256k1:: All > ,
19691971 ) -> Result < Signature , ( ) > {
0 commit comments