@@ -30,6 +30,8 @@ mod hex_utils;
3030mod io_utils;
3131mod logger;
3232mod peer_store;
33+ #[ cfg( test) ]
34+ mod tests;
3335mod types;
3436mod wallet;
3537
@@ -213,19 +215,18 @@ impl Builder {
213215 . expect ( "Failed to read wallet master key" ) ;
214216
215217 let wallet_name = bdk:: wallet:: wallet_name_from_descriptor (
216- Bip84 ( xprv. clone ( ) , bdk:: KeychainKind :: External ) ,
217- Some ( Bip84 ( xprv. clone ( ) , bdk:: KeychainKind :: Internal ) ) ,
218+ Bip84 ( xprv, bdk:: KeychainKind :: External ) ,
219+ Some ( Bip84 ( xprv, bdk:: KeychainKind :: Internal ) ) ,
218220 config. network ,
219221 & Secp256k1 :: new ( ) ,
220222 )
221223 . expect ( "Failed to derive on-chain wallet name" ) ;
222224 let database = sled:: open ( bdk_data_dir) . expect ( "Failed to open BDK database" ) ;
223- let database =
224- database. open_tree ( wallet_name. clone ( ) ) . expect ( "Failed to open BDK database" ) ;
225+ let database = database. open_tree ( wallet_name) . expect ( "Failed to open BDK database" ) ;
225226
226227 let bdk_wallet = bdk:: Wallet :: new (
227- Bip84 ( xprv. clone ( ) , bdk:: KeychainKind :: External ) ,
228- Some ( Bip84 ( xprv. clone ( ) , bdk:: KeychainKind :: Internal ) ) ,
228+ Bip84 ( xprv, bdk:: KeychainKind :: External ) ,
229+ Some ( Bip84 ( xprv, bdk:: KeychainKind :: Internal ) ) ,
229230 config. network ,
230231 database,
231232 )
@@ -292,7 +293,7 @@ impl Builder {
292293 let mut user_config = UserConfig :: default ( ) ;
293294 user_config. channel_handshake_limits . force_announced_channel_preference = false ;
294295 let channel_manager = {
295- if let Ok ( mut f) = fs:: File :: open ( format ! ( "{}/manager" , ldk_data_dir. clone ( ) ) ) {
296+ if let Ok ( mut f) = fs:: File :: open ( format ! ( "{}/manager" , ldk_data_dir) ) {
296297 let mut channel_monitor_mut_references = Vec :: new ( ) ;
297298 for ( _, channel_monitor) in channel_monitors. iter_mut ( ) {
298299 channel_monitor_mut_references. push ( channel_monitor) ;
@@ -323,7 +324,7 @@ impl Builder {
323324 network : config. network ,
324325 best_block : BestBlock :: new ( dummy_block_hash, 0 ) ,
325326 } ;
326- let fresh_channel_manager = channelmanager:: ChannelManager :: new (
327+ channelmanager:: ChannelManager :: new (
327328 Arc :: clone ( & wallet) ,
328329 Arc :: clone ( & chain_monitor) ,
329330 Arc :: clone ( & wallet) ,
@@ -334,8 +335,7 @@ impl Builder {
334335 Arc :: clone ( & keys_manager) ,
335336 user_config,
336337 chain_params,
337- ) ;
338- fresh_channel_manager
338+ )
339339 }
340340 } ;
341341
@@ -387,7 +387,7 @@ impl Builder {
387387
388388 // Step 14: Restore event handler from disk or create a new one.
389389 let event_queue = if let Ok ( mut f) =
390- fs:: File :: open ( format ! ( "{}/{}" , ldk_data_dir. clone ( ) , event:: EVENTS_PERSISTENCE_KEY ) )
390+ fs:: File :: open ( format ! ( "{}/{}" , ldk_data_dir, event:: EVENTS_PERSISTENCE_KEY ) )
391391 {
392392 Arc :: new (
393393 EventQueue :: read ( & mut f, Arc :: clone ( & persister) )
@@ -397,11 +397,9 @@ impl Builder {
397397 Arc :: new ( EventQueue :: new ( Arc :: clone ( & persister) ) )
398398 } ;
399399
400- let peer_store = if let Ok ( mut f) = fs:: File :: open ( format ! (
401- "{}/{}" ,
402- ldk_data_dir. clone( ) ,
403- peer_store:: PEER_INFO_PERSISTENCE_KEY
404- ) ) {
400+ let peer_store = if let Ok ( mut f) =
401+ fs:: File :: open ( format ! ( "{}/{}" , ldk_data_dir, peer_store:: PEER_INFO_PERSISTENCE_KEY ) )
402+ {
405403 Arc :: new (
406404 PeerInfoStorage :: read ( & mut f, Arc :: clone ( & persister) )
407405 . expect ( "Failed to read peer information from disk." ) ,
@@ -650,7 +648,7 @@ impl Node {
650648 if peer_info. pubkey == node_id {
651649 let _ = do_connect_peer (
652650 peer_info. pubkey ,
653- peer_info. address . clone ( ) ,
651+ peer_info. address ,
654652 Arc :: clone ( & connect_pm) ,
655653 Arc :: clone ( & connect_logger) ,
656654 )
@@ -866,8 +864,8 @@ impl Node {
866864 }
867865 } ;
868866
869- let payment_hash = PaymentHash ( invoice. payment_hash ( ) . clone ( ) . into_inner ( ) ) ;
870- let payment_secret = Some ( invoice. payment_secret ( ) . clone ( ) ) ;
867+ let payment_hash = PaymentHash ( ( * invoice. payment_hash ( ) ) . into_inner ( ) ) ;
868+ let payment_secret = Some ( * invoice. payment_secret ( ) ) ;
871869
872870 let mut outbound_payments_lock = self . outbound_payments . lock ( ) . unwrap ( ) ;
873871 outbound_payments_lock. insert (
@@ -963,20 +961,20 @@ impl Node {
963961 }
964962 } ;
965963
966- let payment_hash = PaymentHash ( invoice. payment_hash ( ) . clone ( ) . into_inner ( ) ) ;
964+ let payment_hash = PaymentHash ( ( * invoice. payment_hash ( ) ) . into_inner ( ) ) ;
967965 inbound_payments_lock. insert (
968966 payment_hash,
969967 PaymentInfo {
970968 preimage : None ,
971- secret : Some ( invoice. payment_secret ( ) . clone ( ) ) ,
969+ secret : Some ( * invoice. payment_secret ( ) ) ,
972970 status : PaymentStatus :: Pending ,
973971 amount_msat,
974972 } ,
975973 ) ;
976974 Ok ( invoice)
977975 }
978976
979- /// Query for information about the status of a specific payment.
977+ /// Query for information about the status of a specific payment.
980978 pub fn payment_info ( & self , payment_hash : & [ u8 ; 32 ] ) -> Option < PaymentInfo > {
981979 let payment_hash = PaymentHash ( * payment_hash) ;
982980
0 commit comments