1
1
use crate :: disk:: { self , INBOUND_PAYMENTS_FNAME , OUTBOUND_PAYMENTS_FNAME } ;
2
2
use crate :: hex_utils;
3
3
use crate :: {
4
- ChannelManager , HTLCStatus , MillisatAmount , NetworkGraph , OnionMessenger , PaymentInfo ,
5
- PaymentInfoStorage , PeerManager ,
4
+ ChannelManager , HTLCStatus , InboundPaymentInfoStorage , MillisatAmount , NetworkGraph ,
5
+ OnionMessenger , OutboundPaymentInfoStorage , PaymentInfo , PeerManager ,
6
6
} ;
7
7
use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
8
8
use bitcoin:: hashes:: Hash ;
@@ -12,7 +12,7 @@ use lightning::ln::channelmanager::{PaymentId, RecipientOnionFields, Retry};
12
12
use lightning:: ln:: msgs:: SocketAddress ;
13
13
use lightning:: ln:: { ChannelId , PaymentHash , PaymentPreimage } ;
14
14
use lightning:: onion_message:: OnionMessagePath ;
15
- use lightning:: onion_message:: { CustomOnionMessageContents , Destination , OnionMessageContents } ;
15
+ use lightning:: onion_message:: { Destination , OnionMessageContents } ;
16
16
use lightning:: routing:: gossip:: NodeId ;
17
17
use lightning:: routing:: router:: { PaymentParameters , RouteParameters } ;
18
18
use lightning:: sign:: { EntropySource , KeysManager } ;
@@ -48,7 +48,7 @@ struct UserOnionMessageContents {
48
48
data : Vec < u8 > ,
49
49
}
50
50
51
- impl CustomOnionMessageContents for UserOnionMessageContents {
51
+ impl OnionMessageContents for UserOnionMessageContents {
52
52
fn tlv_type ( & self ) -> u64 {
53
53
self . tlv_type
54
54
}
@@ -63,9 +63,9 @@ impl Writeable for UserOnionMessageContents {
63
63
pub ( crate ) fn poll_for_user_input (
64
64
peer_manager : Arc < PeerManager > , channel_manager : Arc < ChannelManager > ,
65
65
keys_manager : Arc < KeysManager > , network_graph : Arc < NetworkGraph > ,
66
- onion_messenger : Arc < OnionMessenger > , inbound_payments : Arc < Mutex < PaymentInfoStorage > > ,
67
- outbound_payments : Arc < Mutex < PaymentInfoStorage > > , ldk_data_dir : String , network : Network ,
68
- logger : Arc < disk:: FilesystemLogger > , fs_store : Arc < FilesystemStore > ,
66
+ onion_messenger : Arc < OnionMessenger > , inbound_payments : Arc < Mutex < InboundPaymentInfoStorage > > ,
67
+ outbound_payments : Arc < Mutex < OutboundPaymentInfoStorage > > , ldk_data_dir : String ,
68
+ network : Network , logger : Arc < disk:: FilesystemLogger > , fs_store : Arc < FilesystemStore > ,
69
69
) {
70
70
println ! (
71
71
"LDK startup successful. Enter \" help\" to view available commands. Press Ctrl-D to quit."
@@ -445,7 +445,7 @@ pub(crate) fn poll_for_user_input(
445
445
let message_path = OnionMessagePath { intermediate_nodes, destination } ;
446
446
match onion_messenger. send_onion_message (
447
447
message_path,
448
- OnionMessageContents :: Custom ( UserOnionMessageContents { tlv_type, data } ) ,
448
+ UserOnionMessageContents { tlv_type, data } ,
449
449
None ,
450
450
) {
451
451
Ok ( ( ) ) => println ! ( "SUCCESS: forwarded onion message to first hop" ) ,
@@ -553,7 +553,9 @@ fn list_channels(channel_manager: &Arc<ChannelManager>, network_graph: &Arc<Netw
553
553
println ! ( "]" ) ;
554
554
}
555
555
556
- fn list_payments ( inbound_payments : & PaymentInfoStorage , outbound_payments : & PaymentInfoStorage ) {
556
+ fn list_payments (
557
+ inbound_payments : & InboundPaymentInfoStorage , outbound_payments : & OutboundPaymentInfoStorage ,
558
+ ) {
557
559
print ! ( "[" ) ;
558
560
for ( payment_hash, payment_info) in & inbound_payments. payments {
559
561
println ! ( "" ) ;
@@ -684,12 +686,12 @@ fn open_channel(
684
686
685
687
fn send_payment (
686
688
channel_manager : & ChannelManager , invoice : & Bolt11Invoice ,
687
- outbound_payments : & mut PaymentInfoStorage , fs_store : Arc < FilesystemStore > ,
689
+ outbound_payments : & mut OutboundPaymentInfoStorage , fs_store : Arc < FilesystemStore > ,
688
690
) {
689
- let payment_hash = PaymentHash ( ( * invoice. payment_hash ( ) ) . into_inner ( ) ) ;
691
+ let payment_id = PaymentId ( ( * invoice. payment_hash ( ) ) . into_inner ( ) ) ;
690
692
let payment_secret = Some ( * invoice. payment_secret ( ) ) ;
691
693
outbound_payments. payments . insert (
692
- payment_hash ,
694
+ payment_id ,
693
695
PaymentInfo {
694
696
preimage : None ,
695
697
secret : payment_secret,
@@ -708,25 +710,25 @@ fn send_payment(
708
710
Err ( e) => {
709
711
println ! ( "ERROR: failed to send payment: {:?}" , e) ;
710
712
print ! ( "> " ) ;
711
- outbound_payments. payments . get_mut ( & payment_hash ) . unwrap ( ) . status = HTLCStatus :: Failed ;
713
+ outbound_payments. payments . get_mut ( & payment_id ) . unwrap ( ) . status = HTLCStatus :: Failed ;
712
714
fs_store. write ( "" , "" , OUTBOUND_PAYMENTS_FNAME , & outbound_payments. encode ( ) ) . unwrap ( ) ;
713
715
}
714
716
} ;
715
717
}
716
718
717
719
fn keysend < E : EntropySource > (
718
720
channel_manager : & ChannelManager , payee_pubkey : PublicKey , amt_msat : u64 , entropy_source : & E ,
719
- outbound_payments : & mut PaymentInfoStorage , fs_store : Arc < FilesystemStore > ,
721
+ outbound_payments : & mut OutboundPaymentInfoStorage , fs_store : Arc < FilesystemStore > ,
720
722
) {
721
723
let payment_preimage = PaymentPreimage ( entropy_source. get_secure_random_bytes ( ) ) ;
722
- let payment_hash = PaymentHash ( Sha256 :: hash ( & payment_preimage. 0 [ ..] ) . into_inner ( ) ) ;
724
+ let payment_id = PaymentId ( Sha256 :: hash ( & payment_preimage. 0 [ ..] ) . into_inner ( ) ) ;
723
725
724
726
let route_params = RouteParameters :: from_payment_params_and_value (
725
727
PaymentParameters :: for_keysend ( payee_pubkey, 40 , false ) ,
726
728
amt_msat,
727
729
) ;
728
730
outbound_payments. payments . insert (
729
- payment_hash ,
731
+ payment_id ,
730
732
PaymentInfo {
731
733
preimage : None ,
732
734
secret : None ,
@@ -738,7 +740,7 @@ fn keysend<E: EntropySource>(
738
740
match channel_manager. send_spontaneous_payment_with_retry (
739
741
Some ( payment_preimage) ,
740
742
RecipientOnionFields :: spontaneous_empty ( ) ,
741
- PaymentId ( payment_hash . 0 ) ,
743
+ payment_id ,
742
744
route_params,
743
745
Retry :: Timeout ( Duration :: from_secs ( 10 ) ) ,
744
746
) {
@@ -749,16 +751,16 @@ fn keysend<E: EntropySource>(
749
751
Err ( e) => {
750
752
println ! ( "ERROR: failed to send payment: {:?}" , e) ;
751
753
print ! ( "> " ) ;
752
- outbound_payments. payments . get_mut ( & payment_hash ) . unwrap ( ) . status = HTLCStatus :: Failed ;
754
+ outbound_payments. payments . get_mut ( & payment_id ) . unwrap ( ) . status = HTLCStatus :: Failed ;
753
755
fs_store. write ( "" , "" , OUTBOUND_PAYMENTS_FNAME , & outbound_payments. encode ( ) ) . unwrap ( ) ;
754
756
}
755
757
} ;
756
758
}
757
759
758
760
fn get_invoice (
759
- amt_msat : u64 , inbound_payments : & mut PaymentInfoStorage , channel_manager : & ChannelManager ,
760
- keys_manager : Arc < KeysManager > , network : Network , expiry_secs : u32 ,
761
- logger : Arc < disk:: FilesystemLogger > ,
761
+ amt_msat : u64 , inbound_payments : & mut InboundPaymentInfoStorage ,
762
+ channel_manager : & ChannelManager , keys_manager : Arc < KeysManager > , network : Network ,
763
+ expiry_secs : u32 , logger : Arc < disk:: FilesystemLogger > ,
762
764
) {
763
765
let currency = match network {
764
766
Network :: Bitcoin => Currency :: Bitcoin ,
0 commit comments