@@ -281,6 +281,21 @@ impl HTLCCandidate {
281
281
}
282
282
}
283
283
284
+ /// Information needed for constructing an invoice route hint for this channel.
285
+ pub struct CounterpartyForwardingInfo {
286
+ /// Base routing fee in millisatoshis.
287
+ pub fee_base_msat : u32 ,
288
+ /// Amount in millionths of a satoshi the channel will charge per transferred satoshi.
289
+ pub fee_proportional_millionths : u32 ,
290
+ /// The number of blocks such that if:
291
+ /// `htlc.cltv_expiry - current_block_height <= cltv_expiry_delta`
292
+ /// then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta is used to
293
+ /// calculate the outgoing HTLC's cltv_expiry value -- so, if an incoming HTLC comes in with a
294
+ /// cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
295
+ /// then we'll set the outgoing HTLC's cltv_expiry value to 100010.
296
+ pub cltv_expiry_delta : u16 ,
297
+ }
298
+
284
299
// TODO: We should refactor this to be an Inbound/OutboundChannel until initial setup handshaking
285
300
// has been completed, and then turn into a Channel to get compiler-time enforcement of things like
286
301
// calling channel_id() before we're set up or things like get_outbound_funding_signed on an
@@ -391,6 +406,8 @@ pub(super) struct Channel<Signer: Sign> {
391
406
//implied by OUR_MAX_HTLCS: max_accepted_htlcs: u16,
392
407
minimum_depth : u32 ,
393
408
409
+ counterparty_forwarding_info : Option < CounterpartyForwardingInfo > ,
410
+
394
411
pub ( crate ) channel_transaction_parameters : ChannelTransactionParameters ,
395
412
396
413
counterparty_cur_commitment_point : Option < PublicKey > ,
@@ -577,6 +594,8 @@ impl<Signer: Sign> Channel<Signer> {
577
594
counterparty_max_accepted_htlcs : 0 ,
578
595
minimum_depth : 0 , // Filled in in accept_channel
579
596
597
+ counterparty_forwarding_info : None ,
598
+
580
599
channel_transaction_parameters : ChannelTransactionParameters {
581
600
holder_pubkeys : pubkeys,
582
601
holder_selected_contest_delay : config. own_channel_config . our_to_self_delay ,
@@ -813,6 +832,8 @@ impl<Signer: Sign> Channel<Signer> {
813
832
counterparty_max_accepted_htlcs : msg. max_accepted_htlcs ,
814
833
minimum_depth : config. own_channel_config . minimum_depth ,
815
834
835
+ counterparty_forwarding_info : None ,
836
+
816
837
channel_transaction_parameters : ChannelTransactionParameters {
817
838
holder_pubkeys : pubkeys,
818
839
holder_selected_contest_delay : config. own_channel_config . our_to_self_delay ,
@@ -4437,6 +4458,16 @@ impl<Signer: Sign> Writeable for Channel<Signer> {
4437
4458
self . counterparty_max_accepted_htlcs . write ( writer) ?;
4438
4459
self . minimum_depth . write ( writer) ?;
4439
4460
4461
+ match & self . counterparty_forwarding_info {
4462
+ Some ( info) => {
4463
+ 1u8 . write ( writer) ?;
4464
+ info. fee_base_msat . write ( writer) ?;
4465
+ info. fee_proportional_millionths . write ( writer) ?;
4466
+ info. cltv_expiry_delta . write ( writer) ?;
4467
+ } ,
4468
+ None => 0u8 . write ( writer) ?
4469
+ }
4470
+
4440
4471
self . channel_transaction_parameters . write ( writer) ?;
4441
4472
self . counterparty_cur_commitment_point . write ( writer) ?;
4442
4473
@@ -4597,6 +4628,16 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<&'a K> for Channel<Signer>
4597
4628
let counterparty_max_accepted_htlcs = Readable :: read ( reader) ?;
4598
4629
let minimum_depth = Readable :: read ( reader) ?;
4599
4630
4631
+ let counterparty_forwarding_info = match <u8 as Readable >:: read ( reader) ? {
4632
+ 0 => None ,
4633
+ 1 => Some ( CounterpartyForwardingInfo {
4634
+ fee_base_msat : Readable :: read ( reader) ?,
4635
+ fee_proportional_millionths : Readable :: read ( reader) ?,
4636
+ cltv_expiry_delta : Readable :: read ( reader) ?,
4637
+ } ) ,
4638
+ _ => return Err ( DecodeError :: InvalidValue ) ,
4639
+ } ;
4640
+
4600
4641
let channel_parameters = Readable :: read ( reader) ?;
4601
4642
let counterparty_cur_commitment_point = Readable :: read ( reader) ?;
4602
4643
@@ -4667,6 +4708,8 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<&'a K> for Channel<Signer>
4667
4708
counterparty_max_accepted_htlcs,
4668
4709
minimum_depth,
4669
4710
4711
+ counterparty_forwarding_info,
4712
+
4670
4713
channel_transaction_parameters : channel_parameters,
4671
4714
counterparty_cur_commitment_point,
4672
4715
0 commit comments