@@ -18,6 +18,9 @@ use bitcoin::{BlockHash, Script, Transaction, Txid};
18
18
19
19
use std:: sync:: { Arc , Mutex } ;
20
20
21
+ /// The minimum feerate we are allowed to send, as specify by LDK.
22
+ const MIN_FEERATE : u32 = 253 ;
23
+
21
24
pub struct LdkLiteChainAccess < D >
22
25
where
23
26
D : BatchDatabase ,
@@ -261,8 +264,10 @@ where
261
264
{
262
265
fn get_est_sat_per_1000_weight ( & self , confirmation_target : ConfirmationTarget ) -> u32 {
263
266
let num_blocks = num_blocks_from_conf_target ( confirmation_target) ;
264
- self . blockchain . estimate_fee ( num_blocks) . map_or ( 253 , |fee_rate| fee_rate. fee_wu ( 1000 ) )
265
- as u32
267
+ let fallback_fee = fallback_fee_from_conf_target ( confirmation_target) ;
268
+ self . blockchain
269
+ . estimate_fee ( num_blocks)
270
+ . map_or ( fallback_fee, |fee_rate| ( fee_rate. fee_wu ( 1000 ) as u32 ) . max ( MIN_FEERATE ) ) as u32
266
271
}
267
272
}
268
273
@@ -271,7 +276,10 @@ where
271
276
D : BatchDatabase ,
272
277
{
273
278
fn broadcast_transaction ( & self , tx : & Transaction ) {
274
- self . blockchain . broadcast ( tx) . ok ( ) ;
279
+ match self . blockchain . broadcast ( tx) {
280
+ Ok ( _) => { }
281
+ Err ( err) => log_error ! ( self . logger, "Failed to broadcast transaction: {}" , err) ,
282
+ }
275
283
}
276
284
}
277
285
@@ -318,8 +326,16 @@ where
318
326
319
327
fn num_blocks_from_conf_target ( confirmation_target : ConfirmationTarget ) -> usize {
320
328
match confirmation_target {
321
- ConfirmationTarget :: Background => 6 ,
322
- ConfirmationTarget :: Normal => 3 ,
323
- ConfirmationTarget :: HighPriority => 1 ,
329
+ ConfirmationTarget :: Background => 12 ,
330
+ ConfirmationTarget :: Normal => 6 ,
331
+ ConfirmationTarget :: HighPriority => 3 ,
332
+ }
333
+ }
334
+
335
+ fn fallback_fee_from_conf_target ( confirmation_target : ConfirmationTarget ) -> u32 {
336
+ match confirmation_target {
337
+ ConfirmationTarget :: Background => MIN_FEERATE ,
338
+ ConfirmationTarget :: Normal => 2000 ,
339
+ ConfirmationTarget :: HighPriority => 5000 ,
324
340
}
325
341
}
0 commit comments