File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ use bdk_wallet::bitcoin::Transaction as BdkTransaction;
26
26
use bdk_wallet:: bitcoin:: TxIn as BdkTxIn ;
27
27
use bdk_wallet:: bitcoin:: TxOut as BdkTxOut ;
28
28
use bdk_wallet:: bitcoin:: Txid as BitcoinTxid ;
29
+ use bdk_wallet:: bitcoin:: Weight ;
29
30
use bdk_wallet:: bitcoin:: Wtxid as BitcoinWtxid ;
30
31
use bdk_wallet:: miniscript:: psbt:: PsbtExt ;
31
32
use bdk_wallet:: serde_json;
@@ -156,6 +157,22 @@ impl FeeRate {
156
157
pub fn to_sat_per_kwu ( & self ) -> u64 {
157
158
self . 0 . to_sat_per_kwu ( )
158
159
}
160
+
161
+ /// Calculates fee in satoshis by multiplying this fee rate by weight, in virtual bytes, returning `None` if overflow occurred.
162
+ ///
163
+ /// This is equivalent to converting vb to weight using Weight::from_vb and then calling Self::fee_wu(weight).
164
+ pub fn fee_vb ( & self , vb : u64 ) -> Option < u64 > {
165
+ self . 0 . fee_vb ( vb) . map ( |amount| amount. to_sat ( ) )
166
+ }
167
+
168
+ /// Calculates fee in satoshis by multiplying this fee rate by weight, in weight units, returning `None` if overflow occurred.
169
+ //
170
+ // This is equivalent to Self::checked_mul_by_weight().
171
+ pub fn fee_wu ( & self , wu : u64 ) -> Option < u64 > {
172
+ self . 0
173
+ . fee_wu ( Weight :: from_wu ( wu) )
174
+ . map ( |amount| amount. to_sat ( ) )
175
+ }
159
176
}
160
177
161
178
impl Display for FeeRate {
You can’t perform that action at this time.
0 commit comments