1
1
use crate :: disk;
2
2
use crate :: hex_utils;
3
3
use crate :: {
4
- ChannelManager , FilesystemLogger , HTLCStatus , MillisatAmount , PaymentInfo ,
5
- PaymentInfoStorage , PeerManager ,
4
+ ChannelManager , FilesystemLogger , HTLCStatus , MillisatAmount , PaymentInfo , PaymentInfoStorage ,
5
+ PeerManager ,
6
6
} ;
7
7
use bitcoin:: hashes:: sha256:: Hash as Sha256Hash ;
8
8
use bitcoin:: hashes:: Hash ;
@@ -101,8 +101,9 @@ pub(crate) fn parse_startup_args() -> Result<LdkUserInfo, ()> {
101
101
pub ( crate ) async fn poll_for_user_input (
102
102
peer_manager : Arc < PeerManager > , channel_manager : Arc < ChannelManager > ,
103
103
router : Arc < NetGraphMsgHandler < Arc < dyn chain:: Access > , Arc < FilesystemLogger > > > ,
104
- payment_storage : PaymentInfoStorage , node_privkey : SecretKey , event_notifier : mpsc:: Sender < ( ) > ,
105
- ldk_data_dir : String , logger : Arc < FilesystemLogger > , network : Network ,
104
+ inbound_payments : PaymentInfoStorage , outbound_payments : PaymentInfoStorage ,
105
+ node_privkey : SecretKey , event_notifier : mpsc:: Sender < ( ) > , ldk_data_dir : String ,
106
+ logger : Arc < FilesystemLogger > , network : Network ,
106
107
) {
107
108
println ! ( "LDK startup successful. To view available commands: \" help\" .\n LDK logs are available at <your-supplied-ldk-data-dir-path>/.ldk/logs" ) ;
108
109
let stdin = io:: stdin ( ) ;
@@ -278,7 +279,7 @@ pub(crate) async fn poll_for_user_input(
278
279
route_hints,
279
280
router. clone ( ) ,
280
281
channel_manager. clone ( ) ,
281
- payment_storage . clone ( ) ,
282
+ outbound_payments . clone ( ) ,
282
283
logger. clone ( ) ,
283
284
) ;
284
285
}
@@ -300,7 +301,7 @@ pub(crate) async fn poll_for_user_input(
300
301
}
301
302
get_invoice (
302
303
amt_msat. unwrap ( ) ,
303
- payment_storage . clone ( ) ,
304
+ inbound_payments . clone ( ) ,
304
305
node_privkey. clone ( ) ,
305
306
channel_manager. clone ( ) ,
306
307
network,
@@ -336,7 +337,9 @@ pub(crate) async fn poll_for_user_input(
336
337
}
337
338
}
338
339
"listchannels" => list_channels ( channel_manager. clone ( ) ) ,
339
- "listpayments" => list_payments ( payment_storage. clone ( ) ) ,
340
+ "listpayments" => {
341
+ list_payments ( inbound_payments. clone ( ) , outbound_payments. clone ( ) )
342
+ }
340
343
"closechannel" => {
341
344
let channel_id_str = words. next ( ) ;
342
345
if channel_id_str. is_none ( ) {
@@ -419,15 +422,34 @@ fn list_channels(channel_manager: Arc<ChannelManager>) {
419
422
println ! ( "]" ) ;
420
423
}
421
424
422
- fn list_payments ( payment_storage : PaymentInfoStorage ) {
423
- let payments = payment_storage. lock ( ) . unwrap ( ) ;
425
+ fn list_payments ( inbound_payments : PaymentInfoStorage , outbound_payments : PaymentInfoStorage ) {
426
+ let inbound = inbound_payments. lock ( ) . unwrap ( ) ;
427
+ let outbound = outbound_payments. lock ( ) . unwrap ( ) ;
424
428
print ! ( "[" ) ;
425
- for ( payment_hash, payment_info) in payments. deref ( ) {
429
+ for ( payment_hash, payment_info) in inbound. deref ( ) {
430
+ println ! ( "" ) ;
431
+ println ! ( "\t {{" ) ;
432
+ println ! ( "\t \t amount_millisatoshis: {}," , payment_info. amt_msat) ;
433
+ println ! ( "\t \t payment_hash: {}," , hex_utils:: hex_str( & payment_hash. 0 ) ) ;
434
+ println ! ( "\t \t htlc_direction: inbound," ) ;
435
+ println ! (
436
+ "\t \t htlc_status: {}," ,
437
+ match payment_info. status {
438
+ HTLCStatus :: Pending => "pending" ,
439
+ HTLCStatus :: Succeeded => "succeeded" ,
440
+ HTLCStatus :: Failed => "failed" ,
441
+ }
442
+ ) ;
443
+
444
+ println ! ( "\t }}," ) ;
445
+ }
446
+
447
+ for ( payment_hash, payment_info) in outbound. deref ( ) {
426
448
println ! ( "" ) ;
427
449
println ! ( "\t {{" ) ;
428
450
println ! ( "\t \t amount_millisatoshis: {}," , payment_info. amt_msat) ;
429
451
println ! ( "\t \t payment_hash: {}," , hex_utils:: hex_str( & payment_hash. 0 ) ) ;
430
- // println!("\t\thtlc_direction: {},", direction_str );
452
+ println ! ( "\t \t htlc_direction: outbound," ) ;
431
453
println ! (
432
454
"\t \t htlc_status: {}," ,
433
455
match payment_info. status {
0 commit comments