66// accordance with one or both of these licenses.
77
88mod common;
9-
9+ use lightning :: util :: persist :: KVStoreSync ;
1010use std:: collections:: HashSet ;
1111use std:: str:: FromStr ;
1212use std:: sync:: Arc ;
@@ -29,7 +29,7 @@ use ldk_node::config::{AsyncPaymentsRole, EsploraSyncConfig};
2929use ldk_node:: liquidity:: LSPS2ServiceConfig ;
3030use ldk_node:: payment:: {
3131 ConfirmationStatus , PaymentDetails , PaymentDirection , PaymentKind , PaymentStatus ,
32- QrPaymentResult ,
32+ UnifiedPaymentResult ,
3333} ;
3434use ldk_node:: { Builder , DynStore , Event , NodeError } ;
3535use lightning:: ln:: channelmanager:: PaymentId ;
@@ -1392,15 +1392,15 @@ async fn generate_bip21_uri() {
13921392
13931393 // Test 1: Verify URI generation (on-chain + BOLT11) works
13941394 // even before any channels are opened. This checks the graceful fallback behavior.
1395- let initial_uqr_payment = node_b
1396- . unified_qr_payment ( )
1395+ let initial_uni_payment = node_b
1396+ . unified_payment ( )
13971397 . receive ( expected_amount_sats, "asdf" , expiry_sec)
13981398 . expect ( "Failed to generate URI" ) ;
1399- println ! ( "Initial URI (no channels): {}" , initial_uqr_payment ) ;
1399+ println ! ( "Initial URI (no channels): {}" , initial_uni_payment ) ;
14001400
1401- assert ! ( initial_uqr_payment . contains( "bitcoin:" ) ) ;
1402- assert ! ( initial_uqr_payment . contains( "lightning=" ) ) ;
1403- assert ! ( !initial_uqr_payment . contains( "lno=" ) ) ; // BOLT12 requires channels
1401+ assert ! ( initial_uni_payment . contains( "bitcoin:" ) ) ;
1402+ assert ! ( initial_uni_payment . contains( "lightning=" ) ) ;
1403+ assert ! ( !initial_uni_payment . contains( "lno=" ) ) ; // BOLT12 requires channels
14041404
14051405 premine_and_distribute_funds (
14061406 & bitcoind. client ,
@@ -1421,15 +1421,15 @@ async fn generate_bip21_uri() {
14211421 expect_channel_ready_event ! ( node_b, node_a. node_id( ) ) ;
14221422
14231423 // Test 2: Verify URI generation (on-chain + BOLT11 + BOLT12) works after channels are established.
1424- let uqr_payment = node_b
1425- . unified_qr_payment ( )
1424+ let uni_payment = node_b
1425+ . unified_payment ( )
14261426 . receive ( expected_amount_sats, "asdf" , expiry_sec)
14271427 . expect ( "Failed to generate URI" ) ;
14281428
1429- println ! ( "Generated URI: {}" , uqr_payment ) ;
1430- assert ! ( uqr_payment . contains( "bitcoin:" ) ) ;
1431- assert ! ( uqr_payment . contains( "lightning=" ) ) ;
1432- assert ! ( uqr_payment . contains( "lno=" ) ) ;
1429+ println ! ( "Generated URI: {}" , uni_payment ) ;
1430+ assert ! ( uni_payment . contains( "bitcoin:" ) ) ;
1431+ assert ! ( uni_payment . contains( "lightning=" ) ) ;
1432+ assert ! ( uni_payment . contains( "lno=" ) ) ;
14331433}
14341434
14351435#[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
@@ -1471,17 +1471,17 @@ async fn unified_qr_send_receive() {
14711471 let expected_amount_sats = 100_000 ;
14721472 let expiry_sec = 4_000 ;
14731473
1474- let uqr_payment = node_b. unified_qr_payment ( ) . receive ( expected_amount_sats, "asdf" , expiry_sec) ;
1475- let uri_str = uqr_payment . clone ( ) . unwrap ( ) ;
1476- let offer_payment_id: PaymentId = match node_a. unified_qr_payment ( ) . send ( & uri_str) {
1477- Ok ( QrPaymentResult :: Bolt12 { payment_id } ) => {
1474+ let uni_payment = node_b. unified_payment ( ) . receive ( expected_amount_sats, "asdf" , expiry_sec) ;
1475+ let uri_str = uni_payment . clone ( ) . unwrap ( ) ;
1476+ let offer_payment_id: PaymentId = match node_a. unified_payment ( ) . send ( & uri_str) {
1477+ Ok ( UnifiedPaymentResult :: Bolt12 { payment_id } ) => {
14781478 println ! ( "\n Bolt12 payment sent successfully with PaymentID: {:?}" , payment_id) ;
14791479 payment_id
14801480 } ,
1481- Ok ( QrPaymentResult :: Bolt11 { payment_id : _ } ) => {
1481+ Ok ( UnifiedPaymentResult :: Bolt11 { payment_id : _ } ) => {
14821482 panic ! ( "Expected Bolt12 payment but got Bolt11" ) ;
14831483 } ,
1484- Ok ( QrPaymentResult :: Onchain { txid : _ } ) => {
1484+ Ok ( UnifiedPaymentResult :: Onchain { txid : _ } ) => {
14851485 panic ! ( "Expected Bolt12 payment but get On-chain transaction" ) ;
14861486 } ,
14871487 Err ( e) => {
@@ -1493,38 +1493,37 @@ async fn unified_qr_send_receive() {
14931493
14941494 // Cut off the BOLT12 part to fallback to BOLT11.
14951495 let uri_str_without_offer = uri_str. split ( "&lno=" ) . next ( ) . unwrap ( ) ;
1496- let invoice_payment_id: PaymentId =
1497- match node_a. unified_qr_payment ( ) . send ( uri_str_without_offer) {
1498- Ok ( QrPaymentResult :: Bolt12 { payment_id : _ } ) => {
1499- panic ! ( "Expected Bolt11 payment but got Bolt12" ) ;
1500- } ,
1501- Ok ( QrPaymentResult :: Bolt11 { payment_id } ) => {
1502- println ! ( "\n Bolt11 payment sent successfully with PaymentID: {:?}" , payment_id) ;
1503- payment_id
1504- } ,
1505- Ok ( QrPaymentResult :: Onchain { txid : _ } ) => {
1506- panic ! ( "Expected Bolt11 payment but got on-chain transaction" ) ;
1507- } ,
1508- Err ( e) => {
1509- panic ! ( "Expected Bolt11 payment but got error: {:?}" , e) ;
1510- } ,
1511- } ;
1496+ let invoice_payment_id: PaymentId = match node_a. unified_payment ( ) . send ( uri_str_without_offer) {
1497+ Ok ( UnifiedPaymentResult :: Bolt12 { payment_id : _ } ) => {
1498+ panic ! ( "Expected Bolt11 payment but got Bolt12" ) ;
1499+ } ,
1500+ Ok ( UnifiedPaymentResult :: Bolt11 { payment_id } ) => {
1501+ println ! ( "\n Bolt11 payment sent successfully with PaymentID: {:?}" , payment_id) ;
1502+ payment_id
1503+ } ,
1504+ Ok ( UnifiedPaymentResult :: Onchain { txid : _ } ) => {
1505+ panic ! ( "Expected Bolt11 payment but got on-chain transaction" ) ;
1506+ } ,
1507+ Err ( e) => {
1508+ panic ! ( "Expected Bolt11 payment but got error: {:?}" , e) ;
1509+ } ,
1510+ } ;
15121511 expect_payment_successful_event ! ( node_a, Some ( invoice_payment_id) , None ) ;
15131512
15141513 let expect_onchain_amount_sats = 800_000 ;
1515- let onchain_uqr_payment =
1516- node_b. unified_qr_payment ( ) . receive ( expect_onchain_amount_sats, "asdf" , 4_000 ) . unwrap ( ) ;
1514+ let onchain_uni_payment =
1515+ node_b. unified_payment ( ) . receive ( expect_onchain_amount_sats, "asdf" , 4_000 ) . unwrap ( ) ;
15171516
15181517 // Cut off any lightning part to fallback to on-chain only.
1519- let uri_str_without_lightning = onchain_uqr_payment . split ( "&lightning=" ) . next ( ) . unwrap ( ) ;
1520- let txid = match node_a. unified_qr_payment ( ) . send ( & uri_str_without_lightning) {
1521- Ok ( QrPaymentResult :: Bolt12 { payment_id : _ } ) => {
1518+ let uri_str_without_lightning = onchain_uni_payment . split ( "&lightning=" ) . next ( ) . unwrap ( ) ;
1519+ let txid = match node_a. unified_payment ( ) . send ( & uri_str_without_lightning) {
1520+ Ok ( UnifiedPaymentResult :: Bolt12 { payment_id : _ } ) => {
15221521 panic ! ( "Expected on-chain payment but got Bolt12" )
15231522 } ,
1524- Ok ( QrPaymentResult :: Bolt11 { payment_id : _ } ) => {
1523+ Ok ( UnifiedPaymentResult :: Bolt11 { payment_id : _ } ) => {
15251524 panic ! ( "Expected on-chain payment but got Bolt11" ) ;
15261525 } ,
1527- Ok ( QrPaymentResult :: Onchain { txid } ) => {
1526+ Ok ( UnifiedPaymentResult :: Onchain { txid } ) => {
15281527 println ! ( "\n On-chain transaction successful with Txid: {}" , txid) ;
15291528 txid
15301529 } ,
0 commit comments