1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-21 23:18:13 +00:00

feat(proto): add amount_unit to AuthorizeCoinJoin and SignTx

This commit is contained in:
Pavol Rusnak 2020-11-23 13:49:25 +01:00 committed by Tomas Susanka
parent 43ed13b323
commit 345ef52949
8 changed files with 63 additions and 10 deletions

View File

@ -31,6 +31,16 @@ enum OutputScriptType {
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
* @embed
@ -161,16 +171,17 @@ message VerifyMessage {
* @next Failure
*/
message SignTx {
required uint32 outputs_count = 1; // number of transaction outputs
required uint32 inputs_count = 2; // number of transaction inputs
optional string coin_name = 3 [default='Bitcoin']; // coin to use
optional uint32 version = 4 [default=1]; // transaction version
optional uint32 lock_time = 5 [default=0]; // transaction lock_time
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 uint32 version_group_id = 8; // only for Zcash, nVersionGroupId
optional uint32 timestamp = 9; // only for Peercoin
optional uint32 branch_id = 10; // only for Zcash, BRANCH_ID
required uint32 outputs_count = 1; // number of transaction outputs
required uint32 inputs_count = 2; // number of transaction inputs
optional string coin_name = 3 [default='Bitcoin']; // coin to use
optional uint32 version = 4 [default=1]; // transaction version
optional uint32 lock_time = 5 [default=0]; // transaction lock_time
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 uint32 version_group_id = 8; // only for Zcash, nVersionGroupId
optional uint32 timestamp = 9; // only for Peercoin
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')
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 AmountUnit amount_unit = 11 [default=BITCOIN]; // show amounts in
}

View 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

View File

@ -7,6 +7,7 @@ if __debug__:
from typing import Dict, List # noqa: F401
from typing_extensions import Literal # noqa: F401
EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4]
EnumTypeAmountUnit = Literal[0, 1, 2, 3]
except ImportError:
pass
@ -24,6 +25,7 @@ class AuthorizeCoinJoin(p.MessageType):
fee_per_anonymity: int = None,
coin_name: str = "Bitcoin",
script_type: EnumTypeInputScriptType = 0,
amount_unit: EnumTypeAmountUnit = 0,
) -> None:
self.address_n = address_n if address_n is not None else []
self.coordinator = coordinator
@ -31,6 +33,7 @@ class AuthorizeCoinJoin(p.MessageType):
self.fee_per_anonymity = fee_per_anonymity
self.coin_name = coin_name
self.script_type = script_type
self.amount_unit = amount_unit
@classmethod
def get_fields(cls) -> Dict:
@ -41,4 +44,5 @@ class AuthorizeCoinJoin(p.MessageType):
4: ('address_n', p.UVarintType, p.FLAG_REPEATED),
5: ('coin_name', p.UnicodeType, "Bitcoin"), # default=Bitcoin
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
}

View File

@ -6,6 +6,7 @@ if __debug__:
try:
from typing import Dict, List # noqa: F401
from typing_extensions import Literal # noqa: F401
EnumTypeAmountUnit = Literal[0, 1, 2, 3]
except ImportError:
pass
@ -25,6 +26,7 @@ class SignTx(p.MessageType):
version_group_id: int = None,
timestamp: int = None,
branch_id: int = None,
amount_unit: EnumTypeAmountUnit = 0,
) -> None:
self.outputs_count = outputs_count
self.inputs_count = inputs_count
@ -35,6 +37,7 @@ class SignTx(p.MessageType):
self.version_group_id = version_group_id
self.timestamp = timestamp
self.branch_id = branch_id
self.amount_unit = amount_unit
@classmethod
def get_fields(cls) -> Dict:
@ -48,4 +51,5 @@ class SignTx(p.MessageType):
8: ('version_group_id', p.UVarintType, None),
9: ('timestamp', p.UVarintType, None),
10: ('branch_id', p.UVarintType, None),
11: ('amount_unit', p.EnumType("AmountUnit", (0, 1, 2, 3)), 0), # default=BITCOIN
}

View 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

View File

@ -7,6 +7,7 @@ if __debug__:
from typing import Dict, List # noqa: F401
from typing_extensions import Literal # noqa: F401
EnumTypeInputScriptType = Literal[0, 1, 2, 3, 4]
EnumTypeAmountUnit = Literal[0, 1, 2, 3]
except ImportError:
pass
@ -24,6 +25,7 @@ class AuthorizeCoinJoin(p.MessageType):
fee_per_anonymity: int = None,
coin_name: str = "Bitcoin",
script_type: EnumTypeInputScriptType = 0,
amount_unit: EnumTypeAmountUnit = 0,
) -> None:
self.address_n = address_n if address_n is not None else []
self.coordinator = coordinator
@ -31,6 +33,7 @@ class AuthorizeCoinJoin(p.MessageType):
self.fee_per_anonymity = fee_per_anonymity
self.coin_name = coin_name
self.script_type = script_type
self.amount_unit = amount_unit
@classmethod
def get_fields(cls) -> Dict:
@ -41,4 +44,5 @@ class AuthorizeCoinJoin(p.MessageType):
4: ('address_n', p.UVarintType, p.FLAG_REPEATED),
5: ('coin_name', p.UnicodeType, "Bitcoin"), # default=Bitcoin
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
}

View File

@ -6,6 +6,7 @@ if __debug__:
try:
from typing import Dict, List # noqa: F401
from typing_extensions import Literal # noqa: F401
EnumTypeAmountUnit = Literal[0, 1, 2, 3]
except ImportError:
pass
@ -26,6 +27,7 @@ class SignTx(p.MessageType):
version_group_id: int = None,
timestamp: int = None,
branch_id: int = None,
amount_unit: EnumTypeAmountUnit = 0,
) -> None:
self.outputs_count = outputs_count
self.inputs_count = inputs_count
@ -37,6 +39,7 @@ class SignTx(p.MessageType):
self.version_group_id = version_group_id
self.timestamp = timestamp
self.branch_id = branch_id
self.amount_unit = amount_unit
@classmethod
def get_fields(cls) -> Dict:
@ -51,4 +54,5 @@ class SignTx(p.MessageType):
8: ('version_group_id', p.UVarintType, None),
9: ('timestamp', p.UVarintType, None),
10: ('branch_id', p.UVarintType, None),
11: ('amount_unit', p.EnumType("AmountUnit", (0, 1, 2, 3)), 0), # default=BITCOIN
}

View File

@ -299,6 +299,7 @@ from .WebAuthnRemoveResidentCredential import WebAuthnRemoveResidentCredential
from .WipeDevice import WipeDevice
from .WordAck import WordAck
from .WordRequest import WordRequest
from . import AmountUnit
from . import BackupType
from . import BinanceOrderSide
from . import BinanceOrderType