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;
2626use bdk_wallet:: bitcoin:: TxIn as BdkTxIn ;
2727use bdk_wallet:: bitcoin:: TxOut as BdkTxOut ;
2828use bdk_wallet:: bitcoin:: Txid as BitcoinTxid ;
29+ use bdk_wallet:: bitcoin:: Weight ;
2930use bdk_wallet:: bitcoin:: Wtxid as BitcoinWtxid ;
3031use bdk_wallet:: miniscript:: psbt:: PsbtExt ;
3132use bdk_wallet:: serde_json;
@@ -156,6 +157,22 @@ impl FeeRate {
156157 pub fn to_sat_per_kwu ( & self ) -> u64 {
157158 self . 0 . to_sat_per_kwu ( )
158159 }
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+ }
159176}
160177
161178impl Display for FeeRate {
You can’t perform that action at this time.
0 commit comments