@@ -6,6 +6,7 @@ use lightning::chain::chaininterface::{
66 BroadcasterInterface , ConfirmationTarget , FeeEstimator , FEERATE_FLOOR_SATS_PER_KW ,
77} ;
88
9+ use lightning:: events:: bump_transaction:: CoinSelectionSource ;
910use lightning:: ln:: msgs:: { DecodeError , UnsignedGossipMessage } ;
1011use lightning:: ln:: script:: ShutdownScript ;
1112use lightning:: sign:: {
@@ -344,6 +345,38 @@ where
344345 }
345346}
346347
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+
347380/// Similar to [`KeysManager`], but overrides the destination and shutdown scripts so they are
348381/// directly spendable by the BDK wallet.
349382pub struct WalletKeysManager < D , L : Deref >
0 commit comments