You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/types.rs
+52-4
Original file line number
Diff line number
Diff line change
@@ -51,14 +51,34 @@ impl AsRef<[u8]> for KeychainKind {
51
51
pubstructFeeRate(f32);
52
52
53
53
implFeeRate{
54
+
/// Create a new instance checking the value provided
55
+
///
56
+
/// ## Panics
57
+
///
58
+
/// Panics if the value is not [normal](https://doc.rust-lang.org/std/primitive.f32.html#method.is_normal) (except if it's a positive zero) or negative.
59
+
fnnew_checked(value:f32) -> Self{
60
+
assert!(value.is_normal() || value == 0.0);
61
+
assert!(value.is_sign_positive());
62
+
63
+
FeeRate(value)
64
+
}
65
+
54
66
/// Create a new instance of [`FeeRate`] given a float fee rate in btc/kvbytes
67
+
///
68
+
/// ## Panics
69
+
///
70
+
/// Panics if the value is not [normal](https://doc.rust-lang.org/std/primitive.f32.html#method.is_normal) (except if it's a positive zero) or negative.
55
71
pubfnfrom_btc_per_kvb(btc_per_kvb:f32) -> Self{
56
-
FeeRate(btc_per_kvb *1e5)
72
+
FeeRate::new_checked(btc_per_kvb *1e5)
57
73
}
58
74
59
75
/// Create a new instance of [`FeeRate`] given a float fee rate in satoshi/vbyte
/// Panics if the value is not [normal](https://doc.rust-lang.org/std/primitive.f32.html#method.is_normal) (except if it's a positive zero) or negative.
80
+
pubfnfrom_sat_per_vb(sat_per_vb:f32) -> Self{
81
+
FeeRate::new_checked(sat_per_vb)
62
82
}
63
83
64
84
/// Create a new [`FeeRate`] with the default min relay fee value
0 commit comments