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