@@ -363,6 +363,12 @@ const B_OUTPUT_PLUS_SPENDING_INPUT_WEIGHT: u64 = 104; // prevout: 40, nSequence:
363
363
/// it's 2^24.
364
364
pub const MAX_FUNDING_SATOSHIS : u64 = ( 1 << 24 ) ;
365
365
366
+ #[ cfg( test) ]
367
+ pub const ACCEPTED_HTLC_SCRIPT_WEIGHT : usize = 138 ; //Here we have a diff due to HTLC CLTV expiry being < 2^15 in test
368
+ #[ cfg( not( test) ) ]
369
+ pub const ACCEPTED_HTLC_SCRIPT_WEIGHT : usize = 139 ;
370
+ pub const OFFERED_HTLC_SCRIPT_WEIGHT : usize = 133 ;
371
+
366
372
/// Used to return a simple Error back to ChannelManager. Will get converted to a
367
373
/// msgs::ErrorAction::SendErrorMessage or msgs::ErrorAction::IgnoreError as appropriate with our
368
374
/// channel_id in ChannelManager.
@@ -1572,7 +1578,7 @@ impl Channel {
1572
1578
1573
1579
/// Marks an outbound HTLC which we have received update_fail/fulfill/malformed
1574
1580
#[ inline]
1575
- fn mark_outbound_htlc_removed ( & mut self , htlc_id : u64 , check_preimage : Option < [ u8 ; 32 ] > , fail_reason : Option < HTLCFailReason > ) -> Result < & HTLCSource , ChannelError > {
1581
+ fn mark_outbound_htlc_removed ( & mut self , htlc_id : u64 , check_preimage : Option < [ u8 ; 32 ] > , fail_reason : Option < HTLCFailReason > ) -> Result < ( & HTLCSource , [ u8 ; 32 ] ) , ChannelError > {
1576
1582
for htlc in self . pending_outbound_htlcs . iter_mut ( ) {
1577
1583
if htlc. htlc_id == htlc_id {
1578
1584
match check_preimage {
@@ -1592,13 +1598,13 @@ impl Channel {
1592
1598
OutboundHTLCState :: AwaitingRemoteRevokeToRemove | OutboundHTLCState :: AwaitingRemovedRemoteRevoke | OutboundHTLCState :: RemoteRemoved =>
1593
1599
return Err ( ChannelError :: Close ( "Remote tried to fulfill/fail HTLC that they'd already fulfilled/failed" ) ) ,
1594
1600
}
1595
- return Ok ( & htlc. source ) ;
1601
+ return Ok ( ( & htlc. source , htlc . payment_hash ) ) ;
1596
1602
}
1597
1603
}
1598
1604
Err ( ChannelError :: Close ( "Remote tried to fulfill/fail an HTLC we couldn't find" ) )
1599
1605
}
1600
1606
1601
- pub fn update_fulfill_htlc ( & mut self , msg : & msgs:: UpdateFulfillHTLC ) -> Result < & HTLCSource , ChannelError > {
1607
+ pub fn update_fulfill_htlc ( & mut self , msg : & msgs:: UpdateFulfillHTLC ) -> Result < ( & HTLCSource , [ u8 ; 32 ] ) , ChannelError > {
1602
1608
if ( self . channel_state & ( ChannelState :: ChannelFunded as u32 ) ) != ( ChannelState :: ChannelFunded as u32 ) {
1603
1609
return Err ( ChannelError :: Close ( "Got fulfill HTLC message when channel was not in an operational state" ) ) ;
1604
1610
}
@@ -1614,7 +1620,7 @@ impl Channel {
1614
1620
self . mark_outbound_htlc_removed ( msg. htlc_id , Some ( payment_hash) , None )
1615
1621
}
1616
1622
1617
- pub fn update_fail_htlc ( & mut self , msg : & msgs:: UpdateFailHTLC , fail_reason : HTLCFailReason ) -> Result < & HTLCSource , ChannelError > {
1623
+ pub fn update_fail_htlc ( & mut self , msg : & msgs:: UpdateFailHTLC , fail_reason : HTLCFailReason ) -> Result < ( & HTLCSource , [ u8 ; 32 ] ) , ChannelError > {
1618
1624
if ( self . channel_state & ( ChannelState :: ChannelFunded as u32 ) ) != ( ChannelState :: ChannelFunded as u32 ) {
1619
1625
return Err ( ChannelError :: Close ( "Got fail HTLC message when channel was not in an operational state" ) ) ;
1620
1626
}
@@ -1625,7 +1631,7 @@ impl Channel {
1625
1631
self . mark_outbound_htlc_removed ( msg. htlc_id , None , Some ( fail_reason) )
1626
1632
}
1627
1633
1628
- pub fn update_fail_malformed_htlc < ' a > ( & mut self , msg : & msgs:: UpdateFailMalformedHTLC , fail_reason : HTLCFailReason ) -> Result < & HTLCSource , ChannelError > {
1634
+ pub fn update_fail_malformed_htlc < ' a > ( & mut self , msg : & msgs:: UpdateFailMalformedHTLC , fail_reason : HTLCFailReason ) -> Result < ( & HTLCSource , [ u8 ; 32 ] ) , ChannelError > {
1629
1635
if ( self . channel_state & ( ChannelState :: ChannelFunded as u32 ) ) != ( ChannelState :: ChannelFunded as u32 ) {
1630
1636
return Err ( ChannelError :: Close ( "Got fail malformed HTLC message when channel was not in an operational state" ) ) ;
1631
1637
}
0 commit comments