Skip to content

Commit 38d4480

Browse files
valentinewallaceAntoine Riard
and
Antoine Riard
committed
Add CounterpartyForwardingInfo field to channel.
This will be filled in in upcoming commits, then exposed in ChannelDetails to allow constructing route hints for invoices. Co-authored-by: Valentine Wallace <[email protected]> Co-authored-by: Antoine Riard <[email protected]>
1 parent 52edab7 commit 38d4480

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

lightning/src/ln/channel.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,12 @@ impl HTLCCandidate {
281281
}
282282
}
283283

284+
pub struct CounterpartyForwardingInfo {
285+
pub fee_base_msat: u32,
286+
pub fee_proportional_millionths: u32,
287+
pub cltv_expiry_delta: u16,
288+
}
289+
284290
// TODO: We should refactor this to be an Inbound/OutboundChannel until initial setup handshaking
285291
// has been completed, and then turn into a Channel to get compiler-time enforcement of things like
286292
// calling channel_id() before we're set up or things like get_outbound_funding_signed on an
@@ -391,6 +397,8 @@ pub(super) struct Channel<Signer: Sign> {
391397
//implied by OUR_MAX_HTLCS: max_accepted_htlcs: u16,
392398
minimum_depth: u32,
393399

400+
counterparty_forwarding_info: Option<CounterpartyForwardingInfo>,
401+
394402
pub(crate) channel_transaction_parameters: ChannelTransactionParameters,
395403

396404
counterparty_cur_commitment_point: Option<PublicKey>,
@@ -577,6 +585,8 @@ impl<Signer: Sign> Channel<Signer> {
577585
counterparty_max_accepted_htlcs: 0,
578586
minimum_depth: 0, // Filled in in accept_channel
579587

588+
counterparty_forwarding_info: None,
589+
580590
channel_transaction_parameters: ChannelTransactionParameters {
581591
holder_pubkeys: pubkeys,
582592
holder_selected_contest_delay: config.own_channel_config.our_to_self_delay,
@@ -813,6 +823,8 @@ impl<Signer: Sign> Channel<Signer> {
813823
counterparty_max_accepted_htlcs: msg.max_accepted_htlcs,
814824
minimum_depth: config.own_channel_config.minimum_depth,
815825

826+
counterparty_forwarding_info: None,
827+
816828
channel_transaction_parameters: ChannelTransactionParameters {
817829
holder_pubkeys: pubkeys,
818830
holder_selected_contest_delay: config.own_channel_config.our_to_self_delay,
@@ -4437,6 +4449,16 @@ impl<Signer: Sign> Writeable for Channel<Signer> {
44374449
self.counterparty_max_accepted_htlcs.write(writer)?;
44384450
self.minimum_depth.write(writer)?;
44394451

4452+
match &self.counterparty_forwarding_info {
4453+
Some(info) => {
4454+
1u8.write(writer)?;
4455+
info.fee_base_msat.write(writer)?;
4456+
info.fee_proportional_millionths.write(writer)?;
4457+
info.cltv_expiry_delta.write(writer)?;
4458+
},
4459+
None => 0u8.write(writer)?
4460+
}
4461+
44404462
self.channel_transaction_parameters.write(writer)?;
44414463
self.counterparty_cur_commitment_point.write(writer)?;
44424464

@@ -4597,6 +4619,16 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<&'a K> for Channel<Signer>
45974619
let counterparty_max_accepted_htlcs = Readable::read(reader)?;
45984620
let minimum_depth = Readable::read(reader)?;
45994621

4622+
let counterparty_forwarding_info = match <u8 as Readable>::read(reader)? {
4623+
0 => None,
4624+
1 => Some(CounterpartyForwardingInfo {
4625+
fee_base_msat: Readable::read(reader)?,
4626+
fee_proportional_millionths: Readable::read(reader)?,
4627+
cltv_expiry_delta: Readable::read(reader)?,
4628+
}),
4629+
_ => return Err(DecodeError::InvalidValue),
4630+
};
4631+
46004632
let channel_parameters = Readable::read(reader)?;
46014633
let counterparty_cur_commitment_point = Readable::read(reader)?;
46024634

@@ -4667,6 +4699,8 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<&'a K> for Channel<Signer>
46674699
counterparty_max_accepted_htlcs,
46684700
minimum_depth,
46694701

4702+
counterparty_forwarding_info,
4703+
46704704
channel_transaction_parameters: channel_parameters,
46714705
counterparty_cur_commitment_point,
46724706

0 commit comments

Comments
 (0)