@@ -424,24 +424,29 @@ impl DbState {
424424 // check if tx has an immature coinbase output (add to updated UTXOs)
425425 // this is required because `listunspent` does not include immature coinbase outputs
426426 if tx_res. detail . category == GetTransactionResultDetailCategory :: Immature {
427- // let vout = tx_res.detail.vout;
428- // let txout = raw_tx.output.get(vout as usize).cloned().ok_or_else(|| {
429- // Error::Generic(format!(
430- // "Core RPC returned detail with invalid vout '{}' for tx '{}'",
431- // vout, tx_res.info.txid,
432- // ))
433- // })?;
434- // println!("got immature detail!");
435-
436- // if let Some((keychain, _)) = db.get_path_from_script_pubkey(&txout.script_pubkey)? {
437- // let utxo = LocalUtxo {
438- // outpoint: OutPoint::new(tx_res.info.txid, d.vout),
439- // txout,
440- // keychain,
441- // is_spent: false,
442- // };
443- // self.updated_utxos.insert(utxo);
444- // }
427+ let txout = raw_tx
428+ . output
429+ . get ( tx_res. detail . vout as usize )
430+ . cloned ( )
431+ . ok_or_else ( || {
432+ Error :: Generic ( format ! (
433+ "Core RPC returned detail with invalid vout '{}' for tx '{}'" ,
434+ tx_res. detail. vout, tx_res. info. txid,
435+ ) )
436+ } ) ?;
437+
438+ if let Some ( ( keychain, index) ) =
439+ db. get_path_from_script_pubkey ( & txout. script_pubkey ) ?
440+ {
441+ let utxo = LocalUtxo {
442+ outpoint : OutPoint :: new ( tx_res. info . txid , tx_res. detail . vout ) ,
443+ txout,
444+ keychain,
445+ is_spent : false ,
446+ } ;
447+ self . updated_utxos . insert ( utxo) ;
448+ self . _update_last_index ( keychain, index) ;
449+ }
445450 }
446451
447452 // update tx deltas
@@ -511,7 +516,7 @@ impl DbState {
511516 let new_utxos = core_utxos. difference ( & self . utxos ) . cloned ( ) ;
512517
513518 // add to updated utxos
514- self . updated_utxos = spent_utxos. chain ( new_utxos) . collect ( ) ;
519+ self . updated_utxos . extend ( spent_utxos. chain ( new_utxos) ) ;
515520
516521 Ok ( self )
517522 }
@@ -604,6 +609,7 @@ impl DbState {
604609 // update utxos
605610 self . updated_utxos
606611 . iter ( )
612+ . inspect ( |& utxo| println ! ( "updating: {:?}" , utxo. txout) )
607613 . try_for_each ( |utxo| batch. set_utxo ( utxo) ) ?;
608614
609615 // update last indexes
0 commit comments