@@ -1070,7 +1070,16 @@ pub trait ChannelSigner {
1070
1070
}
1071
1071
}
1072
1072
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
1074
1083
fn spend_holder_anchor_output (
1075
1084
& self , anchor_tx : & Transaction , input_idx : usize , secp_ctx : & Secp256k1 < secp256k1:: All > ,
1076
1085
) -> Result < Witness , ( ) > ;
@@ -1855,10 +1864,19 @@ impl ChannelSigner for InMemorySigner {
1855
1864
fn spend_holder_anchor_output (
1856
1865
& self , anchor_tx : & Transaction , input_idx : usize , secp_ctx : & Secp256k1 < secp256k1:: All > ,
1857
1866
) -> 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) )
1862
1880
}
1863
1881
}
1864
1882
@@ -1948,22 +1966,6 @@ impl EcdsaChannelSigner for InMemorySigner {
1948
1966
) )
1949
1967
}
1950
1968
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
-
1967
1969
fn sign_channel_announcement_with_funding_key (
1968
1970
& self , msg : & UnsignedChannelAnnouncement , secp_ctx : & Secp256k1 < secp256k1:: All > ,
1969
1971
) -> Result < Signature , ( ) > {
0 commit comments