segregated witness – The way to create SegWit handle from mnemonic in Python 3.8.10

0
169
segregated witness – The way to create SegWit handle from mnemonic in Python 3.8.10


import cryptotools

# Arrange the mnemonic and derivation path
mnemonic = "your mnemonic goes right here"
path = "m/0'"

# Derive the personal 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 handle from the general public key
segwit_address = cryptotools.bech32.encode("bc", 0, cryptotools.hash160(public_key.to_bytes()))

print(segwit_address)

Notice that this code assumes that you’ve got already put in the cryptotools library utilizing pip. Additionally, make sure that to switch “your mnemonic goes right here” together with your precise mnemonic phrase, and “m/0′” with the precise derivation path you wish to use.

As for disabling pockets saving in BitcoinLib, you possibly can set the BitcoinSecret.Saving property to false to stop the pockets from being saved to disk. Right here is an instance code snippet:

BitcoinSecret secret = new BitcoinSecret(“your personal key goes right here”);
secret.Saving = false;

Once more, change “your personal key goes right here” together with your precise personal key. This code assumes that you’ve got already put in and imported the NBitcoin library, which BitcoinLib relies on.

LEAVE A REPLY

Please enter your comment!
Please enter your name here