@@ -1870,23 +1870,17 @@ impl ChannelMonitor {
1870
1870
let accepted_preimage_claim = input. witness . len ( ) == 5 && input. witness [ 4 ] . len ( ) == ACCEPTED_HTLC_SCRIPT_WEIGHT ;
1871
1871
let offered_preimage_claim = input. witness . len ( ) == 3 && input. witness [ 2 ] . len ( ) == OFFERED_HTLC_SCRIPT_WEIGHT ;
1872
1872
1873
- macro_rules! log_claim {
1874
- ( $tx_info: expr, $local_tx: expr, $htlc: expr, $source_avail: expr) => {
1875
- // We found the output in question, but aren't failing it backwards
1876
- // as we have no corresponding source. This implies either it is an
1877
- // inbound HTLC or an outbound HTLC on a revoked transaction.
1878
- let outbound_htlc = $local_tx == $htlc. offered;
1879
- if ( $local_tx && revocation_sig_claim) ||
1880
- ( outbound_htlc && !$source_avail && ( accepted_preimage_claim || offered_preimage_claim) ) {
1881
- log_error!( self , "Input spending {} ({}:{}) in {} resolves {} HTLC with payment hash {} with {}!" ,
1882
- $tx_info, input. previous_output. txid, input. previous_output. vout, tx. txid( ) ,
1883
- if outbound_htlc { "outbound" } else { "inbound" } , log_bytes!( $htlc. payment_hash. 0 ) ,
1884
- if revocation_sig_claim { "revocation sig" } else { "preimage claim after we'd passed the HTLC resolution back" } ) ;
1885
- } else {
1886
- log_info!( self , "Input spending {} ({}:{}) in {} resolves {} HTLC with payment hash {} with {}" ,
1887
- $tx_info, input. previous_output. txid, input. previous_output. vout, tx. txid( ) ,
1888
- if outbound_htlc { "outbound" } else { "inbound" } , log_bytes!( $htlc. payment_hash. 0 ) ,
1889
- if revocation_sig_claim { "revocation sig" } else if accepted_preimage_claim || offered_preimage_claim { "preimage" } else { "timeout" } ) ;
1873
+ macro_rules! check_htlc_valid_remote {
1874
+ ( $remote_txid: expr, $htlc_output: expr) => {
1875
+ if let & Some ( txid) = $remote_txid {
1876
+ for & ( ref pending_htlc, ref pending_source) in self . remote_claimable_outpoints. get( & txid) . unwrap( ) {
1877
+ if pending_htlc. payment_hash == $htlc_output. payment_hash && pending_htlc. amount_msat == $htlc_output. amount_msat {
1878
+ if let & Some ( ref source) = pending_source {
1879
+ payment_data = Some ( ( ( * * source) . clone( ) , $htlc_output. payment_hash) ) ;
1880
+ break ;
1881
+ }
1882
+ }
1883
+ }
1890
1884
}
1891
1885
}
1892
1886
}
@@ -1903,9 +1897,12 @@ impl ChannelMonitor {
1903
1897
// has timed out, or we screwed up. In any case, we should now
1904
1898
// resolve the source HTLC with the original sender.
1905
1899
payment_data = Some ( ( ( * source) . clone( ) , htlc_output. payment_hash) ) ;
1906
- } else {
1907
- log_claim!( $tx_info, $local_tx, htlc_output, false ) ;
1908
- continue ' outer_loop;
1900
+ } else if !$local_tx {
1901
+ if let Storage :: Local { ref current_remote_commitment_txid, .. } = self . key_storage {
1902
+ check_htlc_valid_remote!( current_remote_commitment_txid, htlc_output) ;
1903
+ } else if let Storage :: Local { ref prev_remote_commitment_txid, .. } = self . key_storage {
1904
+ check_htlc_valid_remote!( prev_remote_commitment_txid, htlc_output) ;
1905
+ }
1909
1906
}
1910
1907
}
1911
1908
}
0 commit comments