mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 06:48:16 +00:00
wallet/address: p2wsh get_address
This commit is contained in:
parent
b7e4fe02a9
commit
4c2dec55ed
@ -1,24 +1,20 @@
|
||||
from micropython import const
|
||||
from trezor import wire, ui
|
||||
from trezor import ui
|
||||
|
||||
|
||||
async def layout_get_address(ctx, msg):
|
||||
from trezor.messages.Address import Address
|
||||
from trezor.messages.InputScriptType import SPENDWITNESS
|
||||
from trezor.messages.FailureType import ProcessError
|
||||
from ..common import coins
|
||||
from ..common import seed
|
||||
from ..wallet.sign_tx import addresses
|
||||
|
||||
if msg.multisig:
|
||||
raise wire.FailureError(ProcessError, 'GetAddress.multisig is unsupported')
|
||||
|
||||
address_n = msg.address_n or ()
|
||||
coin_name = msg.coin_name or 'Bitcoin'
|
||||
coin = coins.by_name(coin_name)
|
||||
|
||||
node = await seed.derive_node(ctx, address_n)
|
||||
address = addresses.get_address(msg.script_type, coin, node)
|
||||
address = addresses.get_address(msg.script_type, coin, node, msg.multisig)
|
||||
|
||||
if msg.show_display:
|
||||
while True:
|
||||
|
@ -30,13 +30,18 @@ def get_address(script_type: InputScriptType, coin: CoinType, node, multisig=Non
|
||||
'Segwit not enabled on this coin')
|
||||
return address_p2wpkh(node.public_key(), coin.bech32_prefix)
|
||||
|
||||
elif script_type == InputScriptType.SPENDP2SHWITNESS: # p2wpkh using p2sh
|
||||
elif script_type == InputScriptType.SPENDP2SHWITNESS: # p2wpkh or p2wsh using p2sh
|
||||
if not coin.segwit or coin.address_type_p2sh is None:
|
||||
raise AddressError(FailureType.ProcessError,
|
||||
'Segwit not enabled on this coin')
|
||||
# p2wsh multisig
|
||||
if multisig is not None:
|
||||
return address_multisig_p2wsh_in_p2sh(multisig_get_pubkeys(multisig), multisig.m, coin.address_type_p2sh)
|
||||
|
||||
# p2wpkh
|
||||
return address_p2wpkh_in_p2sh(node.public_key(), coin.address_type_p2sh)
|
||||
|
||||
elif script_type == InputScriptType.SPENDMULTISIG: # multisig
|
||||
elif script_type == InputScriptType.SPENDMULTISIG: # p2sh multisig
|
||||
if multisig is None:
|
||||
raise AddressError(FailureType.ProcessError,
|
||||
'Multisig details required')
|
||||
|
Loading…
Reference in New Issue
Block a user