Skip to content

Commit

Permalink
Merge pull request #1200 from getlipa/feature/expose-reverse-swap-onc…
Browse files Browse the repository at this point in the history
…hain-fees

Expose reverse swap onchain fees
  • Loading branch information
danielgranhao authored Sep 25, 2024
2 parents 50e6351 + 7dcb74d commit 6b37f3a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
10 changes: 5 additions & 5 deletions examples/node/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,23 +635,23 @@ fn node_info(node: &LightningNode) {
println!("Node PubKey: {}", node_info.node_pubkey);
println!("Connected peer(s): {}", peers_list.join(", "));
println!(
" On-chain balance: {}",
" On-chain balance: {}",
amount_to_string(&node_info.onchain_balance)
);
println!(
" Local balance: {}",
" Local balance: {}",
amount_to_string(&node_info.channels_info.local_balance)
);
println!(
" Max receivable in a single payment: {}",
" Max receivable in a single payment: {}",
amount_to_string(&node_info.channels_info.max_receivable_single_payment)
);
println!(
" Total inbound capacity: {}",
" Total inbound capacity: {}",
amount_to_string(&node_info.channels_info.total_inbound_capacity)
);
println!(
" Outbound capacity: {}",
" Outbound capacity: {}",
amount_to_string(&node_info.channels_info.outbound_capacity)
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,10 @@ impl LightningNode {
} else if let Some(ref s) = payment_details.reverse_swap_info {
let reverse_swap_info = ReverseSwapInfo {
paid_onchain_amount: s.onchain_amount_sat.as_sats().to_amount_up(&exchange_rate),
swap_fees_amount: (breez_payment.amount_msat
- s.onchain_amount_sat.as_sats().msats)
.as_msats()
.to_amount_up(&exchange_rate),
claim_txid: s.claim_txid.clone(),
status: s.status,
};
Expand Down
1 change: 1 addition & 0 deletions src/lipalightninglib.udl
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ dictionary SwapInfo {

dictionary ReverseSwapInfo {
Amount paid_onchain_amount;
Amount swap_fees_amount;
string? claim_txid;
ReverseSwapStatus status;
};
Expand Down
5 changes: 4 additions & 1 deletion src/reverse_swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ use breez_sdk_core::ReverseSwapStatus;
#[derive(PartialEq, Debug)]
pub struct ReverseSwapInfo {
pub paid_onchain_amount: Amount,
/// Total fees paid excluding LN routing fees. Includes onchain
/// fees and reverse-swap provider fees.
pub swap_fees_amount: Amount,
/// The tx id of the claim tx, which is the final tx in the reverse swap flow, which send funds
/// to the targeted on-chain address.
///
/// It will only be present once the claim tx is broacasted.
/// It will only be present once the claim tx is broadcasted.
pub claim_txid: Option<String>,
pub status: ReverseSwapStatus,
}

0 comments on commit 6b37f3a

Please sign in to comment.