@@ -16,7 +16,7 @@ use crypto::hkdf::{hkdf_extract,hkdf_expand};
16
16
use ln:: msgs;
17
17
use ln:: msgs:: { ErrorAction , HandleError , MsgEncodable } ;
18
18
use ln:: channelmonitor:: ChannelMonitor ;
19
- use ln:: channelmanager:: { PendingHTLCStatus , PendingForwardHTLCInfo , HTLCFailReason } ;
19
+ use ln:: channelmanager:: { PendingHTLCStatus , PendingForwardHTLCInfo , HTLCFailReason , HTLCFailureMsg } ;
20
20
use ln:: chan_utils:: { TxCreationKeys , HTLCOutputInCommitment , HTLC_SUCCESS_TX_WEIGHT , HTLC_TIMEOUT_TX_WEIGHT } ;
21
21
use ln:: chan_utils;
22
22
use chain:: chaininterface:: { FeeEstimator , ConfirmationTarget } ;
@@ -1681,7 +1681,8 @@ impl Channel {
1681
1681
1682
1682
let mut to_forward_infos = Vec :: new ( ) ;
1683
1683
let mut revoked_htlcs = Vec :: new ( ) ;
1684
- let mut failed_htlcs = Vec :: new ( ) ;
1684
+ let mut update_fail_htlcs = Vec :: new ( ) ;
1685
+ let mut update_fail_malformed_htlcs = Vec :: new ( ) ;
1685
1686
let mut require_commitment = false ;
1686
1687
let mut value_to_self_msat_diff: i64 = 0 ;
1687
1688
// We really shouldnt have two passes here, but retain gives a non-mutable ref (Rust bug)
@@ -1709,7 +1710,10 @@ impl Channel {
1709
1710
PendingHTLCStatus :: Fail ( fail_msg) => {
1710
1711
htlc. state = HTLCState :: LocalRemoved ;
1711
1712
require_commitment = true ;
1712
- failed_htlcs. push ( fail_msg) ;
1713
+ match fail_msg {
1714
+ HTLCFailureMsg :: Relay ( msg) => update_fail_htlcs. push ( msg) ,
1715
+ HTLCFailureMsg :: Malformed ( msg) => update_fail_malformed_htlcs. push ( msg) ,
1716
+ }
1713
1717
} ,
1714
1718
PendingHTLCStatus :: Forward ( forward_info) => {
1715
1719
to_forward_infos. push ( forward_info) ;
@@ -1728,10 +1732,14 @@ impl Channel {
1728
1732
1729
1733
match self . free_holding_cell_htlcs ( ) ? {
1730
1734
Some ( mut commitment_update) => {
1731
- commitment_update. 0 . update_fail_htlcs . reserve ( failed_htlcs . len ( ) ) ;
1732
- for fail_msg in failed_htlcs . drain ( ..) {
1735
+ commitment_update. 0 . update_fail_htlcs . reserve ( update_fail_htlcs . len ( ) ) ;
1736
+ for fail_msg in update_fail_htlcs . drain ( ..) {
1733
1737
commitment_update. 0 . update_fail_htlcs . push ( fail_msg) ;
1734
1738
}
1739
+ commitment_update. 0 . update_fail_malformed_htlcs . reserve ( update_fail_malformed_htlcs. len ( ) ) ;
1740
+ for fail_msg in update_fail_malformed_htlcs. drain ( ..) {
1741
+ commitment_update. 0 . update_fail_malformed_htlcs . push ( fail_msg) ;
1742
+ }
1735
1743
Ok ( ( Some ( commitment_update. 0 ) , to_forward_infos, revoked_htlcs, commitment_update. 1 ) )
1736
1744
} ,
1737
1745
None => {
@@ -1740,8 +1748,8 @@ impl Channel {
1740
1748
Ok ( ( Some ( msgs:: CommitmentUpdate {
1741
1749
update_add_htlcs : Vec :: new ( ) ,
1742
1750
update_fulfill_htlcs : Vec :: new ( ) ,
1743
- update_fail_htlcs : failed_htlcs ,
1744
- update_fail_malformed_htlcs : Vec :: new ( ) ,
1751
+ update_fail_htlcs,
1752
+ update_fail_malformed_htlcs,
1745
1753
commitment_signed
1746
1754
} ) , to_forward_infos, revoked_htlcs, monitor_update) )
1747
1755
} else {
0 commit comments