@@ -2,28 +2,29 @@ use crate::disk::{self, INBOUND_PAYMENTS_FNAME, OUTBOUND_PAYMENTS_FNAME};
2
2
use crate :: hex_utils;
3
3
use crate :: {
4
4
ChannelManager , HTLCStatus , InboundPaymentInfoStorage , MillisatAmount , NetworkGraph ,
5
- OnionMessenger , OutboundPaymentInfoStorage , PaymentInfo , PeerManager ,
5
+ OutboundPaymentInfoStorage , PaymentInfo , PeerManager ,
6
6
} ;
7
7
use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
8
8
use bitcoin:: hashes:: Hash ;
9
- use bitcoin:: network:: constants :: Network ;
9
+ use bitcoin:: network:: Network ;
10
10
use bitcoin:: secp256k1:: PublicKey ;
11
+ use lightning:: ln:: bolt11_payment:: payment_parameters_from_invoice;
12
+ use lightning:: ln:: bolt11_payment:: payment_parameters_from_zero_amount_invoice;
11
13
use lightning:: ln:: channelmanager:: { PaymentId , RecipientOnionFields , Retry } ;
14
+ use lightning:: ln:: invoice_utils as utils;
12
15
use lightning:: ln:: msgs:: SocketAddress ;
13
- use lightning:: ln:: { ChannelId , PaymentHash , PaymentPreimage } ;
16
+ use lightning:: ln:: types :: ChannelId ;
14
17
use lightning:: offers:: offer:: { self , Offer } ;
15
18
use lightning:: routing:: gossip:: NodeId ;
16
19
use lightning:: routing:: router:: { PaymentParameters , RouteParameters } ;
17
20
use lightning:: sign:: { EntropySource , KeysManager } ;
21
+ use lightning:: types:: payment:: { PaymentHash , PaymentPreimage } ;
18
22
use lightning:: util:: config:: { ChannelHandshakeConfig , ChannelHandshakeLimits , UserConfig } ;
19
23
use lightning:: util:: persist:: KVStore ;
20
- use lightning:: util:: ser:: { Writeable , Writer } ;
21
- use lightning_invoice:: payment:: payment_parameters_from_invoice;
22
- use lightning_invoice:: payment:: payment_parameters_from_zero_amount_invoice;
23
- use lightning_invoice:: { utils, Bolt11Invoice , Currency } ;
24
+ use lightning:: util:: ser:: Writeable ;
25
+ use lightning_invoice:: { Bolt11Invoice , Currency } ;
24
26
use lightning_persister:: fs_store:: FilesystemStore ;
25
27
use std:: env;
26
- use std:: io;
27
28
use std:: io:: Write ;
28
29
use std:: net:: { SocketAddr , ToSocketAddrs } ;
29
30
use std:: path:: Path ;
@@ -46,7 +47,7 @@ pub(crate) struct LdkUserInfo {
46
47
pub ( crate ) fn poll_for_user_input (
47
48
peer_manager : Arc < PeerManager > , channel_manager : Arc < ChannelManager > ,
48
49
keys_manager : Arc < KeysManager > , network_graph : Arc < NetworkGraph > ,
49
- onion_messenger : Arc < OnionMessenger > , inbound_payments : Arc < Mutex < InboundPaymentInfoStorage > > ,
50
+ inbound_payments : Arc < Mutex < InboundPaymentInfoStorage > > ,
50
51
outbound_payments : Arc < Mutex < OutboundPaymentInfoStorage > > , ldk_data_dir : String ,
51
52
network : Network , logger : Arc < disk:: FilesystemLogger > , fs_store : Arc < FilesystemStore > ,
52
53
) {
@@ -57,9 +58,9 @@ pub(crate) fn poll_for_user_input(
57
58
println ! ( "Local Node ID is {}." , channel_manager. get_our_node_id( ) ) ;
58
59
' read_command: loop {
59
60
print ! ( "> " ) ;
60
- io:: stdout ( ) . flush ( ) . unwrap ( ) ; // Without flushing, the `>` doesn't print
61
+ std :: io:: stdout ( ) . flush ( ) . unwrap ( ) ; // Without flushing, the `>` doesn't print
61
62
let mut line = String :: new ( ) ;
62
- if let Err ( e) = io:: stdin ( ) . read_line ( & mut line) {
63
+ if let Err ( e) = std :: io:: stdin ( ) . read_line ( & mut line) {
63
64
break println ! ( "ERROR: {}" , e) ;
64
65
}
65
66
@@ -159,7 +160,7 @@ pub(crate) fn poll_for_user_input(
159
160
let payment_id = PaymentId ( random_bytes) ;
160
161
161
162
let amt_msat = match ( offer. amount ( ) , user_provided_amt) {
162
- ( Some ( offer:: Amount :: Bitcoin { amount_msats } ) , _) => * amount_msats,
163
+ ( Some ( offer:: Amount :: Bitcoin { amount_msats } ) , _) => amount_msats,
163
164
( _, Some ( amt) ) => amt,
164
165
( amt, _) => {
165
166
println ! ( "ERROR: Cannot process non-Bitcoin-denominated offer value {:?}" , amt) ;
@@ -173,9 +174,9 @@ pub(crate) fn poll_for_user_input(
173
174
174
175
while user_provided_amt. is_none ( ) {
175
176
print ! ( "Paying offer for {} msat. Continue (Y/N)? >" , amt_msat) ;
176
- io:: stdout ( ) . flush ( ) . unwrap ( ) ;
177
+ std :: io:: stdout ( ) . flush ( ) . unwrap ( ) ;
177
178
178
- if let Err ( e) = io:: stdin ( ) . read_line ( & mut line) {
179
+ if let Err ( e) = std :: io:: stdin ( ) . read_line ( & mut line) {
179
180
println ! ( "ERROR: {}" , e) ;
180
181
break ' read_command;
181
182
}
@@ -266,7 +267,7 @@ pub(crate) fn poll_for_user_input(
266
267
) ;
267
268
} ,
268
269
"getoffer" => {
269
- let offer_builder = channel_manager. create_offer_builder ( ) ;
270
+ let offer_builder = channel_manager. create_offer_builder ( None ) ;
270
271
if let Err ( e) = offer_builder {
271
272
println ! ( "ERROR: Failed to initiate offer building: {:?}" , e) ;
272
273
continue ;
@@ -554,7 +555,7 @@ fn list_channels(channel_manager: &Arc<ChannelManager>, network_graph: &Arc<Netw
554
555
. get ( & NodeId :: from_pubkey ( & chan_info. counterparty . node_id ) )
555
556
{
556
557
if let Some ( announcement) = & node_info. announcement_info {
557
- println ! ( "\t \t peer_alias: {}" , announcement. alias) ;
558
+ println ! ( "\t \t peer_alias: {}" , announcement. alias( ) ) ;
558
559
}
559
560
}
560
561
@@ -569,7 +570,7 @@ fn list_channels(channel_manager: &Arc<ChannelManager>, network_graph: &Arc<Netw
569
570
println ! ( "\t \t available_balance_for_recv_msat: {}," , chan_info. inbound_capacity_msat) ;
570
571
}
571
572
println ! ( "\t \t channel_can_send_payments: {}," , chan_info. is_usable) ;
572
- println ! ( "\t \t public: {}," , chan_info. is_public ) ;
573
+ println ! ( "\t \t public: {}," , chan_info. is_announced ) ;
573
574
println ! ( "\t }}," ) ;
574
575
}
575
576
println ! ( "]" ) ;
@@ -676,8 +677,8 @@ fn do_disconnect_peer(
676
677
}
677
678
678
679
fn open_channel (
679
- peer_pubkey : PublicKey , channel_amt_sat : u64 , announced_channel : bool , with_anchors : bool ,
680
- channel_manager : Arc < ChannelManager > ,
680
+ peer_pubkey : PublicKey , channel_amt_sat : u64 , announce_for_forwarding : bool ,
681
+ with_anchors : bool , channel_manager : Arc < ChannelManager > ,
681
682
) -> Result < ( ) , ( ) > {
682
683
let config = UserConfig {
683
684
channel_handshake_limits : ChannelHandshakeLimits {
@@ -686,7 +687,7 @@ fn open_channel(
686
687
..Default :: default ( )
687
688
} ,
688
689
channel_handshake_config : ChannelHandshakeConfig {
689
- announced_channel ,
690
+ announce_for_forwarding ,
690
691
negotiate_anchors_zero_fee_htlc_tx : with_anchors,
691
692
..Default :: default ( )
692
693
} ,
@@ -870,8 +871,10 @@ fn close_channel(
870
871
fn force_close_channel (
871
872
channel_id : [ u8 ; 32 ] , counterparty_node_id : PublicKey , channel_manager : Arc < ChannelManager > ,
872
873
) {
874
+ let reason = "Manually force-closed" . to_string ( ) ;
875
+ let channel_id = ChannelId ( channel_id) ;
873
876
match channel_manager
874
- . force_close_broadcasting_latest_txn ( & ChannelId ( channel_id) , & counterparty_node_id)
877
+ . force_close_broadcasting_latest_txn ( & channel_id, & counterparty_node_id, reason )
875
878
{
876
879
Ok ( ( ) ) => println ! ( "EVENT: initiating channel force-close" ) ,
877
880
Err ( e) => println ! ( "ERROR: failed to force-close channel: {:?}" , e) ,
0 commit comments