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