@@ -78,6 +78,7 @@ mod test;
78
78
mod types;
79
79
mod wallet;
80
80
81
+ pub use bip39;
81
82
pub use bitcoin;
82
83
pub use lightning;
83
84
pub use lightning_invoice;
@@ -188,6 +189,7 @@ impl Default for Config {
188
189
enum WalletEntropySource {
189
190
SeedFile ( String ) ,
190
191
SeedBytes ( [ u8 ; WALLET_KEYS_SEED_LEN ] ) ,
192
+ Bip39Mnemonic { mnemonic : bip39:: Mnemonic , passphrase : Option < String > } ,
191
193
}
192
194
193
195
/// A builder for an [`Node`] instance, allowing to set some configuration and module choices from
@@ -227,6 +229,16 @@ impl Builder {
227
229
self
228
230
}
229
231
232
+ /// Configures the [`Node`] instance to source its wallet entropy from a [BIP 39] mnemonic.
233
+ ///
234
+ /// [BIP 39]: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
235
+ pub fn set_entropy_bip39_mnemonic (
236
+ & mut self , mnemonic : bip39:: Mnemonic , passphrase : Option < String > ,
237
+ ) -> & mut Self {
238
+ self . entropy_source = Some ( WalletEntropySource :: Bip39Mnemonic { mnemonic, passphrase } ) ;
239
+ self
240
+ }
241
+
230
242
/// Sets the used storage directory path.
231
243
///
232
244
/// Default: `/tmp/ldk_node/`
@@ -291,6 +303,10 @@ impl Builder {
291
303
WalletEntropySource :: SeedFile ( seed_path) => {
292
304
io:: utils:: read_or_generate_seed_file ( seed_path)
293
305
}
306
+ WalletEntropySource :: Bip39Mnemonic { mnemonic, passphrase } => match passphrase {
307
+ Some ( passphrase) => mnemonic. to_seed ( passphrase) ,
308
+ None => mnemonic. to_seed ( "" ) ,
309
+ } ,
294
310
}
295
311
} else {
296
312
// Default to read or generate from the default location generate a seed file.
0 commit comments