Drop unused change output calculation
[ldk-sample] / src / main.rs
index 57f0bb2ea7f9017c42feb5b6ef7b9b8818bbda7d..9e82f8aa76f079235c8ca4ac87700bab4f77798f 100644 (file)
@@ -129,8 +129,6 @@ async fn handle_ldk_events(
                        // Have your wallet put the inputs into the transaction such that the output is
                        // satisfied.
                        let funded_tx = bitcoind_client.fund_raw_transaction(raw_tx).await;
-                       let change_output_position = funded_tx.changepos;
-                       assert!(change_output_position == 0 || change_output_position == 1);
 
                        // Sign the final funding transaction and broadcast it.
                        let signed_tx = bitcoind_client.sign_raw_transaction_with_wallet(funded_tx.hex).await;
@@ -224,6 +222,23 @@ async fn handle_ldk_events(
                                payment.status = HTLCStatus::Failed;
                        }
                }
+               Event::PaymentForwarded { fee_earned_msat, claim_from_onchain_tx } => {
+                       let from_onchain_str = if claim_from_onchain_tx {
+                               "from onchain downstream claim"
+                       } else {
+                               "from HTLC fulfill message"
+                       };
+                       if let Some(fee_earned) = fee_earned_msat {
+                               println!(
+                                       "\nEVENT: Forwarded payment, earning {} msat {}",
+                                       fee_earned, from_onchain_str
+                               );
+                       } else {
+                               println!("\nEVENT: Forwarded payment, claiming onchain {}", from_onchain_str);
+                       }
+                       print!("> ");
+                       io::stdout().flush().unwrap();
+               }
                Event::PendingHTLCsForwardable { time_forwardable } => {
                        let forwarding_channel_manager = channel_manager.clone();
                        tokio::spawn(async move {