@@ -1558,29 +1558,28 @@ pub fn do_commitment_signed_dance(node_a: &Node<'_, '_, '_>, node_b: &Node<'_, '
1558
1558
}
1559
1559
1560
1560
/// 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.
1561
1573
#[ macro_export]
1562
1574
macro_rules! get_payment_preimage_hash {
1563
1575
( $dest_node: expr) => {
1564
- {
1565
- get_payment_preimage_hash!( $dest_node, None )
1566
- }
1576
+ get_payment_preimage_hash!( $dest_node, None )
1567
1577
} ;
1568
1578
( $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 )
1572
1580
} ;
1573
1581
( $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)
1584
1583
} ;
1585
1584
}
1586
1585
@@ -1608,7 +1607,8 @@ macro_rules! get_route_and_payment_hash {
1608
1607
$crate:: get_route_and_payment_hash!( $send_node, $recv_node, payment_params, $recv_value, TEST_FINAL_CLTV )
1609
1608
} } ;
1610
1609
( $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 ) ;
1612
1612
let route = $crate:: get_route!( $send_node, $payment_params, $recv_value, $cltv) ;
1613
1613
( route. unwrap( ) , payment_hash, payment_preimage, payment_secret)
1614
1614
} }
0 commit comments