File tree 2 files changed +10
-10
lines changed
2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 14
14
//! disconnections, transaction broadcasting, and feerate information requests.
15
15
16
16
use core:: { cmp, ops:: Deref } ;
17
+ use core:: convert:: TryInto ;
17
18
18
19
use bitcoin:: blockdata:: transaction:: Transaction ;
19
20
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
+
20
29
/// An interface to send a transaction to the Bitcoin network.
21
30
pub trait BroadcasterInterface {
22
31
/// Sends a list of transactions out to (hopefully) be mined.
Original file line number Diff line number Diff line change 12
12
//! [`Event`]: crate::events::Event
13
13
14
14
use alloc:: collections:: BTreeMap ;
15
- use core:: convert:: TryInto ;
16
15
use core:: ops:: Deref ;
17
16
18
- use crate :: chain:: chaininterface:: BroadcasterInterface ;
17
+ use crate :: chain:: chaininterface:: { BroadcasterInterface , compute_feerate_sat_per_1000_weight , fee_for_weight } ;
19
18
use crate :: chain:: ClaimId ;
20
19
use crate :: io_extras:: sink;
21
20
use crate :: ln:: channel:: ANCHOR_OUTPUT_VALUE_SATOSHI ;
@@ -44,14 +43,6 @@ const BASE_INPUT_SIZE: u64 = 32 /* txid */ + 4 /* vout */ + 4 /* sequence */;
44
43
45
44
const BASE_INPUT_WEIGHT : u64 = BASE_INPUT_SIZE * WITNESS_SCALE_FACTOR as u64 ;
46
45
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
-
55
46
/// The parameters required to derive a channel signer via [`SignerProvider`].
56
47
#[ derive( Clone , Debug , PartialEq , Eq ) ]
57
48
pub struct ChannelDerivationParameters {
You can’t perform that action at this time.
0 commit comments