feat(common,core,python,tests): add tron.get_address support.

[no changelog]
This commit is contained in:
Jun Luo
2025-07-14 10:40:53 +08:00
committed by Suyash Shandilya
parent adacf4f659
commit 590d3e98b2
36 changed files with 898 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
check: messages.pb messages-bitcoin.pb messages-ble.pb messages-bootloader.pb messages-cardano.pb messages-common.pb messages-crypto.pb messages-debug.pb messages-ethereum.pb messages-management.pb messages-monero.pb messages-nem.pb messages-ripple.pb messages-stellar.pb messages-tezos.pb messages-eos.pb messages-solana.pb messages-definitions.pb
check: messages.pb messages-bitcoin.pb messages-ble.pb messages-bootloader.pb messages-cardano.pb messages-common.pb messages-crypto.pb messages-debug.pb messages-ethereum.pb messages-management.pb messages-monero.pb messages-nem.pb messages-ripple.pb messages-stellar.pb messages-tezos.pb messages-tron.pb messages-eos.pb messages-solana.pb messages-definitions.pb
%.pb: %.proto
protoc -I/usr/include -I. $< -o $@

View File

@@ -0,0 +1,107 @@
syntax = "proto2";
package hw.trezor.messages.tron;
// Sugar for easier handling in Java
option java_package = "com.satoshilabs.trezor.lib.protobuf";
option java_outer_classname = "TrezorMessageTron";
/**
* Request: Ask device for Tron address corresponding to address_n path
* @start
* @next TronAddress
* @next Failure
*/
message TronGetAddress {
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
optional bool show_display = 2; // Optionally show on display before sending the result
optional bool chunkify = 3; // display the address in chunks of 4 characters
}
/**
* Response: Contains Tron address derived from device private seed
* @end
*/
message TronAddress {
required string address = 1; // Tron address in base58_checked encoding
optional bytes mac = 2; // Address authentication code
}
/**
* Request: ask device to sign Stellar transaction
* @start
* @next StellarTxOpRequest
*/
message TronSignTx {
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
required bytes ref_block_bytes = 2; // The height of the transaction reference block, using the 6th to 8th (exclusive) bytes of the reference block height, a total of 2 bytes
required bytes ref_block_hash = 3; // The hash of the transaction reference block
required sint64 expiration = 4; // Transaction expiration time, beyond which the transaction will no longer be packed
optional bytes data = 5; // Transaction memo. (256 bytes maximum, this is a Trezor limitation, not a Tron protocol limitation)
required sint64 timestamp = 6; // Transaction timestamp, set as the transaction creation time
optional sint64 fee_limit = 7; // The maximum energy cost allowed for the execution of smart contract transactions. Only deploying and triggering smart contract transactions need to be set, others not
}
/**
* Response: device is ready for client to send the next operation
* @next TronTransferContract
*/
message TronContractRequest {
}
/**
* Request: ask device to confirm this operation type
* @next TronSignature
*/
message TronTransferContract {
// https://developers.tron.network/docs/tron-contracttype#2-transfercontract
required string owner_address = 1; // Sender's address, base58_checked encoding
required string to_address = 2; // Recipient's address, base58_checked encoding
required sint64 amount = 3; // Transfer amount (in SUN)
}
/**
* Response: signature for transaction
* @end
*/
message TronSignature {
required bytes signature = 1; // Signature of the transaction
}
/**
* TronRawTransaction and embedded messages are used to encode the Tron transaction, not for communication.
* @start
* @end
*/
// https://github.com/tronprotocol/protocol/blob/37bb922a9967bbbef1e84de1c9e5cda56a2d7998/core/Tron.proto#L431-L445
message TronRawTransaction {
required bytes ref_block_bytes = 1;
required bytes ref_block_hash = 4;
required uint64 expiration = 8;
optional bytes data = 10;
repeated TronRawContract contract = 11;
required uint64 timestamp = 14;
optional uint64 fee_limit = 18;
// https://github.com/tronprotocol/protocol/blob/37bb922a9967bbbef1e84de1c9e5cda56a2d7998/core/Tron.proto#L337-L385
message TronRawContract {
// https://github.com/tronprotocol/protocol/blob/37bb922a9967bbbef1e84de1c9e5cda56a2d7998/core/contract/balance_contract.proto#L32-L36
message TronRawTransferContract {
required bytes owner_address = 1;
required bytes to_address = 2;
required uint64 amount = 3;
}
message TronRawParameter {
required string type_url = 1; // e.g., "type.googleapis.com/protocol.TransferContract"
required bytes value = 2; // The serialized value of the contract parameter, e.g., TronTransferContract
}
required TronRawContractType type = 1;
required TronRawParameter parameter = 2;
enum TronRawContractType {
TransferContract = 1;
}
}
}

View File

@@ -348,6 +348,10 @@ enum MessageType {
MessageType_EvoluGetDelegatedIdentityKey = 2104 [(bitcoin_only) = true, (wire_in) = true];
MessageType_EvoluDelegatedIdentityKey = 2105 [(bitcoin_only) = true, (wire_out) = true];
// Tron
MessageType_TronGetAddress = 3000 [(wire_in) = true];
MessageType_TronAddress = 3001 [(wire_out) = true];
// Benchmark
MessageType_BenchmarkListNames = 9100 [(bitcoin_only) = true];
MessageType_BenchmarkNames = 9101 [(bitcoin_only) = true];

View File

@@ -0,0 +1,48 @@
{
"setup": {
"mnemonic": "all all all all all all all all all all all all",
"passphrase": ""
},
"tests": [
{
"parameters": {
"path": "m/44'/195'/0'/0/0"
},
"result": {
"address": "TY72iA3SBtrds3QLYsS7LwYfkzXwAXCRWT"
}
},
{
"parameters": {
"path": "m/44'/195'/0'/0/1"
},
"result": {
"address": "TFz2CJn9CJb8C4i1Gke3jmZX2fRMJxniH2"
}
},
{
"parameters": {
"path": "m/44'/195'/0'/0/2"
},
"result": {
"address": "TQSw9qVAigRwfgPdf7aW4wxbG9tFitexg2"
}
},
{
"parameters": {
"path": "m/44'/195'/1'/0/0"
},
"result": {
"address": "TNPgkSKfz2xS39fcyfrouz7QPbkkJaDLYv"
}
},
{
"parameters": {
"path": "m/44'/195'/2'/0/0"
},
"result": {
"address": "TUKx4Z56RMrYWzAu1qoiDSHQTNiSgYHYyF"
}
}
]
}

View File

@@ -149,6 +149,7 @@ ALTCOIN_PREFIXES = (
"solana",
"stellar",
"tezos",
"tron",
"u2f",
)