Skip to content

Commit

Permalink
Add extra fields for channel RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Feb 25, 2025
1 parent 1169b85 commit 8a6e796
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/rpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,15 @@ The channel data structure
* `received_tlc_balance` - <em>u128</em>, The received balance of the channel
* `latest_commitment_transaction_hash` - <em>`Option<H256>`</em>, The hash of the latest commitment transaction
* `created_at` - <em>u64</em>, The time the channel was created at, in milliseconds from UNIX epoch
* `enabled` - <em>bool</em>, Whether the channel is enabled
* `tlc_expiry_delta` - <em>u64</em>, The expiry delta to forward a tlc, in milliseconds, default to 1 day, which is 24 * 60 * 60 * 1000 milliseconds
This parameter can be updated with rpc `update_channel` later.
* `tlc_fee_proportional_millionths` - <em>u128</em>, The fee proportional millionths for a TLC, proportional to the amount of the forwarded tlc.
The unit is millionths of the amount. default is 1000 which means 0.1%.
This parameter can be updated with rpc `update_channel` later.
Not that, we use outbound channel to calculate the fee for TLC forwarding. For example,
if we have a path A -> B -> C, then the fee B requires for TLC forwarding, is calculated
the channel configuration of B and C, not A and B.
---

<a id="#type-channelinfo"></a>
Expand Down
19 changes: 19 additions & 0 deletions src/rpc/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,20 @@ pub struct Channel {
/// The time the channel was created at, in milliseconds from UNIX epoch
#[serde_as(as = "U64Hex")]
pub created_at: u64,
/// Whether the channel is enabled
pub enabled: bool,
/// The expiry delta to forward a tlc, in milliseconds, default to 1 day, which is 24 * 60 * 60 * 1000 milliseconds
/// This parameter can be updated with rpc `update_channel` later.
#[serde_as(as = "U64Hex")]
pub tlc_expiry_delta: u64,
/// The fee proportional millionths for a TLC, proportional to the amount of the forwarded tlc.
/// The unit is millionths of the amount. default is 1000 which means 0.1%.
/// This parameter can be updated with rpc `update_channel` later.
/// Not that, we use outbound channel to calculate the fee for TLC forwarding. For example,
/// if we have a path A -> B -> C, then the fee B requires for TLC forwarding, is calculated
/// the channel configuration of B and C, not A and B.
#[serde_as(as = "U128Hex")]
pub tlc_fee_proportional_millionths: u128,
}

#[serde_as]
Expand Down Expand Up @@ -427,6 +441,11 @@ where
.as_ref()
.map(|tx| tx.clone().into_view().hash().unpack()),
created_at: state.get_created_at_in_millis(),
enabled: state.local_tlc_info.enabled,
tlc_expiry_delta: state.local_tlc_info.tlc_expiry_delta,
tlc_fee_proportional_millionths: state
.local_tlc_info
.tlc_fee_proportional_millionths,
})
})
.collect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ body:json {
assert {
res.body.error: isUndefined
res.body.result.channels: isDefined
res.body.result.channels[0].enabled: isDefined
res.body.result.channels[0].tlc_expiry_delta: isDefined
res.body.result.channels[0].tlc_fee_proportional_millionths: isDefined
}

script:post-response {
Expand Down

0 comments on commit 8a6e796

Please sign in to comment.