@@ -30,6 +30,8 @@ mod hex_utils;
30
30
mod io_utils;
31
31
mod logger;
32
32
mod peer_store;
33
+ #[ cfg( test) ]
34
+ mod tests;
33
35
mod types;
34
36
mod wallet;
35
37
@@ -206,19 +208,18 @@ impl Builder {
206
208
. expect ( "Failed to read wallet master key" ) ;
207
209
208
210
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 ) ) ,
211
213
config. network ,
212
214
& Secp256k1 :: new ( ) ,
213
215
)
214
216
. expect ( "Failed to derive on-chain wallet name" ) ;
215
217
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" ) ;
218
219
219
220
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 ) ) ,
222
223
config. network ,
223
224
database,
224
225
)
@@ -285,7 +286,7 @@ impl Builder {
285
286
let mut user_config = UserConfig :: default ( ) ;
286
287
user_config. channel_handshake_limits . force_announced_channel_preference = false ;
287
288
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) ) {
289
290
let mut channel_monitor_mut_references = Vec :: new ( ) ;
290
291
for ( _, channel_monitor) in channel_monitors. iter_mut ( ) {
291
292
channel_monitor_mut_references. push ( channel_monitor) ;
@@ -316,7 +317,7 @@ impl Builder {
316
317
network : config. network ,
317
318
best_block : BestBlock :: new ( dummy_block_hash, 0 ) ,
318
319
} ;
319
- let fresh_channel_manager = channelmanager:: ChannelManager :: new (
320
+ channelmanager:: ChannelManager :: new (
320
321
Arc :: clone ( & wallet) ,
321
322
Arc :: clone ( & chain_monitor) ,
322
323
Arc :: clone ( & wallet) ,
@@ -327,8 +328,7 @@ impl Builder {
327
328
Arc :: clone ( & keys_manager) ,
328
329
user_config,
329
330
chain_params,
330
- ) ;
331
- fresh_channel_manager
331
+ )
332
332
}
333
333
} ;
334
334
@@ -380,7 +380,7 @@ impl Builder {
380
380
381
381
// Step 14: Restore event handler from disk or create a new one.
382
382
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 ) )
384
384
{
385
385
Arc :: new (
386
386
EventQueue :: read ( & mut f, Arc :: clone ( & persister) )
@@ -390,11 +390,9 @@ impl Builder {
390
390
Arc :: new ( EventQueue :: new ( Arc :: clone ( & persister) ) )
391
391
} ;
392
392
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
+ {
398
396
Arc :: new (
399
397
PeerInfoStorage :: read ( & mut f, Arc :: clone ( & persister) )
400
398
. expect ( "Failed to read peer information from disk." ) ,
@@ -643,7 +641,7 @@ impl Node {
643
641
if peer_info. pubkey == node_id {
644
642
let _ = do_connect_peer (
645
643
peer_info. pubkey ,
646
- peer_info. address . clone ( ) ,
644
+ peer_info. address ,
647
645
Arc :: clone ( & connect_pm) ,
648
646
Arc :: clone ( & connect_logger) ,
649
647
)
@@ -859,8 +857,8 @@ impl Node {
859
857
}
860
858
} ;
861
859
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 ( ) ) ;
864
862
865
863
let mut outbound_payments_lock = self . outbound_payments . lock ( ) . unwrap ( ) ;
866
864
outbound_payments_lock. insert (
@@ -957,20 +955,20 @@ impl Node {
957
955
}
958
956
} ;
959
957
960
- let payment_hash = PaymentHash ( invoice. payment_hash ( ) . clone ( ) . into_inner ( ) ) ;
958
+ let payment_hash = PaymentHash ( ( * invoice. payment_hash ( ) ) . into_inner ( ) ) ;
961
959
inbound_payments_lock. insert (
962
960
payment_hash,
963
961
PaymentInfo {
964
962
preimage : None ,
965
- secret : Some ( invoice. payment_secret ( ) . clone ( ) ) ,
963
+ secret : Some ( * invoice. payment_secret ( ) ) ,
966
964
status : PaymentStatus :: Pending ,
967
965
amount_msat,
968
966
} ,
969
967
) ;
970
968
Ok ( invoice)
971
969
}
972
970
973
- /// Query for information about the status of a specific payment.
971
+ /// Query for information about the status of a specific payment.
974
972
pub fn payment_info ( & self , payment_hash : & [ u8 ; 32 ] ) -> Option < PaymentInfo > {
975
973
let payment_hash = PaymentHash ( * payment_hash) ;
976
974
0 commit comments