Skip to content

Commit fa7a272

Browse files
committed
f switch to bool for accountable in PendingHTLCInfo and write default
To allow us to get rid of Option<bool>, we just persist false by default for accountable signals. Moving away from the Option means that we can't distinguish between no signal being set and a false one, but we accept this for the sake of simplifying the code.
1 parent 035f50e commit fa7a272

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ pub struct PendingHTLCInfo {
429429
pub skimmed_fee_msat: Option<u64>,
430430
/// An experimental field indicating whether our node's reputation would be held accountable
431431
/// for the timely resolution of the received HTLC.
432-
pub incoming_accountable: Option<bool>,
432+
pub incoming_accountable: bool,
433433
}
434434

435435
#[derive(Clone, Debug)] // See FundedChannel::revoke_and_ack for why, tl;dr: Rust bug
@@ -15894,7 +15894,7 @@ impl_writeable_tlv_based!(PendingHTLCInfo, {
1589415894
(8, outgoing_cltv_value, required),
1589515895
(9, incoming_amt_msat, option),
1589615896
(10, skimmed_fee_msat, option),
15897-
(11, incoming_accountable, option),
15897+
(11, incoming_accountable, (default_value, false)),
1589815898
});
1589915899

1590015900
impl Writeable for HTLCFailureMsg {
@@ -19329,7 +19329,7 @@ mod tests {
1932919329
if let Err(crate::ln::channelmanager::InboundHTLCErr { reason, .. }) =
1933019330
create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
1933119331
sender_intended_amt_msat - extra_fee_msat - 1, 42, None, true, Some(extra_fee_msat),
19332-
None, current_height)
19332+
false, current_height)
1933319333
{
1933419334
assert_eq!(reason, LocalHTLCFailureReason::FinalIncorrectHTLCAmount);
1933519335
} else { panic!(); }
@@ -19352,7 +19352,7 @@ mod tests {
1935219352
let current_height: u32 = node[0].node.best_block.read().unwrap().height;
1935319353
assert!(create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
1935419354
sender_intended_amt_msat - extra_fee_msat, 42, None, true, Some(extra_fee_msat),
19355-
None, current_height).is_ok());
19355+
false, current_height).is_ok());
1935619356
}
1935719357

1935819358
#[test]
@@ -19377,7 +19377,7 @@ mod tests {
1937719377
custom_tlvs: Vec::new(),
1937819378
},
1937919379
shared_secret: SharedSecret::from_bytes([0; 32]),
19380-
}, [0; 32], PaymentHash([0; 32]), 100, TEST_FINAL_CLTV + 1, None, true, None, None, current_height);
19380+
}, [0; 32], PaymentHash([0; 32]), 100, TEST_FINAL_CLTV + 1, None, true, None, false, current_height);
1938119381

1938219382
// Should not return an error as this condition:
1938319383
// https://github.com/lightning/bolts/blob/4dcc377209509b13cf89a4b91fde7d478f5b46d8/04-onion-routing.md?plain=1#L334

lightning/src/ln/onion_payment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ pub(super) fn create_fwd_pending_htlc_info(
249249
pub(super) fn create_recv_pending_htlc_info(
250250
hop_data: onion_utils::Hop, shared_secret: [u8; 32], payment_hash: PaymentHash,
251251
amt_msat: u64, cltv_expiry: u32, phantom_shared_secret: Option<[u8; 32]>, allow_underpay: bool,
252-
counterparty_skimmed_fee_msat: Option<u64>, incoming_accountable: Option<bool>, current_height: u32
252+
counterparty_skimmed_fee_msat: Option<u64>, incoming_accountable: bool, current_height: u32
253253
) -> Result<PendingHTLCInfo, InboundHTLCErr> {
254254
let (
255255
payment_data, keysend_preimage, custom_tlvs, onion_amt_msat, onion_cltv_expiry,

0 commit comments

Comments
 (0)