@@ -1558,29 +1558,28 @@ pub fn do_commitment_signed_dance(node_a: &Node<'_, '_, '_>, node_b: &Node<'_, '
15581558}
15591559
15601560/// Get a payment preimage and hash.
1561+ pub fn get_payment_preimage_hash ( recipient : & Node , min_value_msat : Option < u64 > , min_final_cltv_expiry_delta : Option < u16 > ) -> ( PaymentPreimage , PaymentHash , PaymentSecret ) {
1562+ let mut payment_count = recipient. network_payment_count . borrow_mut ( ) ;
1563+ let payment_preimage = PaymentPreimage ( [ * payment_count; 32 ] ) ;
1564+ * payment_count += 1 ;
1565+ let payment_hash = PaymentHash ( Sha256 :: hash ( & payment_preimage. 0 [ ..] ) . into_inner ( ) ) ;
1566+ let payment_secret = recipient. node . create_inbound_payment_for_hash ( payment_hash, min_value_msat, 7200 , min_final_cltv_expiry_delta) . unwrap ( ) ;
1567+ ( payment_preimage, payment_hash, payment_secret)
1568+ }
1569+
1570+ /// Get a payment preimage and hash.
1571+ ///
1572+ /// Don't use this, use the identically-named function instead.
15611573#[ macro_export]
15621574macro_rules! get_payment_preimage_hash {
15631575 ( $dest_node: expr) => {
1564- {
1565- get_payment_preimage_hash!( $dest_node, None )
1566- }
1576+ get_payment_preimage_hash!( $dest_node, None )
15671577 } ;
15681578 ( $dest_node: expr, $min_value_msat: expr) => {
1569- {
1570- crate :: get_payment_preimage_hash!( $dest_node, $min_value_msat, None )
1571- }
1579+ crate :: get_payment_preimage_hash!( $dest_node, $min_value_msat, None )
15721580 } ;
15731581 ( $dest_node: expr, $min_value_msat: expr, $min_final_cltv_expiry_delta: expr) => {
1574- {
1575- use bitcoin:: hashes:: Hash as _;
1576- let mut payment_count = $dest_node. network_payment_count. borrow_mut( ) ;
1577- let payment_preimage = $crate:: ln:: PaymentPreimage ( [ * payment_count; 32 ] ) ;
1578- * payment_count += 1 ;
1579- let payment_hash = $crate:: ln:: PaymentHash (
1580- bitcoin:: hashes:: sha256:: Hash :: hash( & payment_preimage. 0 [ ..] ) . into_inner( ) ) ;
1581- let payment_secret = $dest_node. node. create_inbound_payment_for_hash( payment_hash, $min_value_msat, 7200 , $min_final_cltv_expiry_delta) . unwrap( ) ;
1582- ( payment_preimage, payment_hash, payment_secret)
1583- }
1582+ $crate:: ln:: functional_test_utils:: get_payment_preimage_hash( & $dest_node, $min_value_msat, $min_final_cltv_expiry_delta)
15841583 } ;
15851584}
15861585
@@ -1608,7 +1607,8 @@ macro_rules! get_route_and_payment_hash {
16081607 $crate:: get_route_and_payment_hash!( $send_node, $recv_node, payment_params, $recv_value, TEST_FINAL_CLTV )
16091608 } } ;
16101609 ( $send_node: expr, $recv_node: expr, $payment_params: expr, $recv_value: expr, $cltv: expr) => { {
1611- let ( payment_preimage, payment_hash, payment_secret) = $crate:: get_payment_preimage_hash!( $recv_node, Some ( $recv_value) ) ;
1610+ let ( payment_preimage, payment_hash, payment_secret) =
1611+ $crate:: ln:: functional_test_utils:: get_payment_preimage_hash( & $recv_node, Some ( $recv_value) , None ) ;
16121612 let route = $crate:: get_route!( $send_node, $payment_params, $recv_value, $cltv) ;
16131613 ( route. unwrap( ) , payment_hash, payment_preimage, payment_secret)
16141614 } }
0 commit comments