Skip to main content
import cryptotools

# Set up the mnemonic and derivation path
mnemonic = "your mnemonic goes here"
path = "m/0'"

# Derive the private key and public key from the mnemonic and path
private_key = cryptotools.bip32.master_key(mnemonic.encode())
derived_private_key = private_key / path
public_key = derived_private_key.public_key()

# Generate the SegWit address from the public key
segwit_address = cryptotools.bech32.encode("bc", 0, cryptotools.hash160(public_key.to_bytes()))

print(segwit_address)

Note that this code assumes that you have already installed the cryptotools library using pip. Also, make sure to replace "your mnemonic goes here" with your actual mnemonic phrase, and "m/0'" with the actual derivation path you want to use.

As for disabling wallet saving in BitcoinLib, you can set the BitcoinSecret.Saving property to false to prevent the wallet from being saved to disk. Here is an example code snippet:

BitcoinSecret secret = new BitcoinSecret("your private key goes here");
secret.Saving = false;

Again, replace "your private key goes here" with your actual private key. This code assumes that you have already installed and imported the NBitcoin library, which BitcoinLib is based on.