@@ -506,18 +506,17 @@ fn main() {
506506 payment_id, payment_hash, amount_msat
507507 ) ;
508508
509- let proto_custom_records: Vec <_> = custom_records
510- . iter( )
511- . map( node_to_proto_custom_tlv)
512- . collect( ) ;
513-
514509 send_payment_event(
515510 & payment_id,
516- move |payment_ref| {
511+ move |payment| {
512+ let custom_records = custom_records
513+ . iter( )
514+ . map( node_to_proto_custom_tlv)
515+ . collect( ) ;
517516 event_envelope:: Event :: PaymentReceived ( events:: PaymentReceived {
518517 payment_id: payment_id. to_string( ) ,
519- payment: Some ( payment_ref . clone ( ) ) ,
520- custom_records: proto_custom_records ,
518+ payment: Some ( payment ) ,
519+ custom_records,
521520 } )
522521 } ,
523522 & event_node,
@@ -529,17 +528,19 @@ fn main() {
529528 }
530529 } ,
531530 Event :: PaymentSuccessful { payment_id, payment_preimage, bolt12_invoice, .. } => {
532- let payment_preimage = payment_preimage. map( |p| p. to_string( ) ) ;
533- let bolt12_invoice = bolt12_invoice. as_ref( ) . and_then( |invoice| {
534- invoice. bolt12_invoice( ) . map( |i| i. encode( ) . to_lower_hex_string( ) )
535- } ) ;
536531 send_payment_event( & payment_id,
537- |payment_ref| event_envelope:: Event :: PaymentSuccessful ( events:: PaymentSuccessful {
538- payment_id: payment_id. to_string( ) ,
539- payment: Some ( payment_ref. clone( ) ) ,
540- payment_preimage,
541- bolt12_invoice,
542- } ) ,
532+ move |payment| {
533+ let payment_preimage = payment_preimage. map( |p| p. to_string( ) ) ;
534+ let bolt12_invoice = bolt12_invoice. as_ref( ) . and_then( |invoice| {
535+ invoice. bolt12_invoice( ) . map( |i| i. encode( ) . to_lower_hex_string( ) )
536+ } ) ;
537+ event_envelope:: Event :: PaymentSuccessful ( events:: PaymentSuccessful {
538+ payment_id: payment_id. to_string( ) ,
539+ payment: Some ( payment) ,
540+ payment_preimage,
541+ bolt12_invoice,
542+ } )
543+ } ,
543544 & event_node,
544545 & event_sender) ;
545546
@@ -550,9 +551,9 @@ fn main() {
550551 Event :: PaymentFailed { payment_id, reason, ..} => {
551552 let proto_reason = reason. as_ref( ) . map( payment_failure_reason_to_proto) ;
552553 send_payment_event( & payment_id,
553- move |payment_ref | event_envelope:: Event :: PaymentFailed ( events:: PaymentFailed {
554+ move |payment | event_envelope:: Event :: PaymentFailed ( events:: PaymentFailed {
554555 payment_id: payment_id. to_string( ) ,
555- payment: Some ( payment_ref . clone ( ) ) ,
556+ payment: Some ( payment ) ,
556557 reason: proto_reason. map( |r| r as i32 ) ,
557558 } ) ,
558559 & event_node,
@@ -562,10 +563,10 @@ fn main() {
562563 Event :: PaymentClaimable { payment_id, custom_records, claim_deadline, claimable_amount_msat, .. } => {
563564 send_payment_event(
564565 & payment_id,
565- |payment_ref | {
566+ |payment | {
566567 event_envelope:: Event :: PaymentClaimable (
567568 build_payment_claimable_proto(
568- payment_ref ,
569+ payment ,
569570 & custom_records,
570571 claim_deadline,
571572 claimable_amount_msat,
@@ -757,7 +758,7 @@ fn main() {
757758}
758759
759760fn send_payment_event (
760- payment_id : & PaymentId , payment_to_event : impl FnOnce ( & Payment ) -> event_envelope:: Event ,
761+ payment_id : & PaymentId , payment_to_event : impl FnOnce ( Payment ) -> event_envelope:: Event ,
761762 event_node : & Node , event_sender : & broadcast:: Sender < EventEnvelope > ,
762763) {
763764 if event_sender. receiver_count ( ) == 0 {
@@ -772,7 +773,7 @@ fn send_payment_event(
772773 Ok ( Some ( payment_details) ) => {
773774 let payment = payment_to_proto ( payment_details) ;
774775
775- let event = payment_to_event ( & payment) ;
776+ let event = payment_to_event ( payment) ;
776777 if let Err ( e) = event_sender. send ( EventEnvelope { event : Some ( event) } ) {
777778 debug ! ( "No event subscribers connected, skipping event: {e}" ) ;
778779 }
@@ -1004,14 +1005,14 @@ fn load_or_generate_api_key(storage_dir: &Path) -> std::io::Result<String> {
10041005}
10051006
10061007fn build_payment_claimable_proto (
1007- payment_ref : & Payment , custom_records : & [ CustomTlvRecord ] , claim_deadline : Option < u32 > ,
1008+ payment : Payment , custom_records : & [ CustomTlvRecord ] , claim_deadline : Option < u32 > ,
10081009 claimable_amount_msat : u64 , payment_id : String ,
10091010) -> events:: PaymentClaimable {
10101011 let proto_custom_records: Vec < _ > =
10111012 custom_records. iter ( ) . map ( node_to_proto_custom_tlv) . collect ( ) ;
10121013 events:: PaymentClaimable {
10131014 payment_id,
1014- payment : Some ( payment_ref . clone ( ) ) ,
1015+ payment : Some ( payment ) ,
10151016 custom_records : proto_custom_records,
10161017 claim_deadline,
10171018 claimable_amount_msat,
@@ -1144,7 +1145,7 @@ mod tests {
11441145 CustomTlvRecord { type_num: 65538 , value: Vec :: new( ) } ,
11451146 ] ;
11461147 let proto = build_payment_claimable_proto (
1147- & payment,
1148+ payment,
11481149 & records,
11491150 Some ( 800_000 ) ,
11501151 42_123 ,
0 commit comments