Skip to content

Commit

Permalink
Merge pull request #191 from nervosnetwork/yukang-more-on-payment-ses…
Browse files Browse the repository at this point in the history
…sion

Payment session and error handling on onion packet forwarding
  • Loading branch information
chenyukang authored Oct 24, 2024
2 parents 19a57e9 + 1252ff5 commit a7e530a
Show file tree
Hide file tree
Showing 46 changed files with 1,883 additions and 443 deletions.
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ socket2 = "0.5.7"
lnd-grpc-tonic-client = "0.3.0"
git-version = "0.3.9"
fiber-sphinx = "1.0.1"
strum = { version = "0.26", features = ["derive"] }
tokio = { version = "1", features = [
"io-util",
"macros",
Expand Down
2 changes: 2 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ pub enum Error {
CkbInvoiceError(#[from] InvoiceError),
#[error("Funding error: {0}")]
FundingError(#[from] FundingError),
#[error("Send payment error: {0}")]
SendPaymentError(String),
#[error("InvalidParameter: {0}")]
InvalidParameter(String),
#[error("Network Graph error: {0}")]
Expand Down
490 changes: 369 additions & 121 deletions src/fiber/channel.rs

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/fiber/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,14 @@ pub(crate) fn calculate_shutdown_tx_fee(
let tx_size = shutdown_tx_size(udt_type_script, shutdown_scripts) as u64;
fee_rate.fee(tx_size).as_u64()
}

pub(crate) fn calculate_tlc_forward_fee(amount: u128, fee_proportational_millionths: u128) -> u128 {
let fee = fee_proportational_millionths * amount;
let base_fee = fee / 1_000_000;
let remainder = fee % 1_000_000;
if remainder > 0 {
base_fee + 1
} else {
base_fee
}
}
Loading

0 comments on commit a7e530a

Please sign in to comment.