@@ -81,6 +81,7 @@ mod test;
8181mod types;
8282mod wallet;
8383
84+ pub use bip39;
8485pub use bitcoin;
8586pub use lightning;
8687pub use lightning_invoice;
@@ -191,6 +192,7 @@ impl Default for Config {
191192enum WalletEntropySource {
192193 SeedFile ( String ) ,
193194 SeedBytes ( [ u8 ; WALLET_KEYS_SEED_LEN ] ) ,
195+ Bip39Mnemonic { mnemonic : bip39:: Mnemonic , passphrase : Option < String > } ,
194196}
195197
196198/// A builder for an [`Node`] instance, allowing to set some configuration and module choices from
@@ -230,6 +232,16 @@ impl Builder {
230232 self
231233 }
232234
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+
233245 /// Sets the used storage directory path.
234246 ///
235247 /// Default: `/tmp/ldk_node/`
@@ -293,6 +305,10 @@ impl Builder {
293305 WalletEntropySource :: SeedFile ( seed_path) => {
294306 io:: utils:: read_or_generate_seed_file ( seed_path)
295307 }
308+ WalletEntropySource :: Bip39Mnemonic { mnemonic, passphrase } => match passphrase {
309+ Some ( passphrase) => mnemonic. to_seed ( passphrase) ,
310+ None => mnemonic. to_seed ( "" ) ,
311+ } ,
296312 }
297313 } else {
298314 // Default to read or generate from the default location generate a seed file.
0 commit comments