Closed lattice0 closed 3 years ago
Also tried with BIP49:
print("P2WSH: m/49'/0'/0'/0/"+str(x)+": " + (key/49./0./0./0/x).address('P2WSH'))
but same error
For BIP49 you want to use P2WPKH-P2SH
as an address type
You can’t generate P2WSH
, P2SH
or P2WSH-P2SH
addresses from a public key, those require a script as the name suggests
Is it possible to generate them from an Xprv or xpub?
xprv = Xprv.from_mnemonic(seed)
xpub = xprv.to_xpub()
print(xprv.to_xpub.to_address('P2WPKH'))
print(xpub.to_address('P2WPKH'))
dit not work
I'm trying to generate all possible addresses that the coldcard generates. I used:
def print_addresses(key, max_count):
for x in range(max_count):
print("P2PKH: m/44./0./0./0/"+str(x)+": " + (key/44./0./0./0/x).address('P2PKH')) #appears on coldcard
print("P2WPKH: m/44./0./0./0/"+str(x)+": " + (key/44./0./0./0/x).address('P2WPKH'))
print("P2PKH: m/49'/0'/0'/0/"+str(x)+": " + (key/49./0./0./0/x).address('P2PKH'))
print("P2WPKH: m/49'/0'/0'/0/"+str(x)+": " + (key/49./0./0./0/x).address('P2WPKH'))
print("P2WPKH-P2SH: m/49'/0'/0'/0/"+str(x)+": " + (key/49./0./0./0/x).address('P2WPKH-P2SH')) #appears
on coldcard
but only
P2PKH: m/44./0./0./0/0 P2WPKH-P2SH: m/49'/0'/0'/0/0
matched, there are still 2 sets of addresses that are not covered in this and I don't know. one set starts with bc... and the other 1. Do you know which type are they and how to generate from the seed + passphrase?
Ok, turns out this:
def print_addresses(key, max_count):
for x in range(max_count):
print("P2PKH: m/44./0./0./0/"+str(x)+": " + (key/44./0./0./0/x).address('P2PKH'))
print("P2WPKH: m/44./0./0./0/"+str(x)+": " + (key/44./0./0./0/x).address('P2WPKH'))
print("P2WPKH-P2SH: m/49./0./0./0/"+str(x)+": " + (key/49./0./0./0/x).address('P2WPKH-P2SH'))
print("P2PKH: m/49'/0'/0'/0/"+str(x)+": " + (key/49./0./0./0/x).address('P2PKH'))
print("P2WPKH: m/49'/0'/0'/0/"+str(x)+": " + (key/49./0./0./0/x).address('P2WPKH'))
print("P2WPKH-P2SH: m/49'/0'/0'/0/"+str(x)+": " + (key/49./0./0./0/x).address('P2WPKH-P2SH'))
print("P2PKH: m/84'/0'/0'/0/"+str(x)+": " + (key/84./0./0./0/x).address('P2PKH'))
print("P2WPKH: m/84'/0'/0'/0/"+str(x)+": " + (key/84./0./0./0/x).address('P2WPKH'))
print("P2WPKH-P2SH: m/84'/0'/0'/0/"+str(x)+": " + (key/84./0./0./0/x).address('P2WPKH-P2SH'))
generates the 3 sets, except the first set of addresses, for which I don't know how to generate. Do you have an idea? Also feel free to put these in the readme if you want to.
BIP44 —> P2PKH
BIP49 —> P2WPKH-P2SH
BIP84 —> P2WPKH
def print_addresses(key, max_count):
for x in range(max_count):
print("P2PKH: m/0/"+str(x)+": " + (key/0/x).address('P2PKH'))
print("P2WPKH: m/0/"+str(x)+": " + (key/0/x).address('P2WPKH'))
print("P2WPKH-P2SH: m/0/"+str(x)+": " + (key/0/x).address('P2WPKH-P2SH'))
print("P2PKH: m/44./0./0./0/"+str(x)+": " + (key/44./0./0./0/x).address('P2PKH'))
print("P2WPKH: m/44./0./0./0/"+str(x)+": " + (key/44./0./0./0/x).address('P2WPKH'))
print("P2WPKH-P2SH: m/49./0./0./0/"+str(x)+": " + (key/49./0./0./0/x).address('P2WPKH-P2SH'))
print("P2PKH: m/49'/0'/0'/0/"+str(x)+": " + (key/49./0./0./0/x).address('P2PKH'))
print("P2WPKH: m/49'/0'/0'/0/"+str(x)+": " + (key/49./0./0./0/x).address('P2WPKH'))
print("P2WPKH-P2SH: m/49'/0'/0'/0/"+str(x)+": " + (key/49./0./0./0/x).address('P2WPKH-P2SH'))
print("P2PKH: m/84'/0'/0'/0/"+str(x)+": " + (key/84./0./0./0/x).address('P2PKH'))
print("P2WPKH: m/84'/0'/0'/0/"+str(x)+": " + (key/84./0./0./0/x).address('P2WPKH'))
print("P2WPKH-P2SH: m/84'/0'/0'/0/"+str(x)+": " + (key/84./0./0./0/x).address('P2WPKH-P2SH'))
all of these appear on the coldcard now, thanks. The one missing was m/0/x
besides existing on the code, I cannot use
P2WSH
orP2WPKH_P2SH
or etc, like:print("P2WSH: m/44./0./0./0/"+str(x)+": " + (key/44./0./0./0/x).address('P2WSH'))
so I can generate addresses starting with 3.
Error: