@@ -240,6 +240,7 @@ impl Wallet {
240240 for event in events {
241241 match event {
242242 WalletEvent :: TxConfirmed { txid, tx, block_time, .. } => {
243+ eprintln ! ( "TX_CONFIRMED: {}" , txid) ;
243244 let cur_height = locked_wallet. latest_checkpoint ( ) . height ( ) ;
244245 let confirmation_height = block_time. block_id . height ;
245246 let payment_status = if cur_height >= confirmation_height + ANTI_REORG_DELAY - 1
@@ -275,6 +276,7 @@ impl Wallet {
275276 self . pending_payment_store . insert_or_update ( pending_payment) ?;
276277 } ,
277278 WalletEvent :: ChainTipChanged { new_tip, .. } => {
279+ eprint ! ( "." ) ;
278280 // Get all payments that are Pending with Confirmed status
279281 let pending_payments: Vec < PendingPaymentDetails > =
280282 self . pending_payment_store . list_filter ( |p| {
@@ -304,6 +306,7 @@ impl Wallet {
304306 }
305307 } ,
306308 WalletEvent :: TxUnconfirmed { txid, tx, old_block_time : None } => {
309+ eprintln ! ( "TX_UNCONFIRMED: {}" , txid) ;
307310 let payment_id = self
308311 . find_payment_by_txid ( txid)
309312 . unwrap_or_else ( || PaymentId ( txid. to_byte_array ( ) ) ) ;
@@ -322,6 +325,7 @@ impl Wallet {
322325 self . pending_payment_store . insert_or_update ( pending_payment) ?;
323326 } ,
324327 WalletEvent :: TxReplaced { txid, conflicts, tx, .. } => {
328+ eprintln ! ( "TX_REPLACED: {}" , txid) ;
325329 let payment_id = self
326330 . find_payment_by_txid ( txid)
327331 . unwrap_or_else ( || PaymentId ( txid. to_byte_array ( ) ) ) ;
@@ -344,6 +348,7 @@ impl Wallet {
344348 self . pending_payment_store . insert_or_update ( pending_payment_details) ?;
345349 } ,
346350 WalletEvent :: TxDropped { txid, tx } => {
351+ eprintln ! ( "TX_DROPPED: {}" , txid) ;
347352 let payment_id = self
348353 . find_payment_by_txid ( txid)
349354 . unwrap_or_else ( || PaymentId ( txid. to_byte_array ( ) ) ) ;
@@ -404,17 +409,27 @@ impl Wallet {
404409 } ,
405410 }
406411
412+ let tx = psbt. extract_tx ( ) . map_err ( |e| {
413+ log_error ! ( self . logger, "Failed to extract transaction: {}" , e) ;
414+ e
415+ } ) ?;
416+
417+ eprintln ! ( "FUNDING: {}" , tx. txid( ) ) ;
418+ log_error ! ( self . logger, "FUNDING: {}" , tx. txid( ) ) ;
419+
420+ let now = std:: time:: SystemTime :: now ( )
421+ . duration_since ( std:: time:: SystemTime :: UNIX_EPOCH )
422+ . unwrap ( )
423+ . as_secs ( ) ;
424+ let unconfirmed_txs = vec ! [ ( Arc :: new( tx. clone( ) ) , now) ] ;
425+ locked_wallet. apply_unconfirmed_txs ( unconfirmed_txs) ;
426+
407427 let mut locked_persister = self . persister . lock ( ) . unwrap ( ) ;
408428 locked_wallet. persist ( & mut locked_persister) . map_err ( |e| {
409429 log_error ! ( self . logger, "Failed to persist wallet: {}" , e) ;
410430 Error :: PersistenceFailed
411431 } ) ?;
412432
413- let tx = psbt. extract_tx ( ) . map_err ( |e| {
414- log_error ! ( self . logger, "Failed to extract transaction: {}" , e) ;
415- e
416- } ) ?;
417-
418433 Ok ( tx)
419434 }
420435
@@ -956,7 +971,14 @@ impl Wallet {
956971
957972 let kind = PaymentKind :: Onchain { txid, status : confirmation_status } ;
958973
959- let fee = locked_wallet. calculate_fee ( tx) . unwrap_or ( Amount :: ZERO ) ;
974+ let fee = locked_wallet. calculate_fee ( tx) ;
975+ for out in & tx. input {
976+ eprintln ! ( "PREV_OUT: {:?}" , out. previous_output) ;
977+ log_error ! ( self . logger, "PREV_OUT: {:?}" , out. previous_output) ;
978+ }
979+ eprintln ! ( "FEE RES: {:?}" , fee) ;
980+ log_error ! ( self . logger, "FEE RES: {:?}" , fee) ;
981+ let fee = fee. unwrap_or ( Amount :: ZERO ) ;
960982 let ( sent, received) = locked_wallet. sent_and_received ( tx) ;
961983 let fee_sat = fee. to_sat ( ) ;
962984
0 commit comments