-
Notifications
You must be signed in to change notification settings - Fork 0
approach-1: Set outgoing signal in PendingHTLCInfo #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
235d5ec
8fb0681
ef58f94
1f00685
c62eb0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -426,6 +426,12 @@ pub struct PendingHTLCInfo { | |
| /// This is used to allow LSPs to take fees as a part of payments, without the sender having to | ||
| /// shoulder them. | ||
| pub skimmed_fee_msat: Option<u64>, | ||
| /// An experimental field indicating whether our node's reputation would be held accountable | ||
| /// for the timely resolution of the received HTLC. | ||
| pub incoming_accountable: Option<u8>, | ||
| /// An experimental field indicating whether the outgoing node's reputation would be held | ||
| /// accountable for the timely resolution of the offered HTLC. | ||
| pub outgoing_accountable: Option<u8>, | ||
| } | ||
|
|
||
| #[derive(Clone)] // See FundedChannel::revoke_and_ack for why, tl;dr: Rust bug | ||
|
|
@@ -5048,7 +5054,7 @@ where | |
| let current_height: u32 = self.best_block.read().unwrap().height; | ||
| create_recv_pending_htlc_info(decoded_hop, shared_secret, msg.payment_hash, | ||
| msg.amount_msat, msg.cltv_expiry, None, allow_underpay, msg.skimmed_fee_msat, | ||
| current_height) | ||
| msg.accountable, current_height) | ||
| }, | ||
| onion_utils::Hop::Forward { .. } | onion_utils::Hop::BlindedForward { .. } => { | ||
| create_fwd_pending_htlc_info(msg, decoded_hop, shared_secret, next_packet_pubkey_opt) | ||
|
|
@@ -5268,6 +5274,7 @@ where | |
| onion_packet, | ||
| None, | ||
| hold_htlc_at_next_hop, | ||
| Some(0), | ||
| &self.fee_estimator, | ||
| &&logger, | ||
| ); | ||
|
|
@@ -7150,6 +7157,7 @@ where | |
| payment_hash, | ||
| outgoing_amt_msat, | ||
| outgoing_cltv_value, | ||
| incoming_accountable, | ||
| .. | ||
| }, | ||
| } = payment; | ||
|
|
@@ -7248,6 +7256,7 @@ where | |
| Some(phantom_shared_secret), | ||
| false, | ||
| None, | ||
| incoming_accountable, | ||
| current_height, | ||
| ); | ||
| match create_res { | ||
|
|
@@ -7357,6 +7366,7 @@ where | |
| outgoing_cltv_value, | ||
| routing, | ||
| skimmed_fee_msat, | ||
| outgoing_accountable, | ||
| .. | ||
| }, | ||
| .. | ||
|
|
@@ -7452,6 +7462,7 @@ where | |
| onion_packet.clone(), | ||
| *skimmed_fee_msat, | ||
| next_blinding_point, | ||
| *outgoing_accountable, | ||
| &self.fee_estimator, | ||
| &&logger, | ||
| ) { | ||
|
|
@@ -11221,7 +11232,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/ | |
| Some(prev_channel_id), | ||
| Some(payment_hash), | ||
| ); | ||
| let pending_add = PendingAddHTLCInfo { | ||
| let mut pending_add = PendingAddHTLCInfo { | ||
| prev_outbound_scid_alias, | ||
| prev_counterparty_node_id, | ||
| prev_funding_outpoint, | ||
|
|
@@ -11315,6 +11326,13 @@ This indicates a bug inside LDK. Please report this error at https://github.com/ | |
| }, | ||
| } | ||
| } else { | ||
| // Set the value for our outgoing accountable signal to copy the received | ||
| // incoming value (or just set zero if not present). This point is where we | ||
| // could introduce an interceptor that provides us with custom accountable | ||
| // values if desired. | ||
| pending_add.forward_info.outgoing_accountable = | ||
| pending_add.forward_info.incoming_accountable.or(Some(0)); | ||
|
|
||
|
Comment on lines
+11329
to
+11335
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if this should be here or in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taken a shot at this here - I think that I prefer this approach for now, because it gives us good flexibility (see PR description). Also addresses the |
||
| match self.forward_htlcs.lock().unwrap().entry(scid) { | ||
| hash_map::Entry::Occupied(mut entry) => { | ||
| entry.get_mut().push(HTLCForwardInfo::AddHTLC(pending_add)); | ||
|
|
@@ -15764,6 +15782,8 @@ impl_writeable_tlv_based!(PendingHTLCInfo, { | |
| (8, outgoing_cltv_value, required), | ||
| (9, incoming_amt_msat, option), | ||
| (10, skimmed_fee_msat, option), | ||
| (11, incoming_accountable, option), | ||
| (13, outgoing_accountable, option), | ||
| }); | ||
|
|
||
| impl Writeable for HTLCFailureMsg { | ||
|
|
@@ -19198,7 +19218,7 @@ mod tests { | |
| if let Err(crate::ln::channelmanager::InboundHTLCErr { reason, .. }) = | ||
| create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]), | ||
| sender_intended_amt_msat - extra_fee_msat - 1, 42, None, true, Some(extra_fee_msat), | ||
| current_height) | ||
| None, current_height) | ||
| { | ||
| assert_eq!(reason, LocalHTLCFailureReason::FinalIncorrectHTLCAmount); | ||
| } else { panic!(); } | ||
|
|
@@ -19221,7 +19241,7 @@ mod tests { | |
| let current_height: u32 = node[0].node.best_block.read().unwrap().height; | ||
| assert!(create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]), | ||
| sender_intended_amt_msat - extra_fee_msat, 42, None, true, Some(extra_fee_msat), | ||
| current_height).is_ok()); | ||
| None, current_height).is_ok()); | ||
| } | ||
|
|
||
| #[test] | ||
|
|
@@ -19246,7 +19266,7 @@ mod tests { | |
| custom_tlvs: Vec::new(), | ||
| }, | ||
| shared_secret: SharedSecret::from_bytes([0; 32]), | ||
| }, [0; 32], PaymentHash([0; 32]), 100, TEST_FINAL_CLTV + 1, None, true, None, current_height); | ||
| }, [0; 32], PaymentHash([0; 32]), 100, TEST_FINAL_CLTV + 1, None, true, None, None, current_height); | ||
|
|
||
| // Should not return an error as this condition: | ||
| // https://github.com/lightning/bolts/blob/4dcc377209509b13cf89a4b91fde7d478f5b46d8/04-onion-routing.md?plain=1#L334 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this field won't apply for receives, would it be better to put it accordingly for each variant in
PendingHTLCRouting?