X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fcli.rs;h=297900a0db7cf15b6ce59480336a91afaefe0bba;hb=aa1635c16624664ba2fde72c0f58da7437e50b74;hp=9cb0f174fa70b3be67d13c4438e2bc011554dcb4;hpb=44b7ad33748d85d885e2876d5afc255791523d3f;p=ldk-sample diff --git a/src/cli.rs b/src/cli.rs index 9cb0f17..297900a 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -12,7 +12,7 @@ use lightning::ln::channelmanager::{PaymentId, RecipientOnionFields, Retry}; use lightning::ln::msgs::SocketAddress; use lightning::ln::{ChannelId, PaymentHash, PaymentPreimage}; use lightning::onion_message::OnionMessagePath; -use lightning::onion_message::{CustomOnionMessageContents, Destination, OnionMessageContents}; +use lightning::onion_message::{Destination, OnionMessageContents}; use lightning::routing::gossip::NodeId; use lightning::routing::router::{PaymentParameters, RouteParameters}; use lightning::sign::{EntropySource, KeysManager}; @@ -48,7 +48,7 @@ struct UserOnionMessageContents { data: Vec, } -impl CustomOnionMessageContents for UserOnionMessageContents { +impl OnionMessageContents for UserOnionMessageContents { fn tlv_type(&self) -> u64 { self.tlv_type } @@ -65,7 +65,7 @@ pub(crate) fn poll_for_user_input( keys_manager: Arc, network_graph: Arc, onion_messenger: Arc, inbound_payments: Arc>, outbound_payments: Arc>, ldk_data_dir: String, network: Network, - logger: Arc, persister: Arc, + logger: Arc, fs_store: Arc, ) { println!( "LDK startup successful. Enter \"help\" to view available commands. Press Ctrl-D to quit." @@ -172,7 +172,7 @@ pub(crate) fn poll_for_user_input( &channel_manager, &invoice, &mut outbound_payments.lock().unwrap(), - persister.clone(), + Arc::clone(&fs_store), ); } "keysend" => { @@ -209,7 +209,7 @@ pub(crate) fn poll_for_user_input( amt_msat, &*keys_manager, &mut outbound_payments.lock().unwrap(), - persister.clone(), + Arc::clone(&fs_store), ); } "getinvoice" => { @@ -247,7 +247,7 @@ pub(crate) fn poll_for_user_input( expiry_secs.unwrap(), Arc::clone(&logger), ); - persister + fs_store .write("", "", INBOUND_PAYMENTS_FNAME, &inbound_payments.encode()) .unwrap(); } @@ -445,7 +445,7 @@ pub(crate) fn poll_for_user_input( let message_path = OnionMessagePath { intermediate_nodes, destination }; match onion_messenger.send_onion_message( message_path, - OnionMessageContents::Custom(UserOnionMessageContents { tlv_type, data }), + UserOnionMessageContents { tlv_type, data }, None, ) { Ok(()) => println!("SUCCESS: forwarded onion message to first hop"), @@ -684,7 +684,7 @@ fn open_channel( fn send_payment( channel_manager: &ChannelManager, invoice: &Bolt11Invoice, - outbound_payments: &mut PaymentInfoStorage, persister: Arc, + outbound_payments: &mut PaymentInfoStorage, fs_store: Arc, ) { let payment_hash = PaymentHash((*invoice.payment_hash()).into_inner()); let payment_secret = Some(*invoice.payment_secret()); @@ -697,7 +697,7 @@ fn send_payment( amt_msat: MillisatAmount(invoice.amount_milli_satoshis()), }, ); - persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap(); + fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap(); match pay_invoice(invoice, Retry::Timeout(Duration::from_secs(10)), channel_manager) { Ok(_payment_id) => { let payee_pubkey = invoice.recover_payee_pub_key(); @@ -709,14 +709,14 @@ fn send_payment( println!("ERROR: failed to send payment: {:?}", e); print!("> "); outbound_payments.payments.get_mut(&payment_hash).unwrap().status = HTLCStatus::Failed; - persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap(); + fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap(); } }; } fn keysend( channel_manager: &ChannelManager, payee_pubkey: PublicKey, amt_msat: u64, entropy_source: &E, - outbound_payments: &mut PaymentInfoStorage, persister: Arc, + outbound_payments: &mut PaymentInfoStorage, fs_store: Arc, ) { let payment_preimage = PaymentPreimage(entropy_source.get_secure_random_bytes()); let payment_hash = PaymentHash(Sha256::hash(&payment_preimage.0[..]).into_inner()); @@ -734,7 +734,7 @@ fn keysend( amt_msat: MillisatAmount(Some(amt_msat)), }, ); - persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap(); + fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap(); match channel_manager.send_spontaneous_payment_with_retry( Some(payment_preimage), RecipientOnionFields::spontaneous_empty(), @@ -750,7 +750,7 @@ fn keysend( println!("ERROR: failed to send payment: {:?}", e); print!("> "); outbound_payments.payments.get_mut(&payment_hash).unwrap().status = HTLCStatus::Failed; - persister.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap(); + fs_store.write("", "", OUTBOUND_PAYMENTS_FNAME, &outbound_payments.encode()).unwrap(); } }; }