Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 162
Allow to override fee rates for onchain payments#434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tnull
merged 1 commit into
lightningdevkit:main
from
tnull:2025-01-allow-to-override-feerateJan 27, 2025
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -17,6 +17,24 @@ use bitcoin::{Address, Txid}; | ||
| use std::sync::{Arc, RwLock}; | ||
| #[cfg(not(feature = "uniffi"))] | ||
| type FeeRate = bitcoin::FeeRate; | ||
| #[cfg(feature = "uniffi")] | ||
| type FeeRate = Arc<bitcoin::FeeRate>; | ||
| macro_rules! maybe_map_fee_rate_opt { | ||
| ($fee_rate_opt: expr) => {{ | ||
| #[cfg(not(feature = "uniffi"))] | ||
| { | ||
| $fee_rate_opt | ||
| } | ||
| #[cfg(feature = "uniffi")] | ||
| { | ||
| $fee_rate_opt.map(|f| *f) | ||
| } | ||
| }}; | ||
| } | ||
| /// A payment handler allowing to send and receive on-chain payments. | ||
| /// | ||
| /// Should be retrieved by calling [`Node::onchain_payment`]. | ||
| @@ -50,9 +68,12 @@ impl OnchainPayment { | ||
| /// This will respect any on-chain reserve we need to keep, i.e., won't allow to cut into | ||
| /// [`BalanceDetails::total_anchor_channels_reserve_sats`]. | ||
| /// | ||
| /// If `fee_rate` is set it will be used on the resulting transaction. Otherwise we'll retrieve | ||
| /// a reasonable estimate from the configured chain source. | ||
| /// | ||
| /// [`BalanceDetails::total_anchor_channels_reserve_sats`]: crate::BalanceDetails::total_anchor_channels_reserve_sats | ||
| pub fn send_to_address( | ||
| &self, address: &bitcoin::Address, amount_sats: u64, | ||
| &self, address: &bitcoin::Address, amount_sats: u64, fee_rate: Option<FeeRate>, | ||
| ) -> Result<Txid, Error> { | ||
| let rt_lock = self.runtime.read().unwrap(); | ||
| if rt_lock.is_none() { | ||
| @@ -63,7 +84,8 @@ impl OnchainPayment { | ||
| crate::total_anchor_channels_reserve_sats(&self.channel_manager, &self.config); | ||
| let send_amount = | ||
| OnchainSendAmount::ExactRetainingReserve { amount_sats, cur_anchor_reserve_sats }; | ||
| self.wallet.send_to_address(address, send_amount) | ||
| let fee_rate_opt = maybe_map_fee_rate_opt!(fee_rate); | ||
| self.wallet.send_to_address(address, send_amount, fee_rate_opt) | ||
| } | ||
| /// Send an on-chain payment to the given address, draining the available funds. | ||
| @@ -77,9 +99,12 @@ impl OnchainPayment { | ||
| /// will try to send all spendable onchain funds, i.e., | ||
| /// [`BalanceDetails::spendable_onchain_balance_sats`]. | ||
| /// | ||
| /// If `fee_rate` is set it will be used on the resulting transaction. Otherwise a reasonable | ||
tnull marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| /// we'll retrieve an estimate from the configured chain source. | ||
| /// | ||
| /// [`BalanceDetails::spendable_onchain_balance_sats`]: crate::balance::BalanceDetails::spendable_onchain_balance_sats | ||
| pub fn send_all_to_address( | ||
| &self, address: &bitcoin::Address, retain_reserves: bool, | ||
| &self, address: &bitcoin::Address, retain_reserves: bool, fee_rate: Option<FeeRate>, | ||
| ) -> Result<Txid, Error> { | ||
| let rt_lock = self.runtime.read().unwrap(); | ||
| if rt_lock.is_none() { | ||
| @@ -94,6 +119,7 @@ impl OnchainPayment { | ||
| OnchainSendAmount::AllDrainingReserve | ||
| }; | ||
| self.wallet.send_to_address(address, send_amount) | ||
| let fee_rate_opt = maybe_map_fee_rate_opt!(fee_rate); | ||
| self.wallet.send_to_address(address, send_amount, fee_rate_opt) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.