@@ -1873,8 +1873,9 @@ impl ChannelMonitor {
1873
1873
macro_rules! log_claim {
1874
1874
( $tx_info: expr, $local_tx: expr, $htlc: expr, $source_avail: expr) => {
1875
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.
1876
+ // as we have no corresponding source and no valid remote commitment txid
1877
+ // to try a weak source binding with same-hash, same-value still-valid offered HTLC.
1878
+ // This implies either it is an inbound HTLC or an outbound HTLC on a revoked transaction.
1878
1879
let outbound_htlc = $local_tx == $htlc. offered;
1879
1880
if ( $local_tx && revocation_sig_claim) ||
1880
1881
( outbound_htlc && !$source_avail && ( accepted_preimage_claim || offered_preimage_claim) ) {
@@ -1891,6 +1892,22 @@ impl ChannelMonitor {
1891
1892
}
1892
1893
}
1893
1894
1895
+ macro_rules! check_htlc_valid_remote {
1896
+ ( $remote_txid: expr, $htlc_output: expr) => {
1897
+ if let & Some ( txid) = $remote_txid {
1898
+ for & ( ref pending_htlc, ref pending_source) in self . remote_claimable_outpoints. get( & txid) . unwrap( ) {
1899
+ if pending_htlc. payment_hash == $htlc_output. payment_hash && pending_htlc. amount_msat == $htlc_output. amount_msat {
1900
+ if let & Some ( ref source) = pending_source {
1901
+ log_claim!( "revoked remote commitment tx" , false , pending_htlc, true ) ;
1902
+ payment_data = Some ( ( ( * * source) . clone( ) , $htlc_output. payment_hash) ) ;
1903
+ break ;
1904
+ }
1905
+ }
1906
+ }
1907
+ }
1908
+ }
1909
+ }
1910
+
1894
1911
macro_rules! scan_commitment {
1895
1912
( $htlcs: expr, $tx_info: expr, $local_tx: expr) => {
1896
1913
for ( ref htlc_output, source_option) in $htlcs {
@@ -1903,7 +1920,17 @@ impl ChannelMonitor {
1903
1920
// has timed out, or we screwed up. In any case, we should now
1904
1921
// resolve the source HTLC with the original sender.
1905
1922
payment_data = Some ( ( ( * source) . clone( ) , htlc_output. payment_hash) ) ;
1906
- } else {
1923
+ } else if !$local_tx {
1924
+ if let Storage :: Local { ref current_remote_commitment_txid, .. } = self . key_storage {
1925
+ check_htlc_valid_remote!( current_remote_commitment_txid, htlc_output) ;
1926
+ }
1927
+ if payment_data. is_none( ) {
1928
+ if let Storage :: Local { ref prev_remote_commitment_txid, .. } = self . key_storage {
1929
+ check_htlc_valid_remote!( prev_remote_commitment_txid, htlc_output) ;
1930
+ }
1931
+ }
1932
+ }
1933
+ if payment_data. is_none( ) {
1907
1934
log_claim!( $tx_info, $local_tx, htlc_output, false ) ;
1908
1935
continue ' outer_loop;
1909
1936
}
0 commit comments