File tree Expand file tree Collapse file tree
bdk-swift/Tests/BitcoinDevKitTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1469,19 +1469,7 @@ interface Amount {
14691469 f64 to_btc();
14701470};
14711471
1472- interface FeeRate {
1473- [Name=from_sat_per_vb, Throws=FeeRateError]
1474- constructor(u64 sat_per_vb);
1475-
1476- [Name=from_sat_per_kwu]
1477- constructor(u64 sat_per_kwu);
1478-
1479- u64 to_sat_per_vb_ceil();
1480-
1481- u64 to_sat_per_vb_floor();
1482-
1483- u64 to_sat_per_kwu();
1484- };
1472+ typedef interface FeeRate;
14851473
14861474dictionary OutPoint {
14871475 string txid;
Original file line number Diff line number Diff line change @@ -54,20 +54,27 @@ impl From<OutPoint> for BdkOutPoint {
5454 }
5555}
5656
57- #[ derive( Clone , Debug ) ]
57+ /// Represents fee rate.
58+ ///
59+ /// This is an integer type representing fee rate in sat/kwu. It provides protection against mixing
60+ /// up the types as well as basic formatting features.
61+ #[ derive( Clone , Debug , uniffi:: Object ) ]
5862pub struct FeeRate ( pub BdkFeeRate ) ;
5963
64+ #[ uniffi:: export]
6065impl FeeRate {
61- pub fn from_sat_per_vb ( sat_per_vb : u64 ) -> Result < Self , FeeRateError > {
62- let fee_rate: Option < BdkFeeRate > = BdkFeeRate :: from_sat_per_vb ( sat_per_vb) ;
66+ #[ uniffi:: constructor]
67+ pub fn from_sat_per_vb ( sat_vb : u64 ) -> Result < Self , FeeRateError > {
68+ let fee_rate: Option < BdkFeeRate > = BdkFeeRate :: from_sat_per_vb ( sat_vb) ;
6369 match fee_rate {
6470 Some ( fee_rate) => Ok ( FeeRate ( fee_rate) ) ,
6571 None => Err ( FeeRateError :: ArithmeticOverflow ) ,
6672 }
6773 }
6874
69- pub fn from_sat_per_kwu ( sat_per_kwu : u64 ) -> Self {
70- FeeRate ( BdkFeeRate :: from_sat_per_kwu ( sat_per_kwu) )
75+ #[ uniffi:: constructor]
76+ pub fn from_sat_per_kwu ( sat_kwu : u64 ) -> Self {
77+ FeeRate ( BdkFeeRate :: from_sat_per_kwu ( sat_kwu) )
7178 }
7279
7380 pub fn to_sat_per_vb_ceil ( & self ) -> u64 {
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ final class LiveTxBuilderTests: XCTestCase {
6161 let recipient : Address = try Address ( address: " tb1qrnfslnrve9uncz9pzpvf83k3ukz22ljgees989 " , network: . signet)
6262 let psbt : Psbt = try TxBuilder ( )
6363 . addRecipient ( script: recipient. scriptPubkey ( ) , amount: Amount . fromSat ( fromSat: 4200 ) )
64- . feeRate ( feeRate: FeeRate . fromSatPerVb ( satPerVb : 2 ) )
64+ . feeRate ( feeRate: FeeRate . fromSatPerVb ( satVb : 2 ) )
6565 . finish ( wallet: wallet)
6666
6767 print ( psbt. serialize ( ) )
@@ -109,7 +109,7 @@ final class LiveTxBuilderTests: XCTestCase {
109109
110110 let psbt : Psbt = try TxBuilder ( )
111111 . setRecipients ( recipients: allRecipients)
112- . feeRate ( feeRate: FeeRate . fromSatPerVb ( satPerVb : 4 ) )
112+ . feeRate ( feeRate: FeeRate . fromSatPerVb ( satVb : 4 ) )
113113 . finish ( wallet: wallet)
114114
115115 let _ = try ! wallet. sign ( psbt: psbt)
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ final class LiveWalletTests: XCTestCase {
9898 let psbt : Psbt = try
9999 TxBuilder ( )
100100 . addRecipient ( script: recipient. scriptPubkey ( ) , amount: Amount . fromSat ( fromSat: 4200 ) )
101- . feeRate ( feeRate: FeeRate . fromSatPerVb ( satPerVb : 2 ) )
101+ . feeRate ( feeRate: FeeRate . fromSatPerVb ( satVb : 2 ) )
102102 . finish ( wallet: wallet)
103103
104104 print ( psbt. serialize ( ) )
You can’t perform that action at this time.
0 commit comments