@@ -111,6 +111,19 @@ pub fn run_persistent_key_mining(context: MiningContext, skey_hex: &String) -> R
111111
112112 match result {
113113 MiningResult :: FoundAndQueued => {
114+ if let Some ( ref destination_address) = context. donate_to_option {
115+ let donation_message = format ! ( "Assign accumulated Scavenger rights to: {}" , destination_address) ;
116+ let donation_signature = cardano:: cip8_sign ( & key_pair, & donation_message) ;
117+
118+ // Intentionally perform donation attempt synchronously here.
119+ match api:: donate_to (
120+ & context. client , & context. api_url , & mining_address, destination_address, & donation_signature. 0 ,
121+ ) {
122+ Ok ( id) => println ! ( "🚀 Donation initiated successfully. ID: {}" , id) ,
123+ Err ( e) => eprintln ! ( "⚠️ Donation failed (synchronous attempt): {}" , e) ,
124+ }
125+ }
126+
114127 println ! ( "\n ✅ Solution queued. Continuing mining immediately." ) ;
115128 // Continue the loop on the same address.
116129 } ,
@@ -286,6 +299,20 @@ pub fn run_mnemonic_sequential_mining(cli: &Cli, context: MiningContext, mnemoni
286299 // --- 4. Post-Mining Index Advancement ---
287300 match result {
288301 MiningResult :: FoundAndQueued => {
302+ if let Some ( ref destination_address) = context. donate_to_option {
303+ // key_pair is available locally in this loop scope
304+ let donation_message = format ! ( "Assign accumulated Scavenger rights to: {}" , destination_address) ;
305+ let donation_signature = cardano:: cip8_sign ( & key_pair, & donation_message) ;
306+
307+ // Attempt donation synchronously. Ignore result here to keep the main flow clean.
308+ match api:: donate_to (
309+ & context. client , & context. api_url , & mining_address, destination_address, & donation_signature. 0 ,
310+ ) {
311+ Ok ( id) => println ! ( "🚀 Donation initiated successfully. ID: {}" , id) ,
312+ Err ( e) => eprintln ! ( "⚠️ Donation failed (synchronous attempt): {}" , e) ,
313+ }
314+ }
315+
289316 wallet_deriv_index = wallet_deriv_index. wrapping_add ( 1 ) ;
290317 println ! ( "\n ✅ Solution queued. Incrementing index to {}." , wallet_deriv_index) ;
291318 } ,
@@ -362,6 +389,19 @@ pub fn run_ephemeral_key_mining(context: MiningContext) -> Result<(), String> {
362389
363390 match result {
364391 MiningResult :: FoundAndQueued => {
392+ if let Some ( ref destination_address) = context. donate_to_option {
393+ // key_pair is available locally in this loop scope
394+ let donation_message = format ! ( "Assign accumulated Scavenger rights to: {}" , destination_address) ;
395+ let donation_signature = cardano:: cip8_sign ( & key_pair, & donation_message) ;
396+
397+ // Attempt donation synchronously. Ignore result here to keep the main thread fast.
398+ match api:: donate_to (
399+ & context. client , & context. api_url , & generated_mining_address, destination_address, & donation_signature. 0 ,
400+ ) {
401+ Ok ( id) => println ! ( "🚀 Donation initiated successfully. ID: {}" , id) ,
402+ Err ( e) => eprintln ! ( "⚠️ Donation failed (synchronous attempt): {}" , e) ,
403+ }
404+ }
365405 eprintln ! ( "Solution queued. Starting next cycle immediately..." ) ;
366406 }
367407 MiningResult :: AlreadySolved => { eprintln ! ( "Solution was already accepted by the network. Starting next cycle immediately..." ) ; }
0 commit comments