@@ -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
@@ -206,19 +208,18 @@ impl Builder {
206208 . expect ( "Failed to read wallet master key" ) ;
207209
208210 let wallet_name = bdk:: wallet:: wallet_name_from_descriptor (
209- Bip84 ( xprv. clone ( ) , bdk:: KeychainKind :: External ) ,
210- Some ( Bip84 ( xprv. clone ( ) , bdk:: KeychainKind :: Internal ) ) ,
211+ Bip84 ( xprv, bdk:: KeychainKind :: External ) ,
212+ Some ( Bip84 ( xprv, bdk:: KeychainKind :: Internal ) ) ,
211213 config. network ,
212214 & Secp256k1 :: new ( ) ,
213215 )
214216 . expect ( "Failed to derive on-chain wallet name" ) ;
215217 let database = sled:: open ( bdk_data_dir) . expect ( "Failed to open BDK database" ) ;
216- let database =
217- database. open_tree ( wallet_name. clone ( ) ) . expect ( "Failed to open BDK database" ) ;
218+ let database = database. open_tree ( wallet_name) . expect ( "Failed to open BDK database" ) ;
218219
219220 let bdk_wallet = bdk:: Wallet :: new (
220- Bip84 ( xprv. clone ( ) , bdk:: KeychainKind :: External ) ,
221- Some ( Bip84 ( xprv. clone ( ) , bdk:: KeychainKind :: Internal ) ) ,
221+ Bip84 ( xprv, bdk:: KeychainKind :: External ) ,
222+ Some ( Bip84 ( xprv, bdk:: KeychainKind :: Internal ) ) ,
222223 config. network ,
223224 database,
224225 )
@@ -285,7 +286,7 @@ impl Builder {
285286 let mut user_config = UserConfig :: default ( ) ;
286287 user_config. channel_handshake_limits . force_announced_channel_preference = false ;
287288 let channel_manager = {
288- if let Ok ( mut f) = fs:: File :: open ( format ! ( "{}/manager" , ldk_data_dir. clone ( ) ) ) {
289+ if let Ok ( mut f) = fs:: File :: open ( format ! ( "{}/manager" , ldk_data_dir) ) {
289290 let mut channel_monitor_mut_references = Vec :: new ( ) ;
290291 for ( _, channel_monitor) in channel_monitors. iter_mut ( ) {
291292 channel_monitor_mut_references. push ( channel_monitor) ;
@@ -316,7 +317,7 @@ impl Builder {
316317 network : config. network ,
317318 best_block : BestBlock :: new ( dummy_block_hash, 0 ) ,
318319 } ;
319- let fresh_channel_manager = channelmanager:: ChannelManager :: new (
320+ channelmanager:: ChannelManager :: new (
320321 Arc :: clone ( & wallet) ,
321322 Arc :: clone ( & chain_monitor) ,
322323 Arc :: clone ( & wallet) ,
@@ -327,8 +328,7 @@ impl Builder {
327328 Arc :: clone ( & keys_manager) ,
328329 user_config,
329330 chain_params,
330- ) ;
331- fresh_channel_manager
331+ )
332332 }
333333 } ;
334334
@@ -380,7 +380,7 @@ impl Builder {
380380
381381 // Step 14: Restore event handler from disk or create a new one.
382382 let event_queue = if let Ok ( mut f) =
383- fs:: File :: open ( format ! ( "{}/{}" , ldk_data_dir. clone ( ) , event:: EVENTS_PERSISTENCE_KEY ) )
383+ fs:: File :: open ( format ! ( "{}/{}" , ldk_data_dir, event:: EVENTS_PERSISTENCE_KEY ) )
384384 {
385385 Arc :: new (
386386 EventQueue :: read ( & mut f, Arc :: clone ( & persister) )
@@ -390,11 +390,9 @@ impl Builder {
390390 Arc :: new ( EventQueue :: new ( Arc :: clone ( & persister) ) )
391391 } ;
392392
393- let peer_store = if let Ok ( mut f) = fs:: File :: open ( format ! (
394- "{}/{}" ,
395- ldk_data_dir. clone( ) ,
396- peer_store:: PEER_INFO_PERSISTENCE_KEY
397- ) ) {
393+ let peer_store = if let Ok ( mut f) =
394+ fs:: File :: open ( format ! ( "{}/{}" , ldk_data_dir, peer_store:: PEER_INFO_PERSISTENCE_KEY ) )
395+ {
398396 Arc :: new (
399397 PeerInfoStorage :: read ( & mut f, Arc :: clone ( & persister) )
400398 . expect ( "Failed to read peer information from disk." ) ,
@@ -643,7 +641,7 @@ impl Node {
643641 if peer_info. pubkey == node_id {
644642 let _ = do_connect_peer (
645643 peer_info. pubkey ,
646- peer_info. address . clone ( ) ,
644+ peer_info. address ,
647645 Arc :: clone ( & connect_pm) ,
648646 Arc :: clone ( & connect_logger) ,
649647 )
@@ -859,8 +857,8 @@ impl Node {
859857 }
860858 } ;
861859
862- let payment_hash = PaymentHash ( invoice. payment_hash ( ) . clone ( ) . into_inner ( ) ) ;
863- let payment_secret = Some ( invoice. payment_secret ( ) . clone ( ) ) ;
860+ let payment_hash = PaymentHash ( ( * invoice. payment_hash ( ) ) . into_inner ( ) ) ;
861+ let payment_secret = Some ( * invoice. payment_secret ( ) ) ;
864862
865863 let mut outbound_payments_lock = self . outbound_payments . lock ( ) . unwrap ( ) ;
866864 outbound_payments_lock. insert (
@@ -957,20 +955,20 @@ impl Node {
957955 }
958956 } ;
959957
960- let payment_hash = PaymentHash ( invoice. payment_hash ( ) . clone ( ) . into_inner ( ) ) ;
958+ let payment_hash = PaymentHash ( ( * invoice. payment_hash ( ) ) . into_inner ( ) ) ;
961959 inbound_payments_lock. insert (
962960 payment_hash,
963961 PaymentInfo {
964962 preimage : None ,
965- secret : Some ( invoice. payment_secret ( ) . clone ( ) ) ,
963+ secret : Some ( * invoice. payment_secret ( ) ) ,
966964 status : PaymentStatus :: Pending ,
967965 amount_msat,
968966 } ,
969967 ) ;
970968 Ok ( invoice)
971969 }
972970
973- /// Query for information about the status of a specific payment.
971+ /// Query for information about the status of a specific payment.
974972 pub fn payment_info ( & self , payment_hash : & [ u8 ; 32 ] ) -> Option < PaymentInfo > {
975973 let payment_hash = PaymentHash ( * payment_hash) ;
976974
0 commit comments