@@ -6,12 +6,12 @@ use lightning::chain::chaininterface::{
6
6
BroadcasterInterface , ConfirmationTarget , FeeEstimator , FEERATE_FLOOR_SATS_PER_KW ,
7
7
} ;
8
8
9
+ use lightning:: ln:: msgs:: { DecodeError , UnsignedGossipMessage } ;
10
+ use lightning:: ln:: script:: ShutdownScript ;
9
11
use lightning:: sign:: {
10
12
EntropySource , InMemorySigner , KeyMaterial , KeysManager , NodeSigner , Recipient , SignerProvider ,
11
13
SpendableOutputDescriptor ,
12
14
} ;
13
- use lightning:: ln:: msgs:: { DecodeError , UnsignedGossipMessage } ;
14
- use lightning:: ln:: script:: ShutdownScript ;
15
15
16
16
use bdk:: blockchain:: { Blockchain , EsploraBlockchain } ;
17
17
use bdk:: database:: BatchDatabase ;
@@ -435,19 +435,16 @@ where
435
435
self . inner . read_chan_signer ( reader)
436
436
}
437
437
438
- fn get_destination_script ( & self ) -> Script {
439
- let address =
440
- self . wallet . get_new_address ( ) . expect ( "Failed to retrieve new address from wallet." ) ;
441
- address. script_pubkey ( )
438
+ fn get_destination_script ( & self ) -> Result < Script , ( ) > {
439
+ let address = self . wallet . get_new_address ( ) . map_err ( |_| ( ) ) ?;
440
+ Ok ( address. script_pubkey ( ) )
442
441
}
443
442
444
- fn get_shutdown_scriptpubkey ( & self ) -> ShutdownScript {
445
- let address =
446
- self . wallet . get_new_address ( ) . expect ( "Failed to retrieve new address from wallet." ) ;
443
+ fn get_shutdown_scriptpubkey ( & self ) -> Result < ShutdownScript , ( ) > {
444
+ let address = self . wallet . get_new_address ( ) . map_err ( |_| ( ) ) ?;
447
445
match address. payload {
448
446
bitcoin:: util:: address:: Payload :: WitnessProgram { version, program } => {
449
- return ShutdownScript :: new_witness_program ( version, & program)
450
- . expect ( "Invalid shutdown script." ) ;
447
+ ShutdownScript :: new_witness_program ( version, & program) . map_err ( |_| ( ) )
451
448
}
452
449
_ => panic ! ( "Tried to use a non-witness address. This must not ever happen." ) ,
453
450
}
0 commit comments