File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed
Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 1414//! disconnections, transaction broadcasting, and feerate information requests.
1515
1616use core:: { cmp, ops:: Deref } ;
17+ use core:: convert:: TryInto ;
1718
1819use bitcoin:: blockdata:: transaction:: Transaction ;
1920
21+ // TODO: Define typed abstraction over feerates to handle their conversions.
22+ pub ( crate ) fn compute_feerate_sat_per_1000_weight ( fee_sat : u64 , weight : u64 ) -> u32 {
23+ ( fee_sat * 1000 / weight) . try_into ( ) . unwrap_or ( u32:: max_value ( ) )
24+ }
25+ pub ( crate ) const fn fee_for_weight ( feerate_sat_per_1000_weight : u32 , weight : u64 ) -> u64 {
26+ ( ( feerate_sat_per_1000_weight as u64 * weight) + 1000 - 1 ) / 1000
27+ }
28+
2029/// An interface to send a transaction to the Bitcoin network.
2130pub trait BroadcasterInterface {
2231 /// Sends a list of transactions out to (hopefully) be mined.
Original file line number Diff line number Diff line change 1212//! [`Event`]: crate::events::Event
1313
1414use alloc:: collections:: BTreeMap ;
15- use core:: convert:: TryInto ;
1615use core:: ops:: Deref ;
1716
18- use crate :: chain:: chaininterface:: BroadcasterInterface ;
17+ use crate :: chain:: chaininterface:: { BroadcasterInterface , compute_feerate_sat_per_1000_weight , fee_for_weight } ;
1918use crate :: chain:: ClaimId ;
2019use crate :: io_extras:: sink;
2120use crate :: ln:: channel:: ANCHOR_OUTPUT_VALUE_SATOSHI ;
@@ -44,14 +43,6 @@ const BASE_INPUT_SIZE: u64 = 32 /* txid */ + 4 /* vout */ + 4 /* sequence */;
4443
4544const BASE_INPUT_WEIGHT : u64 = BASE_INPUT_SIZE * WITNESS_SCALE_FACTOR as u64 ;
4645
47- // TODO: Define typed abstraction over feerates to handle their conversions.
48- fn compute_feerate_sat_per_1000_weight ( fee_sat : u64 , weight : u64 ) -> u32 {
49- ( fee_sat * 1000 / weight) . try_into ( ) . unwrap_or ( u32:: max_value ( ) )
50- }
51- const fn fee_for_weight ( feerate_sat_per_1000_weight : u32 , weight : u64 ) -> u64 {
52- ( ( feerate_sat_per_1000_weight as u64 * weight) + 1000 - 1 ) / 1000
53- }
54-
5546/// The parameters required to derive a channel signer via [`SignerProvider`].
5647#[ derive( Clone , Debug , PartialEq , Eq ) ]
5748pub struct ChannelDerivationParameters {
You can’t perform that action at this time.
0 commit comments