@@ -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
@@ -213,19 +215,18 @@ impl Builder {
213
215
. expect ( "Failed to read wallet master key" ) ;
214
216
215
217
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 ) ) ,
218
220
config. network ,
219
221
& Secp256k1 :: new ( ) ,
220
222
)
221
223
. expect ( "Failed to derive on-chain wallet name" ) ;
222
224
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" ) ;
225
226
226
227
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 ) ) ,
229
230
config. network ,
230
231
database,
231
232
)
@@ -292,7 +293,7 @@ impl Builder {
292
293
let mut user_config = UserConfig :: default ( ) ;
293
294
user_config. channel_handshake_limits . force_announced_channel_preference = false ;
294
295
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) ) {
296
297
let mut channel_monitor_mut_references = Vec :: new ( ) ;
297
298
for ( _, channel_monitor) in channel_monitors. iter_mut ( ) {
298
299
channel_monitor_mut_references. push ( channel_monitor) ;
@@ -323,7 +324,7 @@ impl Builder {
323
324
network : config. network ,
324
325
best_block : BestBlock :: new ( dummy_block_hash, 0 ) ,
325
326
} ;
326
- let fresh_channel_manager = channelmanager:: ChannelManager :: new (
327
+ channelmanager:: ChannelManager :: new (
327
328
Arc :: clone ( & wallet) ,
328
329
Arc :: clone ( & chain_monitor) ,
329
330
Arc :: clone ( & wallet) ,
@@ -334,8 +335,7 @@ impl Builder {
334
335
Arc :: clone ( & keys_manager) ,
335
336
user_config,
336
337
chain_params,
337
- ) ;
338
- fresh_channel_manager
338
+ )
339
339
}
340
340
} ;
341
341
@@ -387,7 +387,7 @@ impl Builder {
387
387
388
388
// Step 14: Restore event handler from disk or create a new one.
389
389
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 ) )
391
391
{
392
392
Arc :: new (
393
393
EventQueue :: read ( & mut f, Arc :: clone ( & persister) )
@@ -397,11 +397,9 @@ impl Builder {
397
397
Arc :: new ( EventQueue :: new ( Arc :: clone ( & persister) ) )
398
398
} ;
399
399
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
+ {
405
403
Arc :: new (
406
404
PeerInfoStorage :: read ( & mut f, Arc :: clone ( & persister) )
407
405
. expect ( "Failed to read peer information from disk." ) ,
@@ -650,7 +648,7 @@ impl Node {
650
648
if peer_info. pubkey == node_id {
651
649
let _ = do_connect_peer (
652
650
peer_info. pubkey ,
653
- peer_info. address . clone ( ) ,
651
+ peer_info. address ,
654
652
Arc :: clone ( & connect_pm) ,
655
653
Arc :: clone ( & connect_logger) ,
656
654
)
@@ -866,8 +864,8 @@ impl Node {
866
864
}
867
865
} ;
868
866
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 ( ) ) ;
871
869
872
870
let mut outbound_payments_lock = self . outbound_payments . lock ( ) . unwrap ( ) ;
873
871
outbound_payments_lock. insert (
@@ -963,20 +961,20 @@ impl Node {
963
961
}
964
962
} ;
965
963
966
- let payment_hash = PaymentHash ( invoice. payment_hash ( ) . clone ( ) . into_inner ( ) ) ;
964
+ let payment_hash = PaymentHash ( ( * invoice. payment_hash ( ) ) . into_inner ( ) ) ;
967
965
inbound_payments_lock. insert (
968
966
payment_hash,
969
967
PaymentInfo {
970
968
preimage : None ,
971
- secret : Some ( invoice. payment_secret ( ) . clone ( ) ) ,
969
+ secret : Some ( * invoice. payment_secret ( ) ) ,
972
970
status : PaymentStatus :: Pending ,
973
971
amount_msat,
974
972
} ,
975
973
) ;
976
974
Ok ( invoice)
977
975
}
978
976
979
- /// Query for information about the status of a specific payment.
977
+ /// Query for information about the status of a specific payment.
980
978
pub fn payment_info ( & self , payment_hash : & [ u8 ; 32 ] ) -> Option < PaymentInfo > {
981
979
let payment_hash = PaymentHash ( * payment_hash) ;
982
980
0 commit comments