mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-16 17:42:02 +00:00
feat(proto): add amount_unit to AuthorizeCoinJoin and SignTx
This commit is contained in:
parent
43ed13b323
commit
345ef52949
@ -31,6 +31,16 @@ enum OutputScriptType {
|
|||||||
PAYTOP2SHWITNESS = 5; // only for change output
|
PAYTOP2SHWITNESS = 5; // only for change output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit to be used when showing amounts on the display
|
||||||
|
*/
|
||||||
|
enum AmountUnit {
|
||||||
|
BITCOIN = 0; // BTC
|
||||||
|
MILLIBITCOIN = 1; // mBTC
|
||||||
|
MICROBITCOIN = 2; // uBTC
|
||||||
|
SATOSHI = 3; // sat
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of redeem script used in input
|
* Type of redeem script used in input
|
||||||
* @embed
|
* @embed
|
||||||
@ -161,16 +171,17 @@ message VerifyMessage {
|
|||||||
* @next Failure
|
* @next Failure
|
||||||
*/
|
*/
|
||||||
message SignTx {
|
message SignTx {
|
||||||
required uint32 outputs_count = 1; // number of transaction outputs
|
required uint32 outputs_count = 1; // number of transaction outputs
|
||||||
required uint32 inputs_count = 2; // number of transaction inputs
|
required uint32 inputs_count = 2; // number of transaction inputs
|
||||||
optional string coin_name = 3 [default='Bitcoin']; // coin to use
|
optional string coin_name = 3 [default='Bitcoin']; // coin to use
|
||||||
optional uint32 version = 4 [default=1]; // transaction version
|
optional uint32 version = 4 [default=1]; // transaction version
|
||||||
optional uint32 lock_time = 5 [default=0]; // transaction lock_time
|
optional uint32 lock_time = 5 [default=0]; // transaction lock_time
|
||||||
optional uint32 expiry = 6; // only for Decred and Zcash
|
optional uint32 expiry = 6; // only for Decred and Zcash
|
||||||
optional bool overwintered = 7 [deprecated=true]; // deprecated in 2.3.2, the field is not needed as it can be derived from `version`
|
optional bool overwintered = 7 [deprecated=true]; // deprecated in 2.3.2, the field is not needed as it can be derived from `version`
|
||||||
optional uint32 version_group_id = 8; // only for Zcash, nVersionGroupId
|
optional uint32 version_group_id = 8; // only for Zcash, nVersionGroupId
|
||||||
optional uint32 timestamp = 9; // only for Peercoin
|
optional uint32 timestamp = 9; // only for Peercoin
|
||||||
optional uint32 branch_id = 10; // only for Zcash, BRANCH_ID
|
optional uint32 branch_id = 10; // only for Zcash, BRANCH_ID
|
||||||
|
optional AmountUnit amount_unit = 11 [default=BITCOIN]; // show amounts in
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -535,4 +546,5 @@ message AuthorizeCoinJoin {
|
|||||||
repeated uint32 address_n = 4; // prefix of the BIP-32 path leading to the account (m / purpose' / coin_type' / account')
|
repeated uint32 address_n = 4; // prefix of the BIP-32 path leading to the account (m / purpose' / coin_type' / account')
|
||||||
optional string coin_name = 5 [default='Bitcoin']; // coin to use
|
optional string coin_name = 5 [default='Bitcoin']; // coin to use
|
||||||
optional InputScriptType script_type = 6 [default=SPENDADDRESS]; // used to distinguish between various address formats (non-segwit, segwit, etc.)
|
optional InputScriptType script_type = 6 [default=SPENDADDRESS]; // used to distinguish between various address formats (non-segwit, segwit, etc.)
|
||||||
|
optional AmountUnit amount_unit = 11 [default=BITCOIN]; // show amounts in
|
||||||
}
|
}
|
||||||
|
12
core/src/trezor/messages/AmountUnit.py
Normal file
12
core/src/trezor/messages/AmountUnit.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Automatically generated by pb2py
|
||||||
|
# fmt: off
|
||||||
|
if __debug__:
|
||||||
|
try:
|
||||||
|
from typing_extensions import Literal # noqa: F401
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
BITCOIN: Literal[0] = 0
|
||||||
|
MILLIBITCOIN: Literal[1] = 1
|
||||||
|
MICROBITCOIN: Literal[2] = 2
|
||||||
|
SATOSHI: Literal[3] = 3
|
@ -7,6 +7,7 @@ if __debug__:
|
|||||||
from typing import Dict, List # noqa: F401
|
from typing import Dict, List # noqa: F401
|
||||||
from typing_extensions import Literal # noqa: F401
|
from typing_extensions import Literal # noqa: F401
|
||||||
EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4]
|
EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4]
|
||||||
|
EnumTypeAmountUnit = Literal[0, 1, 2, 3]
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ class AuthorizeCoinJoin(p.MessageType):
|
|||||||
fee_per_anonymity: int = None,
|
fee_per_anonymity: int = None,
|
||||||
coin_name: str = "Bitcoin",
|
coin_name: str = "Bitcoin",
|
||||||
script_type: EnumTypeInputScriptType = 0,
|
script_type: EnumTypeInputScriptType = 0,
|
||||||
|
amount_unit: EnumTypeAmountUnit = 0,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.address_n = address_n if address_n is not None else []
|
self.address_n = address_n if address_n is not None else []
|
||||||
self.coordinator = coordinator
|
self.coordinator = coordinator
|
||||||
@ -31,6 +33,7 @@ class AuthorizeCoinJoin(p.MessageType):
|
|||||||
self.fee_per_anonymity = fee_per_anonymity
|
self.fee_per_anonymity = fee_per_anonymity
|
||||||
self.coin_name = coin_name
|
self.coin_name = coin_name
|
||||||
self.script_type = script_type
|
self.script_type = script_type
|
||||||
|
self.amount_unit = amount_unit
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_fields(cls) -> Dict:
|
def get_fields(cls) -> Dict:
|
||||||
@ -41,4 +44,5 @@ class AuthorizeCoinJoin(p.MessageType):
|
|||||||
4: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
4: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
5: ('coin_name', p.UnicodeType, "Bitcoin"), # default=Bitcoin
|
5: ('coin_name', p.UnicodeType, "Bitcoin"), # default=Bitcoin
|
||||||
6: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDADDRESS
|
6: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDADDRESS
|
||||||
|
11: ('amount_unit', p.EnumType("AmountUnit", (0, 1, 2, 3)), 0), # default=BITCOIN
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ if __debug__:
|
|||||||
try:
|
try:
|
||||||
from typing import Dict, List # noqa: F401
|
from typing import Dict, List # noqa: F401
|
||||||
from typing_extensions import Literal # noqa: F401
|
from typing_extensions import Literal # noqa: F401
|
||||||
|
EnumTypeAmountUnit = Literal[0, 1, 2, 3]
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ class SignTx(p.MessageType):
|
|||||||
version_group_id: int = None,
|
version_group_id: int = None,
|
||||||
timestamp: int = None,
|
timestamp: int = None,
|
||||||
branch_id: int = None,
|
branch_id: int = None,
|
||||||
|
amount_unit: EnumTypeAmountUnit = 0,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.outputs_count = outputs_count
|
self.outputs_count = outputs_count
|
||||||
self.inputs_count = inputs_count
|
self.inputs_count = inputs_count
|
||||||
@ -35,6 +37,7 @@ class SignTx(p.MessageType):
|
|||||||
self.version_group_id = version_group_id
|
self.version_group_id = version_group_id
|
||||||
self.timestamp = timestamp
|
self.timestamp = timestamp
|
||||||
self.branch_id = branch_id
|
self.branch_id = branch_id
|
||||||
|
self.amount_unit = amount_unit
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_fields(cls) -> Dict:
|
def get_fields(cls) -> Dict:
|
||||||
@ -48,4 +51,5 @@ class SignTx(p.MessageType):
|
|||||||
8: ('version_group_id', p.UVarintType, None),
|
8: ('version_group_id', p.UVarintType, None),
|
||||||
9: ('timestamp', p.UVarintType, None),
|
9: ('timestamp', p.UVarintType, None),
|
||||||
10: ('branch_id', p.UVarintType, None),
|
10: ('branch_id', p.UVarintType, None),
|
||||||
|
11: ('amount_unit', p.EnumType("AmountUnit", (0, 1, 2, 3)), 0), # default=BITCOIN
|
||||||
}
|
}
|
||||||
|
12
python/src/trezorlib/messages/AmountUnit.py
Normal file
12
python/src/trezorlib/messages/AmountUnit.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Automatically generated by pb2py
|
||||||
|
# fmt: off
|
||||||
|
if __debug__:
|
||||||
|
try:
|
||||||
|
from typing_extensions import Literal # noqa: F401
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
BITCOIN: Literal[0] = 0
|
||||||
|
MILLIBITCOIN: Literal[1] = 1
|
||||||
|
MICROBITCOIN: Literal[2] = 2
|
||||||
|
SATOSHI: Literal[3] = 3
|
@ -7,6 +7,7 @@ if __debug__:
|
|||||||
from typing import Dict, List # noqa: F401
|
from typing import Dict, List # noqa: F401
|
||||||
from typing_extensions import Literal # noqa: F401
|
from typing_extensions import Literal # noqa: F401
|
||||||
EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4]
|
EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4]
|
||||||
|
EnumTypeAmountUnit = Literal[0, 1, 2, 3]
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ class AuthorizeCoinJoin(p.MessageType):
|
|||||||
fee_per_anonymity: int = None,
|
fee_per_anonymity: int = None,
|
||||||
coin_name: str = "Bitcoin",
|
coin_name: str = "Bitcoin",
|
||||||
script_type: EnumTypeInputScriptType = 0,
|
script_type: EnumTypeInputScriptType = 0,
|
||||||
|
amount_unit: EnumTypeAmountUnit = 0,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.address_n = address_n if address_n is not None else []
|
self.address_n = address_n if address_n is not None else []
|
||||||
self.coordinator = coordinator
|
self.coordinator = coordinator
|
||||||
@ -31,6 +33,7 @@ class AuthorizeCoinJoin(p.MessageType):
|
|||||||
self.fee_per_anonymity = fee_per_anonymity
|
self.fee_per_anonymity = fee_per_anonymity
|
||||||
self.coin_name = coin_name
|
self.coin_name = coin_name
|
||||||
self.script_type = script_type
|
self.script_type = script_type
|
||||||
|
self.amount_unit = amount_unit
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_fields(cls) -> Dict:
|
def get_fields(cls) -> Dict:
|
||||||
@ -41,4 +44,5 @@ class AuthorizeCoinJoin(p.MessageType):
|
|||||||
4: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
4: ('address_n', p.UVarintType, p.FLAG_REPEATED),
|
||||||
5: ('coin_name', p.UnicodeType, "Bitcoin"), # default=Bitcoin
|
5: ('coin_name', p.UnicodeType, "Bitcoin"), # default=Bitcoin
|
||||||
6: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDADDRESS
|
6: ('script_type', p.EnumType("InputScriptType", (0, 1, 2, 3, 4)), 0), # default=SPENDADDRESS
|
||||||
|
11: ('amount_unit', p.EnumType("AmountUnit", (0, 1, 2, 3)), 0), # default=BITCOIN
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ if __debug__:
|
|||||||
try:
|
try:
|
||||||
from typing import Dict, List # noqa: F401
|
from typing import Dict, List # noqa: F401
|
||||||
from typing_extensions import Literal # noqa: F401
|
from typing_extensions import Literal # noqa: F401
|
||||||
|
EnumTypeAmountUnit = Literal[0, 1, 2, 3]
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -26,6 +27,7 @@ class SignTx(p.MessageType):
|
|||||||
version_group_id: int = None,
|
version_group_id: int = None,
|
||||||
timestamp: int = None,
|
timestamp: int = None,
|
||||||
branch_id: int = None,
|
branch_id: int = None,
|
||||||
|
amount_unit: EnumTypeAmountUnit = 0,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.outputs_count = outputs_count
|
self.outputs_count = outputs_count
|
||||||
self.inputs_count = inputs_count
|
self.inputs_count = inputs_count
|
||||||
@ -37,6 +39,7 @@ class SignTx(p.MessageType):
|
|||||||
self.version_group_id = version_group_id
|
self.version_group_id = version_group_id
|
||||||
self.timestamp = timestamp
|
self.timestamp = timestamp
|
||||||
self.branch_id = branch_id
|
self.branch_id = branch_id
|
||||||
|
self.amount_unit = amount_unit
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_fields(cls) -> Dict:
|
def get_fields(cls) -> Dict:
|
||||||
@ -51,4 +54,5 @@ class SignTx(p.MessageType):
|
|||||||
8: ('version_group_id', p.UVarintType, None),
|
8: ('version_group_id', p.UVarintType, None),
|
||||||
9: ('timestamp', p.UVarintType, None),
|
9: ('timestamp', p.UVarintType, None),
|
||||||
10: ('branch_id', p.UVarintType, None),
|
10: ('branch_id', p.UVarintType, None),
|
||||||
|
11: ('amount_unit', p.EnumType("AmountUnit", (0, 1, 2, 3)), 0), # default=BITCOIN
|
||||||
}
|
}
|
||||||
|
@ -299,6 +299,7 @@ from .WebAuthnRemoveResidentCredential import WebAuthnRemoveResidentCredential
|
|||||||
from .WipeDevice import WipeDevice
|
from .WipeDevice import WipeDevice
|
||||||
from .WordAck import WordAck
|
from .WordAck import WordAck
|
||||||
from .WordRequest import WordRequest
|
from .WordRequest import WordRequest
|
||||||
|
from . import AmountUnit
|
||||||
from . import BackupType
|
from . import BackupType
|
||||||
from . import BinanceOrderSide
|
from . import BinanceOrderSide
|
||||||
from . import BinanceOrderType
|
from . import BinanceOrderType
|
||||||
|
Loading…
Reference in New Issue
Block a user