@@ -6,6 +6,7 @@ use lightning::chain::chaininterface::{
6
6
BroadcasterInterface , ConfirmationTarget , FeeEstimator , FEERATE_FLOOR_SATS_PER_KW ,
7
7
} ;
8
8
9
+ use lightning:: events:: bump_transaction:: CoinSelectionSource ;
9
10
use lightning:: ln:: msgs:: { DecodeError , UnsignedGossipMessage } ;
10
11
use lightning:: ln:: script:: ShutdownScript ;
11
12
use lightning:: sign:: {
@@ -344,6 +345,38 @@ where
344
345
}
345
346
}
346
347
348
+ impl < D , L : Deref > CoinSelectionSource for Wallet < D , L >
349
+ where
350
+ D : BatchDatabase ,
351
+ L :: Target : Logger ,
352
+ {
353
+ fn select_confirmed_utxos (
354
+ & self ,
355
+ claim_id : lightning:: chain:: ClaimId ,
356
+ must_spend : & [ lightning:: events:: bump_transaction:: Input ] ,
357
+ must_pay_to : & [ bitcoin:: TxOut ] ,
358
+ target_feerate_sat_per_1000_weight : u32
359
+ ) -> Result < lightning:: events:: bump_transaction:: CoinSelection , ( ) > {
360
+ let locked_wallet = self . inner . lock ( ) . unwrap ( ) ;
361
+ let fee_rate = FeeRate :: from_sat_per_kwu ( target_feerate_sat_per_1000_weight as f32 ) ;
362
+
363
+ let mut tx_builder = locked_wallet. build_tx ( ) . fee_rate ( fee_rate) ;
364
+
365
+ for i in must_spend {
366
+ tx_builder. add_foreign_utxo ( i. outpoint , bitcoin:: util:: psbt:: Input :: default ( ) , i. satisfaction_weight as usize ) ;
367
+ }
368
+
369
+ for o in must_pay_to {
370
+ tx_builder. add_recipient ( o. script_pubkey , o. value ) ;
371
+ }
372
+
373
+ }
374
+
375
+ fn sign_tx ( & self , tx : & mut bitcoin:: Transaction ) -> Result < ( ) , ( ) > {
376
+ Ok ( ( ) )
377
+ }
378
+ }
379
+
347
380
/// Similar to [`KeysManager`], but overrides the destination and shutdown scripts so they are
348
381
/// directly spendable by the BDK wallet.
349
382
pub struct WalletKeysManager < D , L : Deref >
0 commit comments