@@ -27,6 +27,7 @@ use lightning_invoice::RawBolt11Invoice;
27
27
use bdk:: blockchain:: EsploraBlockchain ;
28
28
use bdk:: wallet:: AddressIndex ;
29
29
use bdk:: { Balance , SignOptions , SyncOptions } ;
30
+ use bdk_chain:: ChainPosition ;
30
31
use bdk_wallet:: Wallet as BdkWallet ;
31
32
32
33
use bitcoin:: blockdata:: constants:: WITNESS_SCALE_FACTOR ;
@@ -373,25 +374,13 @@ where
373
374
fn list_confirmed_utxos ( & self ) -> Result < Vec < Utxo > , ( ) > {
374
375
let locked_wallet = self . inner . lock ( ) . unwrap ( ) ;
375
376
let mut utxos = Vec :: new ( ) ;
376
- let confirmed_txs: Vec < bdk:: TransactionDetails > = locked_wallet
377
- . list_transactions ( false )
378
- . map_err ( |e| {
379
- log_error ! ( self . logger, "Failed to retrieve transactions from wallet: {}" , e) ;
380
- } ) ?
381
- . into_iter ( )
382
- . filter ( |t| t. confirmation_time . is_some ( ) )
377
+ let confirmed_txs: Vec < Txid > = locked_wallet
378
+ . transactions ( )
379
+ . filter ( |t| matches ! ( t. chain_position, ChainPosition :: Confirmed ( _) ) )
380
+ . map ( |t| t. tx_node . txid )
383
381
. collect ( ) ;
384
- let unspent_confirmed_utxos = locked_wallet
385
- . list_unspent ( )
386
- . map_err ( |e| {
387
- log_error ! (
388
- self . logger,
389
- "Failed to retrieve unspent transactions from wallet: {}" ,
390
- e
391
- ) ;
392
- } ) ?
393
- . into_iter ( )
394
- . filter ( |u| confirmed_txs. iter ( ) . find ( |t| t. txid == u. outpoint . txid ) . is_some ( ) ) ;
382
+ let unspent_confirmed_utxos =
383
+ locked_wallet. list_unspent ( ) . filter ( |u| confirmed_txs. contains ( & u. outpoint . txid ) ) ;
395
384
396
385
for u in unspent_confirmed_utxos {
397
386
let script_pubkey = u. txout . script_pubkey ;
0 commit comments