I’ve a script that generates a segwit v1 taproot compliant deal with and personal key. The script at the moment generates a regtest deal with however with minor tweaks it spits out a mainnet deal with. I feel the one distinction between a regtest and mainnet deal with is that for regtest you take away the “bc” from the start of the string and substitute it with “bcrt.” Non-public keys for regtest and mainnet look like the identical. That is my script:
def gen_segwit_v1():
privkey, pubkey = generate_bip340_key_pair()
program = pubkey.get_bytes()
model = 0x01
deal with = program_to_witness(model, program)
return privkey, pubkey, deal with
It creates a bitcoin segwit v1 pockets for utilization in taproot transactions. The issue is that my script depends on generate_bip340_key_pair()
and program_to_witness()
which I copied from https://github.com/bitcoinops/taproot-workshop/blob/grasp/test_framework/deal with.py.
That is what program_to_witness()
seems like:
def program_to_witness(model, program, predominant=False):
if (kind(program) is str):
program = hex_str_to_bytes(program)
assert 0 <= model <= 16
assert 2 <= len(program) <= 40
assert model > 0 or len(program) in [20, 32]
return segwit_addr.encode_segwit_address("bc" if predominant else "bcrt", model, program)
I need to generate a testnet Non-public Key and a testnet segwit v1 deal with. I feel the non-public keys for testnet and mainnet are totally different. I do not know the technical derivation formulation for bitcoin non-public keys, however for some cause, the entire testnet non-public keys I’ve generated begin with a “c” and the entire mainnet keys I’ve generated begin with a “Ok” or “L” . I am guessing the formulation is totally different for testnet and mainnet non-public keys.
So in conclusion, is there a easy method to generate a testnet non-public key and get the testnet taproot compliant segwit v1 deal with?