@@ -115,14 +115,6 @@ impl Readable for ChannelMonitorUpdate {
115
115
}
116
116
}
117
117
118
- /// General Err type for ChannelMonitor actions. Generally, this implies that the data provided is
119
- /// inconsistent with the ChannelMonitor being called. eg for ChannelMonitor::update_monitor this
120
- /// means you tried to update a monitor for a different channel or the ChannelMonitorUpdate was
121
- /// corrupted.
122
- /// Contains a developer-readable error message.
123
- #[ derive( Clone , Debug ) ]
124
- pub struct MonitorUpdateError ( pub & ' static str ) ;
125
-
126
118
/// An event to be processed by the ChannelManager.
127
119
#[ derive( Clone , PartialEq ) ]
128
120
pub enum MonitorEvent {
@@ -1052,7 +1044,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1052
1044
}
1053
1045
1054
1046
#[ cfg( test) ]
1055
- fn provide_secret ( & self , idx : u64 , secret : [ u8 ; 32 ] ) -> Result < ( ) , MonitorUpdateError > {
1047
+ fn provide_secret ( & self , idx : u64 , secret : [ u8 ; 32 ] ) -> Result < ( ) , & ' static str > {
1056
1048
self . inner . lock ( ) . unwrap ( ) . provide_secret ( idx, secret)
1057
1049
}
1058
1050
@@ -1074,12 +1066,10 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1074
1066
1075
1067
#[ cfg( test) ]
1076
1068
fn provide_latest_holder_commitment_tx (
1077
- & self ,
1078
- holder_commitment_tx : HolderCommitmentTransaction ,
1069
+ & self , holder_commitment_tx : HolderCommitmentTransaction ,
1079
1070
htlc_outputs : Vec < ( HTLCOutputInCommitment , Option < Signature > , Option < HTLCSource > ) > ,
1080
- ) -> Result < ( ) , MonitorUpdateError > {
1081
- self . inner . lock ( ) . unwrap ( ) . provide_latest_holder_commitment_tx (
1082
- holder_commitment_tx, htlc_outputs)
1071
+ ) -> Result < ( ) , ( ) > {
1072
+ self . inner . lock ( ) . unwrap ( ) . provide_latest_holder_commitment_tx ( holder_commitment_tx, htlc_outputs) . map_err ( |_| ( ) )
1083
1073
}
1084
1074
1085
1075
#[ cfg( test) ]
@@ -1120,7 +1110,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1120
1110
broadcaster : & B ,
1121
1111
fee_estimator : & F ,
1122
1112
logger : & L ,
1123
- ) -> Result < ( ) , MonitorUpdateError >
1113
+ ) -> Result < ( ) , ( ) >
1124
1114
where
1125
1115
B :: Target : BroadcasterInterface ,
1126
1116
F :: Target : FeeEstimator ,
@@ -1695,9 +1685,9 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1695
1685
/// Inserts a revocation secret into this channel monitor. Prunes old preimages if neither
1696
1686
/// needed by holder commitment transactions HTCLs nor by counterparty ones. Unless we haven't already seen
1697
1687
/// counterparty commitment transaction's secret, they are de facto pruned (we can use revocation key).
1698
- fn provide_secret ( & mut self , idx : u64 , secret : [ u8 ; 32 ] ) -> Result < ( ) , MonitorUpdateError > {
1688
+ fn provide_secret ( & mut self , idx : u64 , secret : [ u8 ; 32 ] ) -> Result < ( ) , & ' static str > {
1699
1689
if let Err ( ( ) ) = self . commitment_secrets . provide_secret ( idx, secret) {
1700
- return Err ( MonitorUpdateError ( "Previous secret did not match new one" ) ) ;
1690
+ return Err ( "Previous secret did not match new one" ) ;
1701
1691
}
1702
1692
1703
1693
// Prune HTLCs from the previous counterparty commitment tx so we don't generate failure/fulfill
@@ -1789,7 +1779,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1789
1779
/// is important that any clones of this channel monitor (including remote clones) by kept
1790
1780
/// up-to-date as our holder commitment transaction is updated.
1791
1781
/// Panics if set_on_holder_tx_csv has never been called.
1792
- fn provide_latest_holder_commitment_tx ( & mut self , holder_commitment_tx : HolderCommitmentTransaction , htlc_outputs : Vec < ( HTLCOutputInCommitment , Option < Signature > , Option < HTLCSource > ) > ) -> Result < ( ) , MonitorUpdateError > {
1782
+ fn provide_latest_holder_commitment_tx ( & mut self , holder_commitment_tx : HolderCommitmentTransaction , htlc_outputs : Vec < ( HTLCOutputInCommitment , Option < Signature > , Option < HTLCSource > ) > ) -> Result < ( ) , & ' static str > {
1793
1783
// block for Rust 1.34 compat
1794
1784
let mut new_holder_commitment_tx = {
1795
1785
let trusted_tx = holder_commitment_tx. trust ( ) ;
@@ -1812,7 +1802,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1812
1802
mem:: swap ( & mut new_holder_commitment_tx, & mut self . current_holder_commitment_tx ) ;
1813
1803
self . prev_holder_signed_commitment_tx = Some ( new_holder_commitment_tx) ;
1814
1804
if self . holder_tx_signed {
1815
- return Err ( MonitorUpdateError ( "Latest holder commitment signed has already been signed, update is rejected" ) ) ;
1805
+ return Err ( "Latest holder commitment signed has already been signed, update is rejected" ) ;
1816
1806
}
1817
1807
Ok ( ( ) )
1818
1808
}
@@ -1876,7 +1866,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1876
1866
self . pending_monitor_events . push ( MonitorEvent :: CommitmentTxConfirmed ( self . funding_info . 0 ) ) ;
1877
1867
}
1878
1868
1879
- pub fn update_monitor < B : Deref , F : Deref , L : Deref > ( & mut self , updates : & ChannelMonitorUpdate , broadcaster : & B , fee_estimator : & F , logger : & L ) -> Result < ( ) , MonitorUpdateError >
1869
+ pub fn update_monitor < B : Deref , F : Deref , L : Deref > ( & mut self , updates : & ChannelMonitorUpdate , broadcaster : & B , fee_estimator : & F , logger : & L ) -> Result < ( ) , ( ) >
1880
1870
where B :: Target : BroadcasterInterface ,
1881
1871
F :: Target : FeeEstimator ,
1882
1872
L :: Target : Logger ,
@@ -1902,8 +1892,8 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1902
1892
if self . lockdown_from_offchain { panic ! ( ) ; }
1903
1893
if let Err ( e) = self . provide_latest_holder_commitment_tx ( commitment_tx. clone ( ) , htlc_outputs. clone ( ) ) {
1904
1894
log_error ! ( logger, "Providing latest holder commitment transaction failed/was refused:" ) ;
1905
- log_error ! ( logger, " {}" , e. 0 ) ;
1906
- ret = Err ( e ) ;
1895
+ log_error ! ( logger, " {}" , e) ;
1896
+ ret = Err ( ( ) ) ;
1907
1897
}
1908
1898
}
1909
1899
ChannelMonitorUpdateStep :: LatestCounterpartyCommitmentTXInfo { commitment_txid, htlc_outputs, commitment_number, their_revocation_point } => {
@@ -1918,8 +1908,8 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1918
1908
log_trace ! ( logger, "Updating ChannelMonitor with commitment secret" ) ;
1919
1909
if let Err ( e) = self . provide_secret ( * idx, * secret) {
1920
1910
log_error ! ( logger, "Providing latest counterparty commitment secret failed/was refused:" ) ;
1921
- log_error ! ( logger, " {}" , e. 0 ) ;
1922
- ret = Err ( e ) ;
1911
+ log_error ! ( logger, " {}" , e) ;
1912
+ ret = Err ( ( ) ) ;
1923
1913
}
1924
1914
} ,
1925
1915
ChannelMonitorUpdateStep :: ChannelForceClosed { should_broadcast } => {
@@ -1947,9 +1937,9 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1947
1937
self . latest_update_id = updates. update_id ;
1948
1938
1949
1939
if ret. is_ok ( ) && self . funding_spend_seen {
1950
- ret = Err ( MonitorUpdateError ( "Counterparty attempted to update commitment after funding was spent") ) ;
1951
- }
1952
- ret
1940
+ log_error ! ( logger , "Refusing Channel Monitor Update as counterparty attempted to update commitment after funding was spent") ;
1941
+ Err ( ( ) )
1942
+ } else { ret }
1953
1943
}
1954
1944
1955
1945
pub fn get_latest_update_id ( & self ) -> u64 {
0 commit comments