BitBox02 Electrum plugin support
This commit adds support for the BitBox02 hardware wallet. It supports both single and multisig for the electrum gui wallet. To use the plugin a local installation of the BitBox02 python library is required. It can be found on PiPy under the name 'bitbox02' and can be installed from the bitbox02-firmware repository in the py/bitbox02 directory. All communication to and from the BitBox02 is noise encrypted, the keys required for this are stored in the wallet config file under the bitbox02 key. The BitBox02 registers a multisig configuration before allowing transaction signing. This multisig configuration includes the threshold, cosigner xpubs, keypath, a variable to indicate for mainnet and testnet, and a name that the user can choose during configuration registration. The user is asked to register the multisig configuration either during address verification or during transaction signing. The check the xpub of the BitBox02 for other hardware wallets, a button is added in the wallet info dialog. The wallet encryption key is fetched in a separate api call, requiring a slightly tweaked override version of the wallet encryption password.
This commit is contained in:
@@ -432,6 +432,21 @@ def address_to_script(addr: str, *, net=None) -> str:
|
||||
raise BitcoinException(f'unknown address type: {addrtype}')
|
||||
return script
|
||||
|
||||
def address_to_hash(addr: str, *, net=None) -> Tuple[int, bytes]:
|
||||
"""Return the pubkey hash / witness program of an address"""
|
||||
if net is None: net = constants.net
|
||||
if not is_address(addr, net=net):
|
||||
raise BitcoinException(f"invalid bitcoin address: {addr}")
|
||||
witver, witprog = segwit_addr.decode(net.SEGWIT_HRP, addr)
|
||||
if witprog is not None:
|
||||
if len(witprog) == 20:
|
||||
return WIF_SCRIPT_TYPES['p2wpkh'], bytes(witprog)
|
||||
return WIF_SCRIPT_TYPES['p2wsh'], bytes(witprog)
|
||||
addrtype, hash_160_ = b58_address_to_hash160(addr)
|
||||
if addrtype == net.ADDRTYPE_P2PKH:
|
||||
return WIF_SCRIPT_TYPES['p2pkh'], hash_160_
|
||||
return WIF_SCRIPT_TYPES['p2sh'], hash_160_
|
||||
|
||||
def address_to_scripthash(addr: str) -> str:
|
||||
script = address_to_script(addr)
|
||||
return script_to_scripthash(script)
|
||||
|
||||
Reference in New Issue
Block a user