Merge pull request #7693 from benma/bb02
bitbox02: bump dependency to v6.0.0, support sending to taproot
This commit is contained in:
@@ -4,4 +4,4 @@ safet>=0.1.5
|
||||
keepkey>=6.3.1
|
||||
btchip-python>=0.1.32
|
||||
ckcc-protocol>=0.7.7
|
||||
bitbox02>=5.2.0
|
||||
bitbox02>=6.0.0
|
||||
|
||||
@@ -485,23 +485,30 @@ class OnchainOutputType(Enum):
|
||||
P2SH = enum.auto()
|
||||
WITVER0_P2WPKH = enum.auto()
|
||||
WITVER0_P2WSH = enum.auto()
|
||||
WITVER1_P2TR = enum.auto()
|
||||
|
||||
|
||||
def address_to_hash(addr: str, *, net=None) -> Tuple[OnchainOutputType, bytes]:
|
||||
def address_to_payload(addr: str, *, net=None) -> Tuple[OnchainOutputType, bytes]:
|
||||
"""Return (type, pubkey hash / witness program) for 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_segwit_address(net.SEGWIT_HRP, addr)
|
||||
if witprog is not None:
|
||||
if witver != 0:
|
||||
raise BitcoinException(f"not implemented handling for witver={witver}")
|
||||
if len(witprog) == 20:
|
||||
return OnchainOutputType.WITVER0_P2WPKH, bytes(witprog)
|
||||
elif len(witprog) == 32:
|
||||
return OnchainOutputType.WITVER0_P2WSH, bytes(witprog)
|
||||
if witver == 0:
|
||||
if len(witprog) == 20:
|
||||
return OnchainOutputType.WITVER0_P2WPKH, bytes(witprog)
|
||||
elif len(witprog) == 32:
|
||||
return OnchainOutputType.WITVER0_P2WSH, bytes(witprog)
|
||||
else:
|
||||
raise BitcoinException(f"unexpected length for segwit witver=0 witprog: len={len(witprog)}")
|
||||
elif witver == 1:
|
||||
if len(witprog) == 32:
|
||||
return OnchainOutputType.WITVER1_P2TR, bytes(witprog)
|
||||
else:
|
||||
raise BitcoinException(f"unexpected length for segwit witver=1 witprog: len={len(witprog)}")
|
||||
else:
|
||||
raise BitcoinException(f"unexpected length for segwit witver=0 witprog: len={len(witprog)}")
|
||||
raise BitcoinException(f"not implemented handling for witver={witver}")
|
||||
addrtype, hash_160_ = b58_address_to_hash160(addr)
|
||||
if addrtype == net.ADDRTYPE_P2PKH:
|
||||
return OnchainOutputType.P2PKH, hash_160_
|
||||
|
||||
@@ -482,7 +482,7 @@ class BitBox02Client(HardwareClientBase):
|
||||
)
|
||||
)
|
||||
else:
|
||||
addrtype, pubkey_hash = bitcoin.address_to_hash(txout.address)
|
||||
addrtype, payload = bitcoin.address_to_payload(txout.address)
|
||||
if addrtype == OnchainOutputType.P2PKH:
|
||||
output_type = bitbox02.btc.P2PKH
|
||||
elif addrtype == OnchainOutputType.P2SH:
|
||||
@@ -491,6 +491,8 @@ class BitBox02Client(HardwareClientBase):
|
||||
output_type = bitbox02.btc.P2WPKH
|
||||
elif addrtype == OnchainOutputType.WITVER0_P2WSH:
|
||||
output_type = bitbox02.btc.P2WSH
|
||||
elif addrtype == OnchainOutputType.WITVER1_P2TR:
|
||||
output_type = bitbox02.btc.P2TR
|
||||
else:
|
||||
raise UserFacingException(
|
||||
"Received unsupported output type during transaction signing: {} is not supported by the BitBox02".format(
|
||||
@@ -500,7 +502,7 @@ class BitBox02Client(HardwareClientBase):
|
||||
outputs.append(
|
||||
bitbox02.BTCOutputExternal(
|
||||
output_type=output_type,
|
||||
output_hash=pubkey_hash,
|
||||
output_payload=payload,
|
||||
value=txout.value,
|
||||
)
|
||||
)
|
||||
@@ -628,7 +630,7 @@ class BitBox02_KeyStore(Hardware_KeyStore):
|
||||
|
||||
class BitBox02Plugin(HW_PluginBase):
|
||||
keystore_class = BitBox02_KeyStore
|
||||
minimum_library = (5, 2, 0)
|
||||
minimum_library = (6, 0, 0)
|
||||
DEVICE_IDS = [(0x03EB, 0x2403)]
|
||||
|
||||
SUPPORTED_XTYPES = ("p2wpkh-p2sh", "p2wpkh", "p2wsh", "p2wsh-p2sh")
|
||||
|
||||
Reference in New Issue
Block a user