Skip to content

Commit 08be941

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 918b3f7 commit 08be941

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
@@ -15968,7 +15968,7 @@ impl_writeable_tlv_based!(PendingHTLCInfo, {
1596815968
(8, outgoing_cltv_value, required),
1596915969
(9, incoming_amt_msat, option),
1597015970
(10, skimmed_fee_msat, option),
15971-
(11, incoming_accountable, option),
15971+
(11, incoming_accountable, (default_value, false)),
1597215972
});
1597315973

1597415974
impl Writeable for HTLCFailureMsg {
@@ -19404,7 +19404,7 @@ mod tests {
1940419404
if let Err(crate::ln::channelmanager::InboundHTLCErr { reason, .. }) =
1940519405
create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
1940619406
sender_intended_amt_msat - extra_fee_msat - 1, 42, None, true, Some(extra_fee_msat),
19407-
None, current_height)
19407+
false, current_height)
1940819408
{
1940919409
assert_eq!(reason, LocalHTLCFailureReason::FinalIncorrectHTLCAmount);
1941019410
} else { panic!(); }
@@ -19427,7 +19427,7 @@ mod tests {
1942719427
let current_height: u32 = node[0].node.best_block.read().unwrap().height;
1942819428
assert!(create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
1942919429
sender_intended_amt_msat - extra_fee_msat, 42, None, true, Some(extra_fee_msat),
19430-
None, current_height).is_ok());
19430+
false, current_height).is_ok());
1943119431
}
1943219432

1943319433
#[test]
@@ -19452,7 +19452,7 @@ mod tests {
1945219452
custom_tlvs: Vec::new(),
1945319453
},
1945419454
shared_secret: SharedSecret::from_bytes([0; 32]),
19455-
}, [0; 32], PaymentHash([0; 32]), 100, TEST_FINAL_CLTV + 1, None, true, None, None, current_height);
19455+
}, [0; 32], PaymentHash([0; 32]), 100, TEST_FINAL_CLTV + 1, None, true, None, false, current_height);
1945619456

1945719457
// Should not return an error as this condition:
1945819458
// 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
@@ -275,7 +275,7 @@ pub(super) fn create_fwd_pending_htlc_info(
275275
pub(super) fn create_recv_pending_htlc_info(
276276
hop_data: onion_utils::Hop, shared_secret: [u8; 32], payment_hash: PaymentHash,
277277
amt_msat: u64, cltv_expiry: u32, phantom_shared_secret: Option<[u8; 32]>, allow_underpay: bool,
278-
counterparty_skimmed_fee_msat: Option<u64>, incoming_accountable: Option<bool>, current_height: u32
278+
counterparty_skimmed_fee_msat: Option<u64>, incoming_accountable: bool, current_height: u32
279279
) -> Result<PendingHTLCInfo, InboundHTLCErr> {
280280
let (
281281
payment_data, keysend_preimage, custom_tlvs, onion_amt_msat, onion_cltv_expiry,

0 commit comments

Comments
 (0)