@@ -281,6 +281,18 @@ 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 minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart,
291
+ /// such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s
292
+ /// `cltv_expiry_delta` for more details.
293
+ pub cltv_expiry_delta : u16 ,
294
+ }
295
+
284
296
// TODO: We should refactor this to be an Inbound/OutboundChannel until initial setup handshaking
285
297
// has been completed, and then turn into a Channel to get compiler-time enforcement of things like
286
298
// calling channel_id() before we're set up or things like get_outbound_funding_signed on an
@@ -391,6 +403,8 @@ pub(super) struct Channel<Signer: Sign> {
391
403
//implied by OUR_MAX_HTLCS: max_accepted_htlcs: u16,
392
404
minimum_depth : u32 ,
393
405
406
+ counterparty_forwarding_info : Option < CounterpartyForwardingInfo > ,
407
+
394
408
pub ( crate ) channel_transaction_parameters : ChannelTransactionParameters ,
395
409
396
410
counterparty_cur_commitment_point : Option < PublicKey > ,
@@ -577,6 +591,8 @@ impl<Signer: Sign> Channel<Signer> {
577
591
counterparty_max_accepted_htlcs : 0 ,
578
592
minimum_depth : 0 , // Filled in in accept_channel
579
593
594
+ counterparty_forwarding_info : None ,
595
+
580
596
channel_transaction_parameters : ChannelTransactionParameters {
581
597
holder_pubkeys : pubkeys,
582
598
holder_selected_contest_delay : config. own_channel_config . our_to_self_delay ,
@@ -813,6 +829,8 @@ impl<Signer: Sign> Channel<Signer> {
813
829
counterparty_max_accepted_htlcs : msg. max_accepted_htlcs ,
814
830
minimum_depth : config. own_channel_config . minimum_depth ,
815
831
832
+ counterparty_forwarding_info : None ,
833
+
816
834
channel_transaction_parameters : ChannelTransactionParameters {
817
835
holder_pubkeys : pubkeys,
818
836
holder_selected_contest_delay : config. own_channel_config . our_to_self_delay ,
@@ -4437,6 +4455,16 @@ impl<Signer: Sign> Writeable for Channel<Signer> {
4437
4455
self . counterparty_max_accepted_htlcs . write ( writer) ?;
4438
4456
self . minimum_depth . write ( writer) ?;
4439
4457
4458
+ match & self . counterparty_forwarding_info {
4459
+ Some ( info) => {
4460
+ 1u8 . write ( writer) ?;
4461
+ info. fee_base_msat . write ( writer) ?;
4462
+ info. fee_proportional_millionths . write ( writer) ?;
4463
+ info. cltv_expiry_delta . write ( writer) ?;
4464
+ } ,
4465
+ None => 0u8 . write ( writer) ?
4466
+ }
4467
+
4440
4468
self . channel_transaction_parameters . write ( writer) ?;
4441
4469
self . counterparty_cur_commitment_point . write ( writer) ?;
4442
4470
@@ -4597,6 +4625,16 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<&'a K> for Channel<Signer>
4597
4625
let counterparty_max_accepted_htlcs = Readable :: read ( reader) ?;
4598
4626
let minimum_depth = Readable :: read ( reader) ?;
4599
4627
4628
+ let counterparty_forwarding_info = match <u8 as Readable >:: read ( reader) ? {
4629
+ 0 => None ,
4630
+ 1 => Some ( CounterpartyForwardingInfo {
4631
+ fee_base_msat : Readable :: read ( reader) ?,
4632
+ fee_proportional_millionths : Readable :: read ( reader) ?,
4633
+ cltv_expiry_delta : Readable :: read ( reader) ?,
4634
+ } ) ,
4635
+ _ => return Err ( DecodeError :: InvalidValue ) ,
4636
+ } ;
4637
+
4600
4638
let channel_parameters = Readable :: read ( reader) ?;
4601
4639
let counterparty_cur_commitment_point = Readable :: read ( reader) ?;
4602
4640
@@ -4667,6 +4705,8 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<&'a K> for Channel<Signer>
4667
4705
counterparty_max_accepted_htlcs,
4668
4706
minimum_depth,
4669
4707
4708
+ counterparty_forwarding_info,
4709
+
4670
4710
channel_transaction_parameters : channel_parameters,
4671
4711
counterparty_cur_commitment_point,
4672
4712
0 commit comments