diff --git a/.github/workflows/prebuild.yml b/.github/workflows/prebuild.yml index 7a9aa2ab79..94deeec3b4 100644 --- a/.github/workflows/prebuild.yml +++ b/.github/workflows/prebuild.yml @@ -116,12 +116,12 @@ jobs: comment-author: 'github-actions[bot]' body-includes: cargolock-comment-${{ github.workflow }} - - name: Create comment - uses: peter-evans/create-or-update-comment@v4 - if: ${{ env.cargo_modified == '1' && steps.fc.outputs.comment-id == '' }} - with: - issue-number: ${{ github.event.pull_request.number }} - body: | - - ${{ env.CARGOLOCK_COMMENT }} - edit-mode: replace + # - name: Create comment + # uses: peter-evans/create-or-update-comment@v4 + # if: ${{ env.cargo_modified == '1' && steps.fc.outputs.comment-id == '' }} + # with: + # issue-number: ${{ github.event.pull_request.number }} + # body: | + # + # ${{ env.CARGOLOCK_COMMENT }} + # edit-mode: replace diff --git a/common/protob/Makefile b/common/protob/Makefile index f8df2d2d5d..309795d365 100644 --- a/common/protob/Makefile +++ b/common/protob/Makefile @@ -1,4 +1,4 @@ -check: messages.pb messages-binance.pb messages-bitcoin.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 +check: messages.pb messages-binance.pb messages-bitcoin.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-mintlayer.pb messages-mintlayer-enums.pb %.pb: %.proto protoc -I/usr/include -I. $< -o $@ diff --git a/common/protob/messages-management.proto b/common/protob/messages-management.proto index 170c02a841..95ad5510d3 100644 --- a/common/protob/messages-management.proto +++ b/common/protob/messages-management.proto @@ -166,6 +166,7 @@ message Features { Capability_Translations = 19 [(bitcoin_only) = true]; Capability_Brightness = 20 [(bitcoin_only) = true]; Capability_Haptic = 21 [(bitcoin_only) = true]; + Capability_Mintlayer = 22; } } diff --git a/common/protob/messages-mintlayer-enums.proto b/common/protob/messages-mintlayer-enums.proto new file mode 100644 index 0000000000..83bf53cab5 --- /dev/null +++ b/common/protob/messages-mintlayer-enums.proto @@ -0,0 +1,31 @@ +syntax = "proto2"; +package hw.trezor.messages.mintlayer; + +// Sugar for easier handling in Java +option java_package = "com.satoshilabs.trezor.lib.protobuf"; +option java_outer_classname = "TrezorMessageMintlayer"; + +/** +* Enum for Account Command type passed between the Python and Rust code +*/ +enum MintlayerAccountCommandType { + MINT_TOKENS = 0; + UNMINT_TOKENS = 1; + LOCK_TOKEN_SUPPLY = 2; + FREEZE_TOKEN = 3; + UNFREEZE_TOKEN = 4; + CHANGE_TOKEN_AUTHORITY = 5; + CONCLUDE_ORDER = 6; + FILL_ORDER = 7; + CHANGE_TOKEN_METADATA_URI = 8; +} + +/** +* Enum for Output time lock type passed between the Python and Rust code +*/ +enum MintlayerOutputTimeLockType { + UNTIL_HEIGHT = 0; + UNTIL_TIME = 1; + FOR_BLOCK_COUNT = 2; + FOR_SECONDS = 3; +} diff --git a/common/protob/messages-mintlayer.proto b/common/protob/messages-mintlayer.proto new file mode 100644 index 0000000000..84c1a74cc4 --- /dev/null +++ b/common/protob/messages-mintlayer.proto @@ -0,0 +1,481 @@ +syntax = "proto2"; +package hw.trezor.messages.mintlayer; + +// Sugar for easier handling in Java +option java_package = "com.satoshilabs.trezor.lib.protobuf"; +option java_outer_classname = "TrezorMessageMintlayer"; + +/** +* Chain Type used to determine the coin name and bech32 prefixes +*/ +enum MintlayerChainType { + Mainnet = 1; + Testnet = 2; + Regtest = 3; + Signet = 4; +} + +/** + * Request: Ask the device for a Mintlayer address. + * @start + * @next MintlayerAddress + * @next Failure + */ +message MintlayerGetAddress { + repeated uint32 address_n = 1; // BIP-32-style path to derive the key from master node + required MintlayerChainType chain_type = 2; // Chain type to use + optional bool show_display = 3; // optionally prompt for confirmation on trezor display + optional bool chunkify = 4; // display the address in chunks of 4 characters +} + +/** + * Response: A Mintlayer address. + * @end + */ +message MintlayerAddress { + required string address = 1; // prefixed bech32 Mintlayer address +} + +/** + * Request: Ask device for a public key corresponding to address_n path. + * @start + * @next MintlayerPublicKey + */ +message MintlayerGetPublicKey { + repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node + required MintlayerChainType chain_type = 2; // Chain type to use + optional bool show_display = 3; // optionally prompt for confirmation on trezor display +} + +/** + * Response: A public key corresponding to address_n path. + * @end + */ +message MintlayerPublicKey { + required bytes public_key = 1; + required bytes chain_code = 2; +} + +/** +* Type of information required by transaction signing process +*/ +enum MintlayerAddressType { + PUBLIC_KEY = 1; + PUBLIC_KEY_HASH = 2; +} + +/** + * Request: Ask device to sign a message + * @start + * @next Success + * @next Failure + */ +message MintlayerSignMessage { + repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node + required MintlayerChainType chain_type = 2; // Chain type to use + required MintlayerAddressType address_type = 3; // Address type to use when signing the message Public key or Public key hash + required bytes message = 4; // message to sign +} + +/** + * Request: Ask device to sign transaction + * @start + * @next MintlayerTxRequest + * @next Failure + */ +message MintlayerSignTx { + required uint32 outputs_count = 1; // number of transaction outputs + required uint32 inputs_count = 2; // number of transaction inputs + required MintlayerChainType chain_type = 3; // Chain type to use + optional uint32 version = 4 [default=1]; // transaction version + optional bool chunkify = 5; // display addresses in chunks of 4 characters +} + +/** + * Response: Device asks for information for signing transaction or returns the last result + * If input_request or output_request is set, device awaits MintlayerTxAck matching the request type. + * @end + * @next MintlayerTxAck + */ +message MintlayerTxRequest { + optional MintlayerTxInputRequest input_request = 1; // request for additional data for an input + optional MintlayerTxOutputRequest output_request = 2; // request for additional data for an output + optional MintlayerTxSigningResult signing_finished = 3; // serialized data containing the signatures + + /** + * Request for additional data for a tx input + */ + message MintlayerTxInputRequest { + required uint32 input_index = 1; // index for the requested input + } + + /** + * Request for additional data for a tx output + */ + message MintlayerTxOutputRequest { + required uint32 output_index = 1; // index for the requested output + optional bytes tx_hash = 2; // transaction hash for the specified output or none for the current transaction that is being signed + } + /** + * Structure representing a single signature + */ + message MintlayerSignature { + required bytes signature = 1; // a single signature + optional uint32 multisig_idx = 2; // in case of multisig the index of the key + } + /** + * Structure representing all of the signatures for a single input, can be multiple for a multisig address + */ + message MintlayerSignaturesForInput { + required uint32 input_index = 1; // 'signatures' field contains signed input of this index + repeated MintlayerSignature signatures = 2; // all signatures for an input + } + /** + * Structure representing serialized data + */ + message MintlayerTxSigningResult { + repeated MintlayerSignaturesForInput signatures = 1; // signatures for all signed inputs + // TODO: add serialized transaction + } +} + + +/** +* Enum for UTXO type used by MintlayerUtxoTxInput +*/ +enum MintlayerUtxoType { + TRANSACTION = 0; + BLOCK = 1; +} + +/** Data type for an address + * @embed + */ +message MintlayerAddressPath { + repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node + optional uint32 multisig_idx = 2; // in case of a multisig the key index +} + +/** Data type for transaction UTXO input to be signed. + * + * @embed + */ +message MintlayerUtxoTxInput { + repeated MintlayerAddressPath addresses = 1; // 0 or more addresses for which the corresponding private keys will be used to sign the transaction + required bytes prev_hash = 2; // hash of previous transaction output to spend by this input + required uint32 prev_index = 3; // index of previous output to spend + required MintlayerUtxoType type = 4; // source type of the utxo (Transaction or BlockReward) +} + +/** Data type for transaction Account input to be signed. + * + * @embed + */ +message MintlayerAccountTxInput { + repeated MintlayerAddressPath addresses = 1; // 0 or more addresses for which the corresponding private keys will be used to sign the transaction + required uint64 nonce = 2; // incremental account nonce + optional MintlayerAccountSpendingDelegationBalance delegation_balance = 3; // spend from a delegation balance +} + +/** Data type for account spending from a Delegation Balance + * @embed + */ +message MintlayerAccountSpendingDelegationBalance { + required string delegation_id = 1; // the delegation id of the account in bech32 encoding + required bytes amount = 2; // amount of coins to spend +} + +/** Data type for transaction Account Command input to be signed. + * + * @embed + */ +message MintlayerAccountCommandTxInput { + repeated MintlayerAddressPath addresses = 1; // 0 or more addresses for which the corresponding private keys will be used to sign the transaction + required uint64 nonce = 2; // incremental account nonce + optional MintlayerMintTokens mint = 3; // mint tokens + optional MintlayerUnmintTokens unmint = 4; // unmint tokens + optional MintlayerLockTokenSupply lock_token_supply = 5; // lock token supply + optional MintlayerFreezeToken freeze_token = 6; // freeze token + optional MintlayerUnfreezeToken unfreeze_token = 7; // unfreeze token + optional MintlayerChangeTokenAuthority change_token_authority = 8; // change token authority + optional MintlayerConcludeOrder conclude_order = 9; // conclude an order + optional MintlayerFillOrder fill_order = 10; // fill an order + optional MintlayerChangeTokenMetadataUri change_token_metadata_uri = 11; // change token metadata uri +} + +/** Data type for account command Mint tokens + * @embed + */ +message MintlayerMintTokens { + required string token_id = 1; // token id in bech32 encoding + required bytes amount = 2; // amount of tokens to mint +} + +/** Data type for account command Unmint tokens + * @embed + */ +message MintlayerUnmintTokens { + required string token_id = 1; // token id in bech32 encoding +} + +/** Data type for account command Lock token supply + * @embed + */ +message MintlayerLockTokenSupply { + required string token_id = 1; // token id in bech32 encoding +} + +/** Data type for account command Freeze token + * @embed + */ +message MintlayerFreezeToken { + required string token_id = 1; // token id in bech32 encoding + required bool is_token_unfreezable = 2; // is unfreezable after freezing it +} + +/** Data type for account command Unfreeze token + * @embed + */ +message MintlayerUnfreezeToken { + required string token_id = 1; // token id in bech32 encoding +} + +/** Data type for account command Change token authority + * @embed + */ +message MintlayerChangeTokenAuthority { + required string token_id = 1; // token id in bech32 encoding + required string destination = 2; // destination for the new authority in bech32 encoding +} + +/** Data type for account command Conclude order + * @embed + */ +message MintlayerConcludeOrder { + required string order_id = 1; // order id in bech32 encoding + required MintlayerOutputValue filled_ask_amount = 2; // the already filled ask amount + required MintlayerOutputValue give_balance = 3; // the remaining give balance of the order +} + +/** Data type for account command Fill order + * @embed + */ +message MintlayerFillOrder { + required string order_id = 1; // order id in bech32 encoding + required bytes amount = 2; // amount in atoms corresponds to the order's ask currency + required string destination = 3; // the destination in bech32 encoding + required MintlayerOutputValue ask_balance = 4; // the remaining ask balance of the order + required MintlayerOutputValue give_balance = 5; // the remaining give balance of the order +} + +/** Data type for account command Change token metadata uri + * @embed + */ +message MintlayerChangeTokenMetadataUri { + required string token_id = 1; // token id in bech32 encoding + required bytes metadata_uri = 2; // new metadata uri +} + + +/** Data type for output value information for the token + * @embed + */ +message MintlayerTokenOutputValue { + required string token_id = 1; // token id in bech32 encoding + required bytes token_ticker = 2; // the token ticker + required uint32 number_of_decimals = 3; // the number of decimals for the token +} + +/** Data type for output value coins or token + * @embed + */ +message MintlayerOutputValue { + required bytes amount = 1; // lock until block height + optional MintlayerTokenOutputValue token = 2; // optional token info +} + +/** Data type for transaction Transfer output to be signed. + * @embed + */ +message MintlayerTransferTxOutput { + required string address = 1; // destination address in bech32 encoding + required MintlayerOutputValue value = 2; // amount to spend in atoms for coin or token +} + +/** Data type for time lock of an output + * @embed + */ +message MintlayerOutputTimeLock { + optional uint64 until_height = 1; // lock until block height + optional uint64 until_time = 2; // lock until time + optional uint64 for_block_count = 3; // lock for number of blocks + optional uint64 for_seconds = 4; // lock for number of seconds +} + +/** Data type for transaction Lock then transfer output to be signed. + * @embed + */ +message MintlayerLockThenTransferTxOutput { + required string address = 1; // destination address in bech32 encoding + required MintlayerOutputValue value = 2; // amount to spend in atoms for coin or token + required MintlayerOutputTimeLock lock = 3; // output lock +} + +/** Data type for transaction Burn output to be signed. + * @embed + */ +message MintlayerBurnTxOutput { + required MintlayerOutputValue value = 1; // amount to burn in atoms for coin or token +} + +/** Data type for transaction Create stake pool output to be signed. + * @embed + */ +message MintlayerCreateStakePoolTxOutput { + required string pool_id = 1; // the pool id in bech32 encoding + required bytes pledge = 2; // the pledge amount + required string staker = 3; // the staker destination address in bech32 encoding + required string vrf_public_key = 4; // the VRF public key address in bech32 encoding + required string decommission_key = 5; // the decommission key in bech32 encoding + required uint32 margin_ratio_per_thousand = 6; // the margin ratio per thousand + required bytes cost_per_block = 7; // the cost per block +} + +/** Data type for transaction Produce block from stake output to be signed. + * @embed + */ +message MintlayerProduceBlockFromStakeTxOutput { + required string destination = 1; // the staker destination address in bech32 encoding + required string pool_id = 2; // the pool id in bech32 encoding + required bytes staker_balance = 3; // the current staker balance of the pool +} + +/** Data type for transaction Create delegation id output to be signed. + * @embed + */ +message MintlayerCreateDelegationIdTxOutput { + required string destination = 1; // the delegation owner destination address in bech32 encoding + required string pool_id = 2; // the pool id in bech32 encoding +} + +/** Data type for transaction Delegate staking output to be signed. + * @embed + */ +message MintlayerDelegateStakingTxOutput { + required bytes amount = 1; // the amount to delegate + required string delegation_id = 2; // the delegation id in bech32 encoding +} + +/** +* Enum for Token total supply used by MintlayerTokenTotalSupply +*/ +enum MintlayerTokenTotalSupplyType { + FIXED = 0; + LOCKABLE = 1; + UNLIMITED = 2; +} + +/** Data type for Total token supply + * @embed + */ +message MintlayerTokenTotalSupply { + required MintlayerTokenTotalSupplyType type = 1; // the type of total token supply + optional bytes fixed_amount = 2; // optional amount in case of fixed total token supply +} + +/** Data type for transaction Issue fungible token output to be signed. + * @embed + */ +message MintlayerIssueFungibleTokenTxOutput { + required bytes token_ticker = 1; // the token ticker + required uint32 number_of_decimals = 2; // the number of decimals for the token + required bytes metadata_uri = 3; // the metadata uri + required MintlayerTokenTotalSupply total_supply = 4; // the total supply limit + required string authority = 5; // the token authority destination address in bech32 encoding + required bool is_freezable = 6; // if the token freezable or not +} + +/** Data type for transaction Issue NFT output to be signed. + * @embed + */ +message MintlayerIssueNftTxOutput { + required string token_id = 1; // the token id in bech32 encoding + required string destination = 2; // the NFT authority destination address in bech32 encoding + optional string creator = 3; // the NFT creator destination address in bech32 encoding + required bytes name = 4; // the NFT name + required bytes description = 5; // the NFT description + required bytes ticker = 6; // the NFT ticker + optional bytes icon_uri = 7; // the NFT icon uri + optional bytes additional_metadata_uri = 8; // the NFT additional metadata uri + optional bytes media_uri = 9; // the NFT media uri + required bytes media_hash = 10; // the NFT media hash +} + +/** Data type for transaction Data deposit output to be signed. + * @embed + */ +message MintlayerDataDepositTxOutput { + required bytes data = 1; // the data to be deposited +} + +/** Data type for transaction HTLC output to be signed. + * @embed + */ +message MintlayerHtlcTxOutput { + required MintlayerOutputValue value = 1; // amount to transfer for coin or token + required bytes secret_hash = 2; // the hash of the exchanged secret + required string spend_key = 3; // the key that can spend the HTLC given the secret in bech32 encoding + required MintlayerOutputTimeLock refund_timelock = 4; // time lock + required string refund_key = 5; // the key for a refund after the time lock has expired in bech32 encoding +} + +/** Data type for transaction output to be signed. + * @embed + */ +message MintlayerCreateOrderTxOutput { + required string conclude_key = 1; // The key that can authorize conclusion of the order in bech32 encoding + required MintlayerOutputValue ask = 2; // ask value of the order for coin or token + required MintlayerOutputValue give = 3; // give value of the order for coin or token +} + +/** + * Request: Data about input or output to be signed. + * + * @next MintlayerTxRequest + */ +message MintlayerTxAck { + optional MintlayerTxInput input = 1; // Ack response for an input + optional MintlayerTxOutput output = 2; // Ack response for an output + + /** + * Request: Data about input to be signed. + * + * @next MintlayerTxRequest + */ + message MintlayerTxInput { + optional MintlayerUtxoTxInput utxo = 1; // UTXO input + optional MintlayerAccountTxInput account = 2; // account spending input + optional MintlayerAccountCommandTxInput account_command = 3; // account command input + } + + /** + * Request: Data about output to be signed. + * + * @next MintlayerTxRequest + */ + message MintlayerTxOutput { + optional MintlayerTransferTxOutput transfer = 1; // transfer output + optional MintlayerLockThenTransferTxOutput lock_then_transfer = 2; // lock then transfer output + optional MintlayerBurnTxOutput burn = 3; // burn output + optional MintlayerCreateStakePoolTxOutput create_stake_pool = 4; // create stake pool output + optional MintlayerProduceBlockFromStakeTxOutput produce_block_from_stake = 5; // create block from stake output + optional MintlayerCreateDelegationIdTxOutput create_delegation_id = 6; // create delegation Id output + optional MintlayerDelegateStakingTxOutput delegate_staking = 7; // delegate staking output + optional MintlayerIssueFungibleTokenTxOutput issue_fungible_token = 8; // issue fungible token output + optional MintlayerIssueNftTxOutput issue_nft = 9; // issue NFT output + optional MintlayerDataDepositTxOutput data_deposit = 10; // data deposit output + optional MintlayerHtlcTxOutput htlc = 11; // HTLC output + optional MintlayerCreateOrderTxOutput create_order = 12; // Create order output + } +} + diff --git a/common/protob/messages.proto b/common/protob/messages.proto index ae7fdfda59..ea50a49c7a 100644 --- a/common/protob/messages.proto +++ b/common/protob/messages.proto @@ -329,4 +329,14 @@ enum MessageType { MessageType_BenchmarkNames = 9101 [(bitcoin_only) = true]; MessageType_BenchmarkRun = 9102 [(bitcoin_only) = true]; MessageType_BenchmarkResult = 9103 [(bitcoin_only) = true]; + + // Mintlayer + MessageType_MintlayerGetAddress = 10000 [(wire_in) = true]; + MessageType_MintlayerAddress = 10001 [(wire_out) = true]; + MessageType_MintlayerGetPublicKey = 10002 [(wire_in) = true]; + MessageType_MintlayerPublicKey = 10003 [(wire_out) = true]; + MessageType_MintlayerSignMessage = 10004 [(wire_in) = true]; + MessageType_MintlayerSignTx = 10005 [(wire_in) = true]; + MessageType_MintlayerTxRequest = 10006 [(wire_out) = true]; + MessageType_MintlayerTxAck = 10007 [(wire_in) = true]; } diff --git a/core/.changelog.d/noissue.added b/core/.changelog.d/noissue.added new file mode 100644 index 0000000000..c62ae1f8e7 --- /dev/null +++ b/core/.changelog.d/noissue.added @@ -0,0 +1 @@ +Added new messages and handles for Mintlayer coin diff --git a/core/CHANGELOG.T2B1.md b/core/CHANGELOG.T2B1.md index 1506cbda91..ff697bd895 100644 --- a/core/CHANGELOG.T2B1.md +++ b/core/CHANGELOG.T2B1.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [2.8.7-Mintlayer] (7th February 2025) + +### Added +- Added new messages and handles for Mintlayer coin [#noissue] + ## [2.8.7] (22th January 2025) ### Added diff --git a/core/CHANGELOG.T2T1.md b/core/CHANGELOG.T2T1.md index ebf49b8603..0411483ab9 100644 --- a/core/CHANGELOG.T2T1.md +++ b/core/CHANGELOG.T2T1.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [2.8.7-Mintlayer] (7th February 2025) + +### Added +- Added new messages and handles for Mintlayer coin [#noissue] + ## [2.8.7] (22th January 2025) ### Added diff --git a/core/CHANGELOG.T3B1.md b/core/CHANGELOG.T3B1.md index 2702bd3121..2da556e45b 100644 --- a/core/CHANGELOG.T3B1.md +++ b/core/CHANGELOG.T3B1.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [2.8.7-Mintlayer] (7th February 2025) + +### Added +- Added new messages and handles for Mintlayer coin [#noissue] + ## [2.8.7] (22th January 2025) ### Added diff --git a/core/CHANGELOG.T3T1.md b/core/CHANGELOG.T3T1.md index 7c7482f868..a238389531 100644 --- a/core/CHANGELOG.T3T1.md +++ b/core/CHANGELOG.T3T1.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [2.8.7-Mintlayer] (7th February 2025) + +### Added +- Added new messages and handles for Mintlayer coin [#noissue] + ## [2.8.7] (22th January 2025) ### Added diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 1c122efd85..b1f1e5fdeb 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [2.8.7-Mintlayer] (7th February 2025) + +### Added +- Added new messages and handles for Mintlayer coin [#noissue] + ## [2.8.7] (22th January 2025) ### Added diff --git a/core/SConscript.firmware b/core/SConscript.firmware index 74c3073415..a31bd81091 100644 --- a/core/SConscript.firmware +++ b/core/SConscript.firmware @@ -88,6 +88,7 @@ SOURCE_MOD += [ 'embed/upymod/modtrezorcrypto/crc.c', 'embed/upymod/modtrezorcrypto/modtrezorcrypto.c', 'embed/upymod/modtrezorcrypto/rand.c', + 'embed/upymod/modtrezormintlayer/modtrezormintlayer.c', ] SOURCE_MOD_CRYPTO += [ 'vendor/trezor-crypto/address.c', @@ -606,6 +607,7 @@ if FROZEN: SOURCE_PY_DIR + 'trezor/enums/Stellar*.py', SOURCE_PY_DIR + 'trezor/enums/Tezos*.py', SOURCE_PY_DIR + 'trezor/enums/Zcash*.py', + SOURCE_PY_DIR + 'trezor/enums/Mintlayer*.py', ]) ) @@ -682,6 +684,10 @@ if FROZEN: SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/zcash/*.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/mintlayer/*.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/mintlayer/sign_tx/*.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Mintlayer*.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/webauthn/*.py')) if TREZOR_MODEL == "T": @@ -785,7 +791,7 @@ def cargo_build(): f'--target-dir=../../build/firmware/rust', '--no-default-features', '--features ' + ','.join(features), - '-Z build-std=core', + '-Z build-std=core,alloc', '-Z build-std-features=panic_immediate_abort', ] diff --git a/core/SConscript.unix b/core/SConscript.unix index e4f1ca56b0..8836594c5e 100644 --- a/core/SConscript.unix +++ b/core/SConscript.unix @@ -85,6 +85,7 @@ SOURCE_MOD += [ 'embed/upymod/trezorobj.c', 'embed/upymod/modtrezorcrypto/crc.c', 'embed/upymod/modtrezorcrypto/modtrezorcrypto.c', + 'embed/upymod/modtrezormintlayer/modtrezormintlayer.c', ] SOURCE_MOD_CRYPTO += [ 'vendor/trezor-crypto/address.c', @@ -661,6 +662,7 @@ if FROZEN: SOURCE_PY_DIR + 'trezor/enums/Stellar*.py', SOURCE_PY_DIR + 'trezor/enums/Tezos*.py', SOURCE_PY_DIR + 'trezor/enums/Zcash*.py', + SOURCE_PY_DIR + 'trezor/enums/Mintlayer*.py', ]) ) @@ -739,6 +741,10 @@ if FROZEN: SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/zcash/*.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/mintlayer/*.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/mintlayer/sign_tx/*.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Mintlayer*.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/webauthn/*.py')) if TREZOR_MODEL == "T": diff --git a/core/embed/rust/Cargo.lock b/core/embed/rust/Cargo.lock index 70ce5e4281..1527e92926 100644 --- a/core/embed/rust/Cargo.lock +++ b/core/embed/rust/Cargo.lock @@ -1,6 +1,15 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] [[package]] name = "alloc-traits" @@ -8,6 +17,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b2d54853319fd101b8dd81de382bcbf3e03410a64d8928bbee85a3e7dcde483" +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + [[package]] name = "autocfg" version = "1.1.0" @@ -16,29 +31,35 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bindgen" -version = "0.62.0" +version = "0.69.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6720a8b7b2d39dd533285ed438d458f65b31b5c257e6ac7bb3d7e82844dd722" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" dependencies = [ "bitflags", "cexpr", "clang-sys", + "itertools", "lazy_static", "lazycell", - "peeking_take_while", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn", + "syn 2.0.61", ] [[package]] name = "bitflags" -version = "1.3.2" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "byte-slice-cast" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "byteorder" @@ -48,9 +69,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cc" -version = "1.0.70" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0" +checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" [[package]] name = "cexpr" @@ -93,6 +114,18 @@ dependencies = [ "num-traits", ] +[[package]] +name = "either" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "glob" version = "0.3.0" @@ -108,6 +141,12 @@ dependencies = [ "byteorder", ] +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + [[package]] name = "heapless" version = "0.8.0" @@ -119,6 +158,42 @@ dependencies = [ "ufmt-write", ] +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.6" @@ -139,9 +214,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.102" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "libloading" @@ -161,9 +236,9 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "memchr" -version = "2.4.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "minimal-lexical" @@ -189,14 +264,25 @@ checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.61", ] [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", "libm", @@ -211,16 +297,43 @@ dependencies = [ ] [[package]] -name = "peeking_take_while" -version = "0.1.2" +name = "parity-scale-codec" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" +dependencies = [ + "arrayvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit", +] [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] @@ -231,27 +344,41 @@ version = "1.8.0" [[package]] name = "quote" -version = "1.0.9" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] [[package]] name = "regex" -version = "1.5.6" +version = "1.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ + "aho-corasick", + "memchr", "regex-syntax", ] [[package]] name = "regex-syntax" -version = "0.6.26" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "rustc-hash" @@ -259,6 +386,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustversion" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" + [[package]] name = "ryu" version = "1.0.13" @@ -267,9 +400,23 @@ checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "serde" -version = "1.0.160" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" +checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.201" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.61", +] [[package]] name = "serde_json" @@ -309,6 +456,28 @@ dependencies = [ "alloc-traits", ] +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.61", +] + [[package]] name = "syn" version = "1.0.109" @@ -320,6 +489,45 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" + +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "trezor-common" +version = "1.0.2" +source = "git+https://github.com/mintlayer/mintlayer-core?branch=master#5e6bb4778bb9e1c02ec3fb2662aac4b471cc4d58" +dependencies = [ + "num-derive 0.4.2", + "num-traits", + "parity-scale-codec", + "strum", +] + [[package]] name = "trezor-tjpgdec" version = "0.1.0" @@ -334,13 +542,15 @@ dependencies = [ "easer", "glob", "heapless", - "num-derive", + "num-derive 0.3.3", "num-traits", "pareen", + "parity-scale-codec", "qrcodegen", "serde_json", "spin", "static-alloc", + "trezor-common", "trezor-tjpgdec", "ufmt", "unsize", @@ -366,7 +576,7 @@ checksum = "d337d3be617449165cb4633c8dece429afd83f84051024079f97ad32a9663716" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -412,6 +622,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + [[package]] name = "without-alloc" version = "0.2.2" diff --git a/core/embed/rust/Cargo.toml b/core/embed/rust/Cargo.toml index 83ecdc4b6e..82f95bfd47 100644 --- a/core/embed/rust/Cargo.toml +++ b/core/embed/rust/Cargo.toml @@ -62,7 +62,8 @@ test = [ "ui_empty_lock", "universal_fw", ] -universal_fw = [] +universal_fw = ["mintlayer"] +mintlayer = ["dep:ml_common", "dep:parity-scale-codec"] [lib] crate-type = ["staticlib"] @@ -94,6 +95,10 @@ trezor-tjpgdec = { version = "0.1.0", path = "../../../rust/trezor-tjpgdec" } ufmt = "0.2.0" zeroize = { version = "1.7.0", default-features = false, optional = true } +# minlayer +parity-scale-codec = { version = "3.1", default-features = false, features = ["derive", "chain-error"], optional = true } +ml_common = { git = "https://github.com/mintlayer/mintlayer-core", package = "trezor-common", branch = "master", optional = true } + # Runtime dependencies [dependencies.cty] @@ -136,7 +141,7 @@ features = ["libm"] # Build dependencies [build-dependencies.bindgen] -version = "0.62.0" +version = "0.69.4" default_features = false features = ["runtime"] diff --git a/core/embed/rust/mintlayer.h b/core/embed/rust/mintlayer.h new file mode 100644 index 0000000000..ed020f2a80 --- /dev/null +++ b/core/embed/rust/mintlayer.h @@ -0,0 +1,133 @@ +#include "common.h" + +uint32_t mintlayer_screen_fatal_error_rust(const char* title, const char* msg, + const char* footer); + +typedef enum { + WrongHashSize = 1, + InvalidUtxoType = 2, + InvalidAmount = 3, + InvalidAccountCommand = 4, + InvalidDestination = 5, + InvalidIsTokenUnfreezable = 6, + InvalidIsTokenFreezable = 7, + InvalidVrfPublicKey = 8, + InvalidPublicKey = 9, + InvalidOutputTimeLock = 10, + InvalidTokenTotalSupply = 11, +} MintlayerErrorCode; + +typedef union { + uint32_t len; + MintlayerErrorCode err; +} LenOrError; + +typedef struct { + const uint8_t* data; + LenOrError len_or_err; +} ByteArray; + +ByteArray mintlayer_encode_utxo_input(const unsigned char* hex, + uint32_t hex_len, uint32_t index, + uint32_t utxo_type); + +ByteArray mintlayer_encode_account_spending_input( + uint64_t nonce, const unsigned char* delegation_id_data, + uint32_t delegation_id_data_len, const unsigned char* amount_data, + uint32_t amount_data_len); + +ByteArray mintlayer_encode_token_account_command_input( + uint64_t nonce, uint32_t command, const unsigned char* token_id_data, + uint32_t token_id_data_len, const unsigned char* data, uint32_t data_len); + +ByteArray mintlayer_encode_conclude_order_account_command_input( + uint64_t nonce, const unsigned char* order_id_data, + uint32_t order_id_data_len); + +ByteArray mintlayer_encode_fill_order_account_command_input( + uint64_t nonce, const unsigned char* order_id_data, + uint32_t order_id_data_len, const unsigned char* coin_amount_data, + uint32_t coin_amount_data_len, const unsigned char* destination_data, + uint32_t destination_data_len); + +ByteArray mintlayer_encode_transfer_output( + const unsigned char* coin_amount_data, uint32_t coin_amount_data_len, + const unsigned char* token_id_data, uint32_t token_id_data_len, + const unsigned char* address_data, uint32_t address_data_len); + +ByteArray mintlayer_encode_lock_then_transfer_output( + const unsigned char* coin_amount_data, uint32_t coin_amount_data_len, + const unsigned char* token_id_data, uint32_t token_id_data_len, + uint8_t lock_type, uint64_t lock_amount, const unsigned char* address_data, + uint32_t address_data_len); + +ByteArray mintlayer_encode_burn_output(const unsigned char* coin_amount_data, + uint32_t coin_amount_data_len, + const unsigned char* token_id_data, + uint32_t token_id_data_len); + +ByteArray mintlayer_encode_create_stake_pool_output( + const unsigned char* pool_id_data, uint32_t pool_id_data_len, + const unsigned char* pledge_amount_data, uint32_t pledge_amount_data_len, + const unsigned char* staker_destination_data, + uint32_t staker_destination_data_len, + const unsigned char* vrf_public_key_data, uint32_t vrf_public_key_data_len, + const unsigned char* decommission_destination_data, + uint32_t decommission_destination_data_len, + uint16_t margin_ratio_per_thousand, + const unsigned char* cost_per_block_amount_data, + uint32_t cost_per_block_amount_data_len); + +ByteArray mintlayer_encode_produce_from_stake_output( + const unsigned char* destination_data, uint32_t destination_data_len, + const unsigned char* pool_id_data, uint32_t pool_id_data_len); + +ByteArray mintlayer_encode_create_delegation_id_output( + const unsigned char* destination_data, uint32_t destination_data_len, + const unsigned char* pool_id_data, uint32_t pool_id_data_len); + +ByteArray mintlayer_encode_delegate_staking_output( + const unsigned char* amount_data, uint32_t amount_data_len, + const unsigned char* pool_id_data, uint32_t pool_id_data_len); + +ByteArray mintlayer_encode_issue_fungible_token_output( + const unsigned char* token_ticker_data, uint32_t token_ticker_data_len, + uint8_t number_of_decimals, const unsigned char* metadata_uri_data, + uint32_t metadata_uri_data_len, uint32_t total_supply_type, + const unsigned char* fixed_amount_data, uint32_t fixed_amount_data_len, + const unsigned char* authority_data, uint32_t authority_data_len, + uint8_t is_freezable); + +ByteArray mintlayer_encode_issue_nft_output( + const unsigned char* token_id_data, uint32_t token_id_data_len, + const unsigned char* creator_data, uint32_t creator_data_len, + const unsigned char* name_data, uint32_t name_data_len, + const unsigned char* description_data, uint32_t description_data_len, + const unsigned char* ticker_data, uint32_t ticker_data_len, + const unsigned char* icon_uri_data, uint32_t icon_uri_data_len, + const unsigned char* additional_metadata_uri_data, + uint32_t additional_metadata_uri_data_len, + const unsigned char* media_uri_data, uint32_t media_uri_data_len, + const unsigned char* media_hash_data, uint32_t media_hash_data_len, + const unsigned char* destination_data, uint32_t destination_data_len); + +ByteArray mintlayer_encode_data_deposit_output( + const unsigned char* deposit_data, uint32_t deposit_data_len); + +ByteArray mintlayer_encode_htlc_output( + const unsigned char* coin_amount_data, uint32_t coin_amount_data_len, + const unsigned char* token_id_data, uint32_t token_id_data_len, + uint8_t lock_type, uint64_t lock_amount, + const unsigned char* refund_key_data, uint32_t refund_key_data_len, + const unsigned char* spend_key_data, uint32_t spend_key_data_len, + const unsigned char* secret_hash_data, uint32_t secret_hash_data_len); + +ByteArray mintlayer_encode_create_order_output( + const unsigned char* conclude_key_data, uint32_t conclude_key_data_len, + const unsigned char* ask_coin_amount_data, + uint32_t ask_coin_amount_data_len, const unsigned char* ask_token_id_data, + uint32_t ask_token_id_data_len, const unsigned char* give_coin_amount_data, + uint32_t give_coin_amount_data_len, const unsigned char* give_token_id_data, + uint32_t give_token_id_data_len); + +ByteArray mintlayer_encode_compact_length(uint32_t length); diff --git a/core/embed/rust/src/lib.rs b/core/embed/rust/src/lib.rs index 23ed6a215d..8a76185da1 100644 --- a/core/embed/rust/src/lib.rs +++ b/core/embed/rust/src/lib.rs @@ -41,6 +41,10 @@ mod trezorhal; #[cfg(feature = "ui")] pub mod ui; +#[cfg(feature = "micropython")] +#[cfg(feature = "mintlayer")] +pub mod mintlayer; + #[cfg(feature = "debug")] #[cfg(not(test))] #[panic_handler] diff --git a/core/embed/rust/src/mintlayer/mod.rs b/core/embed/rust/src/mintlayer/mod.rs new file mode 100644 index 0000000000..27c189aa77 --- /dev/null +++ b/core/embed/rust/src/mintlayer/mod.rs @@ -0,0 +1,919 @@ +use crate::micropython::ffi; +use core::{ + alloc::{GlobalAlloc, Layout}, + ptr::null_mut, +}; + +use ml_common::{ + AccountCommand, AccountCommandTag, AccountOutPoint, AccountSpending, Amount, Destination, + HashedTimelockContract, HtlcSecretHash, IsTokenFreezable, IsTokenUnfreezable, Metadata, + NftIssuance, NftIssuanceV0, OrderData, OutPointSourceId, OutPointSourceIdTag, OutputTimeLock, + OutputTimeLockTag, OutputValue, PublicKey, PublicKeyHolder, StakePoolData, TokenIssuance, + TokenIssuanceV1, TokenTotalSupply, TokenTotalSupplyTag, TxInput, TxOutput, UtxoOutPoint, + VRFPublicKeyHolder, H256, +}; +use num_traits::FromPrimitive; +use parity_scale_codec::{DecodeAll, Encode}; + +#[repr(C)] +#[derive(Eq, PartialEq, Clone, Copy)] +pub enum MintlayerErrorCode { + WrongHashSize = 1, + InvalidUtxoType = 2, + InvalidAmount = 3, + InvalidAccountCommand = 4, + InvalidDestination = 5, + InvalidIsTokenUnfreezable = 6, + InvalidIsTokenFreezable = 7, + InvalidVrfPublicKey = 8, + InvalidPublicKey = 9, + InvalidOutputTimeLock = 10, + InvalidTokenTotalSupply = 11, +} + +#[repr(C)] +pub union LenOrError { + len: cty::c_uint, + err: MintlayerErrorCode, +} + +#[repr(C)] +pub struct ByteArray { + data: *const cty::c_uchar, + len_or_err: LenOrError, +} + +impl From for ByteArray { + fn from(err: MintlayerErrorCode) -> Self { + Self { + data: core::ptr::null(), + len_or_err: LenOrError { err }, + } + } +} + +#[no_mangle] +extern "C" fn mintlayer_encode_utxo_input( + data: *const u8, + data_len: u32, + index: u32, + utxo_type: u32, +) -> ByteArray { + let hash = unsafe { core::slice::from_raw_parts(data, data_len as usize) }; + let res = mintlayer_encode_utxo_input_impl(hash, utxo_type, index); + handle_err_or_encode(res) +} + +fn mintlayer_encode_utxo_input_impl( + hash: &[u8], + utxo_type: u32, + index: u32, +) -> Result { + let hash = H256( + hash.try_into() + .map_err(|_| MintlayerErrorCode::WrongHashSize)?, + ); + let outpoint = match OutPointSourceIdTag::from_u32(utxo_type) + .ok_or(MintlayerErrorCode::InvalidUtxoType)? + { + OutPointSourceIdTag::Transaction => OutPointSourceId::Transaction(hash), + OutPointSourceIdTag::BlockReward => OutPointSourceId::BlockReward(hash), + }; + let utxo_outpoint = UtxoOutPoint::new(outpoint, index); + let tx_input = TxInput::Utxo(utxo_outpoint); + Ok(tx_input) +} + +#[no_mangle] +extern "C" fn mintlayer_encode_account_spending_input( + nonce: u64, + delegation_id_data: *const u8, + delegation_id_data_len: u32, + amount_data: *const u8, + amount_data_len: u32, +) -> ByteArray { + let delegation_id = + unsafe { core::slice::from_raw_parts(delegation_id_data, delegation_id_data_len as usize) }; + let coin_amount = unsafe { core::slice::from_raw_parts(amount_data, amount_data_len as usize) }; + + let res = mintlayer_encode_account_spending_input_impl(delegation_id, coin_amount, nonce); + handle_err_or_encode(res) +} + +fn mintlayer_encode_account_spending_input_impl( + delegation_id: &[u8], + coin_amount: &[u8], + nonce: u64, +) -> Result { + let delegation_id = H256( + delegation_id + .try_into() + .map_err(|_| MintlayerErrorCode::WrongHashSize)?, + ); + let amount = + Amount::from_bytes_be(coin_amount.as_ref()).ok_or(MintlayerErrorCode::InvalidAmount)?; + let tx_input = TxInput::Account(AccountOutPoint { + nonce, + account: AccountSpending::DelegationBalance(delegation_id, amount), + }); + Ok(tx_input) +} + +#[no_mangle] +extern "C" fn mintlayer_encode_token_account_command_input( + nonce: u64, + command: u32, + token_id_data: *const u8, + token_id_data_len: u32, + data: *const u8, + data_len: u32, +) -> ByteArray { + let token_id = + unsafe { core::slice::from_raw_parts(token_id_data, token_id_data_len as usize) }; + let data = unsafe { core::slice::from_raw_parts(data, data_len as usize) }; + + let res = mintlayer_encode_token_account_command_input_impl(token_id, command, data, nonce); + handle_err_or_encode(res) +} + +fn mintlayer_encode_token_account_command_input_impl( + token_id: &[u8], + command: u32, + data: &[u8], + nonce: u64, +) -> Result { + let token_id = H256(match token_id.try_into() { + Ok(hash) => hash, + Err(_) => return Err(MintlayerErrorCode::WrongHashSize), + }); + let account_command = match AccountCommandTag::from_u32(command) + .ok_or(MintlayerErrorCode::InvalidAccountCommand)? + { + AccountCommandTag::MintTokens => { + let amount = + Amount::from_bytes_be(data.as_ref()).ok_or(MintlayerErrorCode::InvalidAmount)?; + AccountCommand::MintTokens(token_id, amount) + } + AccountCommandTag::UnmintTokens => AccountCommand::UnmintTokens(token_id), + AccountCommandTag::LockTokenSupply => AccountCommand::LockTokenSupply(token_id), + AccountCommandTag::FreezeToken => { + let is_token_unfreezabe = IsTokenUnfreezable::decode_all(&mut data.as_ref()) + .map_err(|_| MintlayerErrorCode::InvalidIsTokenUnfreezable)?; + AccountCommand::FreezeToken(token_id, is_token_unfreezabe) + } + AccountCommandTag::UnfreezeToken => AccountCommand::UnfreezeToken(token_id), + AccountCommandTag::ChangeTokenAuthority => { + let destination = Destination::decode_all(&mut data.as_ref()) + .map_err(|_| MintlayerErrorCode::InvalidDestination)?; + AccountCommand::ChangeTokenAuthority(token_id, destination) + } + AccountCommandTag::ChangeTokenMetadataUri => { + AccountCommand::ChangeTokenMetadataUri(token_id, data.to_vec()) + } + _ => return Err(MintlayerErrorCode::InvalidAccountCommand), + }; + let tx_input = TxInput::AccountCommand(nonce, account_command); + Ok(tx_input) +} + +#[no_mangle] +extern "C" fn mintlayer_encode_conclude_order_account_command_input( + nonce: u64, + order_id_data: *const u8, + order_id_data_len: u32, +) -> ByteArray { + let order_id = + unsafe { core::slice::from_raw_parts(order_id_data, order_id_data_len as usize) }; + let order_id = H256(match order_id.try_into() { + Ok(hash) => hash, + Err(_) => return MintlayerErrorCode::WrongHashSize.into(), + }); + let account_command = AccountCommand::ConcludeOrder(order_id); + + let tx_input = TxInput::AccountCommand(nonce, account_command); + + encode_to_byte_array(&tx_input) +} + +#[no_mangle] +extern "C" fn mintlayer_encode_fill_order_account_command_input( + nonce: u64, + order_id_data: *const u8, + order_id_data_len: u32, + amount_data: *const u8, + amount_data_len: u32, + destination_data: *const u8, + destination_data_len: u32, +) -> ByteArray { + let order_id = + unsafe { core::slice::from_raw_parts(order_id_data, order_id_data_len as usize) }; + let coin_amount = unsafe { core::slice::from_raw_parts(amount_data, amount_data_len as usize) }; + let destination_bytes = + unsafe { core::slice::from_raw_parts(destination_data, destination_data_len as usize) }; + + let res = mintlayer_encode_fill_order_account_command_input_impl( + order_id, + coin_amount, + destination_bytes, + nonce, + ); + + handle_err_or_encode(res) +} + +fn mintlayer_encode_fill_order_account_command_input_impl( + order_id: &[u8], + coin_amount: &[u8], + destination_bytes: &[u8], + nonce: u64, +) -> Result { + let order_id = H256( + order_id + .try_into() + .map_err(|_| MintlayerErrorCode::WrongHashSize)?, + ); + let amount = + Amount::from_bytes_be(coin_amount.as_ref()).ok_or(MintlayerErrorCode::InvalidAmount)?; + + let destination = Destination::decode_all(&mut destination_bytes.as_ref()) + .map_err(|_| MintlayerErrorCode::InvalidDestination)?; + let account_command = AccountCommand::FillOrder(order_id, amount, destination); + let tx_input = TxInput::AccountCommand(nonce, account_command); + Ok(tx_input) +} + +fn parse_output_value( + amount_data: *const u8, + amount_data_len: u32, + token_id_data_len: u32, + token_id_data: *const u8, +) -> Result { + let coin_amount = unsafe { core::slice::from_raw_parts(amount_data, amount_data_len as usize) }; + let amount = match Amount::from_bytes_be(coin_amount.as_ref()) { + Some(amount) => amount, + None => return Err(MintlayerErrorCode::InvalidAmount.into()), + }; + let value = if token_id_data_len == 32 { + let token_id = + unsafe { core::slice::from_raw_parts(token_id_data, token_id_data_len as usize) }; + let token_id = H256(match token_id.try_into() { + Ok(hash) => hash, + Err(_) => return Err(MintlayerErrorCode::WrongHashSize.into()), + }); + OutputValue::TokenV1(token_id, amount) + } else { + OutputValue::Coin(amount) + }; + Ok(value) +} + +#[no_mangle] +extern "C" fn mintlayer_encode_transfer_output( + amount_data: *const u8, + amount_data_len: u32, + token_id_data: *const u8, + token_id_data_len: u32, + destination_data: *const u8, + destination_data_len: u32, +) -> ByteArray { + let value = match parse_output_value( + amount_data, + amount_data_len, + token_id_data_len, + token_id_data, + ) { + Ok(value) => value, + Err(value) => return value, + }; + + let destination_bytes = + unsafe { core::slice::from_raw_parts(destination_data, destination_data_len as usize) }; + let destination = match Destination::decode_all(&mut destination_bytes.as_ref()) { + Ok(destination) => destination, + Err(_) => return MintlayerErrorCode::InvalidDestination.into(), + }; + + let txo = TxOutput::Transfer(value, destination); + + encode_to_byte_array(&txo) +} + +#[no_mangle] +extern "C" fn mintlayer_encode_lock_then_transfer_output( + amount_data: *const u8, + amount_data_len: u32, + token_id_data: *const u8, + token_id_data_len: u32, + lock_type: u8, + lock_amount: u64, + destination_data: *const u8, + destination_data_len: u32, +) -> ByteArray { + let value = match parse_output_value( + amount_data, + amount_data_len, + token_id_data_len, + token_id_data, + ) { + Ok(value) => value, + Err(value) => return value, + }; + + let destination_bytes = + unsafe { core::slice::from_raw_parts(destination_data, destination_data_len as usize) }; + let destination = match Destination::decode_all(&mut destination_bytes.as_ref()) { + Ok(destination) => destination, + Err(_) => return MintlayerErrorCode::InvalidDestination.into(), + }; + let lock = match OutputTimeLockTag::from_u8(lock_type) { + Some(OutputTimeLockTag::UntilHeight) => OutputTimeLock::UntilHeight(lock_amount), + Some(OutputTimeLockTag::UntilTime) => OutputTimeLock::UntilTime(lock_amount), + Some(OutputTimeLockTag::ForBlockCount) => OutputTimeLock::ForBlockCount(lock_amount), + Some(OutputTimeLockTag::ForSeconds) => OutputTimeLock::ForSeconds(lock_amount), + None => return MintlayerErrorCode::InvalidOutputTimeLock.into(), + }; + + let txo = TxOutput::LockThenTransfer(value, destination, lock); + + encode_to_byte_array(&txo) +} + +#[no_mangle] +extern "C" fn mintlayer_encode_burn_output( + amount_data: *const u8, + amount_data_len: u32, + token_id_data: *const u8, + token_id_data_len: u32, +) -> ByteArray { + let value = match parse_output_value( + amount_data, + amount_data_len, + token_id_data_len, + token_id_data, + ) { + Ok(value) => value, + Err(value) => return value, + }; + + let txo = TxOutput::Burn(value); + + encode_to_byte_array(&txo) +} + +#[no_mangle] +extern "C" fn mintlayer_encode_create_stake_pool_output( + pool_id_data: *const u8, + pool_id_data_len: u32, + pledge_amount_data: *const u8, + pledge_amount_data_len: u32, + staker_destination_data: *const u8, + staker_destination_data_len: u32, + vrf_public_key_data: *const u8, + vrf_public_key_data_len: u32, + decommission_destination_data: *const u8, + decommission_destination_data_len: u32, + margin_ratio_per_thousand: u16, + cost_per_block_amount_data: *const u8, + cost_per_block_amount_data_len: u32, +) -> ByteArray { + let pool_id = unsafe { core::slice::from_raw_parts(pool_id_data, pool_id_data_len as usize) }; + let pledge_coin_amount = + unsafe { core::slice::from_raw_parts(pledge_amount_data, pledge_amount_data_len as usize) }; + let staker_destination_bytes = unsafe { + core::slice::from_raw_parts( + staker_destination_data, + staker_destination_data_len as usize, + ) + }; + let vrf_public_key = unsafe { + core::slice::from_raw_parts(vrf_public_key_data, vrf_public_key_data_len as usize) + }; + let decommission_destination_bytes = unsafe { + core::slice::from_raw_parts( + decommission_destination_data, + decommission_destination_data_len as usize, + ) + }; + let cost_per_block_coin_amount = unsafe { + core::slice::from_raw_parts( + cost_per_block_amount_data, + cost_per_block_amount_data_len as usize, + ) + }; + + let res = mintlayer_encode_create_stake_pool_output_impl( + pool_id, + pledge_coin_amount, + staker_destination_bytes, + vrf_public_key, + decommission_destination_bytes, + cost_per_block_coin_amount, + margin_ratio_per_thousand, + ); + + handle_err_or_encode(res) +} + +fn mintlayer_encode_create_stake_pool_output_impl( + pool_id: &[u8], + pledge_coin_amount: &[u8], + staker_destination_bytes: &[u8], + vrf_public_key: &[u8], + decommission_destination_bytes: &[u8], + cost_per_block_coin_amount: &[u8], + margin_ratio_per_thousand: u16, +) -> Result { + let pool_id = H256( + pool_id + .try_into() + .map_err(|_| MintlayerErrorCode::WrongHashSize)?, + ); + let pledge = Amount::from_bytes_be(pledge_coin_amount.as_ref()) + .ok_or(MintlayerErrorCode::InvalidAmount)?; + let staker = Destination::decode_all(&mut staker_destination_bytes.as_ref()) + .map_err(|_| MintlayerErrorCode::InvalidDestination)?; + let vrf_public_key = VRFPublicKeyHolder::decode_all(&mut vrf_public_key.as_ref()) + .map_err(|_| MintlayerErrorCode::InvalidVrfPublicKey)?; + let decommission_key = Destination::decode_all(&mut decommission_destination_bytes.as_ref()) + .map_err(|_| MintlayerErrorCode::InvalidDestination)?; + let cost_per_block = Amount::from_bytes_be(cost_per_block_coin_amount.as_ref()) + .ok_or(MintlayerErrorCode::InvalidAmount)?; + let txo = TxOutput::CreateStakePool( + pool_id, + StakePoolData { + pledge, + staker, + decommission_key, + vrf_public_key, + margin_ratio_per_thousand, + cost_per_block, + }, + ); + Ok(txo) +} + +#[no_mangle] +extern "C" fn mintlayer_encode_produce_from_stake_output( + destination_data: *const u8, + destination_data_len: u32, + pool_id_data: *const u8, + pool_id_data_len: u32, +) -> ByteArray { + let pool_id = unsafe { core::slice::from_raw_parts(pool_id_data, pool_id_data_len as usize) }; + let pool_id = H256(match pool_id.try_into() { + Ok(hash) => hash, + Err(_) => return MintlayerErrorCode::WrongHashSize.into(), + }); + + let destination_bytes = + unsafe { core::slice::from_raw_parts(destination_data, destination_data_len as usize) }; + let destination = match Destination::decode_all(&mut destination_bytes.as_ref()) { + Ok(destination) => destination, + Err(_) => return MintlayerErrorCode::InvalidDestination.into(), + }; + + let txo = TxOutput::ProduceBlockFromStake(destination, pool_id); + + encode_to_byte_array(&txo) +} + +#[no_mangle] +extern "C" fn mintlayer_encode_create_delegation_id_output( + destination_data: *const u8, + destination_data_len: u32, + pool_id_data: *const u8, + pool_id_data_len: u32, +) -> ByteArray { + let pool_id = unsafe { core::slice::from_raw_parts(pool_id_data, pool_id_data_len as usize) }; + let pool_id = H256(match pool_id.try_into() { + Ok(hash) => hash, + Err(_) => return MintlayerErrorCode::WrongHashSize.into(), + }); + + let destination_bytes = + unsafe { core::slice::from_raw_parts(destination_data, destination_data_len as usize) }; + let destination = match Destination::decode_all(&mut destination_bytes.as_ref()) { + Ok(destination) => destination, + Err(_) => return MintlayerErrorCode::InvalidDestination.into(), + }; + + let txo = TxOutput::CreateDelegationId(destination, pool_id); + + encode_to_byte_array(&txo) +} + +#[no_mangle] +extern "C" fn mintlayer_encode_delegate_staking_output( + amount_data: *const u8, + amount_data_len: u32, + delegation_id_data: *const u8, + delegation_id_data_len: u32, +) -> ByteArray { + let coin_amount = unsafe { core::slice::from_raw_parts(amount_data, amount_data_len as usize) }; + let amount = match Amount::from_bytes_be(coin_amount.as_ref()) { + Some(amount) => amount, + None => return MintlayerErrorCode::InvalidAmount.into(), + }; + + let delegation_id = + unsafe { core::slice::from_raw_parts(delegation_id_data, delegation_id_data_len as usize) }; + let delegation_id = H256(match delegation_id.try_into() { + Ok(hash) => hash, + Err(_) => return MintlayerErrorCode::WrongHashSize.into(), + }); + + let txo = TxOutput::DelegateStaking(amount, delegation_id); + + encode_to_byte_array(&txo) +} + +#[no_mangle] +extern "C" fn mintlayer_encode_issue_fungible_token_output( + token_ticker_data: *const u8, + token_ticker_data_len: u32, + number_of_decimals: u8, + metadata_uri_data: *const u8, + metadata_uri_data_len: u32, + total_supply_type: u32, + fixed_amount_data: *const u8, + fixed_amount_data_len: u32, + authority_data: *const u8, + authority_data_len: u32, + is_freezable: u8, +) -> ByteArray { + let token_ticker = + unsafe { core::slice::from_raw_parts(token_ticker_data, token_ticker_data_len as usize) }; + let metadata_uri = + unsafe { core::slice::from_raw_parts(metadata_uri_data, metadata_uri_data_len as usize) }; + let authority_bytes = + unsafe { core::slice::from_raw_parts(authority_data, authority_data_len as usize) }; + let coin_amount = + unsafe { core::slice::from_raw_parts(fixed_amount_data, fixed_amount_data_len as usize) }; + + let res = mintlayer_encode_issue_fungible_token_output_impl( + token_ticker, + metadata_uri, + authority_bytes, + is_freezable, + total_supply_type, + coin_amount, + number_of_decimals, + ); + + handle_err_or_encode(res) +} + +fn mintlayer_encode_issue_fungible_token_output_impl( + token_ticker: &[u8], + metadata_uri: &[u8], + authority_bytes: &[u8], + is_freezable: u8, + total_supply_type: u32, + coin_amount: &[u8], + number_of_decimals: u8, +) -> Result { + let token_ticker = token_ticker.to_vec(); + let metadata_uri = metadata_uri.to_vec(); + let authority = Destination::decode_all(&mut authority_bytes.as_ref()) + .map_err(|_| MintlayerErrorCode::InvalidDestination)?; + let is_freezable = IsTokenFreezable::from_u8(is_freezable) + .ok_or(MintlayerErrorCode::InvalidIsTokenFreezable)?; + let total_supply = match TokenTotalSupplyTag::from_u32(total_supply_type) + .ok_or(MintlayerErrorCode::InvalidTokenTotalSupply)? + { + TokenTotalSupplyTag::Fixed => { + let amount = Amount::from_bytes_be(coin_amount.as_ref()) + .ok_or(MintlayerErrorCode::InvalidAmount)?; + TokenTotalSupply::Fixed(amount) + } + TokenTotalSupplyTag::Lockable => TokenTotalSupply::Lockable, + TokenTotalSupplyTag::Unlimited => TokenTotalSupply::Unlimited, + }; + let issuance = TokenIssuance::V1(TokenIssuanceV1 { + token_ticker, + number_of_decimals, + metadata_uri, + total_supply, + authority, + is_freezable, + }); + let txo = TxOutput::IssueFungibleToken(issuance); + Ok(txo) +} + +#[no_mangle] +extern "C" fn mintlayer_encode_issue_nft_output( + token_id_data: *const u8, + token_id_data_len: u32, + creator_data: *const u8, + creator_data_len: u32, + name_data: *const u8, + name_data_len: u32, + description_data: *const u8, + description_data_len: u32, + ticker_data: *const u8, + ticker_data_len: u32, + icon_uri_data: *const u8, + icon_uri_data_len: u32, + additional_metadata_uri_data: *const u8, + additional_metadata_uri_data_len: u32, + media_uri_data: *const u8, + media_uri_data_len: u32, + media_hash_data: *const u8, + media_hash_data_len: u32, + destination_data: *const u8, + destination_data_len: u32, +) -> ByteArray { + let token_id = + unsafe { core::slice::from_raw_parts(token_id_data, token_id_data_len as usize) }; + let creator = unsafe { core::slice::from_raw_parts(creator_data, creator_data_len as usize) }; + let name = unsafe { core::slice::from_raw_parts(name_data, name_data_len as usize) }; + let description = + unsafe { core::slice::from_raw_parts(description_data, description_data_len as usize) }; + let ticker = unsafe { core::slice::from_raw_parts(ticker_data, ticker_data_len as usize) }; + let icon_uri = + unsafe { core::slice::from_raw_parts(icon_uri_data, icon_uri_data_len as usize) }; + let additional_metadata_uri = unsafe { + core::slice::from_raw_parts( + additional_metadata_uri_data, + additional_metadata_uri_data_len as usize, + ) + }; + let media_uri = + unsafe { core::slice::from_raw_parts(media_uri_data, media_uri_data_len as usize) }; + let media_hash = + unsafe { core::slice::from_raw_parts(media_hash_data, media_hash_data_len as usize) }; + let destination_bytes = + unsafe { core::slice::from_raw_parts(destination_data, destination_data_len as usize) }; + + let res = mintlayer_encode_issue_nft_output_impl( + token_id, + creator_data_len, + creator, + name, + description, + ticker, + icon_uri, + additional_metadata_uri, + media_uri, + media_hash, + destination_bytes, + ); + + handle_err_or_encode(res) +} + +fn mintlayer_encode_issue_nft_output_impl( + token_id: &[u8], + creator_data_len: u32, + creator: &[u8], + name: &[u8], + description: &[u8], + ticker: &[u8], + icon_uri: &[u8], + additional_metadata_uri: &[u8], + media_uri: &[u8], + media_hash: &[u8], + destination_bytes: &[u8], +) -> Result { + let token_id = H256( + token_id + .try_into() + .map_err(|_| MintlayerErrorCode::WrongHashSize)?, + ); + let creator = if creator_data_len == 0 { + None + } else { + Some(PublicKeyHolder::Secp256k1Schnorr(PublicKey( + creator + .try_into() + .map_err(|_| MintlayerErrorCode::InvalidPublicKey)?, + ))) + }; + let name = name.to_vec(); + let description = description.to_vec(); + let ticker = ticker.to_vec(); + let icon_uri = icon_uri.to_vec(); + let additional_metadata_uri = additional_metadata_uri.to_vec(); + let media_uri = media_uri.to_vec(); + let media_hash = media_hash.to_vec(); + let destination = Destination::decode_all(&mut destination_bytes.as_ref()) + .map_err(|_| MintlayerErrorCode::InvalidDestination)?; + let issuance = NftIssuance::V0(NftIssuanceV0 { + metadata: Metadata { + creator, + name, + description, + ticker, + icon_uri, + additional_metadata_uri, + media_uri, + media_hash, + }, + }); + let txo = TxOutput::IssueNft(token_id, issuance, destination); + Ok(txo) +} + +#[no_mangle] +extern "C" fn mintlayer_encode_data_deposit_output( + deposit_data: *const u8, + deposit_data_len: u32, +) -> ByteArray { + let deposit = unsafe { core::slice::from_raw_parts(deposit_data, deposit_data_len as usize) }; + let deposit = deposit.to_vec(); + + let txo = TxOutput::DataDeposit(deposit); + + encode_to_byte_array(&txo) +} + +#[no_mangle] +extern "C" fn mintlayer_encode_htlc_output( + amount_data: *const u8, + amount_data_len: u32, + token_id_data: *const u8, + token_id_data_len: u32, + lock_type: u8, + lock_amount: u64, + refund_destination_data: *const u8, + refund_destination_data_len: u32, + spend_destination_data: *const u8, + spend_destination_data_len: u32, + secret_hash_data: *const u8, + secret_hash_data_len: u32, +) -> ByteArray { + let value = match parse_output_value( + amount_data, + amount_data_len, + token_id_data_len, + token_id_data, + ) { + Ok(value) => value, + Err(value) => return value, + }; + + let refund_destination_bytes = unsafe { + core::slice::from_raw_parts( + refund_destination_data, + refund_destination_data_len as usize, + ) + }; + let spend_destination_bytes = unsafe { + core::slice::from_raw_parts(spend_destination_data, spend_destination_data_len as usize) + }; + let hash = + unsafe { core::slice::from_raw_parts(secret_hash_data, secret_hash_data_len as usize) }; + + let res = mintlayer_encode_htlc_output_impl( + refund_destination_bytes, + spend_destination_bytes, + hash, + lock_type, + lock_amount, + value, + ); + + handle_err_or_encode(res) +} + +fn mintlayer_encode_htlc_output_impl( + refund_destination_bytes: &[u8], + spend_destination_bytes: &[u8], + hash: &[u8], + lock_type: u8, + lock_amount: u64, + value: OutputValue, +) -> Result { + let refund_key = Destination::decode_all(&mut refund_destination_bytes.as_ref()) + .map_err(|_| MintlayerErrorCode::InvalidDestination)?; + let spend_key = Destination::decode_all(&mut spend_destination_bytes.as_ref()) + .map_err(|_| MintlayerErrorCode::InvalidDestination)?; + let secret_hash = HtlcSecretHash( + hash.try_into() + .map_err(|_| MintlayerErrorCode::WrongHashSize)?, + ); + let refund_timelock = match OutputTimeLockTag::from_u8(lock_type) + .ok_or(MintlayerErrorCode::InvalidOutputTimeLock)? + { + OutputTimeLockTag::UntilHeight => OutputTimeLock::UntilHeight(lock_amount), + OutputTimeLockTag::UntilTime => OutputTimeLock::UntilTime(lock_amount), + OutputTimeLockTag::ForBlockCount => OutputTimeLock::ForBlockCount(lock_amount), + OutputTimeLockTag::ForSeconds => OutputTimeLock::ForSeconds(lock_amount), + }; + let txo = TxOutput::Htlc( + value, + HashedTimelockContract { + secret_hash, + spend_key, + refund_timelock, + refund_key, + }, + ); + Ok(txo) +} + +#[no_mangle] +extern "C" fn mintlayer_encode_create_order_output( + destination_data: *const u8, + destination_data_len: u32, + ask_amount_data: *const u8, + ask_amount_data_len: u32, + ask_token_id_data: *const u8, + ask_token_id_data_len: u32, + give_amount_data: *const u8, + give_amount_data_len: u32, + give_token_id_data: *const u8, + give_token_id_data_len: u32, +) -> ByteArray { + let ask_value = match parse_output_value( + ask_amount_data, + ask_amount_data_len, + ask_token_id_data_len, + ask_token_id_data, + ) { + Ok(value) => value, + Err(value) => return value, + }; + + let give_value = match parse_output_value( + give_amount_data, + give_amount_data_len, + give_token_id_data_len, + give_token_id_data, + ) { + Ok(value) => value, + Err(value) => return value, + }; + + let destination_bytes = + unsafe { core::slice::from_raw_parts(destination_data, destination_data_len as usize) }; + let destination = match Destination::decode_all(&mut destination_bytes.as_ref()) { + Ok(destination) => destination, + Err(_) => return MintlayerErrorCode::InvalidDestination.into(), + }; + + let txo = TxOutput::CreateOrder(OrderData { + conclude_key: destination, + ask: ask_value, + give: give_value, + }); + + encode_to_byte_array(&txo) +} + +#[derive(Encode, Debug, PartialEq, Eq)] +struct CompactLength { + #[codec(compact)] + pub value: u32, +} + +#[no_mangle] +extern "C" fn mintlayer_encode_compact_length(length: u32) -> ByteArray { + let len = CompactLength { value: length }; + encode_to_byte_array(&len) +} + +struct CustomAllocator; + +unsafe impl GlobalAlloc for CustomAllocator { + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + unsafe { + let ptr_void = ffi::gc_alloc(layout.size(), 0); // Call ffi::gc_alloc + if ptr_void.is_null() { + return null_mut(); + } + ptr_void as *mut u8 // Cast the pointer to *mut u8 + } + } + + unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) { + // Implement deallocation logic here if needed + } +} + +#[global_allocator] +static GLOBAL_ALLOCATOR: CustomAllocator = CustomAllocator; + +fn handle_err_or_encode(x: Result) -> ByteArray { + match x { + Ok(value) => encode_to_byte_array(&value), + Err(value) => value.into(), + } +} + +fn encode_to_byte_array(x: &T) -> ByteArray { + let vec_data = x.encode(); + // Extracting the raw pointer and length from the Vec + let ptr_data = vec_data.as_ptr(); + let len = vec_data.len() as cty::c_uint; + + // Prevent Rust from freeing the memory associated with vec_data + core::mem::forget(vec_data); + + // Construct and return the ByteArray struct + ByteArray { + data: ptr_data, + len_or_err: LenOrError { len }, + } +} diff --git a/core/embed/upymod/modtrezormintlayer/modtrezormintlayer.c b/core/embed/upymod/modtrezormintlayer/modtrezormintlayer.c new file mode 100644 index 0000000000..cfa6d54961 --- /dev/null +++ b/core/embed/upymod/modtrezormintlayer/modtrezormintlayer.c @@ -0,0 +1,140 @@ +/* + * This file is part of the Trezor project, https://trezor.io/ + * + * Copyright (c) SatoshiLabs + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +#include "common.h" + +#include "py/runtime.h" + +#include TREZOR_BOARD + +// #if MICROPY_PY_TREZORMINTLAYER + +#include "modtrezormintlayer.h" + +void handle_err(ByteArray *res) { + if (res->data != NULL) { + return; + } + + switch (res->len_or_err.err) { + case WrongHashSize: + mp_raise_ValueError("Invalid hash size"); + break; + case InvalidUtxoType: + mp_raise_ValueError("Invalid UTXO type"); + break; + case InvalidAmount: + mp_raise_ValueError("Invalid amount"); + break; + case InvalidAccountCommand: + mp_raise_ValueError("Invalid account command"); + break; + case InvalidDestination: + mp_raise_ValueError("Invalid destination"); + break; + case InvalidIsTokenUnfreezable: + mp_raise_ValueError("Invalid token unfreezable flag"); + break; + case InvalidIsTokenFreezable: + mp_raise_ValueError("Invalid token freezable flag"); + break; + case InvalidVrfPublicKey: + mp_raise_ValueError("Invalid VRF public key"); + break; + case InvalidPublicKey: + mp_raise_ValueError("Invalid public key"); + break; + case InvalidOutputTimeLock: + mp_raise_ValueError("Invalid output time lock"); + break; + case InvalidTokenTotalSupply: + mp_raise_ValueError("Invalid token total supply"); + break; + default: + mp_raise_ValueError("Unknown error"); + break; + } +} + +STATIC const mp_rom_map_elem_t mod_trezormintlayer_globals_table[] = { + {MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_trezormintlayer)}, + {MP_ROM_QSTR(MP_QSTR_encode_utxo_input), + MP_ROM_PTR(&mod_trezormintlayer_utils_mintlayer_encode_utxo_input_obj)}, + {MP_ROM_QSTR(MP_QSTR_encode_account_spending_input), + MP_ROM_PTR( + &mod_trezormintlayer_utils_mintlayer_encode_account_spending_input_obj)}, + {MP_ROM_QSTR(MP_QSTR_encode_token_account_command_input), + MP_ROM_PTR( + &mod_trezormintlayer_utils_mintlayer_encode_token_account_command_input_obj)}, + {MP_ROM_QSTR(MP_QSTR_encode_conclude_order_account_command_input), + MP_ROM_PTR( + &mod_trezormintlayer_utils_mintlayer_encode_conclude_order_account_command_input_obj)}, + {MP_ROM_QSTR(MP_QSTR_encode_fill_order_account_command_input), + MP_ROM_PTR( + &mod_trezormintlayer_utils_mintlayer_encode_fill_order_account_command_input_obj)}, + {MP_ROM_QSTR(MP_QSTR_encode_transfer_output), + MP_ROM_PTR( + &mod_trezormintlayer_utils_mintlayer_encode_transfer_output_obj)}, + {MP_ROM_QSTR(MP_QSTR_encode_lock_then_transfer_output), + MP_ROM_PTR( + &mod_trezormintlayer_utils_mintlayer_encode_lock_then_transfer_output_obj)}, + {MP_ROM_QSTR(MP_QSTR_encode_burn_output), + MP_ROM_PTR(&mod_trezormintlayer_utils_mintlayer_encode_burn_output_obj)}, + {MP_ROM_QSTR(MP_QSTR_encode_create_stake_pool_output), + MP_ROM_PTR( + &mod_trezormintlayer_utils_mintlayer_encode_create_stake_pool_output_obj)}, + {MP_ROM_QSTR(MP_QSTR_encode_produce_from_stake_output), + MP_ROM_PTR( + &mod_trezormintlayer_utils_mintlayer_encode_produce_from_stake_output_obj)}, + {MP_ROM_QSTR(MP_QSTR_encode_create_delegation_id_output), + MP_ROM_PTR( + &mod_trezormintlayer_utils_mintlayer_encode_create_delegation_id_output_obj)}, + {MP_ROM_QSTR(MP_QSTR_encode_delegate_staking_output), + MP_ROM_PTR( + &mod_trezormintlayer_utils_mintlayer_encode_delegate_staking_output_obj)}, + {MP_ROM_QSTR(MP_QSTR_encode_issue_fungible_token_output), + MP_ROM_PTR( + &mod_trezormintlayer_utils_mintlayer_encode_issue_fungible_token_output_obj)}, + {MP_ROM_QSTR(MP_QSTR_encode_issue_nft_output), + MP_ROM_PTR( + &mod_trezormintlayer_utils_mintlayer_encode_issue_nft_output_obj)}, + {MP_ROM_QSTR(MP_QSTR_encode_data_deposit_output), + MP_ROM_PTR( + &mod_trezormintlayer_utils_mintlayer_encode_data_deposit_output_obj)}, + {MP_ROM_QSTR(MP_QSTR_encode_htlc_output), + MP_ROM_PTR(&mod_trezormintlayer_utils_mintlayer_encode_htlc_output_obj)}, + {MP_ROM_QSTR(MP_QSTR_encode_create_order_output), + MP_ROM_PTR( + &mod_trezormintlayer_utils_mintlayer_encode_create_order_output_obj)}, + {MP_ROM_QSTR(MP_QSTR_encode_compact_length), + MP_ROM_PTR(&mod_trezormintlayer_utils_mintlayer_encode_comact_length_obj)}, +}; +STATIC MP_DEFINE_CONST_DICT(mod_trezormintlayer_globals, + mod_trezormintlayer_globals_table); + +const mp_obj_module_t mp_module_trezormintlayer = { + .base = {&mp_type_module}, + .globals = (mp_obj_dict_t *)&mod_trezormintlayer_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_trezormintlayer, mp_module_trezormintlayer); + +// #endif // MICROPY_PY_TREZORMINTLAYER diff --git a/core/embed/upymod/modtrezormintlayer/modtrezormintlayer.h b/core/embed/upymod/modtrezormintlayer/modtrezormintlayer.h new file mode 100644 index 0000000000..9f6df796d5 --- /dev/null +++ b/core/embed/upymod/modtrezormintlayer/modtrezormintlayer.h @@ -0,0 +1,507 @@ +#include +#include "py/objstr.h" + +#include "embed/upymod/trezorobj.h" + +#include "embed/rust/mintlayer.h" + +#include "bip32.h" +#include "bip39.h" +#include "curves.h" +#include "memzero.h" + +void handle_err(ByteArray *res); + +/// def encode_utxo_input(tx_hash: bytes, index: int, utxo_type: int) -> bytes: +/// """ +/// encodes an utxo input from tx_hash and index +/// """ +STATIC mp_obj_t mod_trezormintlayer_utils_mintlayer_encode_utxo_input( + mp_obj_t tx_hash, mp_obj_t index, mp_obj_t utxo_type_obj) { + mp_buffer_info_t hash = {0}; + mp_get_buffer_raise(tx_hash, &hash, MP_BUFFER_READ); + uint32_t idx = trezor_obj_get_uint(index); + uint32_t utxo_type = trezor_obj_get_uint(utxo_type_obj); + ByteArray arr = + mintlayer_encode_utxo_input(hash.buf, hash.len, idx, utxo_type); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_3( + mod_trezormintlayer_utils_mintlayer_encode_utxo_input_obj, + mod_trezormintlayer_utils_mintlayer_encode_utxo_input); + +/// def encode_account_spending_input(nonce: int, delegation_id: bytes, amount: +/// bytes) -> bytes: +/// """ +/// encodes an utxo account spending from nonce and delegation id +/// """ +STATIC mp_obj_t +mod_trezormintlayer_utils_mintlayer_encode_account_spending_input( + mp_obj_t nonce_obj, mp_obj_t delegation_id, mp_obj_t amount_obj) { + uint64_t nonce = trezor_obj_get_uint64(nonce_obj); + + mp_buffer_info_t hash = {0}; + mp_get_buffer_raise(delegation_id, &hash, MP_BUFFER_READ); + mp_buffer_info_t amount = {0}; + mp_get_buffer_raise(amount_obj, &amount, MP_BUFFER_READ); + + ByteArray arr = mintlayer_encode_account_spending_input( + nonce, hash.buf, hash.len, amount.buf, amount.len); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_3( + mod_trezormintlayer_utils_mintlayer_encode_account_spending_input_obj, + mod_trezormintlayer_utils_mintlayer_encode_account_spending_input); + +/// def encode_token_account_command_input(nonce: int, command: int, token_id: +/// bytes, data: bytes) -> bytes: +/// """ +/// encodes an account command from the nonce, command, token id and +/// additional command data +/// """ +STATIC mp_obj_t +mod_trezormintlayer_utils_mintlayer_encode_token_account_command_input( + size_t n_args, const mp_obj_t *args) { + uint64_t nonce = trezor_obj_get_uint64(args[0]); + uint32_t command = trezor_obj_get_uint(args[1]); + + mp_buffer_info_t hash = {0}; + mp_get_buffer_raise(args[2], &hash, MP_BUFFER_READ); + mp_buffer_info_t data = {0}; + mp_get_buffer_raise(args[3], &data, MP_BUFFER_READ); + + ByteArray arr = mintlayer_encode_token_account_command_input( + nonce, command, hash.buf, hash.len, data.buf, data.len); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN( + mod_trezormintlayer_utils_mintlayer_encode_token_account_command_input_obj, + 4, 4, + mod_trezormintlayer_utils_mintlayer_encode_token_account_command_input); + +/// def encode_conclude_order_account_command_input(nonce: int, order_id: bytes) +/// -> bytes: +/// """ +/// encodes an conclude order account command from the nonce and order id +/// """ +STATIC mp_obj_t +mod_trezormintlayer_utils_mintlayer_encode_conclude_order_account_command_input( + mp_obj_t nonce_obj, mp_obj_t order_id_obj) { + uint64_t nonce = trezor_obj_get_uint64(nonce_obj); + mp_buffer_info_t order_id = {0}; + mp_get_buffer_raise(order_id_obj, &order_id, MP_BUFFER_READ); + + ByteArray arr = mintlayer_encode_conclude_order_account_command_input( + nonce, order_id.buf, order_id.len); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_2( + mod_trezormintlayer_utils_mintlayer_encode_conclude_order_account_command_input_obj, + mod_trezormintlayer_utils_mintlayer_encode_conclude_order_account_command_input); + +/// def encode_fill_order_account_command_input(nonce: int, order_id: bytes, +/// amount: bytes, destination: bytes) +/// -> bytes: +/// """ +/// encodes an fill order account command from the nonce, order id, output +/// amount and destination +/// """ +STATIC mp_obj_t +mod_trezormintlayer_utils_mintlayer_encode_fill_order_account_command_input( + size_t n_args, const mp_obj_t *args) { + uint64_t nonce = trezor_obj_get_uint64(args[0]); + mp_buffer_info_t order_id = {0}; + mp_get_buffer_raise(args[1], &order_id, MP_BUFFER_READ); + mp_buffer_info_t amount = {0}; + mp_get_buffer_raise(args[2], &amount, MP_BUFFER_READ); + mp_buffer_info_t destination = {0}; + mp_get_buffer_raise(args[3], &destination, MP_BUFFER_READ); + + ByteArray arr = mintlayer_encode_fill_order_account_command_input( + nonce, order_id.buf, order_id.len, amount.buf, amount.len, + destination.buf, destination.len); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN( + mod_trezormintlayer_utils_mintlayer_encode_fill_order_account_command_input_obj, + 4, 4, + mod_trezormintlayer_utils_mintlayer_encode_fill_order_account_command_input); + +/// def encode_transfer_output(amount: bytes, token_id: bytes, address: bytes) +/// -> bytes: +/// """ +/// encodes a transfer output with given amount and destination address +/// """ +STATIC mp_obj_t mod_trezormintlayer_utils_mintlayer_encode_transfer_output( + mp_obj_t amount_obj, mp_obj_t token_id_obj, mp_obj_t address_obj) { + mp_buffer_info_t amount = {0}; + mp_get_buffer_raise(amount_obj, &amount, MP_BUFFER_READ); + mp_buffer_info_t token_id = {0}; + mp_get_buffer_raise(token_id_obj, &token_id, MP_BUFFER_READ); + mp_buffer_info_t address = {0}; + mp_get_buffer_raise(address_obj, &address, MP_BUFFER_READ); + ByteArray arr = + mintlayer_encode_transfer_output(amount.buf, amount.len, token_id.buf, + token_id.len, address.buf, address.len); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_3( + mod_trezormintlayer_utils_mintlayer_encode_transfer_output_obj, + mod_trezormintlayer_utils_mintlayer_encode_transfer_output); + +/// def encode_lock_then_transfer_output(amount: bytes, token_id: bytes, +/// lock_type: int, lock_amount:int, address: bytes) -> bytes: +/// """ +/// encodes a transfer output with given amount, lock type and amount, and +/// destination address +/// """ +STATIC mp_obj_t +mod_trezormintlayer_utils_mintlayer_encode_lock_then_transfer_output( + size_t n_args, const mp_obj_t *args) { + mp_buffer_info_t amount = {0}; + mp_get_buffer_raise(args[0], &amount, MP_BUFFER_READ); + mp_buffer_info_t token_id = {0}; + mp_get_buffer_raise(args[1], &token_id, MP_BUFFER_READ); + uint8_t lock_type = trezor_obj_get_uint8(args[2]); + uint64_t lock_amount = trezor_obj_get_uint64(args[3]); + mp_buffer_info_t address = {0}; + mp_get_buffer_raise(args[4], &address, MP_BUFFER_READ); + ByteArray arr = mintlayer_encode_lock_then_transfer_output( + amount.buf, amount.len, token_id.buf, token_id.len, lock_type, + lock_amount, address.buf, address.len); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN( + mod_trezormintlayer_utils_mintlayer_encode_lock_then_transfer_output_obj, 5, + 5, mod_trezormintlayer_utils_mintlayer_encode_lock_then_transfer_output); + +/// def encode_burn_output(amount: bytes, token_id: bytes) -> +/// bytes: +/// """ +/// encodes a burn output with given amount +/// """ +STATIC mp_obj_t mod_trezormintlayer_utils_mintlayer_encode_burn_output( + mp_obj_t amount_obj, mp_obj_t token_id_obj) { + mp_buffer_info_t amount = {0}; + mp_get_buffer_raise(amount_obj, &amount, MP_BUFFER_READ); + mp_buffer_info_t token_id = {0}; + mp_get_buffer_raise(token_id_obj, &token_id, MP_BUFFER_READ); + ByteArray arr = mintlayer_encode_burn_output(amount.buf, amount.len, + token_id.buf, token_id.len); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_2( + mod_trezormintlayer_utils_mintlayer_encode_burn_output_obj, + mod_trezormintlayer_utils_mintlayer_encode_burn_output); + +/// def encode_create_stake_pool_output(pool_id: bytes, pledge_amount: bytes, +/// staker: bytes, vrf_public_key: bytes, decommission_key: bytes, +/// margin_ratio_per_thousand: int, cost_per_block: bytes) -> bytes: +/// """ +/// encodes a create stake pool output +/// """ +STATIC mp_obj_t +mod_trezormintlayer_utils_mintlayer_encode_create_stake_pool_output( + size_t n_args, const mp_obj_t *args) { + mp_buffer_info_t pool_id = {0}; + mp_get_buffer_raise(args[0], &pool_id, MP_BUFFER_READ); + mp_buffer_info_t pledge_amount = {0}; + mp_get_buffer_raise(args[1], &pledge_amount, MP_BUFFER_READ); + mp_buffer_info_t staker = {0}; + mp_get_buffer_raise(args[2], &staker, MP_BUFFER_READ); + mp_buffer_info_t vrf_public_key = {0}; + mp_get_buffer_raise(args[3], &vrf_public_key, MP_BUFFER_READ); + mp_buffer_info_t decommission_key = {0}; + mp_get_buffer_raise(args[4], &decommission_key, MP_BUFFER_READ); + uint16_t margin_ratio_per_thousand = (uint16_t)trezor_obj_get_uint64(args[5]); + mp_buffer_info_t cost_per_block = {0}; + mp_get_buffer_raise(args[6], &cost_per_block, MP_BUFFER_READ); + + ByteArray arr = mintlayer_encode_create_stake_pool_output( + pool_id.buf, pool_id.len, pledge_amount.buf, pledge_amount.len, + staker.buf, staker.len, vrf_public_key.buf, vrf_public_key.len, + decommission_key.buf, decommission_key.len, margin_ratio_per_thousand, + cost_per_block.buf, cost_per_block.len); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN( + mod_trezormintlayer_utils_mintlayer_encode_create_stake_pool_output_obj, 7, + 7, mod_trezormintlayer_utils_mintlayer_encode_create_stake_pool_output); + +/// def encode_produce_from_stake_output(destination: bytes, pool_id: bytes) -> +/// bytes: +/// """ +/// encodes a produce from stake output +/// """ +STATIC mp_obj_t +mod_trezormintlayer_utils_mintlayer_encode_produce_from_stake_output( + mp_obj_t destination_obj, mp_obj_t pool_id_obj) { + mp_buffer_info_t destination = {0}; + mp_get_buffer_raise(destination_obj, &destination, MP_BUFFER_READ); + mp_buffer_info_t pool_id = {0}; + mp_get_buffer_raise(pool_id_obj, &pool_id, MP_BUFFER_READ); + ByteArray arr = mintlayer_encode_produce_from_stake_output( + destination.buf, destination.len, pool_id.buf, pool_id.len); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_2( + mod_trezormintlayer_utils_mintlayer_encode_produce_from_stake_output_obj, + mod_trezormintlayer_utils_mintlayer_encode_produce_from_stake_output); + +/// def encode_create_delegation_id_output(destination: bytes, pool_id: bytes) +/// -> bytes: +/// """ +/// encodes a create delegation id output +/// """ +STATIC mp_obj_t +mod_trezormintlayer_utils_mintlayer_encode_create_delegation_id_output( + mp_obj_t destination_obj, mp_obj_t pool_id_obj) { + mp_buffer_info_t destination = {0}; + mp_get_buffer_raise(destination_obj, &destination, MP_BUFFER_READ); + mp_buffer_info_t pool_id = {0}; + mp_get_buffer_raise(pool_id_obj, &pool_id, MP_BUFFER_READ); + ByteArray arr = mintlayer_encode_create_delegation_id_output( + destination.buf, destination.len, pool_id.buf, pool_id.len); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_2( + mod_trezormintlayer_utils_mintlayer_encode_create_delegation_id_output_obj, + mod_trezormintlayer_utils_mintlayer_encode_create_delegation_id_output); + +/// def encode_delegate_staking_output(amount: bytes, delegation_id: bytes) -> +/// bytes: +/// """ +/// encodes a delegation staking output, given the amount and delegation id +/// """ +STATIC mp_obj_t +mod_trezormintlayer_utils_mintlayer_encode_delegate_staking_output( + mp_obj_t destination_obj, mp_obj_t delegation_id_obj) { + mp_buffer_info_t amount = {0}; + mp_get_buffer_raise(destination_obj, &amount, MP_BUFFER_READ); + mp_buffer_info_t delegation_id = {0}; + mp_get_buffer_raise(delegation_id_obj, &delegation_id, MP_BUFFER_READ); + ByteArray arr = mintlayer_encode_delegate_staking_output( + amount.buf, amount.len, delegation_id.buf, delegation_id.len); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_2( + mod_trezormintlayer_utils_mintlayer_encode_delegate_staking_output_obj, + mod_trezormintlayer_utils_mintlayer_encode_delegate_staking_output); + +/// def encode_issue_fungible_token_output(token_ticker: bytes, +/// number_of_decimals: int, metadata_uri: bytes, total_supply_type: int, +/// fixed_amount: bytes, authority: bytes, is_freezable: int) -> bytes: +/// """ +/// encodes a issue fungible token output +/// """ +STATIC mp_obj_t +mod_trezormintlayer_utils_mintlayer_encode_issue_fungible_token_output( + size_t n_args, const mp_obj_t *args) { + mp_buffer_info_t token_ticker = {0}; + mp_get_buffer_raise(args[0], &token_ticker, MP_BUFFER_READ); + uint8_t number_of_decimals = trezor_obj_get_uint8(args[1]); + mp_buffer_info_t metadata_uri = {0}; + mp_get_buffer_raise(args[2], &metadata_uri, MP_BUFFER_READ); + uint32_t total_supply_type = (uint32_t)trezor_obj_get_uint64(args[3]); + mp_buffer_info_t fixed_amount = {0}; + mp_get_buffer_raise(args[4], &fixed_amount, MP_BUFFER_READ); + mp_buffer_info_t authority = {0}; + mp_get_buffer_raise(args[5], &authority, MP_BUFFER_READ); + uint8_t is_freezable = trezor_obj_get_uint8(args[6]); + + ByteArray arr = mintlayer_encode_issue_fungible_token_output( + token_ticker.buf, token_ticker.len, number_of_decimals, metadata_uri.buf, + metadata_uri.len, total_supply_type, fixed_amount.buf, fixed_amount.len, + authority.buf, authority.len, is_freezable); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN( + mod_trezormintlayer_utils_mintlayer_encode_issue_fungible_token_output_obj, + 7, 7, + mod_trezormintlayer_utils_mintlayer_encode_issue_fungible_token_output); + +/// def encode_issue_nft_output(token_id: bytes, +/// creator: bytes, name: bytes, destination: bytes, +/// ticker: bytes, icon_uri: bytes, additional_metadata_uri: bytes, media_uri: +/// bytes, media_hash: bytes, destination: bytes) -> bytes: +/// """ +/// encodes a issue NFT output +/// """ +STATIC mp_obj_t mod_trezormintlayer_utils_mintlayer_encode_issue_nft_output( + size_t n_args, const mp_obj_t *args) { + mp_buffer_info_t token_id = {0}; + mp_get_buffer_raise(args[0], &token_id, MP_BUFFER_READ); + mp_buffer_info_t creator = {0}; + mp_get_buffer_raise(args[1], &creator, MP_BUFFER_READ); + mp_buffer_info_t name = {0}; + mp_get_buffer_raise(args[2], &name, MP_BUFFER_READ); + mp_buffer_info_t description = {0}; + mp_get_buffer_raise(args[3], &description, MP_BUFFER_READ); + mp_buffer_info_t ticker = {0}; + mp_get_buffer_raise(args[4], &ticker, MP_BUFFER_READ); + mp_buffer_info_t icon_uri = {0}; + mp_get_buffer_raise(args[5], &icon_uri, MP_BUFFER_READ); + mp_buffer_info_t additional_metadata_uri = {0}; + mp_get_buffer_raise(args[6], &additional_metadata_uri, MP_BUFFER_READ); + mp_buffer_info_t media_uri = {0}; + mp_get_buffer_raise(args[7], &media_uri, MP_BUFFER_READ); + mp_buffer_info_t media_hash = {0}; + mp_get_buffer_raise(args[8], &media_hash, MP_BUFFER_READ); + mp_buffer_info_t destination = {0}; + mp_get_buffer_raise(args[9], &destination, MP_BUFFER_READ); + + ByteArray arr = mintlayer_encode_issue_nft_output( + token_id.buf, token_id.len, creator.buf, creator.len, name.buf, name.len, + description.buf, description.len, ticker.buf, ticker.len, icon_uri.buf, + icon_uri.len, additional_metadata_uri.buf, additional_metadata_uri.len, + media_uri.buf, media_uri.len, media_hash.buf, media_hash.len, + destination.buf, destination.len); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN( + mod_trezormintlayer_utils_mintlayer_encode_issue_nft_output_obj, 10, 10, + mod_trezormintlayer_utils_mintlayer_encode_issue_nft_output); + +/// def encode_data_deposit_output(deposit: bytes) -> +/// bytes: +/// """ +/// encodes a data deposit output +/// """ +STATIC mp_obj_t mod_trezormintlayer_utils_mintlayer_encode_data_deposit_output( + mp_obj_t deposit_obj) { + mp_buffer_info_t deposit = {0}; + mp_get_buffer_raise(deposit_obj, &deposit, MP_BUFFER_READ); + ByteArray arr = + mintlayer_encode_data_deposit_output(deposit.buf, deposit.len); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_1( + mod_trezormintlayer_utils_mintlayer_encode_data_deposit_output_obj, + mod_trezormintlayer_utils_mintlayer_encode_data_deposit_output); + +/// def encode_htlc_output(amount: bytes, token_id: bytes, lock_type: +/// int, lock_amount:int, refund_key: bytes, spend_key: bytes, secret_has: +/// bytes) -> bytes: +/// """ +/// encodes an htlc output with given amount and lock +/// """ +STATIC mp_obj_t mod_trezormintlayer_utils_mintlayer_encode_htlc_output( + size_t n_args, const mp_obj_t *args) { + mp_buffer_info_t amount = {0}; + mp_get_buffer_raise(args[0], &amount, MP_BUFFER_READ); + mp_buffer_info_t token_id = {0}; + mp_get_buffer_raise(args[1], &token_id, MP_BUFFER_READ); + uint8_t lock_type = trezor_obj_get_uint8(args[2]); + uint64_t lock_amount = trezor_obj_get_uint64(args[3]); + mp_buffer_info_t refund_key = {0}; + mp_get_buffer_raise(args[4], &refund_key, MP_BUFFER_READ); + mp_buffer_info_t spend_key = {0}; + mp_get_buffer_raise(args[5], &spend_key, MP_BUFFER_READ); + mp_buffer_info_t secret_hash = {0}; + mp_get_buffer_raise(args[6], &secret_hash, MP_BUFFER_READ); + ByteArray arr = mintlayer_encode_htlc_output( + amount.buf, amount.len, token_id.buf, token_id.len, lock_type, + lock_amount, refund_key.buf, refund_key.len, spend_key.buf, spend_key.len, + secret_hash.buf, secret_hash.len); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN( + mod_trezormintlayer_utils_mintlayer_encode_htlc_output_obj, 7, 7, + mod_trezormintlayer_utils_mintlayer_encode_htlc_output); + +/// def encode_create_order_output(destination: bytes, ask_amount: bytes, +/// ask_token_id: bytes, give_amount: bytes, give_token_id: bytes) -> bytes: +/// """ +/// encodes a create order output with given the conclude key, give and +/// take amounts +/// """ +STATIC mp_obj_t mod_trezormintlayer_utils_mintlayer_encode_create_order_output( + size_t n_args, const mp_obj_t *args) { + mp_buffer_info_t conclude_key = {0}; + mp_get_buffer_raise(args[0], &conclude_key, MP_BUFFER_READ); + mp_buffer_info_t ask_amount = {0}; + mp_get_buffer_raise(args[1], &ask_amount, MP_BUFFER_READ); + mp_buffer_info_t ask_token_id = {0}; + mp_get_buffer_raise(args[2], &ask_token_id, MP_BUFFER_READ); + mp_buffer_info_t give_amount = {0}; + mp_get_buffer_raise(args[3], &give_amount, MP_BUFFER_READ); + mp_buffer_info_t give_token_id = {0}; + mp_get_buffer_raise(args[4], &give_token_id, MP_BUFFER_READ); + + ByteArray arr = mintlayer_encode_create_order_output( + conclude_key.buf, conclude_key.len, ask_amount.buf, ask_amount.len, + ask_token_id.buf, ask_token_id.len, give_amount.buf, give_amount.len, + give_token_id.buf, give_token_id.len); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN( + mod_trezormintlayer_utils_mintlayer_encode_create_order_output_obj, 5, 5, + mod_trezormintlayer_utils_mintlayer_encode_create_order_output); + +/// def encode_compact_length(length: int) -> bytes: +/// """ +/// encodes a compact length to bytes +/// """ +STATIC mp_obj_t +mod_trezormintlayer_utils_mintlayer_encode_comact_length(mp_obj_t length) { + uint32_t len = trezor_obj_get_uint(length); + ByteArray arr = mintlayer_encode_compact_length(len); + handle_err(&arr); + + return mp_obj_new_bytes(arr.data, arr.len_or_err.len); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_1( + mod_trezormintlayer_utils_mintlayer_encode_comact_length_obj, + mod_trezormintlayer_utils_mintlayer_encode_comact_length); diff --git a/core/mocks/generated/trezormintlayer.pyi b/core/mocks/generated/trezormintlayer.pyi new file mode 100644 index 0000000000..3e8302bcfe --- /dev/null +++ b/core/mocks/generated/trezormintlayer.pyi @@ -0,0 +1,153 @@ +from typing import * + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_utxo_input(tx_hash: bytes, index: int, utxo_type: int) -> bytes: + """ + encodes an utxo input from tx_hash and index + """ + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_account_spending_input(nonce: int, delegation_id: bytes, amount: +bytes) -> bytes: + """ + encodes an utxo account spending from nonce and delegation id + """ + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_token_account_command_input(nonce: int, command: int, token_id: +bytes, data: bytes) -> bytes: + """ + encodes an account command from the nonce, command, token id and + additional command data + """ + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_conclude_order_account_command_input(nonce: int, order_id: bytes) +-> bytes: + """ + encodes an conclude order account command from the nonce and order id + """ + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_fill_order_account_command_input(nonce: int, order_id: bytes, +amount: bytes, destination: bytes) +-> bytes: + """ + encodes an fill order account command from the nonce, order id, output + amount and destination + """ + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_transfer_output(amount: bytes, token_id: bytes, address: bytes) +-> bytes: + """ + encodes a transfer output with given amount and destination address + """ + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_lock_then_transfer_output(amount: bytes, token_id: bytes, +lock_type: int, lock_amount:int, address: bytes) -> bytes: + """ + encodes a transfer output with given amount, lock type and amount, and + destination address + """ + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_burn_output(amount: bytes, token_id: bytes) -> +bytes: + """ + encodes a burn output with given amount + """ + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_create_stake_pool_output(pool_id: bytes, pledge_amount: bytes, +staker: bytes, vrf_public_key: bytes, decommission_key: bytes, +margin_ratio_per_thousand: int, cost_per_block: bytes) -> bytes: + """ + encodes a create stake pool output + """ + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_produce_from_stake_output(destination: bytes, pool_id: bytes) -> +bytes: + """ + encodes a produce from stake output + """ + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_create_delegation_id_output(destination: bytes, pool_id: bytes) +-> bytes: + """ + encodes a create delegation id output + """ + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_delegate_staking_output(amount: bytes, delegation_id: bytes) -> +bytes: + """ + encodes a delegation staking output, given the amount and delegation id + """ + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_issue_fungible_token_output(token_ticker: bytes, +number_of_decimals: int, metadata_uri: bytes, total_supply_type: int, +fixed_amount: bytes, authority: bytes, is_freezable: int) -> bytes: + """ + encodes a issue fungible token output + """ + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_issue_nft_output(token_id: bytes, +creator: bytes, name: bytes, destination: bytes, +ticker: bytes, icon_uri: bytes, additional_metadata_uri: bytes, media_uri: +bytes, media_hash: bytes, destination: bytes) -> bytes: + """ + encodes a issue NFT output + """ + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_data_deposit_output(deposit: bytes) -> +bytes: + """ + encodes a data deposit output + """ + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_htlc_output(amount: bytes, token_id: bytes, lock_type: +int, lock_amount:int, refund_key: bytes, spend_key: bytes, secret_has: +bytes) -> bytes: + """ + encodes an htlc output with given amount and lock + """ + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_create_order_output(destination: bytes, ask_amount: bytes, +ask_token_id: bytes, give_amount: bytes, give_token_id: bytes) -> bytes: + """ + encodes a create order output with given the conclude key, give and + take amounts + """ + + +# upymod/modtrezormintlayer/modtrezormintlayer.h +def encode_compact_length(length: int) -> bytes: + """ + encodes a compact length to bytes + """ diff --git a/core/src/all_modules.py b/core/src/all_modules.py index 05f3a3330a..d0755bfd25 100644 --- a/core/src/all_modules.py +++ b/core/src/all_modules.py @@ -459,6 +459,18 @@ import trezor.enums.EthereumDataType trezor.enums.EthereumDefinitionType import trezor.enums.EthereumDefinitionType + trezor.enums.MintlayerAccountCommandType + import trezor.enums.MintlayerAccountCommandType + trezor.enums.MintlayerAddressType + import trezor.enums.MintlayerAddressType + trezor.enums.MintlayerChainType + import trezor.enums.MintlayerChainType + trezor.enums.MintlayerOutputTimeLockType + import trezor.enums.MintlayerOutputTimeLockType + trezor.enums.MintlayerTokenTotalSupplyType + import trezor.enums.MintlayerTokenTotalSupplyType + trezor.enums.MintlayerUtxoType + import trezor.enums.MintlayerUtxoType trezor.enums.MoneroNetworkType import trezor.enums.MoneroNetworkType trezor.enums.NEMImportanceTransferMode @@ -595,6 +607,24 @@ import apps.ethereum.tokens apps.ethereum.verify_message import apps.ethereum.verify_message + apps.mintlayer + import apps.mintlayer + apps.mintlayer.get_address + import apps.mintlayer.get_address + apps.mintlayer.get_public_key + import apps.mintlayer.get_public_key + apps.mintlayer.sign_message + import apps.mintlayer.sign_message + apps.mintlayer.sign_tx + import apps.mintlayer.sign_tx + apps.mintlayer.sign_tx.helpers + import apps.mintlayer.sign_tx.helpers + apps.mintlayer.sign_tx.layout + import apps.mintlayer.sign_tx.layout + apps.mintlayer.sign_tx.progress + import apps.mintlayer.sign_tx.progress + apps.mintlayer.sign_tx.signer + import apps.mintlayer.sign_tx.signer apps.monero import apps.monero apps.monero.diag diff --git a/core/src/all_modules.py.mako b/core/src/all_modules.py.mako index 73aeb01d61..0ea294c056 100644 --- a/core/src/all_modules.py.mako +++ b/core/src/all_modules.py.mako @@ -29,6 +29,7 @@ ALTCOINS = ( "tezos", "webauthn", "zcash", + "mintlayer" ) pyfiles = chain.from_iterable(sorted(SRCDIR.glob(p)) for p in PATTERNS) diff --git a/core/src/apps/base.py b/core/src/apps/base.py index 5552fc86ba..ab752a16a3 100644 --- a/core/src/apps/base.py +++ b/core/src/apps/base.py @@ -130,6 +130,7 @@ def get_features() -> Features: Capability.PassphraseEntry, Capability.Solana, Capability.Translations, + Capability.Mintlayer, ] # We don't support some currencies on later models (see #2793) diff --git a/core/src/apps/mintlayer/__init__.py b/core/src/apps/mintlayer/__init__.py new file mode 100644 index 0000000000..554bb3bf75 --- /dev/null +++ b/core/src/apps/mintlayer/__init__.py @@ -0,0 +1,144 @@ +from trezor.enums import MintlayerChainType +from trezor.wire.errors import DataError + +from apps.common.coininfo import CoinInfo +from apps.common.paths import PATTERN_BIP44, PATTERN_BIP44_PUBKEY + +CURVE = "secp256k1" +SLIP44_ID = 19788 +PATTERNS = [PATTERN_BIP44, PATTERN_BIP44_PUBKEY] + + +class Prefixes: + def __init__( + self, + public_key_hash: str, + public_key: str, + token: str, + delegation: str, + pool: str, + order: str, + ) -> None: + self.public_key_hash = public_key_hash + self.public_key = public_key + self.token = token + self.delegation = delegation + self.pool = pool + self.order = order + + +class MLCoinInfo(CoinInfo): + def __init__( + self, + slip44_id: int, + coin_name: str, + coin_shortcut: str, + decimals: int, + prefixes: Prefixes, + ) -> None: + super().__init__( + coin_name, + coin_shortcut, + decimals, + 0, + 0, + 0, + "", + 0, + None, + None, + None, + None, + None, + None, + slip44_id, + False, + False, + None, + False, + False, + False, + CURVE, + False, + False, + False, + None, + ) + self.prefixes = prefixes + + +TESTNET_COIN = MLCoinInfo( + slip44_id=1, + coin_name="testnet", + coin_shortcut="TML", + decimals=11, + prefixes=Prefixes( + public_key_hash="tmt", + public_key="tpmt", + token="tmltk", + delegation="tdelg", + pool="tpool", + order="tordr", + ), +) + +MAINNET_COIN = MLCoinInfo( + slip44_id=SLIP44_ID, + coin_name="mainnet", + coin_shortcut="ML", + decimals=11, + prefixes=Prefixes( + public_key_hash="mtc", + public_key="mptc", + token="mmltk", + delegation="mdelg", + pool="mpool", + order="mordr", + ), +) + +REGTEST_COIN = MLCoinInfo( + slip44_id=1, + coin_name="regtest", + coin_shortcut="TML", + decimals=11, + prefixes=Prefixes( + public_key_hash="rmt", + public_key="rpmt", + token="rmltk", + delegation="rdelg", + pool="rpool", + order="rordr", + ), +) + +SIGNET_COIN = MLCoinInfo( + slip44_id=1, + coin_name="signet", + coin_shortcut="TML", + decimals=11, + prefixes=Prefixes( + public_key_hash="smt", + public_key="spmt", + token="smltk", + delegation="sdelg", + pool="spool", + order="sordr", + ), +) + + +def find_coin_by_chain_type(chain_type: MintlayerChainType) -> MLCoinInfo: + if chain_type == MintlayerChainType.Mainnet: + return MAINNET_COIN + + if chain_type == MintlayerChainType.Testnet: + return TESTNET_COIN + + if chain_type == MintlayerChainType.Regtest: + return REGTEST_COIN + + if chain_type == MintlayerChainType.Signet: + return SIGNET_COIN + + raise DataError(f"Unknown chain type {chain_type}") diff --git a/core/src/apps/mintlayer/get_address.py b/core/src/apps/mintlayer/get_address.py new file mode 100644 index 0000000000..5c0785580a --- /dev/null +++ b/core/src/apps/mintlayer/get_address.py @@ -0,0 +1,51 @@ +from typing import TYPE_CHECKING + +from trezor.crypto import hashlib +from trezor.enums import InputScriptType + +from apps.common.keychain import with_slip44_keychain + +from ..bitcoin.keychain import validate_path_against_script_type +from . import CURVE, PATTERNS, SLIP44_ID, find_coin_by_chain_type + +if TYPE_CHECKING: + from trezor.messages import MintlayerAddress, MintlayerGetAddress + + from apps.common.keychain import Keychain + + +@with_slip44_keychain(*PATTERNS, curve=CURVE, slip44_id=SLIP44_ID, allow_testnet=True) +async def get_address(msg: MintlayerGetAddress, keychain: Keychain) -> MintlayerAddress: + from trezor.crypto.bech32 import Encoding, bech32_encode, convertbits + from trezor.messages import MintlayerAddress + from trezor.ui.layouts import show_address + + from apps.common import paths + + coin_info = find_coin_by_chain_type(msg.chain_type) + address_n = msg.address_n # local_cache_attribute + + await paths.validate_path( + keychain, + address_n, + validate_path_against_script_type( + coin_info, address_n=msg.address_n, script_type=InputScriptType.SPENDADDRESS + ), + ) + + node = keychain.derive(address_n) + pubkey = node.public_key() + pkh = hashlib.blake2b(bytes([0]) + pubkey).digest()[:20] + data = convertbits(bytes([1]) + pkh, 8, 5) + address = bech32_encode(coin_info.prefixes.public_key_hash, data, Encoding.BECH32M) + if msg.show_display: + await show_address( + address, + path=paths.address_n_to_str(address_n), + account=paths.get_account_name( + coin_info.coin_shortcut, msg.address_n, PATTERNS, coin_info.slip44 + ), + chunkify=bool(msg.chunkify), + ) + + return MintlayerAddress(address=address) diff --git a/core/src/apps/mintlayer/get_public_key.py b/core/src/apps/mintlayer/get_public_key.py new file mode 100644 index 0000000000..69f15290e9 --- /dev/null +++ b/core/src/apps/mintlayer/get_public_key.py @@ -0,0 +1,43 @@ +from typing import TYPE_CHECKING + +from apps.common.keychain import with_slip44_keychain + +from . import CURVE, PATTERNS, SLIP44_ID, find_coin_by_chain_type + +if TYPE_CHECKING: + from trezor.messages import MintlayerGetPublicKey, MintlayerPublicKey + + from apps.common.keychain import Keychain + + +@with_slip44_keychain(*PATTERNS, curve=CURVE, slip44_id=SLIP44_ID, allow_testnet=True) +async def get_public_key( + msg: MintlayerGetPublicKey, keychain: Keychain +) -> MintlayerPublicKey: + from ubinascii import hexlify + + from trezor.messages import MintlayerPublicKey + from trezor.ui.layouts import show_pubkey + + from apps.common import paths + + coin_info = find_coin_by_chain_type(msg.chain_type) + await paths.validate_path( + keychain, + msg.address_n, + ) + node = keychain.derive(msg.address_n) + pubkey = node.public_key() + chain_code = node.chain_code() + + if msg.show_display: + path = paths.address_n_to_str(msg.address_n) + await show_pubkey( + hexlify(pubkey).decode(), + account=paths.get_account_name( + coin_info.coin_shortcut, msg.address_n, PATTERNS, coin_info.slip44 + ), + path=path, + ) + + return MintlayerPublicKey(public_key=pubkey, chain_code=chain_code) diff --git a/core/src/apps/mintlayer/sign_message.py b/core/src/apps/mintlayer/sign_message.py new file mode 100644 index 0000000000..bf34d0d9a9 --- /dev/null +++ b/core/src/apps/mintlayer/sign_message.py @@ -0,0 +1,66 @@ +from typing import TYPE_CHECKING + +from trezor.crypto import hashlib +from trezor.wire.errors import DataError + +from apps.common.keychain import with_slip44_keychain + +from . import CURVE, PATTERNS, SLIP44_ID, find_coin_by_chain_type + +if TYPE_CHECKING: + from trezor.messages import MessageSignature, MintlayerSignMessage + + from apps.common.keychain import Keychain + + +@with_slip44_keychain(*PATTERNS, curve=CURVE, slip44_id=SLIP44_ID, allow_testnet=True) +async def sign_message( + msg: MintlayerSignMessage, keychain: Keychain +) -> MessageSignature: + from trezor.crypto.bech32 import Encoding, bech32_encode, convertbits + from trezor.crypto.curve import bip340 + from trezor.enums import MintlayerAddressType + from trezor.messages import MessageSignature + from trezor.ui.layouts import confirm_signverify + + from apps.common import paths + from apps.common.signverify import decode_message + + coin_info = find_coin_by_chain_type(msg.chain_type) + message = msg.message + address_n = msg.address_n + MESSAGE_MAGIC_PREFIX = b"===MINTLAYER MESSAGE BEGIN===\n" + MESSAGE_MAGIC_SUFFIX = b"\n===MINTLAYER MESSAGE END===" + + node = keychain.derive(address_n) + pubkey = node.public_key() + if msg.address_type == MintlayerAddressType.PUBLIC_KEY: + data = convertbits(bytes([2]) + pubkey, 8, 5) + address = bech32_encode(coin_info.prefixes.public_key, data, Encoding.BECH32M) + elif msg.address_type == MintlayerAddressType.PUBLIC_KEY_HASH: + pkh = hashlib.blake2b(bytes([0]) + pubkey).digest()[:20] + data = convertbits(bytes([1]) + pkh, 8, 5) + address = bech32_encode( + coin_info.prefixes.public_key_hash, data, Encoding.BECH32M + ) + else: + raise DataError(f"Unknown Address type {msg.address_type}") + + await confirm_signverify( + decode_message(message), + address, + verify=False, + account=paths.get_account_name( + coin_info.coin_shortcut, msg.address_n, PATTERNS, coin_info.slip44 + ), + path=paths.address_n_to_str(address_n), + chunkify=False, + ) + + msg2 = MESSAGE_MAGIC_PREFIX + message + MESSAGE_MAGIC_SUFFIX + digest = hashlib.blake2b(msg2).digest()[:32] + digest = hashlib.blake2b(digest).digest()[:32] + + other_sig = bip340.sign(node.private_key(), digest) + + return MessageSignature(signature=other_sig, address=address) diff --git a/core/src/apps/mintlayer/sign_tx/__init__.py b/core/src/apps/mintlayer/sign_tx/__init__.py new file mode 100644 index 0000000000..683550d84d --- /dev/null +++ b/core/src/apps/mintlayer/sign_tx/__init__.py @@ -0,0 +1,52 @@ +from typing import TYPE_CHECKING + +from apps.common.keychain import with_slip44_keychain + +from .. import CURVE, PATTERNS, SLIP44_ID + +if TYPE_CHECKING: + from trezor.messages import ( + MintlayerSignTx, + MintlayerTxAckOutput, + MintlayerTxAckUtxoInput, + MintlayerTxRequest, + ) + + from apps.common.keychain import Keychain + + TxAckType = MintlayerTxAckOutput | MintlayerTxAckUtxoInput + + +@with_slip44_keychain(*PATTERNS, curve=CURVE, slip44_id=SLIP44_ID) +async def sign_tx( + msg: MintlayerSignTx, + keychain: Keychain, +) -> MintlayerTxRequest: + from trezor.messages import MintlayerTxRequest + from trezor.wire import DataError, FirmwareError + from trezor.wire.context import call + + from . import helpers + from .signer import Mintlayer + + if msg.inputs_count == 0: + raise DataError("Cannot sign a transaction with 0 inputs") + + x = Mintlayer(msg, keychain) + progress = x.progress + signer = x.signer() + + res: TxAckType | bool | None = None + while True: + req = signer.send(res) + if isinstance(req, tuple): + request_class, req = req + assert MintlayerTxRequest.is_type_of(req) + if req.signing_finished is not None: + return req + res = await call(req, request_class) + elif isinstance(req, helpers.UiConfirm): + res = await req.confirm_dialog() + progress.report_init() + else: + raise FirmwareError("Invalid signing instruction") diff --git a/core/src/apps/mintlayer/sign_tx/helpers.py b/core/src/apps/mintlayer/sign_tx/helpers.py new file mode 100644 index 0000000000..044a5f5da5 --- /dev/null +++ b/core/src/apps/mintlayer/sign_tx/helpers.py @@ -0,0 +1,247 @@ +from micropython import const +from typing import TYPE_CHECKING, Tuple + +from trezor import utils +from trezor.crypto.bech32 import bech32_decode, convertbits +from trezor.enums import MintlayerOutputTimeLockType +from trezor.messages import MintlayerTokenOutputValue +from trezor.wire import DataError + +from . import layout + +if TYPE_CHECKING: + from typing import Any, Awaitable + + from trezor.messages import ( + MintlayerOutputTimeLock, + MintlayerTxInput, + MintlayerTxOutput, + MintlayerTxRequest, + ) + + from apps.common.coininfo import CoinInfo + +TX_HASH_SIZE = const(32) + +# Machine instructions +# === + + +class UiConfirm: + def confirm_dialog(self) -> Awaitable[Any]: + raise NotImplementedError + + __eq__ = utils.obj_eq + + +class UiConfirmOutput(UiConfirm): + def __init__( + self, + output: MintlayerTxOutput, + output_index: int, + coininfo: CoinInfo, + chunkify: bool, + ) -> None: + self.output = output + self.output_index = output_index + self.chunkify = chunkify + self.coininfo = coininfo + + def confirm_dialog(self) -> Awaitable[Any]: + return layout.confirm_output( + self.output, + self.output_index, + self.coininfo, + self.chunkify, + ) + + +class UiConfirmTotal(UiConfirm): + def __init__( + self, + spending: int, + fee: int, + coininfo: CoinInfo, + token: MintlayerTokenOutputValue | None, + ) -> None: + self.spending = spending + self.fee = fee + self.coininfo = coininfo + self.token = token + + def confirm_dialog(self) -> Awaitable[Any]: + return layout.confirm_total(self.spending, self.fee, self.coininfo, self.token) + + +def confirm_output( + output: MintlayerTxOutput, output_index: int, coininfo: CoinInfo, chunkify: bool +) -> Awaitable[None]: # type: ignore [awaitable-return-type] + return ( + yield UiConfirmOutput( # type: ignore [awaitable-return-type] + output, output_index, coininfo, chunkify + ) + ) + + +def confirm_total( + spending: int, fee: int, coininfo: CoinInfo, token: MintlayerTokenOutputValue | None +) -> Awaitable[None]: # type: ignore [awaitable-return-type] + return (yield UiConfirmTotal(spending, fee, coininfo, token)) # type: ignore [awaitable-return-type] + + +def request_tx_input(tx_req: MintlayerTxRequest, i: int) -> Awaitable[MintlayerTxInput]: # type: ignore [awaitable-return-type] + from trezor.messages import MintlayerTxAck, MintlayerTxInputRequest + + tx_req.input_request = MintlayerTxInputRequest(input_index=i) + assert tx_req.output_request is None and tx_req.signing_finished is None + ack = yield MintlayerTxAck, tx_req # type: ignore [awaitable-return-type] + _clear_tx_request(tx_req) + return _sanitize_tx_input(ack.input) + + +def request_tx_output( + tx_req: MintlayerTxRequest, i: int, tx_hash: bytes | None = None +) -> Awaitable[MintlayerTxOutput]: # type: ignore [awaitable-return-type] + from trezor.messages import MintlayerTxAck, MintlayerTxOutputRequest + + tx_req.output_request = MintlayerTxOutputRequest(output_index=i, tx_hash=tx_hash) + assert tx_req.input_request is None and tx_req.signing_finished is None + ack = yield MintlayerTxAck, tx_req # type: ignore [awaitable-return-type] + _clear_tx_request(tx_req) + return _sanitize_tx_output(ack.output) + + +def request_tx_finish(tx_req: MintlayerTxRequest) -> Awaitable[None]: # type: ignore [awaitable-return-type] + yield None, tx_req # type: ignore [awaitable-return-type]q + assert tx_req.input_request is None and tx_req.output_request is None + _clear_tx_request(tx_req) + + +def _clear_tx_request(tx_req: MintlayerTxRequest) -> None: + assert ( + tx_req.input_request is not None + or tx_req.output_request is not None + or tx_req.signing_finished is not None + ) + tx_req.input_request = None + tx_req.output_request = None + tx_req.signing_finished = None + + +# Data sanitizers +# === + + +def _sanitize_tx_input(txi: MintlayerTxInput | None) -> MintlayerTxInput: + from trezor.wire import DataError # local_cache_global + + if txi is None: + raise DataError("Expected a MintlayerTxInput response") + + if txi.utxo: + if len(txi.utxo.prev_hash) != TX_HASH_SIZE: + raise DataError("Provided prev_hash is invalid.") + + if txi.utxo.prev_index < 0: + raise DataError("Invalid UTXO previous index.") + + if txi.utxo.addresses is None: + raise DataError("Input's addresses must be present for signing.") + elif txi.account_command: + cmd = txi.account_command + no_cmd = ( + cmd.mint is None + and cmd.unmint is None + and cmd.freeze_token is None + and cmd.unfreeze_token is None + and cmd.lock_token_supply is None + and cmd.change_token_metadata_uri is None + and cmd.change_token_authority is None + and cmd.conclude_order is None + and cmd.fill_order is None + ) + if no_cmd: + raise DataError("No account command present") + + if txi.account_command.addresses is None: + raise DataError("Input's addresses must be present for signing.") + elif txi.account: + if txi.account.addresses is None: + raise DataError("Input's addresses must be present for signing.") + + if txi.account.delegation_balance: + pass + else: + raise DataError("No account spending is set") + + else: + raise DataError( + "No input type present either utxo, account_command or account must be present" + ) + + return txi + + +def _sanitize_tx_output(txo: MintlayerTxOutput | None) -> MintlayerTxOutput: + from trezor.wire import DataError # local_cache_global + + if txo is None: + raise DataError("Expected an MintlayerTxOutput response") + + if txo.transfer: + pass + elif txo.lock_then_transfer: + pass + elif txo.burn: + pass + elif txo.issue_nft: + pass + elif txo.create_stake_pool: + pass + elif txo.produce_block_from_stake: + raise DataError("Cannot create a ProduceBlockFromStake output in a transaction") + elif txo.create_delegation_id: + pass + elif txo.delegate_staking: + pass + elif txo.issue_fungible_token: + pass + elif txo.issue_nft: + pass + elif txo.data_deposit: + pass + elif txo.htlc: + pass + elif txo.create_order: + pass + else: + raise DataError("Tx Output not set") + + return txo + + +def get_lock(x: MintlayerOutputTimeLock) -> Tuple[MintlayerOutputTimeLockType, int]: + if x.until_height is not None: + lock_type = MintlayerOutputTimeLockType.UNTIL_HEIGHT + lock_amount = x.until_height + elif x.until_time is not None: + lock_type = MintlayerOutputTimeLockType.UNTIL_TIME + lock_amount = x.until_time + elif x.for_block_count is not None: + lock_type = MintlayerOutputTimeLockType.FOR_BLOCK_COUNT + lock_amount = x.for_block_count + elif x.for_seconds is not None: + lock_type = MintlayerOutputTimeLockType.FOR_SECONDS + lock_amount = x.for_seconds + else: + raise DataError("unhandled mintlayer lock type") + return (lock_type, lock_amount) + + +def mintlayer_decode(address: str, check_hrp: str | None) -> bytes: + hrpgot, data, _ = bech32_decode(address) + if check_hrp is not None and hrpgot != check_hrp: + raise Exception(f"Invalid address expected HRP {check_hrp} got {hrpgot}") + + decoded = bytes(convertbits(data, 5, 8, False)) + return decoded diff --git a/core/src/apps/mintlayer/sign_tx/layout.py b/core/src/apps/mintlayer/sign_tx/layout.py new file mode 100644 index 0000000000..4292eddaf0 --- /dev/null +++ b/core/src/apps/mintlayer/sign_tx/layout.py @@ -0,0 +1,210 @@ +from typing import TYPE_CHECKING + +from trezor import TR +from trezor.enums import ButtonRequestType, MintlayerTokenTotalSupplyType +from trezor.strings import format_amount +from trezor.ui import layouts +from trezor.wire.errors import DataError + +if TYPE_CHECKING: + from trezor.messages import ( + MintlayerOutputTimeLock, + MintlayerTokenOutputValue, + MintlayerTxOutput, + ) + + from apps.common.coininfo import CoinInfo + + +def format_coin_amount( + amount: bytes, token: MintlayerTokenOutputValue | None, coininfo: CoinInfo +) -> str: + return format_coin_amount_int(int.from_bytes(amount, "big"), token, coininfo) + + +def format_coin_amount_int( + amount_int: int, token: MintlayerTokenOutputValue | None, coininfo: CoinInfo +) -> str: + if token is None: + decimals = coininfo.decimals + name = coininfo.coin_shortcut + else: + decimals = token.number_of_decimals + ticker = token.token_ticker.decode("utf-8") + name = f"Unknown token with ID: {token.token_id} and ticker {ticker}" + + amount_str = format_amount(amount_int, decimals) + + return f"{amount_str} {name}" + + +def lock_to_string(lock: MintlayerOutputTimeLock) -> str: + from trezor.strings import format_timestamp + + if lock.until_time is not None: + return f"Lock until {format_timestamp(lock.until_time)}" + elif lock.until_height is not None: + return f"Lock until block height {lock.until_height}" + elif lock.for_seconds is not None: + return f"Lock for {lock.for_seconds} seconds" + elif lock.for_block_count is not None: + return f"Lock for {lock.for_block_count} blocks" + else: + raise DataError("Unhandled lock type") + + +async def confirm_output( + output: MintlayerTxOutput, + output_index: int, + coininfo: CoinInfo, + chunkify: bool, +) -> None: + from ubinascii import hexlify + + title = TR.bitcoin__title_confirm_details + if output.transfer: + x = output.transfer + assert x.address is not None + address_short = x.address + amount = format_coin_amount(x.value.amount, x.value.token, coininfo) + address_label = "Transfer" + elif output.lock_then_transfer: + x = output.lock_then_transfer + assert x.address is not None + address_label = "Lock then Transfer" + address_short = f"Destination: {x.address}\n" + address_short += lock_to_string(x.lock) + amount = format_coin_amount(x.value.amount, x.value.token, coininfo) + elif output.burn: + x = output.burn + address_short = "BURN" + amount = format_coin_amount(x.value.amount, x.value.token, coininfo) + address_label = "" + elif output.create_stake_pool: + x = output.create_stake_pool + assert x.staker is not None and x.decommission_key is not None + address_short = f"""Pool ID: {x.pool_id} +Staker key: {x.staker} +Decommission key: {x.decommission_key}" +VRF public key: {x.vrf_public_key} +Margin ratio per thousand: {x.margin_ratio_per_thousand} +Cost per block: {int.from_bytes(x.cost_per_block, "big")} +""" + amount = format_coin_amount(x.pledge, None, coininfo) + address_label = "Create staking pool" + elif output.produce_block_from_stake: + x = output.produce_block_from_stake + address_short = f"New staker key: {x.destination}" + amount = "" + address_label = "Produce block from stake" + elif output.create_delegation_id: + x = output.create_delegation_id + amount = "" + address_short = f"Address: {x.destination}\nPoolId: {x.pool_id}" + address_label = "Create delegation" + elif output.delegate_staking: + x = output.delegate_staking + address_short = x.delegation_id + amount = format_coin_amount(x.amount, None, coininfo) + address_label = "Delegate staking" + elif output.issue_fungible_token: + x = output.issue_fungible_token + ticker = x.token_ticker.decode("utf-8") + metadata_uri = x.metadata_uri.decode("utf-8") if x.metadata_uri else None + if x.total_supply.type == MintlayerTokenTotalSupplyType.UNLIMITED: + total_supply = "UNLIMITED" + elif x.total_supply.type == MintlayerTokenTotalSupplyType.LOCKABLE: + total_supply = "LOCKABLE" + elif x.total_supply.type == MintlayerTokenTotalSupplyType.FIXED: + if not x.total_supply.fixed_amount: + raise DataError("Token Fixed supply without amount") + fixed_amount = int.from_bytes(x.total_supply.fixed_amount, "big") + formatted_amount = format_amount(fixed_amount, x.number_of_decimals) + total_supply = f"FIXED {formatted_amount}" + else: + raise DataError("Unhandled Token total supply type") + is_freezable = "Yes" if x.is_freezable else "No" + address_short = f"""Ticker: {ticker} +Authority: {x.authority} +Metadata URI: {metadata_uri} +Total token supply: {total_supply} +Number of decimals: {x.number_of_decimals} +Is freezable: {is_freezable}""" + amount = "" + address_label = "Issue fungible token" + elif output.issue_nft: + x = output.issue_nft + ticker = x.ticker.decode("utf-8") + name = x.name.decode("utf-8") + icon_uri = x.icon_uri.decode("utf-8") if x.icon_uri else None + additional_metadata_uri = ( + x.additional_metadata_uri.decode("utf-8") + if x.additional_metadata_uri + else None + ) + media_uri = x.media_uri.decode("utf-8") if x.media_uri else None + address_short = f"""Name: {name} +Creator: {x.creator} +Ticker: {ticker} +Address: {x.destination} +Icon URI: {icon_uri} +Additional medatada URI: {additional_metadata_uri} +Media URI: {media_uri}""" + amount = "" + address_label = "Issue NFT token" + elif output.data_deposit: + x = output.data_deposit + address_short = hexlify(x.data).decode() + amount = "" + address_label = "Data deposit" + elif output.htlc: + x = output.htlc + lock = lock_to_string(x.refund_timelock) + hexified_secret_hash = hexlify(x.secret_hash).decode() + address_short = f"""Secret hash: {hexified_secret_hash} +Spend key: {x.spend_key} +Refund key: {x.refund_key} +Refund time lock: {lock}""" + amount = format_coin_amount(x.value.amount, x.value.token, coininfo) + address_label = "HTLC" + elif output.create_order: + x = output.create_order + ask_amount = format_coin_amount(x.ask.amount, x.ask.token, coininfo) + give_amount = format_coin_amount(x.give.amount, x.give.token, coininfo) + address_short = f"""Conclude key: {x.conclude_key} +Ask: {ask_amount} +Give: {give_amount}""" + amount = "" + address_label = "Create order" + else: + raise DataError("Unhandled output type") + + if amount: + layout = layouts.confirm_output( + address_short, + amount, + title=title, + address_label=address_label, + output_index=output_index, + chunkify=chunkify, + ) + else: + layout = layouts.confirm_text( + "confirm_address", + title=title, + data=address_short, + description=address_label, + br_code=ButtonRequestType.ConfirmOutput, + ) + + await layout + + +async def confirm_total( + spending: int, fee: int, coininfo: CoinInfo, token: MintlayerTokenOutputValue | None +) -> None: + await layouts.confirm_total( + format_coin_amount_int(spending, token, coininfo), + format_coin_amount_int(fee, token, coininfo), + fee_rate_amount=None, + ) diff --git a/core/src/apps/mintlayer/sign_tx/progress.py b/core/src/apps/mintlayer/sign_tx/progress.py new file mode 100644 index 0000000000..19f7188073 --- /dev/null +++ b/core/src/apps/mintlayer/sign_tx/progress.py @@ -0,0 +1,69 @@ +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from trezor.messages import MintlayerSignTx + + +class Progress: + def __init__(self) -> None: + self.progress = 0 + self.steps = 0 + self.signing = False + + def init(self, tx: MintlayerSignTx) -> None: + self.progress = 0 + self.signing = False + + # Step 1 and 2 - load inputs and outputs + self.steps = tx.inputs_count + tx.outputs_count + + self.report_init() + self.report() + + def init_signing( + self, + tx: MintlayerSignTx, + ) -> None: + if __debug__: + self.assert_finished() + + self.progress = 0 + self.signing = True + # Step 3 and 4 - serialize all inputs and outputs + self.steps = tx.inputs_count + tx.outputs_count + + def advance(self) -> None: + self.progress += 1 + self.report() + + def report_init(self) -> None: + from trezor import TR, workflow + from trezor.ui.layouts.progress import bitcoin_progress + + progress_layout = bitcoin_progress + workflow.close_others() + text = ( + TR.progress__signing_transaction + if self.signing + else TR.progress__loading_transaction + ) + self.progress_layout = progress_layout(text) + + def report(self) -> None: + from trezor import utils + + if utils.DISABLE_ANIMATION: + return + p = int(1000 * self.progress / self.steps) + self.progress_layout.report(p) + + if __debug__: + + def assert_finished(self) -> None: + if abs(self.progress - self.steps) > 0.5: + from trezor import wire + + operation = "signing" if self.signing else "loading" + raise wire.FirmwareError( + f"Transaction {operation} progress finished at {self.progress}/{self.steps}." + ) diff --git a/core/src/apps/mintlayer/sign_tx/signer.py b/core/src/apps/mintlayer/sign_tx/signer.py new file mode 100644 index 0000000000..29dbbde62e --- /dev/null +++ b/core/src/apps/mintlayer/sign_tx/signer.py @@ -0,0 +1,696 @@ +from typing import TYPE_CHECKING + +from trezor import log, workflow +from trezor.crypto import mintlayer_utils +from trezor.crypto.curve import bip340 +from trezor.crypto.hashlib import blake2b +from trezor.enums import MintlayerAccountCommandType +from trezor.messages import ( + MintlayerSignature, + MintlayerSignaturesForInput, + MintlayerSignTx, + MintlayerTokenOutputValue, + MintlayerTxInput, + MintlayerTxOutput, + MintlayerTxSigningResult, +) +from trezor.wire.errors import DataError + +from .. import find_coin_by_chain_type +from . import helpers +from .helpers import mintlayer_decode +from .progress import Progress + +if TYPE_CHECKING: + from typing import Dict, List, Tuple + + from trezor.crypto import bip32 + from trezor.messages import MintlayerOutputValue + + from apps.common.keychain import Keychain + + +class OutputValueTpl: + def __init__( + self, coin_or_token_id: str, ticker: bytes, number_of_decimals: int, amount: int + ) -> None: + self.coin_or_token_id = coin_or_token_id + self.ticker = ticker + self.number_of_decimals = number_of_decimals + self.amount = amount + + @staticmethod + def from_token_output_value( + value: MintlayerTokenOutputValue, amount: int + ) -> "OutputValueTpl": + return OutputValueTpl( + value.token_id, + value.token_ticker, + value.number_of_decimals, + amount, + ) + + +def decode_nullable_address(address: str | None) -> bytes: + if address is None: + return bytes() + + return mintlayer_decode(address, None) + + +def decode_nullable_token_id( + token: MintlayerTokenOutputValue | None, token_hrp: str +) -> bytes: + if token is None: + return b"" + return mintlayer_decode(token.token_id, token_hrp) + + +class TxInput: + def __init__( + self, + input: MintlayerTxInput, + utxo: MintlayerTxOutput | None, + nodes: List[Tuple[bip32.HDNode, int | None]], + ) -> None: + self.input = input + self.utxo = utxo + self.nodes = nodes + + +class TxInfo: + def __init__( + self, + tx: MintlayerSignTx, + inputs: List[TxInput], + outputs: List[MintlayerTxOutput], + ) -> None: + self.tx = tx + self.inputs = inputs + self.outputs = outputs + + def add_input( + self, + txi: MintlayerTxInput, + txo: MintlayerTxOutput | None, + nodes: List[Tuple[bip32.HDNode, int | None]], + ) -> None: + self.inputs.append(TxInput(input=txi, utxo=txo, nodes=nodes)) + + def add_output(self, txo: MintlayerTxOutput) -> None: + self.outputs.append(txo) + + +class Mintlayer: + def init_signing(self) -> None: + self.progress.init_signing(self.tx_info.tx) + self.signing = True + + async def signer(self) -> None: + self.progress.init(self.tx_info.tx) + + # Fetch and add inputs and compute the sum of input amounts. + input_totals = await self.step1_process_inputs() + + # Fetch and add outputs, approve outputs and compute sum of output amounts. + output_totals = await self.step2_approve_outputs() + coin_total = output_totals.pop(self.coininfo.coin_shortcut) + + if input_totals[self.coininfo.coin_shortcut] < coin_total.amount: + raise DataError("Transaction trying to print money") + + fee = input_totals[self.coininfo.coin_shortcut] - coin_total.amount + await helpers.confirm_total(coin_total.amount, fee, self.coininfo, None) + for token_id, total in output_totals.items(): + token_output_value = MintlayerTokenOutputValue( + token_id=total.coin_or_token_id, + token_ticker=total.ticker, + number_of_decimals=total.number_of_decimals, + ) + + total_inputs = input_totals.get(token_id, 0) + if total_inputs < total.amount: + raise DataError("Transaction trying to print money") + + fee = total_inputs - total.amount + # FIXME new confirm total + await helpers.confirm_total( + total.amount, fee, self.coininfo, token_output_value + ) + + # Make sure proper progress is shown, in case dialog was not required + if not self.signing: + self.init_signing() + self.progress.report_init() + self.progress.report() + + # Following steps can take a long time, make sure autolock doesn't kick in. + # This is set to True again after workflow is finished in start_default(). + workflow.autolock_interrupts_workflow = False + + # Serialize the inputs. + encoded_inputs, encoded_input_utxos = await self.step3_serialize_inputs() + if __debug__: + log.debug(__name__, "encoded inputs: %s", str(encoded_inputs)) + log.debug(__name__, "encoded utxos: %s", str(encoded_input_utxos)) + + # Serialize the outputs. + encoded_outputs = await self.step4_serialize_outputs() + if __debug__: + log.debug(__name__, "encoded outputs: %s", str(encoded_outputs)) + + # Sign the inputs. + signatures = await self.step5_sign_inputs( + encoded_inputs, encoded_input_utxos, encoded_outputs + ) + + # write the signatures + await self.step6_finish(signatures) + + def __init__( + self, + tx: MintlayerSignTx, + keychain: Keychain, + ) -> None: + from trezor.messages import MintlayerTxRequest + + if tx.version != 1: + raise DataError("Only transactions of version 1 are supported") + + self.progress = Progress() + self.coininfo = find_coin_by_chain_type(tx.chain_type) + self.tx_info = TxInfo(tx=tx, inputs=[], outputs=[]) + self.keychain = keychain + + # indicates whether the transaction is being signed + self.signing = False + + self.chunkify = tx.chunkify or False + self.tx_req = MintlayerTxRequest() + + async def step1_process_inputs( + self, + ) -> Dict[str, int]: + tx_info = self.tx_info # local_cache_attribute + totals: Dict[str, int] = {self.coininfo.coin_shortcut: 0} + + for i in range(tx_info.tx.inputs_count): + self.progress.advance() + # get the input + txi = await helpers.request_tx_input(self.tx_req, i) + if txi.utxo: + # get the utxo + txo = await helpers.request_tx_output( + self.tx_req, txi.utxo.prev_index, txi.utxo.prev_hash + ) + nodes = [] + for address in txi.utxo.addresses: + nodes.append( + ( + self.keychain.derive(address.address_n), + address.multisig_idx, + ) + ) + + update_input_totals(totals, txo, self.coininfo.coin_shortcut) + self.tx_info.add_input(txi, txo, nodes) + elif txi.account: + nodes = [] + for address in txi.account.addresses: + nodes.append( + ( + self.keychain.derive(address.address_n), + address.multisig_idx, + ) + ) + if txi.account.delegation_balance: + value = txi.account.delegation_balance + amount = int.from_bytes(value.amount, "big") + totals[self.coininfo.coin_shortcut] += amount + self.tx_info.add_input(txi, None, nodes) + else: + raise DataError("Unhandled account spending type") + elif txi.account_command: + nodes = [] + for address in txi.account_command.addresses: + nodes.append( + ( + self.keychain.derive(address.address_n), + address.multisig_idx, + ) + ) + x = txi.account_command + if x.mint: + token_id = x.mint.token_id + amount = int.from_bytes(x.mint.amount, "big") + totals[token_id] = totals.get(token_id, 0) + amount + elif x.unmint: + pass + elif x.lock_token_supply: + pass + elif x.freeze_token: + pass + elif x.unfreeze_token: + pass + elif x.change_token_authority: + pass + elif x.change_token_metadata_uri: + pass + elif x.conclude_order: + ask = x.conclude_order.filled_ask_amount + ask_amount = int.from_bytes(ask.amount, "big") + ask_token_or_coin = ( + ask.token.token_id if ask.token else self.coininfo.coin_shortcut + ) + + totals[ask_token_or_coin] = ( + totals.get(ask_token_or_coin, 0) + ask_amount + ) + + give = x.conclude_order.give_balance + give_amount = int.from_bytes(give.amount, "big") + give_token_or_coin = ( + give.token.token_id + if give.token + else self.coininfo.coin_shortcut + ) + + totals[give_token_or_coin] = ( + totals.get(give_token_or_coin, 0) + give_amount + ) + elif x.fill_order: + give_amount = int.from_bytes( + x.fill_order.give_balance.amount, "big" + ) + fill_amount = int.from_bytes(x.fill_order.amount, "big") + ask_amount = int.from_bytes(x.fill_order.ask_balance.amount, "big") + + amount = (give_amount * fill_amount) // ask_amount + + give = x.fill_order.give_balance + ask_token_or_coin = ( + give.token.token_id + if give.token + else self.coininfo.coin_shortcut + ) + + totals[ask_token_or_coin] = ( + totals.get(ask_token_or_coin, 0) + amount + ) + else: + raise DataError("Unknown account command") + self.tx_info.add_input(txi, None, nodes) + else: + raise DataError("Unhandled tx input type") + + return totals + + async def step2_approve_outputs( + self, + ) -> Dict[str, OutputValueTpl]: + totals: Dict[str, OutputValueTpl] = { + self.coininfo.coin_shortcut: OutputValueTpl( + self.coininfo.coin_name, + self.coininfo.coin_shortcut.encode(), + self.coininfo.decimals, + 0, + ) + } + + for i in range(self.tx_info.tx.outputs_count): + self.progress.advance() + txo = await helpers.request_tx_output(self.tx_req, i) + await helpers.confirm_output(txo, i, self.coininfo, self.chunkify) + update_output_totals(totals, txo, self.coininfo.coin_shortcut) + self.tx_info.add_output(txo) + return totals + + async def step3_serialize_inputs(self) -> Tuple[List[bytes], List[bytes]]: + encoded_inputs = [] + encoded_input_utxos = [] + for inp in self.tx_info.inputs: + self.progress.advance() + if inp.input.utxo and inp.utxo: + u = inp.input.utxo + encoded_inp = mintlayer_utils.encode_utxo_input( + u.prev_hash, u.prev_index, int(u.type) + ) + encoded_inputs.append(encoded_inp) + + encoded_inp_utxo = self.serialize_output(inp.utxo) + # prepend \x01 for an active Option + encoded_input_utxos.append(b"\x01" + encoded_inp_utxo) + elif inp.input.account: + a = inp.input.account + nonce = a.nonce + if a.delegation_balance: + deleg_balance = a.delegation_balance + delegation_id = mintlayer_decode( + deleg_balance.delegation_id, self.coininfo.prefixes.delegation + ) + encoded_inp = mintlayer_utils.encode_account_spending_input( + nonce, delegation_id, deleg_balance.amount + ) + encoded_inputs.append(encoded_inp) + # just add a \x00 for an empty Option as accounts don't have an UTXO + encoded_input_utxos.append(b"\x00") + else: + raise DataError("Unknown account spending") + elif inp.input.account_command: + x = inp.input.account_command + if x.mint: + command = MintlayerAccountCommandType.MINT_TOKENS + token_id = x.mint.token_id + data = x.mint.amount + elif x.unmint: + command = MintlayerAccountCommandType.UNMINT_TOKENS + token_id = x.unmint.token_id + data = b"" + elif x.lock_token_supply: + command = MintlayerAccountCommandType.LOCK_TOKEN_SUPPLY + token_id = x.lock_token_supply.token_id + data = b"" + elif x.freeze_token: + command = MintlayerAccountCommandType.FREEZE_TOKEN + token_id = x.freeze_token.token_id + data = int(x.freeze_token.is_token_unfreezable).to_bytes(1, "big") + elif x.unfreeze_token: + command = MintlayerAccountCommandType.UNFREEZE_TOKEN + token_id = x.unfreeze_token.token_id + data = b"" + elif x.change_token_authority: + command = MintlayerAccountCommandType.CHANGE_TOKEN_AUTHORITY + token_id = x.change_token_authority.token_id + data = decode_nullable_address(x.change_token_authority.destination) + elif x.change_token_metadata_uri: + command = MintlayerAccountCommandType.CHANGE_TOKEN_METADATA_URI + token_id = x.change_token_metadata_uri.token_id + data = x.change_token_metadata_uri.metadata_uri + elif x.conclude_order: + ord = x.conclude_order + encoded_inp = ( + mintlayer_utils.encode_conclude_order_account_command_input( + x.nonce, + mintlayer_decode( + ord.order_id, self.coininfo.prefixes.order + ), + ) + ) + encoded_inputs.append(encoded_inp) + # just add a \x00 for an empty Option as account command inputs don't have an UTXO + encoded_input_utxos.append(b"\x00") + continue + elif x.fill_order: + ord = x.fill_order + destination = decode_nullable_address(ord.destination) + encoded_inp = ( + mintlayer_utils.encode_fill_order_account_command_input( + x.nonce, + mintlayer_decode( + ord.order_id, self.coininfo.prefixes.order + ), + ord.amount, + destination, + ) + ) + encoded_inputs.append(encoded_inp) + # just add a \x00 for an empty Option as account command inputs don't have an UTXO + encoded_input_utxos.append(b"\x00") + continue + else: + raise DataError("Unknown account command") + + encoded_inp = mintlayer_utils.encode_token_account_command_input( + x.nonce, + int(command), + mintlayer_decode(token_id, self.coininfo.prefixes.token), + data, + ) + encoded_inputs.append(encoded_inp) + # just add a \x00 for an empty Option as account command inputs don't have an UTXO + encoded_input_utxos.append(b"\x00") + + return encoded_inputs, encoded_input_utxos + + def serialize_output(self, out: MintlayerTxOutput) -> bytes: + if out.transfer: + x = out.transfer + data = decode_nullable_address(x.address) + token_id = decode_nullable_token_id( + x.value.token, self.coininfo.prefixes.token + ) + encoded_out = mintlayer_utils.encode_transfer_output( + x.value.amount, token_id, data + ) + elif out.lock_then_transfer: + x = out.lock_then_transfer + data = decode_nullable_address(x.address) + lock_type, lock_amount = helpers.get_lock(x.lock) + token_id = decode_nullable_token_id( + x.value.token, self.coininfo.prefixes.token + ) + encoded_out = mintlayer_utils.encode_lock_then_transfer_output( + x.value.amount, token_id, int(lock_type), lock_amount, data + ) + elif out.burn: + x = out.burn + token_id = decode_nullable_token_id( + x.value.token, self.coininfo.prefixes.token + ) + encoded_out = mintlayer_utils.encode_burn_output(x.value.amount, token_id) + elif out.create_stake_pool: + x = out.create_stake_pool + staker = decode_nullable_address(x.staker) + vrf_public_key = decode_nullable_address(x.vrf_public_key) + decommission_key = decode_nullable_address(x.decommission_key) + encoded_out = mintlayer_utils.encode_create_stake_pool_output( + mintlayer_decode(x.pool_id, self.coininfo.prefixes.pool), + x.pledge, + staker, + vrf_public_key, + decommission_key, + x.margin_ratio_per_thousand, + x.cost_per_block, + ) + elif out.create_delegation_id: + x = out.create_delegation_id + destination = decode_nullable_address(x.destination) + encoded_out = mintlayer_utils.encode_create_delegation_id_output( + destination, mintlayer_decode(x.pool_id, self.coininfo.prefixes.pool) + ) + elif out.delegate_staking: + x = out.delegate_staking + encoded_out = mintlayer_utils.encode_delegate_staking_output( + x.amount, + mintlayer_decode(x.delegation_id, self.coininfo.prefixes.delegation), + ) + elif out.produce_block_from_stake: + x = out.produce_block_from_stake + destination = decode_nullable_address(x.destination) + encoded_out = mintlayer_utils.encode_produce_from_stake_output( + destination, mintlayer_decode(x.pool_id, self.coininfo.prefixes.pool) + ) + elif out.issue_fungible_token: + x = out.issue_fungible_token + authority = decode_nullable_address(x.authority) + encoded_out = mintlayer_utils.encode_issue_fungible_token_output( + x.token_ticker, + x.number_of_decimals, + x.metadata_uri, + int(x.total_supply.type), + x.total_supply.fixed_amount or b"", + authority, + int(x.is_freezable), + ) + elif out.issue_nft: + x = out.issue_nft + creator = decode_nullable_address(x.creator) + destination = decode_nullable_address(x.destination) + encoded_out = mintlayer_utils.encode_issue_nft_output( + mintlayer_decode(x.token_id, self.coininfo.prefixes.token), + creator, + x.name, + x.description, + x.ticker, + x.icon_uri or b"", + x.additional_metadata_uri or b"", + x.media_uri or b"", + x.media_hash, + destination, + ) + elif out.data_deposit: + x = out.data_deposit + encoded_out = mintlayer_utils.encode_data_deposit_output(x.data) + elif out.htlc: + x = out.htlc + token_id = decode_nullable_token_id( + x.value.token, self.coininfo.prefixes.token + ) + spend_key = decode_nullable_address(x.spend_key) + refund_key = decode_nullable_address(x.refund_key) + lock_type, lock_amount = helpers.get_lock(x.refund_timelock) + encoded_out = mintlayer_utils.encode_htlc_output( + x.value.amount, + token_id, + int(lock_type), + lock_amount, + refund_key, + spend_key, + x.secret_hash, + ) + elif out.create_order: + x = out.create_order + conclude_key = decode_nullable_address(x.conclude_key) + ask_token_id = decode_nullable_token_id( + x.ask.token, self.coininfo.prefixes.token + ) + give_token_id = decode_nullable_token_id( + x.give.token, self.coininfo.prefixes.token + ) + encoded_out = mintlayer_utils.encode_create_order_output( + conclude_key, x.ask.amount, ask_token_id, x.give.amount, give_token_id + ) + else: + raise DataError("Unhandled tx output type") + return encoded_out + + async def step4_serialize_outputs(self) -> List[bytes]: + encoded_outputs = [] + for out in self.tx_info.outputs: + self.progress.advance() + encoded_out = self.serialize_output(out) + encoded_outputs.append(encoded_out) + + return encoded_outputs + + async def step5_sign_inputs( + self, + encoded_inputs: List[bytes], + encoded_input_utxos: List[bytes], + encoded_outputs: List[bytes], + ) -> List[List[Tuple[bytes, int | None]]]: + from trezor.utils import HashWriter + + signatures = [] + if len(encoded_inputs) != len(encoded_input_utxos): + raise DataError( + "number of encoded utxos not the same as the number of inputs" + ) + + for i in range(self.tx_info.tx.inputs_count): + sigs = [] + for node, multisig_idx in self.tx_info.inputs[i].nodes: + writer = HashWriter(blake2b()) + # mode + writer.extend(b"\x01") + + # version + writer.extend(b"\x01") + # flags + writer.extend(bytes([0] * 16)) + + writer.extend(len(encoded_inputs).to_bytes(4, "little")) + for inp in encoded_inputs: + writer.extend(inp) + + writer.extend(len(encoded_input_utxos).to_bytes(4, "little")) + for utxo in encoded_input_utxos: + writer.extend(utxo) + + encoded_len = mintlayer_utils.encode_compact_length( + len(encoded_outputs) + ) + writer.extend(encoded_len) + for out in encoded_outputs: + writer.extend(out) + + hash = writer.get_digest()[:32] + private_key = node.private_key() + digest = blake2b(hash).digest()[:32] + + sig = bip340.sign(private_key, digest) + sigs.append((sig, multisig_idx)) + signatures.append(sigs) + + return signatures + + async def step6_finish( + self, signatures: List[List[Tuple[bytes, int | None]]] + ) -> None: + sigs = [ + MintlayerSignaturesForInput( + input_index=i, + signatures=[ + MintlayerSignature(signature=s[0], multisig_idx=s[1]) for s in sigs + ], + ) + for i, sigs in enumerate(signatures) + ] + self.tx_req.signing_finished = MintlayerTxSigningResult(signatures=sigs) + await helpers.request_tx_finish(self.tx_req) + + +def update_input_totals( + totals: Dict[str, int], + txo: MintlayerTxOutput, + ml_coin: str, +) -> None: + def update(value: MintlayerOutputValue) -> None: + amount = int.from_bytes(value.amount, "big") + token_or_coin = value.token.token_id if value.token else ml_coin + totals[token_or_coin] = totals.get(token_or_coin, 0) + amount + + if txo.transfer: + update(txo.transfer.value) + elif txo.lock_then_transfer: + update(txo.lock_then_transfer.value) + elif txo.issue_nft: + token_or_coin = txo.issue_nft.token_id + totals[token_or_coin] = totals.get(token_or_coin, 0) + 1 + elif txo.create_stake_pool: + amount = int.from_bytes(txo.create_stake_pool.pledge, "big") + totals[ml_coin] += amount + elif txo.produce_block_from_stake: + amount = int.from_bytes(txo.produce_block_from_stake.staker_balance, "big") + totals[ml_coin] += amount + elif txo.htlc: + update(txo.htlc.value) + else: + raise DataError("Unhandled TX output type as UTXO") + + +def update_output_totals( + totals: Dict[str, OutputValueTpl], + txo: MintlayerTxOutput, + ml_coin: str, +) -> None: + def update(value: MintlayerOutputValue) -> None: + amount = int.from_bytes(value.amount, "big") + + token_or_coin = value.token.token_id if value.token else ml_coin + if token_or_coin in totals: + totals[token_or_coin].amount += amount + elif value.token: + token = OutputValueTpl.from_token_output_value(value.token, amount) + totals[token_or_coin] = token + else: + raise DataError("ml_coin not found in totals") + + if txo.transfer: + update(txo.transfer.value) + elif txo.lock_then_transfer: + update(txo.lock_then_transfer.value) + elif txo.burn: + update(txo.burn.value) + elif txo.issue_nft: + pass + elif txo.create_stake_pool: + amount = int.from_bytes(txo.create_stake_pool.pledge, "big") + totals[ml_coin].amount += amount + elif txo.delegate_staking: + amount = int.from_bytes(txo.delegate_staking.amount, "big") + totals[ml_coin].amount += amount + elif txo.htlc: + update(txo.htlc.value) + elif txo.create_order: + pass diff --git a/core/src/apps/workflow_handlers.py b/core/src/apps/workflow_handlers.py index b65c853c93..d1c492f198 100644 --- a/core/src/apps/workflow_handlers.py +++ b/core/src/apps/workflow_handlers.py @@ -210,6 +210,16 @@ def _find_message_handler_module(msg_type: int) -> str: if msg_type == MessageType.SolanaSignTx: return "apps.solana.sign_tx" + # mintlayer + if msg_type == MessageType.MintlayerGetAddress: + return "apps.mintlayer.get_address" + if msg_type == MessageType.MintlayerGetPublicKey: + return "apps.mintlayer.get_public_key" + if msg_type == MessageType.MintlayerSignMessage: + return "apps.mintlayer.sign_message" + if msg_type == MessageType.MintlayerSignTx: + return "apps.mintlayer.sign_tx" + raise ValueError diff --git a/core/src/trezor/crypto/__init__.py b/core/src/trezor/crypto/__init__.py index 51c159fe16..16017a3d54 100644 --- a/core/src/trezor/crypto/__init__.py +++ b/core/src/trezor/crypto/__init__.py @@ -19,6 +19,8 @@ if not utils.BITCOIN_ONLY: from trezorcrypto import cardano, monero, nem # noqa: F401 + import trezormintlayer as mintlayer_utils # noqa: F401 + if utils.USE_OPTIGA: from trezorcrypto import optiga # noqa: F401 diff --git a/core/src/trezor/enums/Capability.py b/core/src/trezor/enums/Capability.py index bb26adb21b..ed14671ebe 100644 --- a/core/src/trezor/enums/Capability.py +++ b/core/src/trezor/enums/Capability.py @@ -25,3 +25,4 @@ Tezos = 13 U2F = 14 Solana = 18 + Mintlayer = 22 diff --git a/core/src/trezor/enums/MessageType.py b/core/src/trezor/enums/MessageType.py index ed569795b0..be8d447db7 100644 --- a/core/src/trezor/enums/MessageType.py +++ b/core/src/trezor/enums/MessageType.py @@ -250,3 +250,11 @@ SolanaAddress = 903 SolanaSignTx = 904 SolanaTxSignature = 905 + MintlayerGetAddress = 10000 + MintlayerAddress = 10001 + MintlayerGetPublicKey = 10002 + MintlayerPublicKey = 10003 + MintlayerSignMessage = 10004 + MintlayerSignTx = 10005 + MintlayerTxRequest = 10006 + MintlayerTxAck = 10007 diff --git a/core/src/trezor/enums/MintlayerAccountCommandType.py b/core/src/trezor/enums/MintlayerAccountCommandType.py new file mode 100644 index 0000000000..fe22dbd6a5 --- /dev/null +++ b/core/src/trezor/enums/MintlayerAccountCommandType.py @@ -0,0 +1,13 @@ +# Automatically generated by pb2py +# fmt: off +# isort:skip_file + +MINT_TOKENS = 0 +UNMINT_TOKENS = 1 +LOCK_TOKEN_SUPPLY = 2 +FREEZE_TOKEN = 3 +UNFREEZE_TOKEN = 4 +CHANGE_TOKEN_AUTHORITY = 5 +CONCLUDE_ORDER = 6 +FILL_ORDER = 7 +CHANGE_TOKEN_METADATA_URI = 8 diff --git a/core/src/trezor/enums/MintlayerAddressType.py b/core/src/trezor/enums/MintlayerAddressType.py new file mode 100644 index 0000000000..c785e85af0 --- /dev/null +++ b/core/src/trezor/enums/MintlayerAddressType.py @@ -0,0 +1,6 @@ +# Automatically generated by pb2py +# fmt: off +# isort:skip_file + +PUBLIC_KEY = 1 +PUBLIC_KEY_HASH = 2 diff --git a/core/src/trezor/enums/MintlayerChainType.py b/core/src/trezor/enums/MintlayerChainType.py new file mode 100644 index 0000000000..f24fbec87b --- /dev/null +++ b/core/src/trezor/enums/MintlayerChainType.py @@ -0,0 +1,8 @@ +# Automatically generated by pb2py +# fmt: off +# isort:skip_file + +Mainnet = 1 +Testnet = 2 +Regtest = 3 +Signet = 4 diff --git a/core/src/trezor/enums/MintlayerOutputTimeLockType.py b/core/src/trezor/enums/MintlayerOutputTimeLockType.py new file mode 100644 index 0000000000..1fc5ab4d0f --- /dev/null +++ b/core/src/trezor/enums/MintlayerOutputTimeLockType.py @@ -0,0 +1,8 @@ +# Automatically generated by pb2py +# fmt: off +# isort:skip_file + +UNTIL_HEIGHT = 0 +UNTIL_TIME = 1 +FOR_BLOCK_COUNT = 2 +FOR_SECONDS = 3 diff --git a/core/src/trezor/enums/MintlayerTokenTotalSupplyType.py b/core/src/trezor/enums/MintlayerTokenTotalSupplyType.py new file mode 100644 index 0000000000..c8a8ec6016 --- /dev/null +++ b/core/src/trezor/enums/MintlayerTokenTotalSupplyType.py @@ -0,0 +1,7 @@ +# Automatically generated by pb2py +# fmt: off +# isort:skip_file + +FIXED = 0 +LOCKABLE = 1 +UNLIMITED = 2 diff --git a/core/src/trezor/enums/MintlayerUtxoType.py b/core/src/trezor/enums/MintlayerUtxoType.py new file mode 100644 index 0000000000..434d1da7e3 --- /dev/null +++ b/core/src/trezor/enums/MintlayerUtxoType.py @@ -0,0 +1,6 @@ +# Automatically generated by pb2py +# fmt: off +# isort:skip_file + +TRANSACTION = 0 +BLOCK = 1 diff --git a/core/src/trezor/enums/__init__.py b/core/src/trezor/enums/__init__.py index d16c3c4a66..c4cf407562 100644 --- a/core/src/trezor/enums/__init__.py +++ b/core/src/trezor/enums/__init__.py @@ -245,6 +245,7 @@ class Capability(IntEnum): Translations = 19 Brightness = 20 Haptic = 21 + Mintlayer = 22 class SdProtectOperationType(IntEnum): DISABLE = 0 @@ -299,6 +300,42 @@ class EthereumDataType(IntEnum): ARRAY = 7 STRUCT = 8 + class MintlayerAccountCommandType(IntEnum): + MINT_TOKENS = 0 + UNMINT_TOKENS = 1 + LOCK_TOKEN_SUPPLY = 2 + FREEZE_TOKEN = 3 + UNFREEZE_TOKEN = 4 + CHANGE_TOKEN_AUTHORITY = 5 + CONCLUDE_ORDER = 6 + FILL_ORDER = 7 + CHANGE_TOKEN_METADATA_URI = 8 + + class MintlayerOutputTimeLockType(IntEnum): + UNTIL_HEIGHT = 0 + UNTIL_TIME = 1 + FOR_BLOCK_COUNT = 2 + FOR_SECONDS = 3 + + class MintlayerChainType(IntEnum): + Mainnet = 1 + Testnet = 2 + Regtest = 3 + Signet = 4 + + class MintlayerAddressType(IntEnum): + PUBLIC_KEY = 1 + PUBLIC_KEY_HASH = 2 + + class MintlayerUtxoType(IntEnum): + TRANSACTION = 0 + BLOCK = 1 + + class MintlayerTokenTotalSupplyType(IntEnum): + FIXED = 0 + LOCKABLE = 1 + UNLIMITED = 2 + class MoneroNetworkType(IntEnum): MAINNET = 0 TESTNET = 1 @@ -595,3 +632,11 @@ class MessageType(IntEnum): BenchmarkNames = 9101 BenchmarkRun = 9102 BenchmarkResult = 9103 + MintlayerGetAddress = 10000 + MintlayerAddress = 10001 + MintlayerGetPublicKey = 10002 + MintlayerPublicKey = 10003 + MintlayerSignMessage = 10004 + MintlayerSignTx = 10005 + MintlayerTxRequest = 10006 + MintlayerTxAck = 10007 diff --git a/core/src/trezor/messages.py b/core/src/trezor/messages.py index 2a3ce05125..547f9e5808 100644 --- a/core/src/trezor/messages.py +++ b/core/src/trezor/messages.py @@ -49,6 +49,12 @@ def __getattr__(name: str) -> Any: from trezor.enums import HomescreenFormat # noqa: F401 from trezor.enums import InputScriptType # noqa: F401 from trezor.enums import MessageType # noqa: F401 + from trezor.enums import MintlayerAccountCommandType # noqa: F401 + from trezor.enums import MintlayerAddressType # noqa: F401 + from trezor.enums import MintlayerChainType # noqa: F401 + from trezor.enums import MintlayerOutputTimeLockType # noqa: F401 + from trezor.enums import MintlayerTokenTotalSupplyType # noqa: F401 + from trezor.enums import MintlayerUtxoType # noqa: F401 from trezor.enums import MoneroNetworkType # noqa: F401 from trezor.enums import MultisigPubkeysOrder # noqa: F401 from trezor.enums import NEMImportanceTransferMode # noqa: F401 @@ -4034,6 +4040,834 @@ def __init__( def is_type_of(cls, msg: Any) -> TypeGuard["EthereumAccessList"]: return isinstance(msg, cls) + class MintlayerGetAddress(protobuf.MessageType): + address_n: "list[int]" + chain_type: "MintlayerChainType" + show_display: "bool | None" + chunkify: "bool | None" + + def __init__( + self, + *, + chain_type: "MintlayerChainType", + address_n: "list[int] | None" = None, + show_display: "bool | None" = None, + chunkify: "bool | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerGetAddress"]: + return isinstance(msg, cls) + + class MintlayerAddress(protobuf.MessageType): + address: "str" + + def __init__( + self, + *, + address: "str", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerAddress"]: + return isinstance(msg, cls) + + class MintlayerGetPublicKey(protobuf.MessageType): + address_n: "list[int]" + chain_type: "MintlayerChainType" + show_display: "bool | None" + + def __init__( + self, + *, + chain_type: "MintlayerChainType", + address_n: "list[int] | None" = None, + show_display: "bool | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerGetPublicKey"]: + return isinstance(msg, cls) + + class MintlayerPublicKey(protobuf.MessageType): + public_key: "bytes" + chain_code: "bytes" + + def __init__( + self, + *, + public_key: "bytes", + chain_code: "bytes", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerPublicKey"]: + return isinstance(msg, cls) + + class MintlayerSignMessage(protobuf.MessageType): + address_n: "list[int]" + chain_type: "MintlayerChainType" + address_type: "MintlayerAddressType" + message: "bytes" + + def __init__( + self, + *, + chain_type: "MintlayerChainType", + address_type: "MintlayerAddressType", + message: "bytes", + address_n: "list[int] | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerSignMessage"]: + return isinstance(msg, cls) + + class MintlayerSignTx(protobuf.MessageType): + outputs_count: "int" + inputs_count: "int" + chain_type: "MintlayerChainType" + version: "int" + chunkify: "bool | None" + + def __init__( + self, + *, + outputs_count: "int", + inputs_count: "int", + chain_type: "MintlayerChainType", + version: "int | None" = None, + chunkify: "bool | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerSignTx"]: + return isinstance(msg, cls) + + class MintlayerTxRequest(protobuf.MessageType): + input_request: "MintlayerTxInputRequest | None" + output_request: "MintlayerTxOutputRequest | None" + signing_finished: "MintlayerTxSigningResult | None" + + def __init__( + self, + *, + input_request: "MintlayerTxInputRequest | None" = None, + output_request: "MintlayerTxOutputRequest | None" = None, + signing_finished: "MintlayerTxSigningResult | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerTxRequest"]: + return isinstance(msg, cls) + + class MintlayerAddressPath(protobuf.MessageType): + address_n: "list[int]" + multisig_idx: "int | None" + + def __init__( + self, + *, + address_n: "list[int] | None" = None, + multisig_idx: "int | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerAddressPath"]: + return isinstance(msg, cls) + + class MintlayerUtxoTxInput(protobuf.MessageType): + addresses: "list[MintlayerAddressPath]" + prev_hash: "bytes" + prev_index: "int" + type: "MintlayerUtxoType" + + def __init__( + self, + *, + prev_hash: "bytes", + prev_index: "int", + type: "MintlayerUtxoType", + addresses: "list[MintlayerAddressPath] | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerUtxoTxInput"]: + return isinstance(msg, cls) + + class MintlayerAccountTxInput(protobuf.MessageType): + addresses: "list[MintlayerAddressPath]" + nonce: "int" + delegation_balance: "MintlayerAccountSpendingDelegationBalance | None" + + def __init__( + self, + *, + nonce: "int", + addresses: "list[MintlayerAddressPath] | None" = None, + delegation_balance: "MintlayerAccountSpendingDelegationBalance | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerAccountTxInput"]: + return isinstance(msg, cls) + + class MintlayerAccountSpendingDelegationBalance(protobuf.MessageType): + delegation_id: "str" + amount: "bytes" + + def __init__( + self, + *, + delegation_id: "str", + amount: "bytes", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerAccountSpendingDelegationBalance"]: + return isinstance(msg, cls) + + class MintlayerAccountCommandTxInput(protobuf.MessageType): + addresses: "list[MintlayerAddressPath]" + nonce: "int" + mint: "MintlayerMintTokens | None" + unmint: "MintlayerUnmintTokens | None" + lock_token_supply: "MintlayerLockTokenSupply | None" + freeze_token: "MintlayerFreezeToken | None" + unfreeze_token: "MintlayerUnfreezeToken | None" + change_token_authority: "MintlayerChangeTokenAuthority | None" + conclude_order: "MintlayerConcludeOrder | None" + fill_order: "MintlayerFillOrder | None" + change_token_metadata_uri: "MintlayerChangeTokenMetadataUri | None" + + def __init__( + self, + *, + nonce: "int", + addresses: "list[MintlayerAddressPath] | None" = None, + mint: "MintlayerMintTokens | None" = None, + unmint: "MintlayerUnmintTokens | None" = None, + lock_token_supply: "MintlayerLockTokenSupply | None" = None, + freeze_token: "MintlayerFreezeToken | None" = None, + unfreeze_token: "MintlayerUnfreezeToken | None" = None, + change_token_authority: "MintlayerChangeTokenAuthority | None" = None, + conclude_order: "MintlayerConcludeOrder | None" = None, + fill_order: "MintlayerFillOrder | None" = None, + change_token_metadata_uri: "MintlayerChangeTokenMetadataUri | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerAccountCommandTxInput"]: + return isinstance(msg, cls) + + class MintlayerMintTokens(protobuf.MessageType): + token_id: "str" + amount: "bytes" + + def __init__( + self, + *, + token_id: "str", + amount: "bytes", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerMintTokens"]: + return isinstance(msg, cls) + + class MintlayerUnmintTokens(protobuf.MessageType): + token_id: "str" + + def __init__( + self, + *, + token_id: "str", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerUnmintTokens"]: + return isinstance(msg, cls) + + class MintlayerLockTokenSupply(protobuf.MessageType): + token_id: "str" + + def __init__( + self, + *, + token_id: "str", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerLockTokenSupply"]: + return isinstance(msg, cls) + + class MintlayerFreezeToken(protobuf.MessageType): + token_id: "str" + is_token_unfreezable: "bool" + + def __init__( + self, + *, + token_id: "str", + is_token_unfreezable: "bool", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerFreezeToken"]: + return isinstance(msg, cls) + + class MintlayerUnfreezeToken(protobuf.MessageType): + token_id: "str" + + def __init__( + self, + *, + token_id: "str", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerUnfreezeToken"]: + return isinstance(msg, cls) + + class MintlayerChangeTokenAuthority(protobuf.MessageType): + token_id: "str" + destination: "str" + + def __init__( + self, + *, + token_id: "str", + destination: "str", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerChangeTokenAuthority"]: + return isinstance(msg, cls) + + class MintlayerConcludeOrder(protobuf.MessageType): + order_id: "str" + filled_ask_amount: "MintlayerOutputValue" + give_balance: "MintlayerOutputValue" + + def __init__( + self, + *, + order_id: "str", + filled_ask_amount: "MintlayerOutputValue", + give_balance: "MintlayerOutputValue", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerConcludeOrder"]: + return isinstance(msg, cls) + + class MintlayerFillOrder(protobuf.MessageType): + order_id: "str" + amount: "bytes" + destination: "str" + ask_balance: "MintlayerOutputValue" + give_balance: "MintlayerOutputValue" + + def __init__( + self, + *, + order_id: "str", + amount: "bytes", + destination: "str", + ask_balance: "MintlayerOutputValue", + give_balance: "MintlayerOutputValue", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerFillOrder"]: + return isinstance(msg, cls) + + class MintlayerChangeTokenMetadataUri(protobuf.MessageType): + token_id: "str" + metadata_uri: "bytes" + + def __init__( + self, + *, + token_id: "str", + metadata_uri: "bytes", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerChangeTokenMetadataUri"]: + return isinstance(msg, cls) + + class MintlayerTokenOutputValue(protobuf.MessageType): + token_id: "str" + token_ticker: "bytes" + number_of_decimals: "int" + + def __init__( + self, + *, + token_id: "str", + token_ticker: "bytes", + number_of_decimals: "int", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerTokenOutputValue"]: + return isinstance(msg, cls) + + class MintlayerOutputValue(protobuf.MessageType): + amount: "bytes" + token: "MintlayerTokenOutputValue | None" + + def __init__( + self, + *, + amount: "bytes", + token: "MintlayerTokenOutputValue | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerOutputValue"]: + return isinstance(msg, cls) + + class MintlayerTransferTxOutput(protobuf.MessageType): + address: "str" + value: "MintlayerOutputValue" + + def __init__( + self, + *, + address: "str", + value: "MintlayerOutputValue", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerTransferTxOutput"]: + return isinstance(msg, cls) + + class MintlayerOutputTimeLock(protobuf.MessageType): + until_height: "int | None" + until_time: "int | None" + for_block_count: "int | None" + for_seconds: "int | None" + + def __init__( + self, + *, + until_height: "int | None" = None, + until_time: "int | None" = None, + for_block_count: "int | None" = None, + for_seconds: "int | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerOutputTimeLock"]: + return isinstance(msg, cls) + + class MintlayerLockThenTransferTxOutput(protobuf.MessageType): + address: "str" + value: "MintlayerOutputValue" + lock: "MintlayerOutputTimeLock" + + def __init__( + self, + *, + address: "str", + value: "MintlayerOutputValue", + lock: "MintlayerOutputTimeLock", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerLockThenTransferTxOutput"]: + return isinstance(msg, cls) + + class MintlayerBurnTxOutput(protobuf.MessageType): + value: "MintlayerOutputValue" + + def __init__( + self, + *, + value: "MintlayerOutputValue", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerBurnTxOutput"]: + return isinstance(msg, cls) + + class MintlayerCreateStakePoolTxOutput(protobuf.MessageType): + pool_id: "str" + pledge: "bytes" + staker: "str" + vrf_public_key: "str" + decommission_key: "str" + margin_ratio_per_thousand: "int" + cost_per_block: "bytes" + + def __init__( + self, + *, + pool_id: "str", + pledge: "bytes", + staker: "str", + vrf_public_key: "str", + decommission_key: "str", + margin_ratio_per_thousand: "int", + cost_per_block: "bytes", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerCreateStakePoolTxOutput"]: + return isinstance(msg, cls) + + class MintlayerProduceBlockFromStakeTxOutput(protobuf.MessageType): + destination: "str" + pool_id: "str" + staker_balance: "bytes" + + def __init__( + self, + *, + destination: "str", + pool_id: "str", + staker_balance: "bytes", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerProduceBlockFromStakeTxOutput"]: + return isinstance(msg, cls) + + class MintlayerCreateDelegationIdTxOutput(protobuf.MessageType): + destination: "str" + pool_id: "str" + + def __init__( + self, + *, + destination: "str", + pool_id: "str", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerCreateDelegationIdTxOutput"]: + return isinstance(msg, cls) + + class MintlayerDelegateStakingTxOutput(protobuf.MessageType): + amount: "bytes" + delegation_id: "str" + + def __init__( + self, + *, + amount: "bytes", + delegation_id: "str", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerDelegateStakingTxOutput"]: + return isinstance(msg, cls) + + class MintlayerTokenTotalSupply(protobuf.MessageType): + type: "MintlayerTokenTotalSupplyType" + fixed_amount: "bytes | None" + + def __init__( + self, + *, + type: "MintlayerTokenTotalSupplyType", + fixed_amount: "bytes | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerTokenTotalSupply"]: + return isinstance(msg, cls) + + class MintlayerIssueFungibleTokenTxOutput(protobuf.MessageType): + token_ticker: "bytes" + number_of_decimals: "int" + metadata_uri: "bytes" + total_supply: "MintlayerTokenTotalSupply" + authority: "str" + is_freezable: "bool" + + def __init__( + self, + *, + token_ticker: "bytes", + number_of_decimals: "int", + metadata_uri: "bytes", + total_supply: "MintlayerTokenTotalSupply", + authority: "str", + is_freezable: "bool", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerIssueFungibleTokenTxOutput"]: + return isinstance(msg, cls) + + class MintlayerIssueNftTxOutput(protobuf.MessageType): + token_id: "str" + destination: "str" + creator: "str | None" + name: "bytes" + description: "bytes" + ticker: "bytes" + icon_uri: "bytes | None" + additional_metadata_uri: "bytes | None" + media_uri: "bytes | None" + media_hash: "bytes" + + def __init__( + self, + *, + token_id: "str", + destination: "str", + name: "bytes", + description: "bytes", + ticker: "bytes", + media_hash: "bytes", + creator: "str | None" = None, + icon_uri: "bytes | None" = None, + additional_metadata_uri: "bytes | None" = None, + media_uri: "bytes | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerIssueNftTxOutput"]: + return isinstance(msg, cls) + + class MintlayerDataDepositTxOutput(protobuf.MessageType): + data: "bytes" + + def __init__( + self, + *, + data: "bytes", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerDataDepositTxOutput"]: + return isinstance(msg, cls) + + class MintlayerHtlcTxOutput(protobuf.MessageType): + value: "MintlayerOutputValue" + secret_hash: "bytes" + spend_key: "str" + refund_timelock: "MintlayerOutputTimeLock" + refund_key: "str" + + def __init__( + self, + *, + value: "MintlayerOutputValue", + secret_hash: "bytes", + spend_key: "str", + refund_timelock: "MintlayerOutputTimeLock", + refund_key: "str", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerHtlcTxOutput"]: + return isinstance(msg, cls) + + class MintlayerCreateOrderTxOutput(protobuf.MessageType): + conclude_key: "str" + ask: "MintlayerOutputValue" + give: "MintlayerOutputValue" + + def __init__( + self, + *, + conclude_key: "str", + ask: "MintlayerOutputValue", + give: "MintlayerOutputValue", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerCreateOrderTxOutput"]: + return isinstance(msg, cls) + + class MintlayerTxAck(protobuf.MessageType): + input: "MintlayerTxInput | None" + output: "MintlayerTxOutput | None" + + def __init__( + self, + *, + input: "MintlayerTxInput | None" = None, + output: "MintlayerTxOutput | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerTxAck"]: + return isinstance(msg, cls) + + class MintlayerTxInputRequest(protobuf.MessageType): + input_index: "int" + + def __init__( + self, + *, + input_index: "int", + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerTxInputRequest"]: + return isinstance(msg, cls) + + class MintlayerTxOutputRequest(protobuf.MessageType): + output_index: "int" + tx_hash: "bytes | None" + + def __init__( + self, + *, + output_index: "int", + tx_hash: "bytes | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerTxOutputRequest"]: + return isinstance(msg, cls) + + class MintlayerSignature(protobuf.MessageType): + signature: "bytes" + multisig_idx: "int | None" + + def __init__( + self, + *, + signature: "bytes", + multisig_idx: "int | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerSignature"]: + return isinstance(msg, cls) + + class MintlayerSignaturesForInput(protobuf.MessageType): + input_index: "int" + signatures: "list[MintlayerSignature]" + + def __init__( + self, + *, + input_index: "int", + signatures: "list[MintlayerSignature] | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerSignaturesForInput"]: + return isinstance(msg, cls) + + class MintlayerTxSigningResult(protobuf.MessageType): + signatures: "list[MintlayerSignaturesForInput]" + + def __init__( + self, + *, + signatures: "list[MintlayerSignaturesForInput] | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerTxSigningResult"]: + return isinstance(msg, cls) + + class MintlayerTxInput(protobuf.MessageType): + utxo: "MintlayerUtxoTxInput | None" + account: "MintlayerAccountTxInput | None" + account_command: "MintlayerAccountCommandTxInput | None" + + def __init__( + self, + *, + utxo: "MintlayerUtxoTxInput | None" = None, + account: "MintlayerAccountTxInput | None" = None, + account_command: "MintlayerAccountCommandTxInput | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerTxInput"]: + return isinstance(msg, cls) + + class MintlayerTxOutput(protobuf.MessageType): + transfer: "MintlayerTransferTxOutput | None" + lock_then_transfer: "MintlayerLockThenTransferTxOutput | None" + burn: "MintlayerBurnTxOutput | None" + create_stake_pool: "MintlayerCreateStakePoolTxOutput | None" + produce_block_from_stake: "MintlayerProduceBlockFromStakeTxOutput | None" + create_delegation_id: "MintlayerCreateDelegationIdTxOutput | None" + delegate_staking: "MintlayerDelegateStakingTxOutput | None" + issue_fungible_token: "MintlayerIssueFungibleTokenTxOutput | None" + issue_nft: "MintlayerIssueNftTxOutput | None" + data_deposit: "MintlayerDataDepositTxOutput | None" + htlc: "MintlayerHtlcTxOutput | None" + create_order: "MintlayerCreateOrderTxOutput | None" + + def __init__( + self, + *, + transfer: "MintlayerTransferTxOutput | None" = None, + lock_then_transfer: "MintlayerLockThenTransferTxOutput | None" = None, + burn: "MintlayerBurnTxOutput | None" = None, + create_stake_pool: "MintlayerCreateStakePoolTxOutput | None" = None, + produce_block_from_stake: "MintlayerProduceBlockFromStakeTxOutput | None" = None, + create_delegation_id: "MintlayerCreateDelegationIdTxOutput | None" = None, + delegate_staking: "MintlayerDelegateStakingTxOutput | None" = None, + issue_fungible_token: "MintlayerIssueFungibleTokenTxOutput | None" = None, + issue_nft: "MintlayerIssueNftTxOutput | None" = None, + data_deposit: "MintlayerDataDepositTxOutput | None" = None, + htlc: "MintlayerHtlcTxOutput | None" = None, + create_order: "MintlayerCreateOrderTxOutput | None" = None, + ) -> None: + pass + + @classmethod + def is_type_of(cls, msg: Any) -> TypeGuard["MintlayerTxOutput"]: + return isinstance(msg, cls) + class MoneroTransactionSourceEntry(protobuf.MessageType): outputs: "list[MoneroOutputEntry]" real_output: "int | None" diff --git a/legacy/firmware/.changelog.d/noissue.added b/legacy/firmware/.changelog.d/noissue.added new file mode 100644 index 0000000000..b70e59e8cf --- /dev/null +++ b/legacy/firmware/.changelog.d/noissue.added @@ -0,0 +1 @@ +Mintlayer support diff --git a/legacy/firmware/CHANGELOG.md b/legacy/firmware/CHANGELOG.md index 0e04397217..55bcdb1e40 100644 --- a/legacy/firmware/CHANGELOG.md +++ b/legacy/firmware/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## 2.8.7-Mintlayer [7th February 2025] + +### Added +- Mintlayer support [#noissue] + ## 1.12.1 [15th March 2023] ### Added diff --git a/legacy/firmware/protob/Makefile b/legacy/firmware/protob/Makefile index 48dbd5ddc7..ec10ff0a4e 100644 --- a/legacy/firmware/protob/Makefile +++ b/legacy/firmware/protob/Makefile @@ -2,7 +2,7 @@ ifneq ($(V),1) Q := @ endif -SKIPPED_MESSAGES := Binance Cardano DebugMonero Eos Monero Ontology Ripple SdProtect Tezos WebAuthn \ +SKIPPED_MESSAGES := Binance Cardano DebugMonero Eos Monero Ontology Ripple SdProtect Tezos WebAuthn Mintlayer \ DebugLinkRecordScreen DebugLinkEraseSdCard DebugLinkWatchLayout \ DebugLinkLayout DebugLinkResetDebugEvents GetNonce \ TxAckInput TxAckOutput TxAckPrev TxAckPaymentRequest \ diff --git a/python/.changelog.d/noissue.added b/python/.changelog.d/noissue.added new file mode 100644 index 0000000000..9fc56ee1b2 --- /dev/null +++ b/python/.changelog.d/noissue.added @@ -0,0 +1 @@ +Mintlayer coin handlers diff --git a/python/CHANGELOG.md b/python/CHANGELOG.md index a37d368424..1cacdee78c 100644 --- a/python/CHANGELOG.md +++ b/python/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.8.7-Mintlayer] (7th February 2025) + +### Added +- Mintlayer coin handlers [#noissue] + ## [0.13.9] (2024-06-19) [0.13.9]: https://github.com/trezor/trezor-firmware/compare/python/v0.13.8...python/v0.13.9 diff --git a/python/src/trezorlib/cli/mintlayer.py b/python/src/trezorlib/cli/mintlayer.py new file mode 100644 index 0000000000..0245bb2453 --- /dev/null +++ b/python/src/trezorlib/cli/mintlayer.py @@ -0,0 +1,193 @@ +import base64 +import json +from typing import TYPE_CHECKING, TextIO + +import click + +from .. import messages, mintlayer, protobuf, tools +from . import with_client + +if TYPE_CHECKING: + from ..client import TrezorClient + + +@click.group(name="mintlayer") +def cli() -> None: + """Mintlayer coin commands.""" + + +@cli.command() +@click.option( + "-c", + "--chain-type", + type=int, + required=True, + help="Chain type: 1 for Mainnet, 2 for Testnet, 3 for Regtest or 4 for Signet", +) +@click.option("-n", "--address", required=True, help="BIP-32 path") +@click.option("-d", "--show-display", is_flag=True) +@click.option("-C", "--chunkify", is_flag=True) +@with_client +def get_address( + client: "TrezorClient", + chain_type: int, + address: str, + show_display: bool, + chunkify: bool, +) -> str: + """Get address for specified path. + + \b + $ trezorctl mintlayer get-address -c 1 -n m/44h/19788h/0h/0/0 + """ + address_n = tools.parse_path(address) + + return mintlayer.get_address( + client, + address_n, + chain_type, + show_display, + chunkify=chunkify, + ) + + +@cli.command() +@click.option( + "-c", + "--chain-type", + type=int, + required=True, + help="Chain type: 1 for Mainnet, 2 for Testnet, 3 for Regtest or 4 for Signet", +) +@click.option("-n", "--address", required=True, help="BIP-32 path, e.g. m/44h/0h/0h") +@click.option("-d", "--show-display", is_flag=True) +@with_client +def get_public_key( + client: "TrezorClient", + chain_type: int, + address: str, + show_display: bool, +) -> dict: + """Get public key with its chain code of given path. + + \b + $ trezorctl mintlayer get-public-key -c 1 -n m/44h/19788h/0h/0/0 + """ + address_n = tools.parse_path(address) + result = mintlayer.get_public_key( + client, + address_n, + chain_type, + show_display=show_display, + ) + if isinstance(result, messages.MintlayerPublicKey): + return { + "chain_code": result.chain_code.hex(), + "public_key": result.public_key.hex(), + } + else: + return {"error": result} + + +@cli.command() +@click.option( + "-c", + "--chain-type", + type=int, + required=True, + help="Chain type: 1 for Mainnet, 2 for Testnet, 3 for Regtest or 4 for Signet", +) +@click.option("-n", "--address_n", required=True, help="BIP-32 path") +@click.option( + "-a", + "--address-type", + required=True, + help="Address type: PUBLIC_KEY or PUBLIC_KEY_HASH", +) +@click.argument("message") +@with_client +def sign_message( + client: "TrezorClient", + chain_type: int, + address_n: str, + address_type: str, + message: str, +) -> dict: + """Sign message using address of given path. + + \b + $ trezorctl mintlayer sign-message -c 1 -a PUBLIC_KEY_HASH -n m/44h/19788h/0h/0/0 "hello" + """ + result = mintlayer.sign_message( + client, + chain_type=chain_type, + address_n=tools.parse_path(address_n), + address_type=address_type, + message=message.encode(), + ) + if isinstance(result, messages.MessageSignature): + return { + "message": message, + "address": result.address, + "signature": base64.b64encode(result.signature).decode(), + } + else: + return {"error": result} + + +@cli.command() +@click.option( + "-c", + "--chain-type", + type=int, + required=True, + help="Chain type: 1 for Mainnet, 2 for Testnet, 3 for Regtest or 4 for Signet", +) +@click.option("-C", "--chunkify", is_flag=True) +@click.argument("json_file", type=click.File()) +@with_client +def sign_tx( + client: "TrezorClient", chain_type: int, json_file: TextIO, chunkify: bool +) -> None: + """Sign transaction. + + Transaction data must be provided in a JSON file. The structure of the JSON matches the shape of the relevant protobuf messages. See + file [messages-mintlayer.proto] for up-to-date structure + """ + data = json.load(json_file) + details = data.get("details", {}) + inputs = [ + protobuf.dict_to_proto(messages.MintlayerTxInput, i) + for i in data.get("inputs", ()) + ] + outputs = [ + protobuf.dict_to_proto(messages.MintlayerTxOutput, output) + for output in data.get("outputs", ()) + ] + prev_txes = { + bytes.fromhex(txid): { + idx: protobuf.dict_to_proto(messages.MintlayerTxOutput, utxo) + for idx, utxo in tx_utxos.items() + } + for txid, tx_utxos in data.get("prev_txes", {}).items() + } + + results = mintlayer.sign_tx( + client, + chain_type, + inputs, + outputs, + prev_txs=prev_txes, + chunkify=chunkify, + **details, + ) + + click.echo() + click.echo("Signatures:") + for res in results: + click.echo(f"input index: {res.input_index}") + click.echo("signature:") + for sig in res.signatures: + if sig.multisig_idx is not None: + click.echo(f"multisig index: {sig.multisig_idx}") + click.echo(sig.signature.hex()) diff --git a/python/src/trezorlib/cli/trezorctl.py b/python/src/trezorlib/cli/trezorctl.py index 60f8e8d309..e4f0060167 100755 --- a/python/src/trezorlib/cli/trezorctl.py +++ b/python/src/trezorlib/cli/trezorctl.py @@ -42,6 +42,7 @@ ethereum, fido, firmware, + mintlayer, monero, nem, ripple, @@ -407,6 +408,7 @@ def wait_for_emulator(obj: TrezorConnection, timeout: float) -> None: cli.add_command(eos.cli) cli.add_command(ethereum.cli) cli.add_command(fido.cli) +cli.add_command(mintlayer.cli) cli.add_command(monero.cli) cli.add_command(nem.cli) cli.add_command(ripple.cli) diff --git a/python/src/trezorlib/messages.py b/python/src/trezorlib/messages.py index 06a36af68b..0c3d846717 100644 --- a/python/src/trezorlib/messages.py +++ b/python/src/trezorlib/messages.py @@ -277,6 +277,7 @@ class Capability(IntEnum): Translations = 19 Brightness = 20 Haptic = 21 + Mintlayer = 22 class SdProtectOperationType(IntEnum): @@ -342,6 +343,48 @@ class EthereumDataType(IntEnum): STRUCT = 8 +class MintlayerAccountCommandType(IntEnum): + MINT_TOKENS = 0 + UNMINT_TOKENS = 1 + LOCK_TOKEN_SUPPLY = 2 + FREEZE_TOKEN = 3 + UNFREEZE_TOKEN = 4 + CHANGE_TOKEN_AUTHORITY = 5 + CONCLUDE_ORDER = 6 + FILL_ORDER = 7 + CHANGE_TOKEN_METADATA_URI = 8 + + +class MintlayerOutputTimeLockType(IntEnum): + UNTIL_HEIGHT = 0 + UNTIL_TIME = 1 + FOR_BLOCK_COUNT = 2 + FOR_SECONDS = 3 + + +class MintlayerChainType(IntEnum): + Mainnet = 1 + Testnet = 2 + Regtest = 3 + Signet = 4 + + +class MintlayerAddressType(IntEnum): + PUBLIC_KEY = 1 + PUBLIC_KEY_HASH = 2 + + +class MintlayerUtxoType(IntEnum): + TRANSACTION = 0 + BLOCK = 1 + + +class MintlayerTokenTotalSupplyType(IntEnum): + FIXED = 0 + LOCKABLE = 1 + UNLIMITED = 2 + + class MoneroNetworkType(IntEnum): MAINNET = 0 TESTNET = 1 @@ -648,6 +691,14 @@ class MessageType(IntEnum): BenchmarkNames = 9101 BenchmarkRun = 9102 BenchmarkResult = 9103 + MintlayerGetAddress = 10000 + MintlayerAddress = 10001 + MintlayerGetPublicKey = 10002 + MintlayerPublicKey = 10003 + MintlayerSignMessage = 10004 + MintlayerSignTx = 10005 + MintlayerTxRequest = 10006 + MintlayerTxAck = 10007 class BenchmarkListNames(protobuf.MessageType): @@ -5434,6 +5485,933 @@ def __init__( self.address = address +class MintlayerGetAddress(protobuf.MessageType): + MESSAGE_WIRE_TYPE = 10000 + FIELDS = { + 1: protobuf.Field("address_n", "uint32", repeated=True, required=False, default=None), + 2: protobuf.Field("chain_type", "MintlayerChainType", repeated=False, required=True), + 3: protobuf.Field("show_display", "bool", repeated=False, required=False, default=None), + 4: protobuf.Field("chunkify", "bool", repeated=False, required=False, default=None), + } + + def __init__( + self, + *, + chain_type: "MintlayerChainType", + address_n: Optional[Sequence["int"]] = None, + show_display: Optional["bool"] = None, + chunkify: Optional["bool"] = None, + ) -> None: + self.address_n: Sequence["int"] = address_n if address_n is not None else [] + self.chain_type = chain_type + self.show_display = show_display + self.chunkify = chunkify + + +class MintlayerAddress(protobuf.MessageType): + MESSAGE_WIRE_TYPE = 10001 + FIELDS = { + 1: protobuf.Field("address", "string", repeated=False, required=True), + } + + def __init__( + self, + *, + address: "str", + ) -> None: + self.address = address + + +class MintlayerGetPublicKey(protobuf.MessageType): + MESSAGE_WIRE_TYPE = 10002 + FIELDS = { + 1: protobuf.Field("address_n", "uint32", repeated=True, required=False, default=None), + 2: protobuf.Field("chain_type", "MintlayerChainType", repeated=False, required=True), + 3: protobuf.Field("show_display", "bool", repeated=False, required=False, default=None), + } + + def __init__( + self, + *, + chain_type: "MintlayerChainType", + address_n: Optional[Sequence["int"]] = None, + show_display: Optional["bool"] = None, + ) -> None: + self.address_n: Sequence["int"] = address_n if address_n is not None else [] + self.chain_type = chain_type + self.show_display = show_display + + +class MintlayerPublicKey(protobuf.MessageType): + MESSAGE_WIRE_TYPE = 10003 + FIELDS = { + 1: protobuf.Field("public_key", "bytes", repeated=False, required=True), + 2: protobuf.Field("chain_code", "bytes", repeated=False, required=True), + } + + def __init__( + self, + *, + public_key: "bytes", + chain_code: "bytes", + ) -> None: + self.public_key = public_key + self.chain_code = chain_code + + +class MintlayerSignMessage(protobuf.MessageType): + MESSAGE_WIRE_TYPE = 10004 + FIELDS = { + 1: protobuf.Field("address_n", "uint32", repeated=True, required=False, default=None), + 2: protobuf.Field("chain_type", "MintlayerChainType", repeated=False, required=True), + 3: protobuf.Field("address_type", "MintlayerAddressType", repeated=False, required=True), + 4: protobuf.Field("message", "bytes", repeated=False, required=True), + } + + def __init__( + self, + *, + chain_type: "MintlayerChainType", + address_type: "MintlayerAddressType", + message: "bytes", + address_n: Optional[Sequence["int"]] = None, + ) -> None: + self.address_n: Sequence["int"] = address_n if address_n is not None else [] + self.chain_type = chain_type + self.address_type = address_type + self.message = message + + +class MintlayerSignTx(protobuf.MessageType): + MESSAGE_WIRE_TYPE = 10005 + FIELDS = { + 1: protobuf.Field("outputs_count", "uint32", repeated=False, required=True), + 2: protobuf.Field("inputs_count", "uint32", repeated=False, required=True), + 3: protobuf.Field("chain_type", "MintlayerChainType", repeated=False, required=True), + 4: protobuf.Field("version", "uint32", repeated=False, required=False, default=1), + 5: protobuf.Field("chunkify", "bool", repeated=False, required=False, default=None), + } + + def __init__( + self, + *, + outputs_count: "int", + inputs_count: "int", + chain_type: "MintlayerChainType", + version: Optional["int"] = 1, + chunkify: Optional["bool"] = None, + ) -> None: + self.outputs_count = outputs_count + self.inputs_count = inputs_count + self.chain_type = chain_type + self.version = version + self.chunkify = chunkify + + +class MintlayerTxRequest(protobuf.MessageType): + MESSAGE_WIRE_TYPE = 10006 + FIELDS = { + 1: protobuf.Field("input_request", "MintlayerTxInputRequest", repeated=False, required=False, default=None), + 2: protobuf.Field("output_request", "MintlayerTxOutputRequest", repeated=False, required=False, default=None), + 3: protobuf.Field("signing_finished", "MintlayerTxSigningResult", repeated=False, required=False, default=None), + } + + def __init__( + self, + *, + input_request: Optional["MintlayerTxInputRequest"] = None, + output_request: Optional["MintlayerTxOutputRequest"] = None, + signing_finished: Optional["MintlayerTxSigningResult"] = None, + ) -> None: + self.input_request = input_request + self.output_request = output_request + self.signing_finished = signing_finished + + +class MintlayerAddressPath(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("address_n", "uint32", repeated=True, required=False, default=None), + 2: protobuf.Field("multisig_idx", "uint32", repeated=False, required=False, default=None), + } + + def __init__( + self, + *, + address_n: Optional[Sequence["int"]] = None, + multisig_idx: Optional["int"] = None, + ) -> None: + self.address_n: Sequence["int"] = address_n if address_n is not None else [] + self.multisig_idx = multisig_idx + + +class MintlayerUtxoTxInput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("addresses", "MintlayerAddressPath", repeated=True, required=False, default=None), + 2: protobuf.Field("prev_hash", "bytes", repeated=False, required=True), + 3: protobuf.Field("prev_index", "uint32", repeated=False, required=True), + 4: protobuf.Field("type", "MintlayerUtxoType", repeated=False, required=True), + } + + def __init__( + self, + *, + prev_hash: "bytes", + prev_index: "int", + type: "MintlayerUtxoType", + addresses: Optional[Sequence["MintlayerAddressPath"]] = None, + ) -> None: + self.addresses: Sequence["MintlayerAddressPath"] = addresses if addresses is not None else [] + self.prev_hash = prev_hash + self.prev_index = prev_index + self.type = type + + +class MintlayerAccountTxInput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("addresses", "MintlayerAddressPath", repeated=True, required=False, default=None), + 2: protobuf.Field("nonce", "uint64", repeated=False, required=True), + 3: protobuf.Field("delegation_balance", "MintlayerAccountSpendingDelegationBalance", repeated=False, required=False, default=None), + } + + def __init__( + self, + *, + nonce: "int", + addresses: Optional[Sequence["MintlayerAddressPath"]] = None, + delegation_balance: Optional["MintlayerAccountSpendingDelegationBalance"] = None, + ) -> None: + self.addresses: Sequence["MintlayerAddressPath"] = addresses if addresses is not None else [] + self.nonce = nonce + self.delegation_balance = delegation_balance + + +class MintlayerAccountSpendingDelegationBalance(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("delegation_id", "string", repeated=False, required=True), + 2: protobuf.Field("amount", "bytes", repeated=False, required=True), + } + + def __init__( + self, + *, + delegation_id: "str", + amount: "bytes", + ) -> None: + self.delegation_id = delegation_id + self.amount = amount + + +class MintlayerAccountCommandTxInput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("addresses", "MintlayerAddressPath", repeated=True, required=False, default=None), + 2: protobuf.Field("nonce", "uint64", repeated=False, required=True), + 3: protobuf.Field("mint", "MintlayerMintTokens", repeated=False, required=False, default=None), + 4: protobuf.Field("unmint", "MintlayerUnmintTokens", repeated=False, required=False, default=None), + 5: protobuf.Field("lock_token_supply", "MintlayerLockTokenSupply", repeated=False, required=False, default=None), + 6: protobuf.Field("freeze_token", "MintlayerFreezeToken", repeated=False, required=False, default=None), + 7: protobuf.Field("unfreeze_token", "MintlayerUnfreezeToken", repeated=False, required=False, default=None), + 8: protobuf.Field("change_token_authority", "MintlayerChangeTokenAuthority", repeated=False, required=False, default=None), + 9: protobuf.Field("conclude_order", "MintlayerConcludeOrder", repeated=False, required=False, default=None), + 10: protobuf.Field("fill_order", "MintlayerFillOrder", repeated=False, required=False, default=None), + 11: protobuf.Field("change_token_metadata_uri", "MintlayerChangeTokenMetadataUri", repeated=False, required=False, default=None), + } + + def __init__( + self, + *, + nonce: "int", + addresses: Optional[Sequence["MintlayerAddressPath"]] = None, + mint: Optional["MintlayerMintTokens"] = None, + unmint: Optional["MintlayerUnmintTokens"] = None, + lock_token_supply: Optional["MintlayerLockTokenSupply"] = None, + freeze_token: Optional["MintlayerFreezeToken"] = None, + unfreeze_token: Optional["MintlayerUnfreezeToken"] = None, + change_token_authority: Optional["MintlayerChangeTokenAuthority"] = None, + conclude_order: Optional["MintlayerConcludeOrder"] = None, + fill_order: Optional["MintlayerFillOrder"] = None, + change_token_metadata_uri: Optional["MintlayerChangeTokenMetadataUri"] = None, + ) -> None: + self.addresses: Sequence["MintlayerAddressPath"] = addresses if addresses is not None else [] + self.nonce = nonce + self.mint = mint + self.unmint = unmint + self.lock_token_supply = lock_token_supply + self.freeze_token = freeze_token + self.unfreeze_token = unfreeze_token + self.change_token_authority = change_token_authority + self.conclude_order = conclude_order + self.fill_order = fill_order + self.change_token_metadata_uri = change_token_metadata_uri + + +class MintlayerMintTokens(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("token_id", "string", repeated=False, required=True), + 2: protobuf.Field("amount", "bytes", repeated=False, required=True), + } + + def __init__( + self, + *, + token_id: "str", + amount: "bytes", + ) -> None: + self.token_id = token_id + self.amount = amount + + +class MintlayerUnmintTokens(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("token_id", "string", repeated=False, required=True), + } + + def __init__( + self, + *, + token_id: "str", + ) -> None: + self.token_id = token_id + + +class MintlayerLockTokenSupply(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("token_id", "string", repeated=False, required=True), + } + + def __init__( + self, + *, + token_id: "str", + ) -> None: + self.token_id = token_id + + +class MintlayerFreezeToken(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("token_id", "string", repeated=False, required=True), + 2: protobuf.Field("is_token_unfreezable", "bool", repeated=False, required=True), + } + + def __init__( + self, + *, + token_id: "str", + is_token_unfreezable: "bool", + ) -> None: + self.token_id = token_id + self.is_token_unfreezable = is_token_unfreezable + + +class MintlayerUnfreezeToken(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("token_id", "string", repeated=False, required=True), + } + + def __init__( + self, + *, + token_id: "str", + ) -> None: + self.token_id = token_id + + +class MintlayerChangeTokenAuthority(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("token_id", "string", repeated=False, required=True), + 2: protobuf.Field("destination", "string", repeated=False, required=True), + } + + def __init__( + self, + *, + token_id: "str", + destination: "str", + ) -> None: + self.token_id = token_id + self.destination = destination + + +class MintlayerConcludeOrder(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("order_id", "string", repeated=False, required=True), + 2: protobuf.Field("filled_ask_amount", "MintlayerOutputValue", repeated=False, required=True), + 3: protobuf.Field("give_balance", "MintlayerOutputValue", repeated=False, required=True), + } + + def __init__( + self, + *, + order_id: "str", + filled_ask_amount: "MintlayerOutputValue", + give_balance: "MintlayerOutputValue", + ) -> None: + self.order_id = order_id + self.filled_ask_amount = filled_ask_amount + self.give_balance = give_balance + + +class MintlayerFillOrder(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("order_id", "string", repeated=False, required=True), + 2: protobuf.Field("amount", "bytes", repeated=False, required=True), + 3: protobuf.Field("destination", "string", repeated=False, required=True), + 4: protobuf.Field("ask_balance", "MintlayerOutputValue", repeated=False, required=True), + 5: protobuf.Field("give_balance", "MintlayerOutputValue", repeated=False, required=True), + } + + def __init__( + self, + *, + order_id: "str", + amount: "bytes", + destination: "str", + ask_balance: "MintlayerOutputValue", + give_balance: "MintlayerOutputValue", + ) -> None: + self.order_id = order_id + self.amount = amount + self.destination = destination + self.ask_balance = ask_balance + self.give_balance = give_balance + + +class MintlayerChangeTokenMetadataUri(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("token_id", "string", repeated=False, required=True), + 2: protobuf.Field("metadata_uri", "bytes", repeated=False, required=True), + } + + def __init__( + self, + *, + token_id: "str", + metadata_uri: "bytes", + ) -> None: + self.token_id = token_id + self.metadata_uri = metadata_uri + + +class MintlayerTokenOutputValue(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("token_id", "string", repeated=False, required=True), + 2: protobuf.Field("token_ticker", "bytes", repeated=False, required=True), + 3: protobuf.Field("number_of_decimals", "uint32", repeated=False, required=True), + } + + def __init__( + self, + *, + token_id: "str", + token_ticker: "bytes", + number_of_decimals: "int", + ) -> None: + self.token_id = token_id + self.token_ticker = token_ticker + self.number_of_decimals = number_of_decimals + + +class MintlayerOutputValue(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("amount", "bytes", repeated=False, required=True), + 2: protobuf.Field("token", "MintlayerTokenOutputValue", repeated=False, required=False, default=None), + } + + def __init__( + self, + *, + amount: "bytes", + token: Optional["MintlayerTokenOutputValue"] = None, + ) -> None: + self.amount = amount + self.token = token + + +class MintlayerTransferTxOutput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("address", "string", repeated=False, required=True), + 2: protobuf.Field("value", "MintlayerOutputValue", repeated=False, required=True), + } + + def __init__( + self, + *, + address: "str", + value: "MintlayerOutputValue", + ) -> None: + self.address = address + self.value = value + + +class MintlayerOutputTimeLock(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("until_height", "uint64", repeated=False, required=False, default=None), + 2: protobuf.Field("until_time", "uint64", repeated=False, required=False, default=None), + 3: protobuf.Field("for_block_count", "uint64", repeated=False, required=False, default=None), + 4: protobuf.Field("for_seconds", "uint64", repeated=False, required=False, default=None), + } + + def __init__( + self, + *, + until_height: Optional["int"] = None, + until_time: Optional["int"] = None, + for_block_count: Optional["int"] = None, + for_seconds: Optional["int"] = None, + ) -> None: + self.until_height = until_height + self.until_time = until_time + self.for_block_count = for_block_count + self.for_seconds = for_seconds + + +class MintlayerLockThenTransferTxOutput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("address", "string", repeated=False, required=True), + 2: protobuf.Field("value", "MintlayerOutputValue", repeated=False, required=True), + 3: protobuf.Field("lock", "MintlayerOutputTimeLock", repeated=False, required=True), + } + + def __init__( + self, + *, + address: "str", + value: "MintlayerOutputValue", + lock: "MintlayerOutputTimeLock", + ) -> None: + self.address = address + self.value = value + self.lock = lock + + +class MintlayerBurnTxOutput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("value", "MintlayerOutputValue", repeated=False, required=True), + } + + def __init__( + self, + *, + value: "MintlayerOutputValue", + ) -> None: + self.value = value + + +class MintlayerCreateStakePoolTxOutput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("pool_id", "string", repeated=False, required=True), + 2: protobuf.Field("pledge", "bytes", repeated=False, required=True), + 3: protobuf.Field("staker", "string", repeated=False, required=True), + 4: protobuf.Field("vrf_public_key", "string", repeated=False, required=True), + 5: protobuf.Field("decommission_key", "string", repeated=False, required=True), + 6: protobuf.Field("margin_ratio_per_thousand", "uint32", repeated=False, required=True), + 7: protobuf.Field("cost_per_block", "bytes", repeated=False, required=True), + } + + def __init__( + self, + *, + pool_id: "str", + pledge: "bytes", + staker: "str", + vrf_public_key: "str", + decommission_key: "str", + margin_ratio_per_thousand: "int", + cost_per_block: "bytes", + ) -> None: + self.pool_id = pool_id + self.pledge = pledge + self.staker = staker + self.vrf_public_key = vrf_public_key + self.decommission_key = decommission_key + self.margin_ratio_per_thousand = margin_ratio_per_thousand + self.cost_per_block = cost_per_block + + +class MintlayerProduceBlockFromStakeTxOutput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("destination", "string", repeated=False, required=True), + 2: protobuf.Field("pool_id", "string", repeated=False, required=True), + 3: protobuf.Field("staker_balance", "bytes", repeated=False, required=True), + } + + def __init__( + self, + *, + destination: "str", + pool_id: "str", + staker_balance: "bytes", + ) -> None: + self.destination = destination + self.pool_id = pool_id + self.staker_balance = staker_balance + + +class MintlayerCreateDelegationIdTxOutput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("destination", "string", repeated=False, required=True), + 2: protobuf.Field("pool_id", "string", repeated=False, required=True), + } + + def __init__( + self, + *, + destination: "str", + pool_id: "str", + ) -> None: + self.destination = destination + self.pool_id = pool_id + + +class MintlayerDelegateStakingTxOutput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("amount", "bytes", repeated=False, required=True), + 2: protobuf.Field("delegation_id", "string", repeated=False, required=True), + } + + def __init__( + self, + *, + amount: "bytes", + delegation_id: "str", + ) -> None: + self.amount = amount + self.delegation_id = delegation_id + + +class MintlayerTokenTotalSupply(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("type", "MintlayerTokenTotalSupplyType", repeated=False, required=True), + 2: protobuf.Field("fixed_amount", "bytes", repeated=False, required=False, default=None), + } + + def __init__( + self, + *, + type: "MintlayerTokenTotalSupplyType", + fixed_amount: Optional["bytes"] = None, + ) -> None: + self.type = type + self.fixed_amount = fixed_amount + + +class MintlayerIssueFungibleTokenTxOutput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("token_ticker", "bytes", repeated=False, required=True), + 2: protobuf.Field("number_of_decimals", "uint32", repeated=False, required=True), + 3: protobuf.Field("metadata_uri", "bytes", repeated=False, required=True), + 4: protobuf.Field("total_supply", "MintlayerTokenTotalSupply", repeated=False, required=True), + 5: protobuf.Field("authority", "string", repeated=False, required=True), + 6: protobuf.Field("is_freezable", "bool", repeated=False, required=True), + } + + def __init__( + self, + *, + token_ticker: "bytes", + number_of_decimals: "int", + metadata_uri: "bytes", + total_supply: "MintlayerTokenTotalSupply", + authority: "str", + is_freezable: "bool", + ) -> None: + self.token_ticker = token_ticker + self.number_of_decimals = number_of_decimals + self.metadata_uri = metadata_uri + self.total_supply = total_supply + self.authority = authority + self.is_freezable = is_freezable + + +class MintlayerIssueNftTxOutput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("token_id", "string", repeated=False, required=True), + 2: protobuf.Field("destination", "string", repeated=False, required=True), + 3: protobuf.Field("creator", "string", repeated=False, required=False, default=None), + 4: protobuf.Field("name", "bytes", repeated=False, required=True), + 5: protobuf.Field("description", "bytes", repeated=False, required=True), + 6: protobuf.Field("ticker", "bytes", repeated=False, required=True), + 7: protobuf.Field("icon_uri", "bytes", repeated=False, required=False, default=None), + 8: protobuf.Field("additional_metadata_uri", "bytes", repeated=False, required=False, default=None), + 9: protobuf.Field("media_uri", "bytes", repeated=False, required=False, default=None), + 10: protobuf.Field("media_hash", "bytes", repeated=False, required=True), + } + + def __init__( + self, + *, + token_id: "str", + destination: "str", + name: "bytes", + description: "bytes", + ticker: "bytes", + media_hash: "bytes", + creator: Optional["str"] = None, + icon_uri: Optional["bytes"] = None, + additional_metadata_uri: Optional["bytes"] = None, + media_uri: Optional["bytes"] = None, + ) -> None: + self.token_id = token_id + self.destination = destination + self.name = name + self.description = description + self.ticker = ticker + self.media_hash = media_hash + self.creator = creator + self.icon_uri = icon_uri + self.additional_metadata_uri = additional_metadata_uri + self.media_uri = media_uri + + +class MintlayerDataDepositTxOutput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("data", "bytes", repeated=False, required=True), + } + + def __init__( + self, + *, + data: "bytes", + ) -> None: + self.data = data + + +class MintlayerHtlcTxOutput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("value", "MintlayerOutputValue", repeated=False, required=True), + 2: protobuf.Field("secret_hash", "bytes", repeated=False, required=True), + 3: protobuf.Field("spend_key", "string", repeated=False, required=True), + 4: protobuf.Field("refund_timelock", "MintlayerOutputTimeLock", repeated=False, required=True), + 5: protobuf.Field("refund_key", "string", repeated=False, required=True), + } + + def __init__( + self, + *, + value: "MintlayerOutputValue", + secret_hash: "bytes", + spend_key: "str", + refund_timelock: "MintlayerOutputTimeLock", + refund_key: "str", + ) -> None: + self.value = value + self.secret_hash = secret_hash + self.spend_key = spend_key + self.refund_timelock = refund_timelock + self.refund_key = refund_key + + +class MintlayerCreateOrderTxOutput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("conclude_key", "string", repeated=False, required=True), + 2: protobuf.Field("ask", "MintlayerOutputValue", repeated=False, required=True), + 3: protobuf.Field("give", "MintlayerOutputValue", repeated=False, required=True), + } + + def __init__( + self, + *, + conclude_key: "str", + ask: "MintlayerOutputValue", + give: "MintlayerOutputValue", + ) -> None: + self.conclude_key = conclude_key + self.ask = ask + self.give = give + + +class MintlayerTxAck(protobuf.MessageType): + MESSAGE_WIRE_TYPE = 10007 + FIELDS = { + 1: protobuf.Field("input", "MintlayerTxInput", repeated=False, required=False, default=None), + 2: protobuf.Field("output", "MintlayerTxOutput", repeated=False, required=False, default=None), + } + + def __init__( + self, + *, + input: Optional["MintlayerTxInput"] = None, + output: Optional["MintlayerTxOutput"] = None, + ) -> None: + self.input = input + self.output = output + + +class MintlayerTxInputRequest(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("input_index", "uint32", repeated=False, required=True), + } + + def __init__( + self, + *, + input_index: "int", + ) -> None: + self.input_index = input_index + + +class MintlayerTxOutputRequest(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("output_index", "uint32", repeated=False, required=True), + 2: protobuf.Field("tx_hash", "bytes", repeated=False, required=False, default=None), + } + + def __init__( + self, + *, + output_index: "int", + tx_hash: Optional["bytes"] = None, + ) -> None: + self.output_index = output_index + self.tx_hash = tx_hash + + +class MintlayerSignature(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("signature", "bytes", repeated=False, required=True), + 2: protobuf.Field("multisig_idx", "uint32", repeated=False, required=False, default=None), + } + + def __init__( + self, + *, + signature: "bytes", + multisig_idx: Optional["int"] = None, + ) -> None: + self.signature = signature + self.multisig_idx = multisig_idx + + +class MintlayerSignaturesForInput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("input_index", "uint32", repeated=False, required=True), + 2: protobuf.Field("signatures", "MintlayerSignature", repeated=True, required=False, default=None), + } + + def __init__( + self, + *, + input_index: "int", + signatures: Optional[Sequence["MintlayerSignature"]] = None, + ) -> None: + self.signatures: Sequence["MintlayerSignature"] = signatures if signatures is not None else [] + self.input_index = input_index + + +class MintlayerTxSigningResult(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("signatures", "MintlayerSignaturesForInput", repeated=True, required=False, default=None), + } + + def __init__( + self, + *, + signatures: Optional[Sequence["MintlayerSignaturesForInput"]] = None, + ) -> None: + self.signatures: Sequence["MintlayerSignaturesForInput"] = signatures if signatures is not None else [] + + +class MintlayerTxInput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("utxo", "MintlayerUtxoTxInput", repeated=False, required=False, default=None), + 2: protobuf.Field("account", "MintlayerAccountTxInput", repeated=False, required=False, default=None), + 3: protobuf.Field("account_command", "MintlayerAccountCommandTxInput", repeated=False, required=False, default=None), + } + + def __init__( + self, + *, + utxo: Optional["MintlayerUtxoTxInput"] = None, + account: Optional["MintlayerAccountTxInput"] = None, + account_command: Optional["MintlayerAccountCommandTxInput"] = None, + ) -> None: + self.utxo = utxo + self.account = account + self.account_command = account_command + + +class MintlayerTxOutput(protobuf.MessageType): + MESSAGE_WIRE_TYPE = None + FIELDS = { + 1: protobuf.Field("transfer", "MintlayerTransferTxOutput", repeated=False, required=False, default=None), + 2: protobuf.Field("lock_then_transfer", "MintlayerLockThenTransferTxOutput", repeated=False, required=False, default=None), + 3: protobuf.Field("burn", "MintlayerBurnTxOutput", repeated=False, required=False, default=None), + 4: protobuf.Field("create_stake_pool", "MintlayerCreateStakePoolTxOutput", repeated=False, required=False, default=None), + 5: protobuf.Field("produce_block_from_stake", "MintlayerProduceBlockFromStakeTxOutput", repeated=False, required=False, default=None), + 6: protobuf.Field("create_delegation_id", "MintlayerCreateDelegationIdTxOutput", repeated=False, required=False, default=None), + 7: protobuf.Field("delegate_staking", "MintlayerDelegateStakingTxOutput", repeated=False, required=False, default=None), + 8: protobuf.Field("issue_fungible_token", "MintlayerIssueFungibleTokenTxOutput", repeated=False, required=False, default=None), + 9: protobuf.Field("issue_nft", "MintlayerIssueNftTxOutput", repeated=False, required=False, default=None), + 10: protobuf.Field("data_deposit", "MintlayerDataDepositTxOutput", repeated=False, required=False, default=None), + 11: protobuf.Field("htlc", "MintlayerHtlcTxOutput", repeated=False, required=False, default=None), + 12: protobuf.Field("create_order", "MintlayerCreateOrderTxOutput", repeated=False, required=False, default=None), + } + + def __init__( + self, + *, + transfer: Optional["MintlayerTransferTxOutput"] = None, + lock_then_transfer: Optional["MintlayerLockThenTransferTxOutput"] = None, + burn: Optional["MintlayerBurnTxOutput"] = None, + create_stake_pool: Optional["MintlayerCreateStakePoolTxOutput"] = None, + produce_block_from_stake: Optional["MintlayerProduceBlockFromStakeTxOutput"] = None, + create_delegation_id: Optional["MintlayerCreateDelegationIdTxOutput"] = None, + delegate_staking: Optional["MintlayerDelegateStakingTxOutput"] = None, + issue_fungible_token: Optional["MintlayerIssueFungibleTokenTxOutput"] = None, + issue_nft: Optional["MintlayerIssueNftTxOutput"] = None, + data_deposit: Optional["MintlayerDataDepositTxOutput"] = None, + htlc: Optional["MintlayerHtlcTxOutput"] = None, + create_order: Optional["MintlayerCreateOrderTxOutput"] = None, + ) -> None: + self.transfer = transfer + self.lock_then_transfer = lock_then_transfer + self.burn = burn + self.create_stake_pool = create_stake_pool + self.produce_block_from_stake = produce_block_from_stake + self.create_delegation_id = create_delegation_id + self.delegate_staking = delegate_staking + self.issue_fungible_token = issue_fungible_token + self.issue_nft = issue_nft + self.data_deposit = data_deposit + self.htlc = htlc + self.create_order = create_order + + class MoneroTransactionSourceEntry(protobuf.MessageType): MESSAGE_WIRE_TYPE = None FIELDS = { diff --git a/python/src/trezorlib/mintlayer.py b/python/src/trezorlib/mintlayer.py new file mode 100644 index 0000000000..d2f5001bd2 --- /dev/null +++ b/python/src/trezorlib/mintlayer.py @@ -0,0 +1,136 @@ +# This file is part of the Trezor project. +# +# Copyright (C) 2012-2022 SatoshiLabs and contributors +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the License along with this library. +# If not, see . + +from dataclasses import dataclass +from typing import TYPE_CHECKING, Dict, List, Optional + +from . import messages +from .tools import expect, session + +if TYPE_CHECKING: + from .client import TrezorClient + from .protobuf import MessageType + from .tools import Address + + +@expect(messages.MintlayerAddress, field="address", ret_type=str) +def get_address( + client: "TrezorClient", + address_n: "Address", + chain_type: int, + show_display: bool = False, + chunkify: bool = False, +) -> "MessageType": + + return client.call( + messages.MintlayerGetAddress( + address_n=address_n, + chain_type=messages.MintlayerChainType(chain_type), + show_display=show_display, + chunkify=chunkify, + ) + ) + + +def get_public_key( + client: "TrezorClient", + address_n: "Address", + chain_type: int, + show_display: bool = False, +) -> "MessageType": + return client.call( + messages.MintlayerGetPublicKey( + address_n=address_n, + chain_type=messages.MintlayerChainType(chain_type), + show_display=show_display, + ) + ) + + +def sign_message( + client: "TrezorClient", + address_n: "Address", + chain_type: int, + address_type: str, + message: bytes, +) -> "MessageType": + if address_type == "PUBLIC_KEY": + addr_type = messages.MintlayerAddressType.PUBLIC_KEY + elif address_type == "PUBLIC_KEY_HASH": + addr_type = messages.MintlayerAddressType.PUBLIC_KEY_HASH + else: + raise ValueError(f"Invalid address type {address_type}") + + return client.call( + messages.MintlayerSignMessage( + chain_type=messages.MintlayerChainType(chain_type), + address_type=addr_type, + address_n=address_n, + message=message, + ) + ) + + +Input = messages.MintlayerTxInput +Output = messages.MintlayerTxOutput +TxHash = bytes + + +@dataclass +class Tx: + inputs: List[Input] + outputs: List[Output] + + +@session +def sign_tx( + client: "TrezorClient", + chain_type: int, + inputs: List[Input], + outputs: List[Output], + prev_txs: Dict[TxHash, Dict[int, Output]], + version: Optional["int"] = 1, + chunkify: Optional["bool"] = None, +) -> List[messages.MintlayerSignaturesForInput]: + res = client.call( + messages.MintlayerSignTx( + outputs_count=len(outputs), + inputs_count=len(inputs), + chain_type=messages.MintlayerChainType(chain_type), + version=version, + chunkify=chunkify, + ) + ) + + while isinstance(res, messages.MintlayerTxRequest): + if res.signing_finished: + return list(res.signing_finished.signatures) + + if res.input_request: + msg = inputs[res.input_request.input_index] + msg = messages.MintlayerTxAck(input=msg) + res = client.call(msg) + elif res.output_request: + if res.output_request.tx_hash: + out = prev_txs[res.output_request.tx_hash][ + res.output_request.output_index + ] + else: + out = outputs[res.output_request.output_index] + msg = messages.MintlayerTxAck(output=out) + res = client.call(msg) + + raise Exception("Invalid response from trezor") diff --git a/rust/trezor-client/Cargo.toml b/rust/trezor-client/Cargo.toml index d158e4e8c0..f73ce7577e 100644 --- a/rust/trezor-client/Cargo.toml +++ b/rust/trezor-client/Cargo.toml @@ -49,7 +49,7 @@ tracing-subscriber = "0.3" serial_test = "2.0.0" [features] -default = ["bitcoin", "ethereum", "solana"] +default = ["bitcoin", "ethereum", "solana", "mintlayer"] # Client implementations bitcoin = ["dep:bitcoin", "unicode-normalization"] @@ -66,3 +66,4 @@ solana = [] stellar = [] tezos = [] webauthn = [] +mintlayer = [] diff --git a/rust/trezor-client/scripts/build_messages b/rust/trezor-client/scripts/build_messages index 33d736fe3a..8e0da67d66 100755 --- a/rust/trezor-client/scripts/build_messages +++ b/rust/trezor-client/scripts/build_messages @@ -29,6 +29,7 @@ FEATURES = { "Stellar": "stellar", "Tezos": "tezos", "WebAuthn": "webauthn", + "Mintlayer": "mintlayer", } MACRO = "trezor_message_impl" INDENT = " " diff --git a/rust/trezor-client/src/client/mintlayer.rs b/rust/trezor-client/src/client/mintlayer.rs new file mode 100644 index 0000000000..939b28ff86 --- /dev/null +++ b/rust/trezor-client/src/client/mintlayer.rs @@ -0,0 +1,140 @@ +use std::collections::BTreeMap; + +use bitcoin::secp256k1; +use protobuf::MessageField; + +use super::{handle_interaction, Trezor}; +use crate::{ + error::Result, + protos::{ + self, + mintlayer_tx_ack::{MintlayerTxInput, MintlayerTxOutput}, + MintlayerChainType, MintlayerTxAck, + }, + Error, +}; + +/// A chain code +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct ChainCode(pub [u8; 32]); + +pub struct XPub { + pub public_key: secp256k1::PublicKey, + pub chain_code: ChainCode, +} + +#[derive(Debug)] +pub struct MintlayerSignature { + pub signature: Vec, + pub multisig_idx: Option, +} + +impl MintlayerSignature { + fn new(signature: Vec, multisig_idx: Option) -> Self { + Self { signature, multisig_idx } + } +} + +pub type TransactionId = [u8; 32]; + +impl Trezor { + // Mintlayer + pub fn mintlayer_get_public_key( + &mut self, + chain_type: MintlayerChainType, + path: Vec, + ) -> Result { + let mut req = protos::MintlayerGetPublicKey::new(); + req.set_chain_type(chain_type); + req.address_n = path; + let msg = self.call::<_, _, protos::MintlayerPublicKey>( + req, + Box::new(|_, m| { + Ok(XPub { + public_key: secp256k1::PublicKey::from_slice(m.public_key())?, + chain_code: ChainCode( + m.chain_code().try_into().map_err(|_| Error::InvalidChaincodeFromDevice)?, + ), + }) + }), + )?; + + handle_interaction(msg) + } + + pub fn mintlayer_sign_message( + &mut self, + chain_type: MintlayerChainType, + path: Vec, + address_type: protos::MintlayerAddressType, + message: Vec, + ) -> Result> { + let mut req = protos::MintlayerSignMessage::new(); + req.address_n = path; + req.set_message(message); + req.set_chain_type(chain_type); + req.set_address_type(address_type); + let msg = self.call::<_, _, protos::MessageSignature>( + req, + Box::new(|_, m| Ok(m.signature().to_vec())), + )?; + + handle_interaction(msg) + } + + pub fn mintlayer_sign_tx( + &mut self, + chain_type: MintlayerChainType, + inputs: Vec, + outputs: Vec, + utxos: BTreeMap>, + ) -> Result>> { + let mut req = protos::MintlayerSignTx::new(); + req.set_version(1); + req.set_chain_type(chain_type); + req.set_inputs_count(inputs.len() as u32); + req.set_outputs_count(outputs.len() as u32); + + let mut msg = self.call::<_, _, protos::MintlayerTxRequest>(req, Box::new(|_, m| Ok(m)))?; + loop { + let response = handle_interaction(msg)?; + + if let Some(inp) = response.input_request.as_ref() { + let mut req = MintlayerTxAck::new(); + req.input = + MessageField::from_option(inputs.get(inp.input_index() as usize).cloned()); + msg = self.call::<_, _, protos::MintlayerTxRequest>(req, Box::new(|_, m| Ok(m)))?; + } else if let Some(out_req) = response.output_request.as_ref() { + let mut req = MintlayerTxAck::new(); + if out_req.has_tx_hash() { + let tx_id: TransactionId = out_req + .tx_hash() + .try_into() + .map_err(|_| Error::InvalidChaincodeFromDevice)?; + let out = utxos.get(&tx_id).and_then(|tx| tx.get(&out_req.output_index())); + req.output = MessageField::from_option(out.cloned()); + } else { + req.output = MessageField::from_option( + outputs.get(out_req.output_index() as usize).cloned(), + ); + } + msg = self.call::<_, _, protos::MintlayerTxRequest>(req, Box::new(|_, m| Ok(m)))?; + } else if let Some(finish) = response.signing_finished.as_ref() { + return Ok(finish + .signatures + .iter() + .map(|s| { + s.signatures + .iter() + .map(|s| { + MintlayerSignature::new(s.signature().to_vec(), s.multisig_idx) + }) + .collect() + }) + .collect()) + } else { + return Err(Error::MalformedMintlayerTxRequest(response)) + } + } + } +} diff --git a/rust/trezor-client/src/client/mod.rs b/rust/trezor-client/src/client/mod.rs index 338b3671a3..28baef1903 100644 --- a/rust/trezor-client/src/client/mod.rs +++ b/rust/trezor-client/src/client/mod.rs @@ -16,6 +16,11 @@ pub use solana::*; pub mod common; pub use common::*; +#[cfg(feature = "mintlayer")] +pub mod mintlayer; +#[cfg(feature = "mintlayer")] +pub use mintlayer::*; + use crate::{ error::{Error, Result}, messages::TrezorMessage, diff --git a/rust/trezor-client/src/error.rs b/rust/trezor-client/src/error.rs index 62bdac5f52..dace365498 100644 --- a/rust/trezor-client/src/error.rs +++ b/rust/trezor-client/src/error.rs @@ -92,4 +92,14 @@ pub enum Error { #[cfg(feature = "bitcoin")] #[error(transparent)] Address(#[from] bitcoin::address::ParseError), + + // mintlayer + /// Chaincode error. + #[cfg(feature = "mintlayer")] + #[error("Invalid chaincode returned from device")] + InvalidChaincodeFromDevice, + /// Device produced invalid TxRequest message. + #[cfg(feature = "mintlayer")] + #[error("Malformed MintlayerTxRequest: {0:?}")] + MalformedMintlayerTxRequest(protos::MintlayerTxRequest), } diff --git a/rust/trezor-client/src/messages/generated.rs b/rust/trezor-client/src/messages/generated.rs index 551a1e92e2..aafbdc874f 100644 --- a/rust/trezor-client/src/messages/generated.rs +++ b/rust/trezor-client/src/messages/generated.rs @@ -187,6 +187,18 @@ trezor_message_impl! { EthereumSignTypedHash => MessageType_EthereumSignTypedHash, } +#[cfg(feature = "mintlayer")] +trezor_message_impl! { + MintlayerGetAddress => MessageType_MintlayerGetAddress, + MintlayerAddress => MessageType_MintlayerAddress, + MintlayerGetPublicKey => MessageType_MintlayerGetPublicKey, + MintlayerPublicKey => MessageType_MintlayerPublicKey, + MintlayerSignMessage => MessageType_MintlayerSignMessage, + MintlayerSignTx => MessageType_MintlayerSignTx, + MintlayerTxRequest => MessageType_MintlayerTxRequest, + MintlayerTxAck => MessageType_MintlayerTxAck, +} + #[cfg(feature = "monero")] trezor_message_impl! { MoneroTransactionInitRequest => MessageType_MoneroTransactionInitRequest, diff --git a/rust/trezor-client/src/protos/generated/messages.rs b/rust/trezor-client/src/protos/generated/messages.rs index 0a265410a6..59bd90e4eb 100644 --- a/rust/trezor-client/src/protos/generated/messages.rs +++ b/rust/trezor-client/src/protos/generated/messages.rs @@ -522,6 +522,22 @@ pub enum MessageType { MessageType_BenchmarkRun = 9102, // @@protoc_insertion_point(enum_value:hw.trezor.messages.MessageType.MessageType_BenchmarkResult) MessageType_BenchmarkResult = 9103, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.MessageType.MessageType_MintlayerGetAddress) + MessageType_MintlayerGetAddress = 10000, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.MessageType.MessageType_MintlayerAddress) + MessageType_MintlayerAddress = 10001, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.MessageType.MessageType_MintlayerGetPublicKey) + MessageType_MintlayerGetPublicKey = 10002, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.MessageType.MessageType_MintlayerPublicKey) + MessageType_MintlayerPublicKey = 10003, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.MessageType.MessageType_MintlayerSignMessage) + MessageType_MintlayerSignMessage = 10004, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.MessageType.MessageType_MintlayerSignTx) + MessageType_MintlayerSignTx = 10005, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.MessageType.MessageType_MintlayerTxRequest) + MessageType_MintlayerTxRequest = 10006, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.MessageType.MessageType_MintlayerTxAck) + MessageType_MintlayerTxAck = 10007, } impl ::protobuf::Enum for MessageType { @@ -780,6 +796,14 @@ impl ::protobuf::Enum for MessageType { 9101 => ::std::option::Option::Some(MessageType::MessageType_BenchmarkNames), 9102 => ::std::option::Option::Some(MessageType::MessageType_BenchmarkRun), 9103 => ::std::option::Option::Some(MessageType::MessageType_BenchmarkResult), + 10000 => ::std::option::Option::Some(MessageType::MessageType_MintlayerGetAddress), + 10001 => ::std::option::Option::Some(MessageType::MessageType_MintlayerAddress), + 10002 => ::std::option::Option::Some(MessageType::MessageType_MintlayerGetPublicKey), + 10003 => ::std::option::Option::Some(MessageType::MessageType_MintlayerPublicKey), + 10004 => ::std::option::Option::Some(MessageType::MessageType_MintlayerSignMessage), + 10005 => ::std::option::Option::Some(MessageType::MessageType_MintlayerSignTx), + 10006 => ::std::option::Option::Some(MessageType::MessageType_MintlayerTxRequest), + 10007 => ::std::option::Option::Some(MessageType::MessageType_MintlayerTxAck), _ => ::std::option::Option::None } } @@ -1033,6 +1057,14 @@ impl ::protobuf::Enum for MessageType { "MessageType_BenchmarkNames" => ::std::option::Option::Some(MessageType::MessageType_BenchmarkNames), "MessageType_BenchmarkRun" => ::std::option::Option::Some(MessageType::MessageType_BenchmarkRun), "MessageType_BenchmarkResult" => ::std::option::Option::Some(MessageType::MessageType_BenchmarkResult), + "MessageType_MintlayerGetAddress" => ::std::option::Option::Some(MessageType::MessageType_MintlayerGetAddress), + "MessageType_MintlayerAddress" => ::std::option::Option::Some(MessageType::MessageType_MintlayerAddress), + "MessageType_MintlayerGetPublicKey" => ::std::option::Option::Some(MessageType::MessageType_MintlayerGetPublicKey), + "MessageType_MintlayerPublicKey" => ::std::option::Option::Some(MessageType::MessageType_MintlayerPublicKey), + "MessageType_MintlayerSignMessage" => ::std::option::Option::Some(MessageType::MessageType_MintlayerSignMessage), + "MessageType_MintlayerSignTx" => ::std::option::Option::Some(MessageType::MessageType_MintlayerSignTx), + "MessageType_MintlayerTxRequest" => ::std::option::Option::Some(MessageType::MessageType_MintlayerTxRequest), + "MessageType_MintlayerTxAck" => ::std::option::Option::Some(MessageType::MessageType_MintlayerTxAck), _ => ::std::option::Option::None } } @@ -1285,6 +1317,14 @@ impl ::protobuf::Enum for MessageType { MessageType::MessageType_BenchmarkNames, MessageType::MessageType_BenchmarkRun, MessageType::MessageType_BenchmarkResult, + MessageType::MessageType_MintlayerGetAddress, + MessageType::MessageType_MintlayerAddress, + MessageType::MessageType_MintlayerGetPublicKey, + MessageType::MessageType_MintlayerPublicKey, + MessageType::MessageType_MintlayerSignMessage, + MessageType::MessageType_MintlayerSignTx, + MessageType::MessageType_MintlayerTxRequest, + MessageType::MessageType_MintlayerTxAck, ]; } @@ -1543,6 +1583,14 @@ impl ::protobuf::EnumFull for MessageType { MessageType::MessageType_BenchmarkNames => 244, MessageType::MessageType_BenchmarkRun => 245, MessageType::MessageType_BenchmarkResult => 246, + MessageType::MessageType_MintlayerGetAddress => 247, + MessageType::MessageType_MintlayerAddress => 248, + MessageType::MessageType_MintlayerGetPublicKey => 249, + MessageType::MessageType_MintlayerPublicKey => 250, + MessageType::MessageType_MintlayerSignMessage => 251, + MessageType::MessageType_MintlayerSignTx => 252, + MessageType::MessageType_MintlayerTxRequest => 253, + MessageType::MessageType_MintlayerTxAck => 254, }; Self::enum_descriptor().value_by_index(index) } @@ -1561,7 +1609,7 @@ impl MessageType { } static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x0emessages.proto\x12\x12hw.trezor.messages\x1a\roptions.proto*\xe8U\ + \n\x0emessages.proto\x12\x12hw.trezor.messages\x1a\roptions.proto*\xbdX\ \n\x0bMessageType\x12(\n\x16MessageType_Initialize\x10\0\x1a\x0c\x80\xa6\ \x1d\x01\xb0\xb5\x18\x01\x90\xb5\x18\x01\x12\x1e\n\x10MessageType_Ping\ \x10\x01\x1a\x08\x80\xa6\x1d\x01\x90\xb5\x18\x01\x12%\n\x13MessageType_S\ @@ -1842,11 +1890,19 @@ static file_descriptor_proto_data: &'static [u8] = b"\ \x80\xa6\x1d\x01\x12%\n\x1aMessageType_BenchmarkNames\x10\x8dG\x1a\x04\ \x80\xa6\x1d\x01\x12#\n\x18MessageType_BenchmarkRun\x10\x8eG\x1a\x04\x80\ \xa6\x1d\x01\x12&\n\x1bMessageType_BenchmarkResult\x10\x8fG\x1a\x04\x80\ - \xa6\x1d\x01\x1a\x04\xc8\xf3\x18\x01\"\x04\x08Z\x10\\\"\x04\x08G\x10J\"\ - \x04\x08r\x10z\"\x06\x08\xdb\x01\x10\xdb\x01\"\x06\x08\xe0\x01\x10\xe0\ - \x01\"\x06\x08\xac\x02\x10\xb0\x02\"\x06\x08\xb5\x02\x10\xb8\x02\"\x06\ - \x08\xe8\x07\x10\xcb\x08B8\n#com.satoshilabs.trezor.lib.protobufB\rTrezo\ - rMessage\x80\xa6\x1d\x01\ + \xa6\x1d\x01\x12*\n\x1fMessageType_MintlayerGetAddress\x10\x90N\x1a\x04\ + \x90\xb5\x18\x01\x12'\n\x1cMessageType_MintlayerAddress\x10\x91N\x1a\x04\ + \x98\xb5\x18\x01\x12,\n!MessageType_MintlayerGetPublicKey\x10\x92N\x1a\ + \x04\x90\xb5\x18\x01\x12)\n\x1eMessageType_MintlayerPublicKey\x10\x93N\ + \x1a\x04\x98\xb5\x18\x01\x12+\n\x20MessageType_MintlayerSignMessage\x10\ + \x94N\x1a\x04\x90\xb5\x18\x01\x12&\n\x1bMessageType_MintlayerSignTx\x10\ + \x95N\x1a\x04\x90\xb5\x18\x01\x12)\n\x1eMessageType_MintlayerTxRequest\ + \x10\x96N\x1a\x04\x98\xb5\x18\x01\x12%\n\x1aMessageType_MintlayerTxAck\ + \x10\x97N\x1a\x04\x90\xb5\x18\x01\x1a\x04\xc8\xf3\x18\x01\"\x04\x08Z\x10\ + \\\"\x04\x08G\x10J\"\x04\x08r\x10z\"\x06\x08\xdb\x01\x10\xdb\x01\"\x06\ + \x08\xe0\x01\x10\xe0\x01\"\x06\x08\xac\x02\x10\xb0\x02\"\x06\x08\xb5\x02\ + \x10\xb8\x02\"\x06\x08\xe8\x07\x10\xcb\x08B8\n#com.satoshilabs.trezor.li\ + b.protobufB\rTrezorMessage\x80\xa6\x1d\x01\ "; /// `FileDescriptorProto` object which was a source for this generated file diff --git a/rust/trezor-client/src/protos/generated/messages_management.rs b/rust/trezor-client/src/protos/generated/messages_management.rs index 5fa5e2b328..233b0d729d 100644 --- a/rust/trezor-client/src/protos/generated/messages_management.rs +++ b/rust/trezor-client/src/protos/generated/messages_management.rs @@ -2753,6 +2753,8 @@ pub mod features { Capability_Brightness = 20, // @@protoc_insertion_point(enum_value:hw.trezor.messages.management.Features.Capability.Capability_Haptic) Capability_Haptic = 21, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.management.Features.Capability.Capability_Mintlayer) + Capability_Mintlayer = 22, } impl ::protobuf::Enum for Capability { @@ -2785,6 +2787,7 @@ pub mod features { 19 => ::std::option::Option::Some(Capability::Capability_Translations), 20 => ::std::option::Option::Some(Capability::Capability_Brightness), 21 => ::std::option::Option::Some(Capability::Capability_Haptic), + 22 => ::std::option::Option::Some(Capability::Capability_Mintlayer), _ => ::std::option::Option::None } } @@ -2812,6 +2815,7 @@ pub mod features { "Capability_Translations" => ::std::option::Option::Some(Capability::Capability_Translations), "Capability_Brightness" => ::std::option::Option::Some(Capability::Capability_Brightness), "Capability_Haptic" => ::std::option::Option::Some(Capability::Capability_Haptic), + "Capability_Mintlayer" => ::std::option::Option::Some(Capability::Capability_Mintlayer), _ => ::std::option::Option::None } } @@ -2838,6 +2842,7 @@ pub mod features { Capability::Capability_Translations, Capability::Capability_Brightness, Capability::Capability_Haptic, + Capability::Capability_Mintlayer, ]; } @@ -2870,6 +2875,7 @@ pub mod features { Capability::Capability_Translations => 18, Capability::Capability_Brightness => 19, Capability::Capability_Haptic => 20, + Capability::Capability_Mintlayer => 21, }; Self::enum_descriptor().value_by_index(index) } @@ -11562,7 +11568,7 @@ static file_descriptor_proto_data: &'static [u8] = b"\ \roptions.proto\"\x80\x01\n\nInitialize\x12\x1d\n\nsession_id\x18\x01\ \x20\x01(\x0cR\tsessionId\x12,\n\x10_skip_passphrase\x18\x02\x20\x01(\ \x08R\x0eSkipPassphraseB\x02\x18\x01\x12%\n\x0ederive_cardano\x18\x03\ - \x20\x01(\x08R\rderiveCardano\"\r\n\x0bGetFeatures\"\x86\x18\n\x08Featur\ + \x20\x01(\x08R\rderiveCardano\"\r\n\x0bGetFeatures\"\xa0\x18\n\x08Featur\ es\x12\x16\n\x06vendor\x18\x01\x20\x01(\tR\x06vendor\x12#\n\rmajor_versi\ on\x18\x02\x20\x02(\rR\x0cmajorVersion\x12#\n\rminor_version\x18\x03\x20\ \x02(\rR\x0cminorVersion\x12#\n\rpatch_version\x18\x04\x20\x02(\rR\x0cpa\ @@ -11616,7 +11622,7 @@ static file_descriptor_proto_data: &'static [u8] = b"\ \toptigaSec\"C\n\x12BackupAvailability\x12\x10\n\x0cNotAvailable\x10\0\ \x12\x0c\n\x08Required\x10\x01\x12\r\n\tAvailable\x10\x02\"7\n\x0eRecove\ ryStatus\x12\x0b\n\x07Nothing\x10\0\x12\x0c\n\x08Recovery\x10\x01\x12\n\ - \n\x06Backup\x10\x02\"\xc2\x04\n\nCapability\x12\x1c\n\x12Capability_Bit\ + \n\x06Backup\x10\x02\"\xdc\x04\n\nCapability\x12\x1c\n\x12Capability_Bit\ coin\x10\x01\x1a\x04\x80\xa6\x1d\x01\x12\x1b\n\x17Capability_Bitcoin_lik\ e\x10\x02\x12\x16\n\x12Capability_Binance\x10\x03\x12\x16\n\x12Capabilit\ y_Cardano\x10\x04\x12\x1b\n\x11Capability_Crypto\x10\x05\x1a\x04\x80\xa6\ @@ -11631,113 +11637,114 @@ static file_descriptor_proto_data: &'static [u8] = b"\ Capability_Solana\x10\x12\x12!\n\x17Capability_Translations\x10\x13\x1a\ \x04\x80\xa6\x1d\x01\x12\x1f\n\x15Capability_Brightness\x10\x14\x1a\x04\ \x80\xa6\x1d\x01\x12\x1b\n\x11Capability_Haptic\x10\x15\x1a\x04\x80\xa6\ - \x1d\x01\x1a\x04\xc8\xf3\x18\x01\"\x0c\n\nLockDevice\"&\n\x07SetBusy\x12\ - \x1b\n\texpiry_ms\x18\x01\x20\x01(\rR\x08expiryMs\"\x0c\n\nEndSession\"\ - \xf4\x04\n\rApplySettings\x12\x1e\n\x08language\x18\x01\x20\x01(\tR\x08l\ - anguageB\x02\x18\x01\x12\x14\n\x05label\x18\x02\x20\x01(\tR\x05label\x12\ - %\n\x0euse_passphrase\x18\x03\x20\x01(\x08R\rusePassphrase\x12\x1e\n\nho\ - mescreen\x18\x04\x20\x01(\x0cR\nhomescreen\x120\n\x12_passphrase_source\ - \x18\x05\x20\x01(\rR\x10PassphraseSourceB\x02\x18\x01\x12+\n\x12auto_loc\ - k_delay_ms\x18\x06\x20\x01(\rR\x0fautoLockDelayMs\x12Y\n\x10display_rota\ - tion\x18\x07\x20\x01(\x0e2..hw.trezor.messages.management.DisplayRotatio\ - nR\x0fdisplayRotation\x12=\n\x1bpassphrase_always_on_device\x18\x08\x20\ - \x01(\x08R\x18passphraseAlwaysOnDevice\x12T\n\rsafety_checks\x18\t\x20\ - \x01(\x0e2/.hw.trezor.messages.management.SafetyCheckLevelR\x0csafetyChe\ - cks\x123\n\x15experimental_features\x18\n\x20\x01(\x08R\x14experimentalF\ - eatures\x129\n\x19hide_passphrase_from_host\x18\x0b\x20\x01(\x08R\x16hid\ - ePassphraseFromHost\x12'\n\x0fhaptic_feedback\x18\r\x20\x01(\x08R\x0ehap\ - ticFeedback\"T\n\x0eChangeLanguage\x12\x1f\n\x0bdata_length\x18\x01\x20\ - \x02(\rR\ndataLength\x12!\n\x0cshow_display\x18\x02\x20\x01(\x08R\x0bsho\ - wDisplay\"Z\n\x16TranslationDataRequest\x12\x1f\n\x0bdata_length\x18\x01\ - \x20\x02(\rR\ndataLength\x12\x1f\n\x0bdata_offset\x18\x02\x20\x02(\rR\nd\ - ataOffset\"3\n\x12TranslationDataAck\x12\x1d\n\ndata_chunk\x18\x01\x20\ - \x02(\x0cR\tdataChunk\"\"\n\nApplyFlags\x12\x14\n\x05flags\x18\x01\x20\ - \x02(\rR\x05flags\"#\n\tChangePin\x12\x16\n\x06remove\x18\x01\x20\x01(\ - \x08R\x06remove\"(\n\x0eChangeWipeCode\x12\x16\n\x06remove\x18\x01\x20\ - \x01(\x08R\x06remove\"\xaa\x01\n\tSdProtect\x12]\n\toperation\x18\x01\ - \x20\x02(\x0e2?.hw.trezor.messages.management.SdProtect.SdProtectOperati\ - onTypeR\toperation\">\n\x16SdProtectOperationType\x12\x0b\n\x07DISABLE\ - \x10\0\x12\n\n\x06ENABLE\x10\x01\x12\x0b\n\x07REFRESH\x10\x02\"O\n\x04Pi\ - ng\x12\x1a\n\x07message\x18\x01\x20\x01(\t:\0R\x07message\x12+\n\x11butt\ - on_protection\x18\x02\x20\x01(\x08R\x10buttonProtection\"\x08\n\x06Cance\ - l\"\x20\n\nGetEntropy\x12\x12\n\x04size\x18\x01\x20\x02(\rR\x04size\"#\n\ - \x07Entropy\x12\x18\n\x07entropy\x18\x01\x20\x02(\x0cR\x07entropy\"/\n\ - \x0fGetFirmwareHash\x12\x1c\n\tchallenge\x18\x01\x20\x01(\x0cR\tchalleng\ - e\"\"\n\x0cFirmwareHash\x12\x12\n\x04hash\x18\x01\x20\x02(\x0cR\x04hash\ - \"2\n\x12AuthenticateDevice\x12\x1c\n\tchallenge\x18\x01\x20\x02(\x0cR\t\ - challenge\"U\n\x11AuthenticityProof\x12\"\n\x0ccertificates\x18\x01\x20\ - \x03(\x0cR\x0ccertificates\x12\x1c\n\tsignature\x18\x02\x20\x02(\x0cR\ts\ - ignature\"\x0c\n\nWipeDevice\"\xad\x02\n\nLoadDevice\x12\x1c\n\tmnemonic\ - s\x18\x01\x20\x03(\tR\tmnemonics\x12\x10\n\x03pin\x18\x03\x20\x01(\tR\ - \x03pin\x123\n\x15passphrase_protection\x18\x04\x20\x01(\x08R\x14passphr\ - aseProtection\x12\x1e\n\x08language\x18\x05\x20\x01(\tR\x08languageB\x02\ - \x18\x01\x12\x14\n\x05label\x18\x06\x20\x01(\tR\x05label\x12#\n\rskip_ch\ - ecksum\x18\x07\x20\x01(\x08R\x0cskipChecksum\x12\x1f\n\x0bu2f_counter\ - \x18\x08\x20\x01(\rR\nu2fCounter\x12!\n\x0cneeds_backup\x18\t\x20\x01(\ - \x08R\x0bneedsBackup\x12\x1b\n\tno_backup\x18\n\x20\x01(\x08R\x08noBacku\ - p\"\x9d\x03\n\x0bResetDevice\x12\x1f\n\x08strength\x18\x02\x20\x01(\r:\ - \x03256R\x08strength\x123\n\x15passphrase_protection\x18\x03\x20\x01(\ - \x08R\x14passphraseProtection\x12%\n\x0epin_protection\x18\x04\x20\x01(\ - \x08R\rpinProtection\x12\x1e\n\x08language\x18\x05\x20\x01(\tR\x08langua\ - geB\x02\x18\x01\x12\x14\n\x05label\x18\x06\x20\x01(\tR\x05label\x12\x1f\ - \n\x0bu2f_counter\x18\x07\x20\x01(\rR\nu2fCounter\x12\x1f\n\x0bskip_back\ - up\x18\x08\x20\x01(\x08R\nskipBackup\x12\x1b\n\tno_backup\x18\t\x20\x01(\ - \x08R\x08noBackup\x12Q\n\x0bbackup_type\x18\n\x20\x01(\x0e2).hw.trezor.m\ - essages.management.BackupType:\x05Bip39R\nbackupType\x12#\n\rentropy_che\ - ck\x18\x0b\x20\x01(\x08R\x0centropyCheckJ\x04\x08\x01\x10\x02\"\xe5\x01\ - \n\x0cBackupDevice\x12'\n\x0fgroup_threshold\x18\x01\x20\x01(\rR\x0egrou\ - pThreshold\x12O\n\x06groups\x18\x02\x20\x03(\x0b27.hw.trezor.messages.ma\ - nagement.BackupDevice.Slip39GroupR\x06groups\x1a[\n\x0bSlip39Group\x12)\ - \n\x10member_threshold\x18\x01\x20\x02(\rR\x0fmemberThreshold\x12!\n\x0c\ - member_count\x18\x02\x20\x02(\rR\x0bmemberCount\"b\n\x0eEntropyRequest\ - \x12-\n\x12entropy_commitment\x18\x01\x20\x01(\x0cR\x11entropyCommitment\ - \x12!\n\x0cprev_entropy\x18\x02\x20\x01(\x0cR\x0bprevEntropy\"&\n\nEntro\ - pyAck\x12\x18\n\x07entropy\x18\x01\x20\x02(\x0cR\x07entropy\"\x13\n\x11E\ - ntropyCheckReady\"5\n\x14EntropyCheckContinue\x12\x1d\n\x06finish\x18\ - \x01\x20\x01(\x08:\x05falseR\x06finish\"\x8d\x04\n\x0eRecoveryDevice\x12\ - \x1d\n\nword_count\x18\x01\x20\x01(\rR\twordCount\x123\n\x15passphrase_p\ - rotection\x18\x02\x20\x01(\x08R\x14passphraseProtection\x12%\n\x0epin_pr\ - otection\x18\x03\x20\x01(\x08R\rpinProtection\x12\x1e\n\x08language\x18\ - \x04\x20\x01(\tR\x08languageB\x02\x18\x01\x12\x14\n\x05label\x18\x05\x20\ - \x01(\tR\x05label\x12)\n\x10enforce_wordlist\x18\x06\x20\x01(\x08R\x0fen\ - forceWordlist\x12j\n\x0cinput_method\x18\x08\x20\x01(\x0e2G.hw.trezor.me\ - ssages.management.RecoveryDevice.RecoveryDeviceInputMethodR\x0binputMeth\ - od\x12\x1f\n\x0bu2f_counter\x18\t\x20\x01(\rR\nu2fCounter\x12O\n\x04type\ - \x18\n\x20\x01(\x0e2+.hw.trezor.messages.management.RecoveryType:\x0eNor\ - malRecoveryR\x04type\";\n\x19RecoveryDeviceInputMethod\x12\x12\n\x0eScra\ - mbledWords\x10\0\x12\n\n\x06Matrix\x10\x01J\x04\x08\x07\x10\x08\"\xc5\ - \x01\n\x0bWordRequest\x12N\n\x04type\x18\x01\x20\x02(\x0e2:.hw.trezor.me\ - ssages.management.WordRequest.WordRequestTypeR\x04type\"f\n\x0fWordReque\ - stType\x12\x19\n\x15WordRequestType_Plain\x10\0\x12\x1b\n\x17WordRequest\ - Type_Matrix9\x10\x01\x12\x1b\n\x17WordRequestType_Matrix6\x10\x02\"\x1d\ - \n\x07WordAck\x12\x12\n\x04word\x18\x01\x20\x02(\tR\x04word\"0\n\rSetU2F\ - Counter\x12\x1f\n\x0bu2f_counter\x18\x01\x20\x02(\rR\nu2fCounter\"\x13\n\ - \x11GetNextU2FCounter\"1\n\x0eNextU2FCounter\x12\x1f\n\x0bu2f_counter\ - \x18\x01\x20\x02(\rR\nu2fCounter\"\x11\n\x0fDoPreauthorized\"\x16\n\x14P\ - reauthorizedRequest\"\x15\n\x13CancelAuthorization\"\x9a\x02\n\x12Reboot\ - ToBootloader\x12o\n\x0cboot_command\x18\x01\x20\x01(\x0e2=.hw.trezor.mes\ - sages.management.RebootToBootloader.BootCommand:\rSTOP_AND_WAITR\x0bboot\ - Command\x12'\n\x0ffirmware_header\x18\x02\x20\x01(\x0cR\x0efirmwareHeade\ - r\x123\n\x14language_data_length\x18\x03\x20\x01(\r:\x010R\x12languageDa\ - taLength\"5\n\x0bBootCommand\x12\x11\n\rSTOP_AND_WAIT\x10\0\x12\x13\n\ - \x0fINSTALL_UPGRADE\x10\x01\"\x10\n\x08GetNonce:\x04\x88\xb2\x19\x01\"#\ - \n\x05Nonce\x12\x14\n\x05nonce\x18\x01\x20\x02(\x0cR\x05nonce:\x04\x88\ - \xb2\x19\x01\";\n\nUnlockPath\x12\x1b\n\taddress_n\x18\x01\x20\x03(\rR\ - \x08addressN\x12\x10\n\x03mac\x18\x02\x20\x01(\x0cR\x03mac\"'\n\x13Unloc\ - kedPathRequest\x12\x10\n\x03mac\x18\x01\x20\x01(\x0cR\x03mac\"\x14\n\x12\ - ShowDeviceTutorial\"\x12\n\x10UnlockBootloader\"%\n\rSetBrightness\x12\ - \x14\n\x05value\x18\x01\x20\x01(\rR\x05value*\x99\x01\n\nBackupType\x12\ - \t\n\x05Bip39\x10\0\x12\x10\n\x0cSlip39_Basic\x10\x01\x12\x13\n\x0fSlip3\ - 9_Advanced\x10\x02\x12\x1c\n\x18Slip39_Single_Extendable\x10\x03\x12\x1b\ - \n\x17Slip39_Basic_Extendable\x10\x04\x12\x1e\n\x1aSlip39_Advanced_Exten\ - dable\x10\x05*G\n\x10SafetyCheckLevel\x12\n\n\x06Strict\x10\0\x12\x10\n\ - \x0cPromptAlways\x10\x01\x12\x15\n\x11PromptTemporarily\x10\x02*=\n\x0fD\ - isplayRotation\x12\t\n\x05North\x10\0\x12\x08\n\x04East\x10Z\x12\n\n\x05\ - South\x10\xb4\x01\x12\t\n\x04West\x10\x8e\x02*0\n\x10HomescreenFormat\ - \x12\x08\n\x04Toif\x10\x01\x12\x08\n\x04Jpeg\x10\x02\x12\x08\n\x04ToiG\ - \x10\x03*H\n\x0cRecoveryType\x12\x12\n\x0eNormalRecovery\x10\0\x12\n\n\ - \x06DryRun\x10\x01\x12\x18\n\x14UnlockRepeatedBackup\x10\x02BB\n#com.sat\ - oshilabs.trezor.lib.protobufB\x17TrezorMessageManagement\x80\xa6\x1d\x01\ + \x1d\x01\x12\x18\n\x14Capability_Mintlayer\x10\x16\x1a\x04\xc8\xf3\x18\ + \x01\"\x0c\n\nLockDevice\"&\n\x07SetBusy\x12\x1b\n\texpiry_ms\x18\x01\ + \x20\x01(\rR\x08expiryMs\"\x0c\n\nEndSession\"\xf4\x04\n\rApplySettings\ + \x12\x1e\n\x08language\x18\x01\x20\x01(\tR\x08languageB\x02\x18\x01\x12\ + \x14\n\x05label\x18\x02\x20\x01(\tR\x05label\x12%\n\x0euse_passphrase\ + \x18\x03\x20\x01(\x08R\rusePassphrase\x12\x1e\n\nhomescreen\x18\x04\x20\ + \x01(\x0cR\nhomescreen\x120\n\x12_passphrase_source\x18\x05\x20\x01(\rR\ + \x10PassphraseSourceB\x02\x18\x01\x12+\n\x12auto_lock_delay_ms\x18\x06\ + \x20\x01(\rR\x0fautoLockDelayMs\x12Y\n\x10display_rotation\x18\x07\x20\ + \x01(\x0e2..hw.trezor.messages.management.DisplayRotationR\x0fdisplayRot\ + ation\x12=\n\x1bpassphrase_always_on_device\x18\x08\x20\x01(\x08R\x18pas\ + sphraseAlwaysOnDevice\x12T\n\rsafety_checks\x18\t\x20\x01(\x0e2/.hw.trez\ + or.messages.management.SafetyCheckLevelR\x0csafetyChecks\x123\n\x15exper\ + imental_features\x18\n\x20\x01(\x08R\x14experimentalFeatures\x129\n\x19h\ + ide_passphrase_from_host\x18\x0b\x20\x01(\x08R\x16hidePassphraseFromHost\ + \x12'\n\x0fhaptic_feedback\x18\r\x20\x01(\x08R\x0ehapticFeedback\"T\n\ + \x0eChangeLanguage\x12\x1f\n\x0bdata_length\x18\x01\x20\x02(\rR\ndataLen\ + gth\x12!\n\x0cshow_display\x18\x02\x20\x01(\x08R\x0bshowDisplay\"Z\n\x16\ + TranslationDataRequest\x12\x1f\n\x0bdata_length\x18\x01\x20\x02(\rR\ndat\ + aLength\x12\x1f\n\x0bdata_offset\x18\x02\x20\x02(\rR\ndataOffset\"3\n\ + \x12TranslationDataAck\x12\x1d\n\ndata_chunk\x18\x01\x20\x02(\x0cR\tdata\ + Chunk\"\"\n\nApplyFlags\x12\x14\n\x05flags\x18\x01\x20\x02(\rR\x05flags\ + \"#\n\tChangePin\x12\x16\n\x06remove\x18\x01\x20\x01(\x08R\x06remove\"(\ + \n\x0eChangeWipeCode\x12\x16\n\x06remove\x18\x01\x20\x01(\x08R\x06remove\ + \"\xaa\x01\n\tSdProtect\x12]\n\toperation\x18\x01\x20\x02(\x0e2?.hw.trez\ + or.messages.management.SdProtect.SdProtectOperationTypeR\toperation\">\n\ + \x16SdProtectOperationType\x12\x0b\n\x07DISABLE\x10\0\x12\n\n\x06ENABLE\ + \x10\x01\x12\x0b\n\x07REFRESH\x10\x02\"O\n\x04Ping\x12\x1a\n\x07message\ + \x18\x01\x20\x01(\t:\0R\x07message\x12+\n\x11button_protection\x18\x02\ + \x20\x01(\x08R\x10buttonProtection\"\x08\n\x06Cancel\"\x20\n\nGetEntropy\ + \x12\x12\n\x04size\x18\x01\x20\x02(\rR\x04size\"#\n\x07Entropy\x12\x18\n\ + \x07entropy\x18\x01\x20\x02(\x0cR\x07entropy\"/\n\x0fGetFirmwareHash\x12\ + \x1c\n\tchallenge\x18\x01\x20\x01(\x0cR\tchallenge\"\"\n\x0cFirmwareHash\ + \x12\x12\n\x04hash\x18\x01\x20\x02(\x0cR\x04hash\"2\n\x12AuthenticateDev\ + ice\x12\x1c\n\tchallenge\x18\x01\x20\x02(\x0cR\tchallenge\"U\n\x11Authen\ + ticityProof\x12\"\n\x0ccertificates\x18\x01\x20\x03(\x0cR\x0ccertificate\ + s\x12\x1c\n\tsignature\x18\x02\x20\x02(\x0cR\tsignature\"\x0c\n\nWipeDev\ + ice\"\xad\x02\n\nLoadDevice\x12\x1c\n\tmnemonics\x18\x01\x20\x03(\tR\tmn\ + emonics\x12\x10\n\x03pin\x18\x03\x20\x01(\tR\x03pin\x123\n\x15passphrase\ + _protection\x18\x04\x20\x01(\x08R\x14passphraseProtection\x12\x1e\n\x08l\ + anguage\x18\x05\x20\x01(\tR\x08languageB\x02\x18\x01\x12\x14\n\x05label\ + \x18\x06\x20\x01(\tR\x05label\x12#\n\rskip_checksum\x18\x07\x20\x01(\x08\ + R\x0cskipChecksum\x12\x1f\n\x0bu2f_counter\x18\x08\x20\x01(\rR\nu2fCount\ + er\x12!\n\x0cneeds_backup\x18\t\x20\x01(\x08R\x0bneedsBackup\x12\x1b\n\t\ + no_backup\x18\n\x20\x01(\x08R\x08noBackup\"\x9d\x03\n\x0bResetDevice\x12\ + \x1f\n\x08strength\x18\x02\x20\x01(\r:\x03256R\x08strength\x123\n\x15pas\ + sphrase_protection\x18\x03\x20\x01(\x08R\x14passphraseProtection\x12%\n\ + \x0epin_protection\x18\x04\x20\x01(\x08R\rpinProtection\x12\x1e\n\x08lan\ + guage\x18\x05\x20\x01(\tR\x08languageB\x02\x18\x01\x12\x14\n\x05label\ + \x18\x06\x20\x01(\tR\x05label\x12\x1f\n\x0bu2f_counter\x18\x07\x20\x01(\ + \rR\nu2fCounter\x12\x1f\n\x0bskip_backup\x18\x08\x20\x01(\x08R\nskipBack\ + up\x12\x1b\n\tno_backup\x18\t\x20\x01(\x08R\x08noBackup\x12Q\n\x0bbackup\ + _type\x18\n\x20\x01(\x0e2).hw.trezor.messages.management.BackupType:\x05\ + Bip39R\nbackupType\x12#\n\rentropy_check\x18\x0b\x20\x01(\x08R\x0centrop\ + yCheckJ\x04\x08\x01\x10\x02\"\xe5\x01\n\x0cBackupDevice\x12'\n\x0fgroup_\ + threshold\x18\x01\x20\x01(\rR\x0egroupThreshold\x12O\n\x06groups\x18\x02\ + \x20\x03(\x0b27.hw.trezor.messages.management.BackupDevice.Slip39GroupR\ + \x06groups\x1a[\n\x0bSlip39Group\x12)\n\x10member_threshold\x18\x01\x20\ + \x02(\rR\x0fmemberThreshold\x12!\n\x0cmember_count\x18\x02\x20\x02(\rR\ + \x0bmemberCount\"b\n\x0eEntropyRequest\x12-\n\x12entropy_commitment\x18\ + \x01\x20\x01(\x0cR\x11entropyCommitment\x12!\n\x0cprev_entropy\x18\x02\ + \x20\x01(\x0cR\x0bprevEntropy\"&\n\nEntropyAck\x12\x18\n\x07entropy\x18\ + \x01\x20\x02(\x0cR\x07entropy\"\x13\n\x11EntropyCheckReady\"5\n\x14Entro\ + pyCheckContinue\x12\x1d\n\x06finish\x18\x01\x20\x01(\x08:\x05falseR\x06f\ + inish\"\x8d\x04\n\x0eRecoveryDevice\x12\x1d\n\nword_count\x18\x01\x20\ + \x01(\rR\twordCount\x123\n\x15passphrase_protection\x18\x02\x20\x01(\x08\ + R\x14passphraseProtection\x12%\n\x0epin_protection\x18\x03\x20\x01(\x08R\ + \rpinProtection\x12\x1e\n\x08language\x18\x04\x20\x01(\tR\x08languageB\ + \x02\x18\x01\x12\x14\n\x05label\x18\x05\x20\x01(\tR\x05label\x12)\n\x10e\ + nforce_wordlist\x18\x06\x20\x01(\x08R\x0fenforceWordlist\x12j\n\x0cinput\ + _method\x18\x08\x20\x01(\x0e2G.hw.trezor.messages.management.RecoveryDev\ + ice.RecoveryDeviceInputMethodR\x0binputMethod\x12\x1f\n\x0bu2f_counter\ + \x18\t\x20\x01(\rR\nu2fCounter\x12O\n\x04type\x18\n\x20\x01(\x0e2+.hw.tr\ + ezor.messages.management.RecoveryType:\x0eNormalRecoveryR\x04type\";\n\ + \x19RecoveryDeviceInputMethod\x12\x12\n\x0eScrambledWords\x10\0\x12\n\n\ + \x06Matrix\x10\x01J\x04\x08\x07\x10\x08\"\xc5\x01\n\x0bWordRequest\x12N\ + \n\x04type\x18\x01\x20\x02(\x0e2:.hw.trezor.messages.management.WordRequ\ + est.WordRequestTypeR\x04type\"f\n\x0fWordRequestType\x12\x19\n\x15WordRe\ + questType_Plain\x10\0\x12\x1b\n\x17WordRequestType_Matrix9\x10\x01\x12\ + \x1b\n\x17WordRequestType_Matrix6\x10\x02\"\x1d\n\x07WordAck\x12\x12\n\ + \x04word\x18\x01\x20\x02(\tR\x04word\"0\n\rSetU2FCounter\x12\x1f\n\x0bu2\ + f_counter\x18\x01\x20\x02(\rR\nu2fCounter\"\x13\n\x11GetNextU2FCounter\"\ + 1\n\x0eNextU2FCounter\x12\x1f\n\x0bu2f_counter\x18\x01\x20\x02(\rR\nu2fC\ + ounter\"\x11\n\x0fDoPreauthorized\"\x16\n\x14PreauthorizedRequest\"\x15\ + \n\x13CancelAuthorization\"\x9a\x02\n\x12RebootToBootloader\x12o\n\x0cbo\ + ot_command\x18\x01\x20\x01(\x0e2=.hw.trezor.messages.management.RebootTo\ + Bootloader.BootCommand:\rSTOP_AND_WAITR\x0bbootCommand\x12'\n\x0ffirmwar\ + e_header\x18\x02\x20\x01(\x0cR\x0efirmwareHeader\x123\n\x14language_data\ + _length\x18\x03\x20\x01(\r:\x010R\x12languageDataLength\"5\n\x0bBootComm\ + and\x12\x11\n\rSTOP_AND_WAIT\x10\0\x12\x13\n\x0fINSTALL_UPGRADE\x10\x01\ + \"\x10\n\x08GetNonce:\x04\x88\xb2\x19\x01\"#\n\x05Nonce\x12\x14\n\x05non\ + ce\x18\x01\x20\x02(\x0cR\x05nonce:\x04\x88\xb2\x19\x01\";\n\nUnlockPath\ + \x12\x1b\n\taddress_n\x18\x01\x20\x03(\rR\x08addressN\x12\x10\n\x03mac\ + \x18\x02\x20\x01(\x0cR\x03mac\"'\n\x13UnlockedPathRequest\x12\x10\n\x03m\ + ac\x18\x01\x20\x01(\x0cR\x03mac\"\x14\n\x12ShowDeviceTutorial\"\x12\n\ + \x10UnlockBootloader\"%\n\rSetBrightness\x12\x14\n\x05value\x18\x01\x20\ + \x01(\rR\x05value*\x99\x01\n\nBackupType\x12\t\n\x05Bip39\x10\0\x12\x10\ + \n\x0cSlip39_Basic\x10\x01\x12\x13\n\x0fSlip39_Advanced\x10\x02\x12\x1c\ + \n\x18Slip39_Single_Extendable\x10\x03\x12\x1b\n\x17Slip39_Basic_Extenda\ + ble\x10\x04\x12\x1e\n\x1aSlip39_Advanced_Extendable\x10\x05*G\n\x10Safet\ + yCheckLevel\x12\n\n\x06Strict\x10\0\x12\x10\n\x0cPromptAlways\x10\x01\ + \x12\x15\n\x11PromptTemporarily\x10\x02*=\n\x0fDisplayRotation\x12\t\n\ + \x05North\x10\0\x12\x08\n\x04East\x10Z\x12\n\n\x05South\x10\xb4\x01\x12\ + \t\n\x04West\x10\x8e\x02*0\n\x10HomescreenFormat\x12\x08\n\x04Toif\x10\ + \x01\x12\x08\n\x04Jpeg\x10\x02\x12\x08\n\x04ToiG\x10\x03*H\n\x0cRecovery\ + Type\x12\x12\n\x0eNormalRecovery\x10\0\x12\n\n\x06DryRun\x10\x01\x12\x18\ + \n\x14UnlockRepeatedBackup\x10\x02BB\n#com.satoshilabs.trezor.lib.protob\ + ufB\x17TrezorMessageManagement\x80\xa6\x1d\x01\ "; /// `FileDescriptorProto` object which was a source for this generated file diff --git a/rust/trezor-client/src/protos/generated/messages_mintlayer.rs b/rust/trezor-client/src/protos/generated/messages_mintlayer.rs new file mode 100644 index 0000000000..69ded346d7 --- /dev/null +++ b/rust/trezor-client/src/protos/generated/messages_mintlayer.rs @@ -0,0 +1,11185 @@ +// This file is generated by rust-protobuf 3.3.0. Do not edit +// .proto file is parsed by protoc 3.19.6 +// @generated + +// https://github.com/rust-lang/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![allow(unused_attributes)] +#![cfg_attr(rustfmt, rustfmt::skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unused_results)] +#![allow(unused_mut)] + +//! Generated file from `messages-mintlayer.proto` + +/// Generated files are compatible only with the same version +/// of protobuf runtime. +const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_3_0; + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerGetAddress) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerGetAddress { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerGetAddress.address_n) + pub address_n: ::std::vec::Vec, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerGetAddress.chain_type) + pub chain_type: ::std::option::Option<::protobuf::EnumOrUnknown>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerGetAddress.show_display) + pub show_display: ::std::option::Option, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerGetAddress.chunkify) + pub chunkify: ::std::option::Option, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerGetAddress.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerGetAddress { + fn default() -> &'a MintlayerGetAddress { + ::default_instance() + } +} + +impl MintlayerGetAddress { + pub fn new() -> MintlayerGetAddress { + ::std::default::Default::default() + } + + // required .hw.trezor.messages.mintlayer.MintlayerChainType chain_type = 2; + + pub fn chain_type(&self) -> MintlayerChainType { + match self.chain_type { + Some(e) => e.enum_value_or(MintlayerChainType::Mainnet), + None => MintlayerChainType::Mainnet, + } + } + + pub fn clear_chain_type(&mut self) { + self.chain_type = ::std::option::Option::None; + } + + pub fn has_chain_type(&self) -> bool { + self.chain_type.is_some() + } + + // Param is passed by value, moved + pub fn set_chain_type(&mut self, v: MintlayerChainType) { + self.chain_type = ::std::option::Option::Some(::protobuf::EnumOrUnknown::new(v)); + } + + // optional bool show_display = 3; + + pub fn show_display(&self) -> bool { + self.show_display.unwrap_or(false) + } + + pub fn clear_show_display(&mut self) { + self.show_display = ::std::option::Option::None; + } + + pub fn has_show_display(&self) -> bool { + self.show_display.is_some() + } + + // Param is passed by value, moved + pub fn set_show_display(&mut self, v: bool) { + self.show_display = ::std::option::Option::Some(v); + } + + // optional bool chunkify = 4; + + pub fn chunkify(&self) -> bool { + self.chunkify.unwrap_or(false) + } + + pub fn clear_chunkify(&mut self) { + self.chunkify = ::std::option::Option::None; + } + + pub fn has_chunkify(&self) -> bool { + self.chunkify.is_some() + } + + // Param is passed by value, moved + pub fn set_chunkify(&mut self, v: bool) { + self.chunkify = ::std::option::Option::Some(v); + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(4); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "address_n", + |m: &MintlayerGetAddress| { &m.address_n }, + |m: &mut MintlayerGetAddress| { &mut m.address_n }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "chain_type", + |m: &MintlayerGetAddress| { &m.chain_type }, + |m: &mut MintlayerGetAddress| { &mut m.chain_type }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "show_display", + |m: &MintlayerGetAddress| { &m.show_display }, + |m: &mut MintlayerGetAddress| { &mut m.show_display }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "chunkify", + |m: &MintlayerGetAddress| { &m.chunkify }, + |m: &mut MintlayerGetAddress| { &mut m.chunkify }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerGetAddress", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerGetAddress { + const NAME: &'static str = "MintlayerGetAddress"; + + fn is_initialized(&self) -> bool { + if self.chain_type.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + is.read_repeated_packed_uint32_into(&mut self.address_n)?; + }, + 8 => { + self.address_n.push(is.read_uint32()?); + }, + 16 => { + self.chain_type = ::std::option::Option::Some(is.read_enum_or_unknown()?); + }, + 24 => { + self.show_display = ::std::option::Option::Some(is.read_bool()?); + }, + 32 => { + self.chunkify = ::std::option::Option::Some(is.read_bool()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + for value in &self.address_n { + my_size += ::protobuf::rt::uint32_size(1, *value); + }; + if let Some(v) = self.chain_type { + my_size += ::protobuf::rt::int32_size(2, v.value()); + } + if let Some(v) = self.show_display { + my_size += 1 + 1; + } + if let Some(v) = self.chunkify { + my_size += 1 + 1; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + for v in &self.address_n { + os.write_uint32(1, *v)?; + }; + if let Some(v) = self.chain_type { + os.write_enum(2, ::protobuf::EnumOrUnknown::value(&v))?; + } + if let Some(v) = self.show_display { + os.write_bool(3, v)?; + } + if let Some(v) = self.chunkify { + os.write_bool(4, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerGetAddress { + MintlayerGetAddress::new() + } + + fn clear(&mut self) { + self.address_n.clear(); + self.chain_type = ::std::option::Option::None; + self.show_display = ::std::option::Option::None; + self.chunkify = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerGetAddress { + static instance: MintlayerGetAddress = MintlayerGetAddress { + address_n: ::std::vec::Vec::new(), + chain_type: ::std::option::Option::None, + show_display: ::std::option::Option::None, + chunkify: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerGetAddress { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerGetAddress").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerGetAddress { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerGetAddress { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerAddress) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerAddress { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAddress.address) + pub address: ::std::option::Option<::std::string::String>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerAddress.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerAddress { + fn default() -> &'a MintlayerAddress { + ::default_instance() + } +} + +impl MintlayerAddress { + pub fn new() -> MintlayerAddress { + ::std::default::Default::default() + } + + // required string address = 1; + + pub fn address(&self) -> &str { + match self.address.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_address(&mut self) { + self.address = ::std::option::Option::None; + } + + pub fn has_address(&self) -> bool { + self.address.is_some() + } + + // Param is passed by value, moved + pub fn set_address(&mut self, v: ::std::string::String) { + self.address = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_address(&mut self) -> &mut ::std::string::String { + if self.address.is_none() { + self.address = ::std::option::Option::Some(::std::string::String::new()); + } + self.address.as_mut().unwrap() + } + + // Take field + pub fn take_address(&mut self) -> ::std::string::String { + self.address.take().unwrap_or_else(|| ::std::string::String::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(1); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "address", + |m: &MintlayerAddress| { &m.address }, + |m: &mut MintlayerAddress| { &mut m.address }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerAddress", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerAddress { + const NAME: &'static str = "MintlayerAddress"; + + fn is_initialized(&self) -> bool { + if self.address.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.address = ::std::option::Option::Some(is.read_string()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.address.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.address.as_ref() { + os.write_string(1, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerAddress { + MintlayerAddress::new() + } + + fn clear(&mut self) { + self.address = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerAddress { + static instance: MintlayerAddress = MintlayerAddress { + address: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerAddress { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerAddress").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerAddress { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerAddress { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerGetPublicKey) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerGetPublicKey { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerGetPublicKey.address_n) + pub address_n: ::std::vec::Vec, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerGetPublicKey.chain_type) + pub chain_type: ::std::option::Option<::protobuf::EnumOrUnknown>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerGetPublicKey.show_display) + pub show_display: ::std::option::Option, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerGetPublicKey.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerGetPublicKey { + fn default() -> &'a MintlayerGetPublicKey { + ::default_instance() + } +} + +impl MintlayerGetPublicKey { + pub fn new() -> MintlayerGetPublicKey { + ::std::default::Default::default() + } + + // required .hw.trezor.messages.mintlayer.MintlayerChainType chain_type = 2; + + pub fn chain_type(&self) -> MintlayerChainType { + match self.chain_type { + Some(e) => e.enum_value_or(MintlayerChainType::Mainnet), + None => MintlayerChainType::Mainnet, + } + } + + pub fn clear_chain_type(&mut self) { + self.chain_type = ::std::option::Option::None; + } + + pub fn has_chain_type(&self) -> bool { + self.chain_type.is_some() + } + + // Param is passed by value, moved + pub fn set_chain_type(&mut self, v: MintlayerChainType) { + self.chain_type = ::std::option::Option::Some(::protobuf::EnumOrUnknown::new(v)); + } + + // optional bool show_display = 3; + + pub fn show_display(&self) -> bool { + self.show_display.unwrap_or(false) + } + + pub fn clear_show_display(&mut self) { + self.show_display = ::std::option::Option::None; + } + + pub fn has_show_display(&self) -> bool { + self.show_display.is_some() + } + + // Param is passed by value, moved + pub fn set_show_display(&mut self, v: bool) { + self.show_display = ::std::option::Option::Some(v); + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(3); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "address_n", + |m: &MintlayerGetPublicKey| { &m.address_n }, + |m: &mut MintlayerGetPublicKey| { &mut m.address_n }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "chain_type", + |m: &MintlayerGetPublicKey| { &m.chain_type }, + |m: &mut MintlayerGetPublicKey| { &mut m.chain_type }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "show_display", + |m: &MintlayerGetPublicKey| { &m.show_display }, + |m: &mut MintlayerGetPublicKey| { &mut m.show_display }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerGetPublicKey", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerGetPublicKey { + const NAME: &'static str = "MintlayerGetPublicKey"; + + fn is_initialized(&self) -> bool { + if self.chain_type.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + is.read_repeated_packed_uint32_into(&mut self.address_n)?; + }, + 8 => { + self.address_n.push(is.read_uint32()?); + }, + 16 => { + self.chain_type = ::std::option::Option::Some(is.read_enum_or_unknown()?); + }, + 24 => { + self.show_display = ::std::option::Option::Some(is.read_bool()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + for value in &self.address_n { + my_size += ::protobuf::rt::uint32_size(1, *value); + }; + if let Some(v) = self.chain_type { + my_size += ::protobuf::rt::int32_size(2, v.value()); + } + if let Some(v) = self.show_display { + my_size += 1 + 1; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + for v in &self.address_n { + os.write_uint32(1, *v)?; + }; + if let Some(v) = self.chain_type { + os.write_enum(2, ::protobuf::EnumOrUnknown::value(&v))?; + } + if let Some(v) = self.show_display { + os.write_bool(3, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerGetPublicKey { + MintlayerGetPublicKey::new() + } + + fn clear(&mut self) { + self.address_n.clear(); + self.chain_type = ::std::option::Option::None; + self.show_display = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerGetPublicKey { + static instance: MintlayerGetPublicKey = MintlayerGetPublicKey { + address_n: ::std::vec::Vec::new(), + chain_type: ::std::option::Option::None, + show_display: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerGetPublicKey { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerGetPublicKey").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerGetPublicKey { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerGetPublicKey { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerPublicKey) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerPublicKey { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerPublicKey.public_key) + pub public_key: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerPublicKey.chain_code) + pub chain_code: ::std::option::Option<::std::vec::Vec>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerPublicKey.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerPublicKey { + fn default() -> &'a MintlayerPublicKey { + ::default_instance() + } +} + +impl MintlayerPublicKey { + pub fn new() -> MintlayerPublicKey { + ::std::default::Default::default() + } + + // required bytes public_key = 1; + + pub fn public_key(&self) -> &[u8] { + match self.public_key.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_public_key(&mut self) { + self.public_key = ::std::option::Option::None; + } + + pub fn has_public_key(&self) -> bool { + self.public_key.is_some() + } + + // Param is passed by value, moved + pub fn set_public_key(&mut self, v: ::std::vec::Vec) { + self.public_key = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_public_key(&mut self) -> &mut ::std::vec::Vec { + if self.public_key.is_none() { + self.public_key = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.public_key.as_mut().unwrap() + } + + // Take field + pub fn take_public_key(&mut self) -> ::std::vec::Vec { + self.public_key.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // required bytes chain_code = 2; + + pub fn chain_code(&self) -> &[u8] { + match self.chain_code.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_chain_code(&mut self) { + self.chain_code = ::std::option::Option::None; + } + + pub fn has_chain_code(&self) -> bool { + self.chain_code.is_some() + } + + // Param is passed by value, moved + pub fn set_chain_code(&mut self, v: ::std::vec::Vec) { + self.chain_code = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_chain_code(&mut self) -> &mut ::std::vec::Vec { + if self.chain_code.is_none() { + self.chain_code = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.chain_code.as_mut().unwrap() + } + + // Take field + pub fn take_chain_code(&mut self) -> ::std::vec::Vec { + self.chain_code.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "public_key", + |m: &MintlayerPublicKey| { &m.public_key }, + |m: &mut MintlayerPublicKey| { &mut m.public_key }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "chain_code", + |m: &MintlayerPublicKey| { &m.chain_code }, + |m: &mut MintlayerPublicKey| { &mut m.chain_code }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerPublicKey", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerPublicKey { + const NAME: &'static str = "MintlayerPublicKey"; + + fn is_initialized(&self) -> bool { + if self.public_key.is_none() { + return false; + } + if self.chain_code.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.public_key = ::std::option::Option::Some(is.read_bytes()?); + }, + 18 => { + self.chain_code = ::std::option::Option::Some(is.read_bytes()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.public_key.as_ref() { + my_size += ::protobuf::rt::bytes_size(1, &v); + } + if let Some(v) = self.chain_code.as_ref() { + my_size += ::protobuf::rt::bytes_size(2, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.public_key.as_ref() { + os.write_bytes(1, v)?; + } + if let Some(v) = self.chain_code.as_ref() { + os.write_bytes(2, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerPublicKey { + MintlayerPublicKey::new() + } + + fn clear(&mut self) { + self.public_key = ::std::option::Option::None; + self.chain_code = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerPublicKey { + static instance: MintlayerPublicKey = MintlayerPublicKey { + public_key: ::std::option::Option::None, + chain_code: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerPublicKey { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerPublicKey").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerPublicKey { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerPublicKey { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerSignMessage) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerSignMessage { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerSignMessage.address_n) + pub address_n: ::std::vec::Vec, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerSignMessage.chain_type) + pub chain_type: ::std::option::Option<::protobuf::EnumOrUnknown>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerSignMessage.address_type) + pub address_type: ::std::option::Option<::protobuf::EnumOrUnknown>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerSignMessage.message) + pub message: ::std::option::Option<::std::vec::Vec>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerSignMessage.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerSignMessage { + fn default() -> &'a MintlayerSignMessage { + ::default_instance() + } +} + +impl MintlayerSignMessage { + pub fn new() -> MintlayerSignMessage { + ::std::default::Default::default() + } + + // required .hw.trezor.messages.mintlayer.MintlayerChainType chain_type = 2; + + pub fn chain_type(&self) -> MintlayerChainType { + match self.chain_type { + Some(e) => e.enum_value_or(MintlayerChainType::Mainnet), + None => MintlayerChainType::Mainnet, + } + } + + pub fn clear_chain_type(&mut self) { + self.chain_type = ::std::option::Option::None; + } + + pub fn has_chain_type(&self) -> bool { + self.chain_type.is_some() + } + + // Param is passed by value, moved + pub fn set_chain_type(&mut self, v: MintlayerChainType) { + self.chain_type = ::std::option::Option::Some(::protobuf::EnumOrUnknown::new(v)); + } + + // required .hw.trezor.messages.mintlayer.MintlayerAddressType address_type = 3; + + pub fn address_type(&self) -> MintlayerAddressType { + match self.address_type { + Some(e) => e.enum_value_or(MintlayerAddressType::PUBLIC_KEY), + None => MintlayerAddressType::PUBLIC_KEY, + } + } + + pub fn clear_address_type(&mut self) { + self.address_type = ::std::option::Option::None; + } + + pub fn has_address_type(&self) -> bool { + self.address_type.is_some() + } + + // Param is passed by value, moved + pub fn set_address_type(&mut self, v: MintlayerAddressType) { + self.address_type = ::std::option::Option::Some(::protobuf::EnumOrUnknown::new(v)); + } + + // required bytes message = 4; + + pub fn message(&self) -> &[u8] { + match self.message.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_message(&mut self) { + self.message = ::std::option::Option::None; + } + + pub fn has_message(&self) -> bool { + self.message.is_some() + } + + // Param is passed by value, moved + pub fn set_message(&mut self, v: ::std::vec::Vec) { + self.message = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_message(&mut self) -> &mut ::std::vec::Vec { + if self.message.is_none() { + self.message = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.message.as_mut().unwrap() + } + + // Take field + pub fn take_message(&mut self) -> ::std::vec::Vec { + self.message.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(4); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "address_n", + |m: &MintlayerSignMessage| { &m.address_n }, + |m: &mut MintlayerSignMessage| { &mut m.address_n }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "chain_type", + |m: &MintlayerSignMessage| { &m.chain_type }, + |m: &mut MintlayerSignMessage| { &mut m.chain_type }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "address_type", + |m: &MintlayerSignMessage| { &m.address_type }, + |m: &mut MintlayerSignMessage| { &mut m.address_type }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "message", + |m: &MintlayerSignMessage| { &m.message }, + |m: &mut MintlayerSignMessage| { &mut m.message }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerSignMessage", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerSignMessage { + const NAME: &'static str = "MintlayerSignMessage"; + + fn is_initialized(&self) -> bool { + if self.chain_type.is_none() { + return false; + } + if self.address_type.is_none() { + return false; + } + if self.message.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + is.read_repeated_packed_uint32_into(&mut self.address_n)?; + }, + 8 => { + self.address_n.push(is.read_uint32()?); + }, + 16 => { + self.chain_type = ::std::option::Option::Some(is.read_enum_or_unknown()?); + }, + 24 => { + self.address_type = ::std::option::Option::Some(is.read_enum_or_unknown()?); + }, + 34 => { + self.message = ::std::option::Option::Some(is.read_bytes()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + for value in &self.address_n { + my_size += ::protobuf::rt::uint32_size(1, *value); + }; + if let Some(v) = self.chain_type { + my_size += ::protobuf::rt::int32_size(2, v.value()); + } + if let Some(v) = self.address_type { + my_size += ::protobuf::rt::int32_size(3, v.value()); + } + if let Some(v) = self.message.as_ref() { + my_size += ::protobuf::rt::bytes_size(4, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + for v in &self.address_n { + os.write_uint32(1, *v)?; + }; + if let Some(v) = self.chain_type { + os.write_enum(2, ::protobuf::EnumOrUnknown::value(&v))?; + } + if let Some(v) = self.address_type { + os.write_enum(3, ::protobuf::EnumOrUnknown::value(&v))?; + } + if let Some(v) = self.message.as_ref() { + os.write_bytes(4, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerSignMessage { + MintlayerSignMessage::new() + } + + fn clear(&mut self) { + self.address_n.clear(); + self.chain_type = ::std::option::Option::None; + self.address_type = ::std::option::Option::None; + self.message = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerSignMessage { + static instance: MintlayerSignMessage = MintlayerSignMessage { + address_n: ::std::vec::Vec::new(), + chain_type: ::std::option::Option::None, + address_type: ::std::option::Option::None, + message: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerSignMessage { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerSignMessage").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerSignMessage { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerSignMessage { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerSignTx) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerSignTx { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerSignTx.outputs_count) + pub outputs_count: ::std::option::Option, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerSignTx.inputs_count) + pub inputs_count: ::std::option::Option, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerSignTx.chain_type) + pub chain_type: ::std::option::Option<::protobuf::EnumOrUnknown>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerSignTx.version) + pub version: ::std::option::Option, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerSignTx.chunkify) + pub chunkify: ::std::option::Option, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerSignTx.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerSignTx { + fn default() -> &'a MintlayerSignTx { + ::default_instance() + } +} + +impl MintlayerSignTx { + pub fn new() -> MintlayerSignTx { + ::std::default::Default::default() + } + + // required uint32 outputs_count = 1; + + pub fn outputs_count(&self) -> u32 { + self.outputs_count.unwrap_or(0) + } + + pub fn clear_outputs_count(&mut self) { + self.outputs_count = ::std::option::Option::None; + } + + pub fn has_outputs_count(&self) -> bool { + self.outputs_count.is_some() + } + + // Param is passed by value, moved + pub fn set_outputs_count(&mut self, v: u32) { + self.outputs_count = ::std::option::Option::Some(v); + } + + // required uint32 inputs_count = 2; + + pub fn inputs_count(&self) -> u32 { + self.inputs_count.unwrap_or(0) + } + + pub fn clear_inputs_count(&mut self) { + self.inputs_count = ::std::option::Option::None; + } + + pub fn has_inputs_count(&self) -> bool { + self.inputs_count.is_some() + } + + // Param is passed by value, moved + pub fn set_inputs_count(&mut self, v: u32) { + self.inputs_count = ::std::option::Option::Some(v); + } + + // required .hw.trezor.messages.mintlayer.MintlayerChainType chain_type = 3; + + pub fn chain_type(&self) -> MintlayerChainType { + match self.chain_type { + Some(e) => e.enum_value_or(MintlayerChainType::Mainnet), + None => MintlayerChainType::Mainnet, + } + } + + pub fn clear_chain_type(&mut self) { + self.chain_type = ::std::option::Option::None; + } + + pub fn has_chain_type(&self) -> bool { + self.chain_type.is_some() + } + + // Param is passed by value, moved + pub fn set_chain_type(&mut self, v: MintlayerChainType) { + self.chain_type = ::std::option::Option::Some(::protobuf::EnumOrUnknown::new(v)); + } + + // optional uint32 version = 4; + + pub fn version(&self) -> u32 { + self.version.unwrap_or(1u32) + } + + pub fn clear_version(&mut self) { + self.version = ::std::option::Option::None; + } + + pub fn has_version(&self) -> bool { + self.version.is_some() + } + + // Param is passed by value, moved + pub fn set_version(&mut self, v: u32) { + self.version = ::std::option::Option::Some(v); + } + + // optional bool chunkify = 5; + + pub fn chunkify(&self) -> bool { + self.chunkify.unwrap_or(false) + } + + pub fn clear_chunkify(&mut self) { + self.chunkify = ::std::option::Option::None; + } + + pub fn has_chunkify(&self) -> bool { + self.chunkify.is_some() + } + + // Param is passed by value, moved + pub fn set_chunkify(&mut self, v: bool) { + self.chunkify = ::std::option::Option::Some(v); + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(5); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "outputs_count", + |m: &MintlayerSignTx| { &m.outputs_count }, + |m: &mut MintlayerSignTx| { &mut m.outputs_count }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "inputs_count", + |m: &MintlayerSignTx| { &m.inputs_count }, + |m: &mut MintlayerSignTx| { &mut m.inputs_count }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "chain_type", + |m: &MintlayerSignTx| { &m.chain_type }, + |m: &mut MintlayerSignTx| { &mut m.chain_type }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "version", + |m: &MintlayerSignTx| { &m.version }, + |m: &mut MintlayerSignTx| { &mut m.version }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "chunkify", + |m: &MintlayerSignTx| { &m.chunkify }, + |m: &mut MintlayerSignTx| { &mut m.chunkify }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerSignTx", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerSignTx { + const NAME: &'static str = "MintlayerSignTx"; + + fn is_initialized(&self) -> bool { + if self.outputs_count.is_none() { + return false; + } + if self.inputs_count.is_none() { + return false; + } + if self.chain_type.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 8 => { + self.outputs_count = ::std::option::Option::Some(is.read_uint32()?); + }, + 16 => { + self.inputs_count = ::std::option::Option::Some(is.read_uint32()?); + }, + 24 => { + self.chain_type = ::std::option::Option::Some(is.read_enum_or_unknown()?); + }, + 32 => { + self.version = ::std::option::Option::Some(is.read_uint32()?); + }, + 40 => { + self.chunkify = ::std::option::Option::Some(is.read_bool()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.outputs_count { + my_size += ::protobuf::rt::uint32_size(1, v); + } + if let Some(v) = self.inputs_count { + my_size += ::protobuf::rt::uint32_size(2, v); + } + if let Some(v) = self.chain_type { + my_size += ::protobuf::rt::int32_size(3, v.value()); + } + if let Some(v) = self.version { + my_size += ::protobuf::rt::uint32_size(4, v); + } + if let Some(v) = self.chunkify { + my_size += 1 + 1; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.outputs_count { + os.write_uint32(1, v)?; + } + if let Some(v) = self.inputs_count { + os.write_uint32(2, v)?; + } + if let Some(v) = self.chain_type { + os.write_enum(3, ::protobuf::EnumOrUnknown::value(&v))?; + } + if let Some(v) = self.version { + os.write_uint32(4, v)?; + } + if let Some(v) = self.chunkify { + os.write_bool(5, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerSignTx { + MintlayerSignTx::new() + } + + fn clear(&mut self) { + self.outputs_count = ::std::option::Option::None; + self.inputs_count = ::std::option::Option::None; + self.chain_type = ::std::option::Option::None; + self.version = ::std::option::Option::None; + self.chunkify = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerSignTx { + static instance: MintlayerSignTx = MintlayerSignTx { + outputs_count: ::std::option::Option::None, + inputs_count: ::std::option::Option::None, + chain_type: ::std::option::Option::None, + version: ::std::option::Option::None, + chunkify: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerSignTx { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerSignTx").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerSignTx { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerSignTx { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerTxRequest) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerTxRequest { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxRequest.input_request) + pub input_request: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxRequest.output_request) + pub output_request: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxRequest.signing_finished) + pub signing_finished: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerTxRequest.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerTxRequest { + fn default() -> &'a MintlayerTxRequest { + ::default_instance() + } +} + +impl MintlayerTxRequest { + pub fn new() -> MintlayerTxRequest { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(3); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, mintlayer_tx_request::MintlayerTxInputRequest>( + "input_request", + |m: &MintlayerTxRequest| { &m.input_request }, + |m: &mut MintlayerTxRequest| { &mut m.input_request }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, mintlayer_tx_request::MintlayerTxOutputRequest>( + "output_request", + |m: &MintlayerTxRequest| { &m.output_request }, + |m: &mut MintlayerTxRequest| { &mut m.output_request }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, mintlayer_tx_request::MintlayerTxSigningResult>( + "signing_finished", + |m: &MintlayerTxRequest| { &m.signing_finished }, + |m: &mut MintlayerTxRequest| { &mut m.signing_finished }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerTxRequest", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerTxRequest { + const NAME: &'static str = "MintlayerTxRequest"; + + fn is_initialized(&self) -> bool { + for v in &self.input_request { + if !v.is_initialized() { + return false; + } + }; + for v in &self.output_request { + if !v.is_initialized() { + return false; + } + }; + for v in &self.signing_finished { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.input_request)?; + }, + 18 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.output_request)?; + }, + 26 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.signing_finished)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.input_request.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.output_request.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.signing_finished.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.input_request.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(1, v, os)?; + } + if let Some(v) = self.output_request.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(2, v, os)?; + } + if let Some(v) = self.signing_finished.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(3, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerTxRequest { + MintlayerTxRequest::new() + } + + fn clear(&mut self) { + self.input_request.clear(); + self.output_request.clear(); + self.signing_finished.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerTxRequest { + static instance: MintlayerTxRequest = MintlayerTxRequest { + input_request: ::protobuf::MessageField::none(), + output_request: ::protobuf::MessageField::none(), + signing_finished: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerTxRequest { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerTxRequest").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerTxRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerTxRequest { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +/// Nested message and enums of message `MintlayerTxRequest` +pub mod mintlayer_tx_request { + // @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerTxInputRequest) + #[derive(PartialEq,Clone,Default,Debug)] + pub struct MintlayerTxInputRequest { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerTxInputRequest.input_index) + pub input_index: ::std::option::Option, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerTxInputRequest.special_fields) + pub special_fields: ::protobuf::SpecialFields, + } + + impl<'a> ::std::default::Default for &'a MintlayerTxInputRequest { + fn default() -> &'a MintlayerTxInputRequest { + ::default_instance() + } + } + + impl MintlayerTxInputRequest { + pub fn new() -> MintlayerTxInputRequest { + ::std::default::Default::default() + } + + // required uint32 input_index = 1; + + pub fn input_index(&self) -> u32 { + self.input_index.unwrap_or(0) + } + + pub fn clear_input_index(&mut self) { + self.input_index = ::std::option::Option::None; + } + + pub fn has_input_index(&self) -> bool { + self.input_index.is_some() + } + + // Param is passed by value, moved + pub fn set_input_index(&mut self, v: u32) { + self.input_index = ::std::option::Option::Some(v); + } + + pub(in super) fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(1); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "input_index", + |m: &MintlayerTxInputRequest| { &m.input_index }, + |m: &mut MintlayerTxInputRequest| { &mut m.input_index }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerTxRequest.MintlayerTxInputRequest", + fields, + oneofs, + ) + } + } + + impl ::protobuf::Message for MintlayerTxInputRequest { + const NAME: &'static str = "MintlayerTxInputRequest"; + + fn is_initialized(&self) -> bool { + if self.input_index.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 8 => { + self.input_index = ::std::option::Option::Some(is.read_uint32()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.input_index { + my_size += ::protobuf::rt::uint32_size(1, v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.input_index { + os.write_uint32(1, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerTxInputRequest { + MintlayerTxInputRequest::new() + } + + fn clear(&mut self) { + self.input_index = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerTxInputRequest { + static instance: MintlayerTxInputRequest = MintlayerTxInputRequest { + input_index: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } + } + + impl ::protobuf::MessageFull for MintlayerTxInputRequest { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| super::file_descriptor().message_by_package_relative_name("MintlayerTxRequest.MintlayerTxInputRequest").unwrap()).clone() + } + } + + impl ::std::fmt::Display for MintlayerTxInputRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } + } + + impl ::protobuf::reflect::ProtobufValue for MintlayerTxInputRequest { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; + } + + // @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerTxOutputRequest) + #[derive(PartialEq,Clone,Default,Debug)] + pub struct MintlayerTxOutputRequest { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerTxOutputRequest.output_index) + pub output_index: ::std::option::Option, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerTxOutputRequest.tx_hash) + pub tx_hash: ::std::option::Option<::std::vec::Vec>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerTxOutputRequest.special_fields) + pub special_fields: ::protobuf::SpecialFields, + } + + impl<'a> ::std::default::Default for &'a MintlayerTxOutputRequest { + fn default() -> &'a MintlayerTxOutputRequest { + ::default_instance() + } + } + + impl MintlayerTxOutputRequest { + pub fn new() -> MintlayerTxOutputRequest { + ::std::default::Default::default() + } + + // required uint32 output_index = 1; + + pub fn output_index(&self) -> u32 { + self.output_index.unwrap_or(0) + } + + pub fn clear_output_index(&mut self) { + self.output_index = ::std::option::Option::None; + } + + pub fn has_output_index(&self) -> bool { + self.output_index.is_some() + } + + // Param is passed by value, moved + pub fn set_output_index(&mut self, v: u32) { + self.output_index = ::std::option::Option::Some(v); + } + + // optional bytes tx_hash = 2; + + pub fn tx_hash(&self) -> &[u8] { + match self.tx_hash.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_tx_hash(&mut self) { + self.tx_hash = ::std::option::Option::None; + } + + pub fn has_tx_hash(&self) -> bool { + self.tx_hash.is_some() + } + + // Param is passed by value, moved + pub fn set_tx_hash(&mut self, v: ::std::vec::Vec) { + self.tx_hash = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_tx_hash(&mut self) -> &mut ::std::vec::Vec { + if self.tx_hash.is_none() { + self.tx_hash = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.tx_hash.as_mut().unwrap() + } + + // Take field + pub fn take_tx_hash(&mut self) -> ::std::vec::Vec { + self.tx_hash.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + pub(in super) fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "output_index", + |m: &MintlayerTxOutputRequest| { &m.output_index }, + |m: &mut MintlayerTxOutputRequest| { &mut m.output_index }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "tx_hash", + |m: &MintlayerTxOutputRequest| { &m.tx_hash }, + |m: &mut MintlayerTxOutputRequest| { &mut m.tx_hash }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerTxRequest.MintlayerTxOutputRequest", + fields, + oneofs, + ) + } + } + + impl ::protobuf::Message for MintlayerTxOutputRequest { + const NAME: &'static str = "MintlayerTxOutputRequest"; + + fn is_initialized(&self) -> bool { + if self.output_index.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 8 => { + self.output_index = ::std::option::Option::Some(is.read_uint32()?); + }, + 18 => { + self.tx_hash = ::std::option::Option::Some(is.read_bytes()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.output_index { + my_size += ::protobuf::rt::uint32_size(1, v); + } + if let Some(v) = self.tx_hash.as_ref() { + my_size += ::protobuf::rt::bytes_size(2, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.output_index { + os.write_uint32(1, v)?; + } + if let Some(v) = self.tx_hash.as_ref() { + os.write_bytes(2, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerTxOutputRequest { + MintlayerTxOutputRequest::new() + } + + fn clear(&mut self) { + self.output_index = ::std::option::Option::None; + self.tx_hash = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerTxOutputRequest { + static instance: MintlayerTxOutputRequest = MintlayerTxOutputRequest { + output_index: ::std::option::Option::None, + tx_hash: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } + } + + impl ::protobuf::MessageFull for MintlayerTxOutputRequest { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| super::file_descriptor().message_by_package_relative_name("MintlayerTxRequest.MintlayerTxOutputRequest").unwrap()).clone() + } + } + + impl ::std::fmt::Display for MintlayerTxOutputRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } + } + + impl ::protobuf::reflect::ProtobufValue for MintlayerTxOutputRequest { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; + } + + // @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerSignature) + #[derive(PartialEq,Clone,Default,Debug)] + pub struct MintlayerSignature { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerSignature.signature) + pub signature: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerSignature.multisig_idx) + pub multisig_idx: ::std::option::Option, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerSignature.special_fields) + pub special_fields: ::protobuf::SpecialFields, + } + + impl<'a> ::std::default::Default for &'a MintlayerSignature { + fn default() -> &'a MintlayerSignature { + ::default_instance() + } + } + + impl MintlayerSignature { + pub fn new() -> MintlayerSignature { + ::std::default::Default::default() + } + + // required bytes signature = 1; + + pub fn signature(&self) -> &[u8] { + match self.signature.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_signature(&mut self) { + self.signature = ::std::option::Option::None; + } + + pub fn has_signature(&self) -> bool { + self.signature.is_some() + } + + // Param is passed by value, moved + pub fn set_signature(&mut self, v: ::std::vec::Vec) { + self.signature = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_signature(&mut self) -> &mut ::std::vec::Vec { + if self.signature.is_none() { + self.signature = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.signature.as_mut().unwrap() + } + + // Take field + pub fn take_signature(&mut self) -> ::std::vec::Vec { + self.signature.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // optional uint32 multisig_idx = 2; + + pub fn multisig_idx(&self) -> u32 { + self.multisig_idx.unwrap_or(0) + } + + pub fn clear_multisig_idx(&mut self) { + self.multisig_idx = ::std::option::Option::None; + } + + pub fn has_multisig_idx(&self) -> bool { + self.multisig_idx.is_some() + } + + // Param is passed by value, moved + pub fn set_multisig_idx(&mut self, v: u32) { + self.multisig_idx = ::std::option::Option::Some(v); + } + + pub(in super) fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "signature", + |m: &MintlayerSignature| { &m.signature }, + |m: &mut MintlayerSignature| { &mut m.signature }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "multisig_idx", + |m: &MintlayerSignature| { &m.multisig_idx }, + |m: &mut MintlayerSignature| { &mut m.multisig_idx }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerTxRequest.MintlayerSignature", + fields, + oneofs, + ) + } + } + + impl ::protobuf::Message for MintlayerSignature { + const NAME: &'static str = "MintlayerSignature"; + + fn is_initialized(&self) -> bool { + if self.signature.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.signature = ::std::option::Option::Some(is.read_bytes()?); + }, + 16 => { + self.multisig_idx = ::std::option::Option::Some(is.read_uint32()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.signature.as_ref() { + my_size += ::protobuf::rt::bytes_size(1, &v); + } + if let Some(v) = self.multisig_idx { + my_size += ::protobuf::rt::uint32_size(2, v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.signature.as_ref() { + os.write_bytes(1, v)?; + } + if let Some(v) = self.multisig_idx { + os.write_uint32(2, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerSignature { + MintlayerSignature::new() + } + + fn clear(&mut self) { + self.signature = ::std::option::Option::None; + self.multisig_idx = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerSignature { + static instance: MintlayerSignature = MintlayerSignature { + signature: ::std::option::Option::None, + multisig_idx: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } + } + + impl ::protobuf::MessageFull for MintlayerSignature { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| super::file_descriptor().message_by_package_relative_name("MintlayerTxRequest.MintlayerSignature").unwrap()).clone() + } + } + + impl ::std::fmt::Display for MintlayerSignature { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } + } + + impl ::protobuf::reflect::ProtobufValue for MintlayerSignature { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; + } + + // @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerSignaturesForInput) + #[derive(PartialEq,Clone,Default,Debug)] + pub struct MintlayerSignaturesForInput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerSignaturesForInput.input_index) + pub input_index: ::std::option::Option, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerSignaturesForInput.signatures) + pub signatures: ::std::vec::Vec, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerSignaturesForInput.special_fields) + pub special_fields: ::protobuf::SpecialFields, + } + + impl<'a> ::std::default::Default for &'a MintlayerSignaturesForInput { + fn default() -> &'a MintlayerSignaturesForInput { + ::default_instance() + } + } + + impl MintlayerSignaturesForInput { + pub fn new() -> MintlayerSignaturesForInput { + ::std::default::Default::default() + } + + // required uint32 input_index = 1; + + pub fn input_index(&self) -> u32 { + self.input_index.unwrap_or(0) + } + + pub fn clear_input_index(&mut self) { + self.input_index = ::std::option::Option::None; + } + + pub fn has_input_index(&self) -> bool { + self.input_index.is_some() + } + + // Param is passed by value, moved + pub fn set_input_index(&mut self, v: u32) { + self.input_index = ::std::option::Option::Some(v); + } + + pub(in super) fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "input_index", + |m: &MintlayerSignaturesForInput| { &m.input_index }, + |m: &mut MintlayerSignaturesForInput| { &mut m.input_index }, + )); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "signatures", + |m: &MintlayerSignaturesForInput| { &m.signatures }, + |m: &mut MintlayerSignaturesForInput| { &mut m.signatures }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerTxRequest.MintlayerSignaturesForInput", + fields, + oneofs, + ) + } + } + + impl ::protobuf::Message for MintlayerSignaturesForInput { + const NAME: &'static str = "MintlayerSignaturesForInput"; + + fn is_initialized(&self) -> bool { + if self.input_index.is_none() { + return false; + } + for v in &self.signatures { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 8 => { + self.input_index = ::std::option::Option::Some(is.read_uint32()?); + }, + 18 => { + self.signatures.push(is.read_message()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.input_index { + my_size += ::protobuf::rt::uint32_size(1, v); + } + for value in &self.signatures { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.input_index { + os.write_uint32(1, v)?; + } + for v in &self.signatures { + ::protobuf::rt::write_message_field_with_cached_size(2, v, os)?; + }; + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerSignaturesForInput { + MintlayerSignaturesForInput::new() + } + + fn clear(&mut self) { + self.input_index = ::std::option::Option::None; + self.signatures.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerSignaturesForInput { + static instance: MintlayerSignaturesForInput = MintlayerSignaturesForInput { + input_index: ::std::option::Option::None, + signatures: ::std::vec::Vec::new(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } + } + + impl ::protobuf::MessageFull for MintlayerSignaturesForInput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| super::file_descriptor().message_by_package_relative_name("MintlayerTxRequest.MintlayerSignaturesForInput").unwrap()).clone() + } + } + + impl ::std::fmt::Display for MintlayerSignaturesForInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } + } + + impl ::protobuf::reflect::ProtobufValue for MintlayerSignaturesForInput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; + } + + // @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerTxSigningResult) + #[derive(PartialEq,Clone,Default,Debug)] + pub struct MintlayerTxSigningResult { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerTxSigningResult.signatures) + pub signatures: ::std::vec::Vec, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerTxRequest.MintlayerTxSigningResult.special_fields) + pub special_fields: ::protobuf::SpecialFields, + } + + impl<'a> ::std::default::Default for &'a MintlayerTxSigningResult { + fn default() -> &'a MintlayerTxSigningResult { + ::default_instance() + } + } + + impl MintlayerTxSigningResult { + pub fn new() -> MintlayerTxSigningResult { + ::std::default::Default::default() + } + + pub(in super) fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(1); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "signatures", + |m: &MintlayerTxSigningResult| { &m.signatures }, + |m: &mut MintlayerTxSigningResult| { &mut m.signatures }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerTxRequest.MintlayerTxSigningResult", + fields, + oneofs, + ) + } + } + + impl ::protobuf::Message for MintlayerTxSigningResult { + const NAME: &'static str = "MintlayerTxSigningResult"; + + fn is_initialized(&self) -> bool { + for v in &self.signatures { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.signatures.push(is.read_message()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + for value in &self.signatures { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + for v in &self.signatures { + ::protobuf::rt::write_message_field_with_cached_size(1, v, os)?; + }; + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerTxSigningResult { + MintlayerTxSigningResult::new() + } + + fn clear(&mut self) { + self.signatures.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerTxSigningResult { + static instance: MintlayerTxSigningResult = MintlayerTxSigningResult { + signatures: ::std::vec::Vec::new(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } + } + + impl ::protobuf::MessageFull for MintlayerTxSigningResult { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| super::file_descriptor().message_by_package_relative_name("MintlayerTxRequest.MintlayerTxSigningResult").unwrap()).clone() + } + } + + impl ::std::fmt::Display for MintlayerTxSigningResult { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } + } + + impl ::protobuf::reflect::ProtobufValue for MintlayerTxSigningResult { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; + } +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerAddressPath) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerAddressPath { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAddressPath.address_n) + pub address_n: ::std::vec::Vec, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAddressPath.multisig_idx) + pub multisig_idx: ::std::option::Option, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerAddressPath.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerAddressPath { + fn default() -> &'a MintlayerAddressPath { + ::default_instance() + } +} + +impl MintlayerAddressPath { + pub fn new() -> MintlayerAddressPath { + ::std::default::Default::default() + } + + // optional uint32 multisig_idx = 2; + + pub fn multisig_idx(&self) -> u32 { + self.multisig_idx.unwrap_or(0) + } + + pub fn clear_multisig_idx(&mut self) { + self.multisig_idx = ::std::option::Option::None; + } + + pub fn has_multisig_idx(&self) -> bool { + self.multisig_idx.is_some() + } + + // Param is passed by value, moved + pub fn set_multisig_idx(&mut self, v: u32) { + self.multisig_idx = ::std::option::Option::Some(v); + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "address_n", + |m: &MintlayerAddressPath| { &m.address_n }, + |m: &mut MintlayerAddressPath| { &mut m.address_n }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "multisig_idx", + |m: &MintlayerAddressPath| { &m.multisig_idx }, + |m: &mut MintlayerAddressPath| { &mut m.multisig_idx }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerAddressPath", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerAddressPath { + const NAME: &'static str = "MintlayerAddressPath"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + is.read_repeated_packed_uint32_into(&mut self.address_n)?; + }, + 8 => { + self.address_n.push(is.read_uint32()?); + }, + 16 => { + self.multisig_idx = ::std::option::Option::Some(is.read_uint32()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + for value in &self.address_n { + my_size += ::protobuf::rt::uint32_size(1, *value); + }; + if let Some(v) = self.multisig_idx { + my_size += ::protobuf::rt::uint32_size(2, v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + for v in &self.address_n { + os.write_uint32(1, *v)?; + }; + if let Some(v) = self.multisig_idx { + os.write_uint32(2, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerAddressPath { + MintlayerAddressPath::new() + } + + fn clear(&mut self) { + self.address_n.clear(); + self.multisig_idx = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerAddressPath { + static instance: MintlayerAddressPath = MintlayerAddressPath { + address_n: ::std::vec::Vec::new(), + multisig_idx: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerAddressPath { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerAddressPath").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerAddressPath { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerAddressPath { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerUtxoTxInput) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerUtxoTxInput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerUtxoTxInput.addresses) + pub addresses: ::std::vec::Vec, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerUtxoTxInput.prev_hash) + pub prev_hash: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerUtxoTxInput.prev_index) + pub prev_index: ::std::option::Option, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerUtxoTxInput.type) + pub type_: ::std::option::Option<::protobuf::EnumOrUnknown>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerUtxoTxInput.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerUtxoTxInput { + fn default() -> &'a MintlayerUtxoTxInput { + ::default_instance() + } +} + +impl MintlayerUtxoTxInput { + pub fn new() -> MintlayerUtxoTxInput { + ::std::default::Default::default() + } + + // required bytes prev_hash = 2; + + pub fn prev_hash(&self) -> &[u8] { + match self.prev_hash.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_prev_hash(&mut self) { + self.prev_hash = ::std::option::Option::None; + } + + pub fn has_prev_hash(&self) -> bool { + self.prev_hash.is_some() + } + + // Param is passed by value, moved + pub fn set_prev_hash(&mut self, v: ::std::vec::Vec) { + self.prev_hash = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_prev_hash(&mut self) -> &mut ::std::vec::Vec { + if self.prev_hash.is_none() { + self.prev_hash = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.prev_hash.as_mut().unwrap() + } + + // Take field + pub fn take_prev_hash(&mut self) -> ::std::vec::Vec { + self.prev_hash.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // required uint32 prev_index = 3; + + pub fn prev_index(&self) -> u32 { + self.prev_index.unwrap_or(0) + } + + pub fn clear_prev_index(&mut self) { + self.prev_index = ::std::option::Option::None; + } + + pub fn has_prev_index(&self) -> bool { + self.prev_index.is_some() + } + + // Param is passed by value, moved + pub fn set_prev_index(&mut self, v: u32) { + self.prev_index = ::std::option::Option::Some(v); + } + + // required .hw.trezor.messages.mintlayer.MintlayerUtxoType type = 4; + + pub fn type_(&self) -> MintlayerUtxoType { + match self.type_ { + Some(e) => e.enum_value_or(MintlayerUtxoType::TRANSACTION), + None => MintlayerUtxoType::TRANSACTION, + } + } + + pub fn clear_type_(&mut self) { + self.type_ = ::std::option::Option::None; + } + + pub fn has_type(&self) -> bool { + self.type_.is_some() + } + + // Param is passed by value, moved + pub fn set_type(&mut self, v: MintlayerUtxoType) { + self.type_ = ::std::option::Option::Some(::protobuf::EnumOrUnknown::new(v)); + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(4); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "addresses", + |m: &MintlayerUtxoTxInput| { &m.addresses }, + |m: &mut MintlayerUtxoTxInput| { &mut m.addresses }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "prev_hash", + |m: &MintlayerUtxoTxInput| { &m.prev_hash }, + |m: &mut MintlayerUtxoTxInput| { &mut m.prev_hash }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "prev_index", + |m: &MintlayerUtxoTxInput| { &m.prev_index }, + |m: &mut MintlayerUtxoTxInput| { &mut m.prev_index }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "type", + |m: &MintlayerUtxoTxInput| { &m.type_ }, + |m: &mut MintlayerUtxoTxInput| { &mut m.type_ }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerUtxoTxInput", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerUtxoTxInput { + const NAME: &'static str = "MintlayerUtxoTxInput"; + + fn is_initialized(&self) -> bool { + if self.prev_hash.is_none() { + return false; + } + if self.prev_index.is_none() { + return false; + } + if self.type_.is_none() { + return false; + } + for v in &self.addresses { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.addresses.push(is.read_message()?); + }, + 18 => { + self.prev_hash = ::std::option::Option::Some(is.read_bytes()?); + }, + 24 => { + self.prev_index = ::std::option::Option::Some(is.read_uint32()?); + }, + 32 => { + self.type_ = ::std::option::Option::Some(is.read_enum_or_unknown()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + for value in &self.addresses { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + }; + if let Some(v) = self.prev_hash.as_ref() { + my_size += ::protobuf::rt::bytes_size(2, &v); + } + if let Some(v) = self.prev_index { + my_size += ::protobuf::rt::uint32_size(3, v); + } + if let Some(v) = self.type_ { + my_size += ::protobuf::rt::int32_size(4, v.value()); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + for v in &self.addresses { + ::protobuf::rt::write_message_field_with_cached_size(1, v, os)?; + }; + if let Some(v) = self.prev_hash.as_ref() { + os.write_bytes(2, v)?; + } + if let Some(v) = self.prev_index { + os.write_uint32(3, v)?; + } + if let Some(v) = self.type_ { + os.write_enum(4, ::protobuf::EnumOrUnknown::value(&v))?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerUtxoTxInput { + MintlayerUtxoTxInput::new() + } + + fn clear(&mut self) { + self.addresses.clear(); + self.prev_hash = ::std::option::Option::None; + self.prev_index = ::std::option::Option::None; + self.type_ = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerUtxoTxInput { + static instance: MintlayerUtxoTxInput = MintlayerUtxoTxInput { + addresses: ::std::vec::Vec::new(), + prev_hash: ::std::option::Option::None, + prev_index: ::std::option::Option::None, + type_: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerUtxoTxInput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerUtxoTxInput").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerUtxoTxInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerUtxoTxInput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerAccountTxInput) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerAccountTxInput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAccountTxInput.addresses) + pub addresses: ::std::vec::Vec, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAccountTxInput.nonce) + pub nonce: ::std::option::Option, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAccountTxInput.delegation_balance) + pub delegation_balance: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerAccountTxInput.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerAccountTxInput { + fn default() -> &'a MintlayerAccountTxInput { + ::default_instance() + } +} + +impl MintlayerAccountTxInput { + pub fn new() -> MintlayerAccountTxInput { + ::std::default::Default::default() + } + + // required uint64 nonce = 2; + + pub fn nonce(&self) -> u64 { + self.nonce.unwrap_or(0) + } + + pub fn clear_nonce(&mut self) { + self.nonce = ::std::option::Option::None; + } + + pub fn has_nonce(&self) -> bool { + self.nonce.is_some() + } + + // Param is passed by value, moved + pub fn set_nonce(&mut self, v: u64) { + self.nonce = ::std::option::Option::Some(v); + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(3); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "addresses", + |m: &MintlayerAccountTxInput| { &m.addresses }, + |m: &mut MintlayerAccountTxInput| { &mut m.addresses }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "nonce", + |m: &MintlayerAccountTxInput| { &m.nonce }, + |m: &mut MintlayerAccountTxInput| { &mut m.nonce }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerAccountSpendingDelegationBalance>( + "delegation_balance", + |m: &MintlayerAccountTxInput| { &m.delegation_balance }, + |m: &mut MintlayerAccountTxInput| { &mut m.delegation_balance }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerAccountTxInput", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerAccountTxInput { + const NAME: &'static str = "MintlayerAccountTxInput"; + + fn is_initialized(&self) -> bool { + if self.nonce.is_none() { + return false; + } + for v in &self.addresses { + if !v.is_initialized() { + return false; + } + }; + for v in &self.delegation_balance { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.addresses.push(is.read_message()?); + }, + 16 => { + self.nonce = ::std::option::Option::Some(is.read_uint64()?); + }, + 26 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.delegation_balance)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + for value in &self.addresses { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + }; + if let Some(v) = self.nonce { + my_size += ::protobuf::rt::uint64_size(2, v); + } + if let Some(v) = self.delegation_balance.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + for v in &self.addresses { + ::protobuf::rt::write_message_field_with_cached_size(1, v, os)?; + }; + if let Some(v) = self.nonce { + os.write_uint64(2, v)?; + } + if let Some(v) = self.delegation_balance.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(3, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerAccountTxInput { + MintlayerAccountTxInput::new() + } + + fn clear(&mut self) { + self.addresses.clear(); + self.nonce = ::std::option::Option::None; + self.delegation_balance.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerAccountTxInput { + static instance: MintlayerAccountTxInput = MintlayerAccountTxInput { + addresses: ::std::vec::Vec::new(), + nonce: ::std::option::Option::None, + delegation_balance: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerAccountTxInput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerAccountTxInput").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerAccountTxInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerAccountTxInput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerAccountSpendingDelegationBalance) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerAccountSpendingDelegationBalance { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAccountSpendingDelegationBalance.delegation_id) + pub delegation_id: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAccountSpendingDelegationBalance.amount) + pub amount: ::std::option::Option<::std::vec::Vec>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerAccountSpendingDelegationBalance.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerAccountSpendingDelegationBalance { + fn default() -> &'a MintlayerAccountSpendingDelegationBalance { + ::default_instance() + } +} + +impl MintlayerAccountSpendingDelegationBalance { + pub fn new() -> MintlayerAccountSpendingDelegationBalance { + ::std::default::Default::default() + } + + // required string delegation_id = 1; + + pub fn delegation_id(&self) -> &str { + match self.delegation_id.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_delegation_id(&mut self) { + self.delegation_id = ::std::option::Option::None; + } + + pub fn has_delegation_id(&self) -> bool { + self.delegation_id.is_some() + } + + // Param is passed by value, moved + pub fn set_delegation_id(&mut self, v: ::std::string::String) { + self.delegation_id = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_delegation_id(&mut self) -> &mut ::std::string::String { + if self.delegation_id.is_none() { + self.delegation_id = ::std::option::Option::Some(::std::string::String::new()); + } + self.delegation_id.as_mut().unwrap() + } + + // Take field + pub fn take_delegation_id(&mut self) -> ::std::string::String { + self.delegation_id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required bytes amount = 2; + + pub fn amount(&self) -> &[u8] { + match self.amount.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_amount(&mut self) { + self.amount = ::std::option::Option::None; + } + + pub fn has_amount(&self) -> bool { + self.amount.is_some() + } + + // Param is passed by value, moved + pub fn set_amount(&mut self, v: ::std::vec::Vec) { + self.amount = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_amount(&mut self) -> &mut ::std::vec::Vec { + if self.amount.is_none() { + self.amount = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.amount.as_mut().unwrap() + } + + // Take field + pub fn take_amount(&mut self) -> ::std::vec::Vec { + self.amount.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "delegation_id", + |m: &MintlayerAccountSpendingDelegationBalance| { &m.delegation_id }, + |m: &mut MintlayerAccountSpendingDelegationBalance| { &mut m.delegation_id }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "amount", + |m: &MintlayerAccountSpendingDelegationBalance| { &m.amount }, + |m: &mut MintlayerAccountSpendingDelegationBalance| { &mut m.amount }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerAccountSpendingDelegationBalance", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerAccountSpendingDelegationBalance { + const NAME: &'static str = "MintlayerAccountSpendingDelegationBalance"; + + fn is_initialized(&self) -> bool { + if self.delegation_id.is_none() { + return false; + } + if self.amount.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.delegation_id = ::std::option::Option::Some(is.read_string()?); + }, + 18 => { + self.amount = ::std::option::Option::Some(is.read_bytes()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.delegation_id.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.amount.as_ref() { + my_size += ::protobuf::rt::bytes_size(2, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.delegation_id.as_ref() { + os.write_string(1, v)?; + } + if let Some(v) = self.amount.as_ref() { + os.write_bytes(2, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerAccountSpendingDelegationBalance { + MintlayerAccountSpendingDelegationBalance::new() + } + + fn clear(&mut self) { + self.delegation_id = ::std::option::Option::None; + self.amount = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerAccountSpendingDelegationBalance { + static instance: MintlayerAccountSpendingDelegationBalance = MintlayerAccountSpendingDelegationBalance { + delegation_id: ::std::option::Option::None, + amount: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerAccountSpendingDelegationBalance { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerAccountSpendingDelegationBalance").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerAccountSpendingDelegationBalance { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerAccountSpendingDelegationBalance { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerAccountCommandTxInput) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerAccountCommandTxInput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAccountCommandTxInput.addresses) + pub addresses: ::std::vec::Vec, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAccountCommandTxInput.nonce) + pub nonce: ::std::option::Option, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAccountCommandTxInput.mint) + pub mint: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAccountCommandTxInput.unmint) + pub unmint: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAccountCommandTxInput.lock_token_supply) + pub lock_token_supply: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAccountCommandTxInput.freeze_token) + pub freeze_token: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAccountCommandTxInput.unfreeze_token) + pub unfreeze_token: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAccountCommandTxInput.change_token_authority) + pub change_token_authority: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAccountCommandTxInput.conclude_order) + pub conclude_order: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAccountCommandTxInput.fill_order) + pub fill_order: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerAccountCommandTxInput.change_token_metadata_uri) + pub change_token_metadata_uri: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerAccountCommandTxInput.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerAccountCommandTxInput { + fn default() -> &'a MintlayerAccountCommandTxInput { + ::default_instance() + } +} + +impl MintlayerAccountCommandTxInput { + pub fn new() -> MintlayerAccountCommandTxInput { + ::std::default::Default::default() + } + + // required uint64 nonce = 2; + + pub fn nonce(&self) -> u64 { + self.nonce.unwrap_or(0) + } + + pub fn clear_nonce(&mut self) { + self.nonce = ::std::option::Option::None; + } + + pub fn has_nonce(&self) -> bool { + self.nonce.is_some() + } + + // Param is passed by value, moved + pub fn set_nonce(&mut self, v: u64) { + self.nonce = ::std::option::Option::Some(v); + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(11); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_vec_simpler_accessor::<_, _>( + "addresses", + |m: &MintlayerAccountCommandTxInput| { &m.addresses }, + |m: &mut MintlayerAccountCommandTxInput| { &mut m.addresses }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "nonce", + |m: &MintlayerAccountCommandTxInput| { &m.nonce }, + |m: &mut MintlayerAccountCommandTxInput| { &mut m.nonce }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerMintTokens>( + "mint", + |m: &MintlayerAccountCommandTxInput| { &m.mint }, + |m: &mut MintlayerAccountCommandTxInput| { &mut m.mint }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerUnmintTokens>( + "unmint", + |m: &MintlayerAccountCommandTxInput| { &m.unmint }, + |m: &mut MintlayerAccountCommandTxInput| { &mut m.unmint }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerLockTokenSupply>( + "lock_token_supply", + |m: &MintlayerAccountCommandTxInput| { &m.lock_token_supply }, + |m: &mut MintlayerAccountCommandTxInput| { &mut m.lock_token_supply }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerFreezeToken>( + "freeze_token", + |m: &MintlayerAccountCommandTxInput| { &m.freeze_token }, + |m: &mut MintlayerAccountCommandTxInput| { &mut m.freeze_token }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerUnfreezeToken>( + "unfreeze_token", + |m: &MintlayerAccountCommandTxInput| { &m.unfreeze_token }, + |m: &mut MintlayerAccountCommandTxInput| { &mut m.unfreeze_token }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerChangeTokenAuthority>( + "change_token_authority", + |m: &MintlayerAccountCommandTxInput| { &m.change_token_authority }, + |m: &mut MintlayerAccountCommandTxInput| { &mut m.change_token_authority }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerConcludeOrder>( + "conclude_order", + |m: &MintlayerAccountCommandTxInput| { &m.conclude_order }, + |m: &mut MintlayerAccountCommandTxInput| { &mut m.conclude_order }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerFillOrder>( + "fill_order", + |m: &MintlayerAccountCommandTxInput| { &m.fill_order }, + |m: &mut MintlayerAccountCommandTxInput| { &mut m.fill_order }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerChangeTokenMetadataUri>( + "change_token_metadata_uri", + |m: &MintlayerAccountCommandTxInput| { &m.change_token_metadata_uri }, + |m: &mut MintlayerAccountCommandTxInput| { &mut m.change_token_metadata_uri }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerAccountCommandTxInput", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerAccountCommandTxInput { + const NAME: &'static str = "MintlayerAccountCommandTxInput"; + + fn is_initialized(&self) -> bool { + if self.nonce.is_none() { + return false; + } + for v in &self.addresses { + if !v.is_initialized() { + return false; + } + }; + for v in &self.mint { + if !v.is_initialized() { + return false; + } + }; + for v in &self.unmint { + if !v.is_initialized() { + return false; + } + }; + for v in &self.lock_token_supply { + if !v.is_initialized() { + return false; + } + }; + for v in &self.freeze_token { + if !v.is_initialized() { + return false; + } + }; + for v in &self.unfreeze_token { + if !v.is_initialized() { + return false; + } + }; + for v in &self.change_token_authority { + if !v.is_initialized() { + return false; + } + }; + for v in &self.conclude_order { + if !v.is_initialized() { + return false; + } + }; + for v in &self.fill_order { + if !v.is_initialized() { + return false; + } + }; + for v in &self.change_token_metadata_uri { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.addresses.push(is.read_message()?); + }, + 16 => { + self.nonce = ::std::option::Option::Some(is.read_uint64()?); + }, + 26 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.mint)?; + }, + 34 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.unmint)?; + }, + 42 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.lock_token_supply)?; + }, + 50 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.freeze_token)?; + }, + 58 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.unfreeze_token)?; + }, + 66 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.change_token_authority)?; + }, + 74 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.conclude_order)?; + }, + 82 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.fill_order)?; + }, + 90 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.change_token_metadata_uri)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + for value in &self.addresses { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + }; + if let Some(v) = self.nonce { + my_size += ::protobuf::rt::uint64_size(2, v); + } + if let Some(v) = self.mint.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.unmint.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.lock_token_supply.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.freeze_token.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.unfreeze_token.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.change_token_authority.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.conclude_order.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.fill_order.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.change_token_metadata_uri.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + for v in &self.addresses { + ::protobuf::rt::write_message_field_with_cached_size(1, v, os)?; + }; + if let Some(v) = self.nonce { + os.write_uint64(2, v)?; + } + if let Some(v) = self.mint.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(3, v, os)?; + } + if let Some(v) = self.unmint.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(4, v, os)?; + } + if let Some(v) = self.lock_token_supply.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(5, v, os)?; + } + if let Some(v) = self.freeze_token.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(6, v, os)?; + } + if let Some(v) = self.unfreeze_token.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(7, v, os)?; + } + if let Some(v) = self.change_token_authority.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(8, v, os)?; + } + if let Some(v) = self.conclude_order.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(9, v, os)?; + } + if let Some(v) = self.fill_order.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(10, v, os)?; + } + if let Some(v) = self.change_token_metadata_uri.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(11, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerAccountCommandTxInput { + MintlayerAccountCommandTxInput::new() + } + + fn clear(&mut self) { + self.addresses.clear(); + self.nonce = ::std::option::Option::None; + self.mint.clear(); + self.unmint.clear(); + self.lock_token_supply.clear(); + self.freeze_token.clear(); + self.unfreeze_token.clear(); + self.change_token_authority.clear(); + self.conclude_order.clear(); + self.fill_order.clear(); + self.change_token_metadata_uri.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerAccountCommandTxInput { + static instance: MintlayerAccountCommandTxInput = MintlayerAccountCommandTxInput { + addresses: ::std::vec::Vec::new(), + nonce: ::std::option::Option::None, + mint: ::protobuf::MessageField::none(), + unmint: ::protobuf::MessageField::none(), + lock_token_supply: ::protobuf::MessageField::none(), + freeze_token: ::protobuf::MessageField::none(), + unfreeze_token: ::protobuf::MessageField::none(), + change_token_authority: ::protobuf::MessageField::none(), + conclude_order: ::protobuf::MessageField::none(), + fill_order: ::protobuf::MessageField::none(), + change_token_metadata_uri: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerAccountCommandTxInput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerAccountCommandTxInput").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerAccountCommandTxInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerAccountCommandTxInput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerMintTokens) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerMintTokens { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerMintTokens.token_id) + pub token_id: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerMintTokens.amount) + pub amount: ::std::option::Option<::std::vec::Vec>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerMintTokens.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerMintTokens { + fn default() -> &'a MintlayerMintTokens { + ::default_instance() + } +} + +impl MintlayerMintTokens { + pub fn new() -> MintlayerMintTokens { + ::std::default::Default::default() + } + + // required string token_id = 1; + + pub fn token_id(&self) -> &str { + match self.token_id.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_token_id(&mut self) { + self.token_id = ::std::option::Option::None; + } + + pub fn has_token_id(&self) -> bool { + self.token_id.is_some() + } + + // Param is passed by value, moved + pub fn set_token_id(&mut self, v: ::std::string::String) { + self.token_id = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_token_id(&mut self) -> &mut ::std::string::String { + if self.token_id.is_none() { + self.token_id = ::std::option::Option::Some(::std::string::String::new()); + } + self.token_id.as_mut().unwrap() + } + + // Take field + pub fn take_token_id(&mut self) -> ::std::string::String { + self.token_id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required bytes amount = 2; + + pub fn amount(&self) -> &[u8] { + match self.amount.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_amount(&mut self) { + self.amount = ::std::option::Option::None; + } + + pub fn has_amount(&self) -> bool { + self.amount.is_some() + } + + // Param is passed by value, moved + pub fn set_amount(&mut self, v: ::std::vec::Vec) { + self.amount = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_amount(&mut self) -> &mut ::std::vec::Vec { + if self.amount.is_none() { + self.amount = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.amount.as_mut().unwrap() + } + + // Take field + pub fn take_amount(&mut self) -> ::std::vec::Vec { + self.amount.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "token_id", + |m: &MintlayerMintTokens| { &m.token_id }, + |m: &mut MintlayerMintTokens| { &mut m.token_id }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "amount", + |m: &MintlayerMintTokens| { &m.amount }, + |m: &mut MintlayerMintTokens| { &mut m.amount }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerMintTokens", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerMintTokens { + const NAME: &'static str = "MintlayerMintTokens"; + + fn is_initialized(&self) -> bool { + if self.token_id.is_none() { + return false; + } + if self.amount.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.token_id = ::std::option::Option::Some(is.read_string()?); + }, + 18 => { + self.amount = ::std::option::Option::Some(is.read_bytes()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.token_id.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.amount.as_ref() { + my_size += ::protobuf::rt::bytes_size(2, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.token_id.as_ref() { + os.write_string(1, v)?; + } + if let Some(v) = self.amount.as_ref() { + os.write_bytes(2, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerMintTokens { + MintlayerMintTokens::new() + } + + fn clear(&mut self) { + self.token_id = ::std::option::Option::None; + self.amount = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerMintTokens { + static instance: MintlayerMintTokens = MintlayerMintTokens { + token_id: ::std::option::Option::None, + amount: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerMintTokens { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerMintTokens").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerMintTokens { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerMintTokens { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerUnmintTokens) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerUnmintTokens { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerUnmintTokens.token_id) + pub token_id: ::std::option::Option<::std::string::String>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerUnmintTokens.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerUnmintTokens { + fn default() -> &'a MintlayerUnmintTokens { + ::default_instance() + } +} + +impl MintlayerUnmintTokens { + pub fn new() -> MintlayerUnmintTokens { + ::std::default::Default::default() + } + + // required string token_id = 1; + + pub fn token_id(&self) -> &str { + match self.token_id.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_token_id(&mut self) { + self.token_id = ::std::option::Option::None; + } + + pub fn has_token_id(&self) -> bool { + self.token_id.is_some() + } + + // Param is passed by value, moved + pub fn set_token_id(&mut self, v: ::std::string::String) { + self.token_id = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_token_id(&mut self) -> &mut ::std::string::String { + if self.token_id.is_none() { + self.token_id = ::std::option::Option::Some(::std::string::String::new()); + } + self.token_id.as_mut().unwrap() + } + + // Take field + pub fn take_token_id(&mut self) -> ::std::string::String { + self.token_id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(1); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "token_id", + |m: &MintlayerUnmintTokens| { &m.token_id }, + |m: &mut MintlayerUnmintTokens| { &mut m.token_id }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerUnmintTokens", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerUnmintTokens { + const NAME: &'static str = "MintlayerUnmintTokens"; + + fn is_initialized(&self) -> bool { + if self.token_id.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.token_id = ::std::option::Option::Some(is.read_string()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.token_id.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.token_id.as_ref() { + os.write_string(1, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerUnmintTokens { + MintlayerUnmintTokens::new() + } + + fn clear(&mut self) { + self.token_id = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerUnmintTokens { + static instance: MintlayerUnmintTokens = MintlayerUnmintTokens { + token_id: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerUnmintTokens { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerUnmintTokens").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerUnmintTokens { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerUnmintTokens { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerLockTokenSupply) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerLockTokenSupply { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerLockTokenSupply.token_id) + pub token_id: ::std::option::Option<::std::string::String>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerLockTokenSupply.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerLockTokenSupply { + fn default() -> &'a MintlayerLockTokenSupply { + ::default_instance() + } +} + +impl MintlayerLockTokenSupply { + pub fn new() -> MintlayerLockTokenSupply { + ::std::default::Default::default() + } + + // required string token_id = 1; + + pub fn token_id(&self) -> &str { + match self.token_id.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_token_id(&mut self) { + self.token_id = ::std::option::Option::None; + } + + pub fn has_token_id(&self) -> bool { + self.token_id.is_some() + } + + // Param is passed by value, moved + pub fn set_token_id(&mut self, v: ::std::string::String) { + self.token_id = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_token_id(&mut self) -> &mut ::std::string::String { + if self.token_id.is_none() { + self.token_id = ::std::option::Option::Some(::std::string::String::new()); + } + self.token_id.as_mut().unwrap() + } + + // Take field + pub fn take_token_id(&mut self) -> ::std::string::String { + self.token_id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(1); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "token_id", + |m: &MintlayerLockTokenSupply| { &m.token_id }, + |m: &mut MintlayerLockTokenSupply| { &mut m.token_id }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerLockTokenSupply", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerLockTokenSupply { + const NAME: &'static str = "MintlayerLockTokenSupply"; + + fn is_initialized(&self) -> bool { + if self.token_id.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.token_id = ::std::option::Option::Some(is.read_string()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.token_id.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.token_id.as_ref() { + os.write_string(1, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerLockTokenSupply { + MintlayerLockTokenSupply::new() + } + + fn clear(&mut self) { + self.token_id = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerLockTokenSupply { + static instance: MintlayerLockTokenSupply = MintlayerLockTokenSupply { + token_id: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerLockTokenSupply { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerLockTokenSupply").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerLockTokenSupply { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerLockTokenSupply { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerFreezeToken) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerFreezeToken { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerFreezeToken.token_id) + pub token_id: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerFreezeToken.is_token_unfreezable) + pub is_token_unfreezable: ::std::option::Option, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerFreezeToken.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerFreezeToken { + fn default() -> &'a MintlayerFreezeToken { + ::default_instance() + } +} + +impl MintlayerFreezeToken { + pub fn new() -> MintlayerFreezeToken { + ::std::default::Default::default() + } + + // required string token_id = 1; + + pub fn token_id(&self) -> &str { + match self.token_id.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_token_id(&mut self) { + self.token_id = ::std::option::Option::None; + } + + pub fn has_token_id(&self) -> bool { + self.token_id.is_some() + } + + // Param is passed by value, moved + pub fn set_token_id(&mut self, v: ::std::string::String) { + self.token_id = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_token_id(&mut self) -> &mut ::std::string::String { + if self.token_id.is_none() { + self.token_id = ::std::option::Option::Some(::std::string::String::new()); + } + self.token_id.as_mut().unwrap() + } + + // Take field + pub fn take_token_id(&mut self) -> ::std::string::String { + self.token_id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required bool is_token_unfreezable = 2; + + pub fn is_token_unfreezable(&self) -> bool { + self.is_token_unfreezable.unwrap_or(false) + } + + pub fn clear_is_token_unfreezable(&mut self) { + self.is_token_unfreezable = ::std::option::Option::None; + } + + pub fn has_is_token_unfreezable(&self) -> bool { + self.is_token_unfreezable.is_some() + } + + // Param is passed by value, moved + pub fn set_is_token_unfreezable(&mut self, v: bool) { + self.is_token_unfreezable = ::std::option::Option::Some(v); + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "token_id", + |m: &MintlayerFreezeToken| { &m.token_id }, + |m: &mut MintlayerFreezeToken| { &mut m.token_id }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "is_token_unfreezable", + |m: &MintlayerFreezeToken| { &m.is_token_unfreezable }, + |m: &mut MintlayerFreezeToken| { &mut m.is_token_unfreezable }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerFreezeToken", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerFreezeToken { + const NAME: &'static str = "MintlayerFreezeToken"; + + fn is_initialized(&self) -> bool { + if self.token_id.is_none() { + return false; + } + if self.is_token_unfreezable.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.token_id = ::std::option::Option::Some(is.read_string()?); + }, + 16 => { + self.is_token_unfreezable = ::std::option::Option::Some(is.read_bool()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.token_id.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.is_token_unfreezable { + my_size += 1 + 1; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.token_id.as_ref() { + os.write_string(1, v)?; + } + if let Some(v) = self.is_token_unfreezable { + os.write_bool(2, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerFreezeToken { + MintlayerFreezeToken::new() + } + + fn clear(&mut self) { + self.token_id = ::std::option::Option::None; + self.is_token_unfreezable = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerFreezeToken { + static instance: MintlayerFreezeToken = MintlayerFreezeToken { + token_id: ::std::option::Option::None, + is_token_unfreezable: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerFreezeToken { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerFreezeToken").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerFreezeToken { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerFreezeToken { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerUnfreezeToken) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerUnfreezeToken { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerUnfreezeToken.token_id) + pub token_id: ::std::option::Option<::std::string::String>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerUnfreezeToken.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerUnfreezeToken { + fn default() -> &'a MintlayerUnfreezeToken { + ::default_instance() + } +} + +impl MintlayerUnfreezeToken { + pub fn new() -> MintlayerUnfreezeToken { + ::std::default::Default::default() + } + + // required string token_id = 1; + + pub fn token_id(&self) -> &str { + match self.token_id.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_token_id(&mut self) { + self.token_id = ::std::option::Option::None; + } + + pub fn has_token_id(&self) -> bool { + self.token_id.is_some() + } + + // Param is passed by value, moved + pub fn set_token_id(&mut self, v: ::std::string::String) { + self.token_id = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_token_id(&mut self) -> &mut ::std::string::String { + if self.token_id.is_none() { + self.token_id = ::std::option::Option::Some(::std::string::String::new()); + } + self.token_id.as_mut().unwrap() + } + + // Take field + pub fn take_token_id(&mut self) -> ::std::string::String { + self.token_id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(1); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "token_id", + |m: &MintlayerUnfreezeToken| { &m.token_id }, + |m: &mut MintlayerUnfreezeToken| { &mut m.token_id }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerUnfreezeToken", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerUnfreezeToken { + const NAME: &'static str = "MintlayerUnfreezeToken"; + + fn is_initialized(&self) -> bool { + if self.token_id.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.token_id = ::std::option::Option::Some(is.read_string()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.token_id.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.token_id.as_ref() { + os.write_string(1, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerUnfreezeToken { + MintlayerUnfreezeToken::new() + } + + fn clear(&mut self) { + self.token_id = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerUnfreezeToken { + static instance: MintlayerUnfreezeToken = MintlayerUnfreezeToken { + token_id: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerUnfreezeToken { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerUnfreezeToken").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerUnfreezeToken { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerUnfreezeToken { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerChangeTokenAuthority) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerChangeTokenAuthority { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerChangeTokenAuthority.token_id) + pub token_id: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerChangeTokenAuthority.destination) + pub destination: ::std::option::Option<::std::string::String>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerChangeTokenAuthority.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerChangeTokenAuthority { + fn default() -> &'a MintlayerChangeTokenAuthority { + ::default_instance() + } +} + +impl MintlayerChangeTokenAuthority { + pub fn new() -> MintlayerChangeTokenAuthority { + ::std::default::Default::default() + } + + // required string token_id = 1; + + pub fn token_id(&self) -> &str { + match self.token_id.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_token_id(&mut self) { + self.token_id = ::std::option::Option::None; + } + + pub fn has_token_id(&self) -> bool { + self.token_id.is_some() + } + + // Param is passed by value, moved + pub fn set_token_id(&mut self, v: ::std::string::String) { + self.token_id = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_token_id(&mut self) -> &mut ::std::string::String { + if self.token_id.is_none() { + self.token_id = ::std::option::Option::Some(::std::string::String::new()); + } + self.token_id.as_mut().unwrap() + } + + // Take field + pub fn take_token_id(&mut self) -> ::std::string::String { + self.token_id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required string destination = 2; + + pub fn destination(&self) -> &str { + match self.destination.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_destination(&mut self) { + self.destination = ::std::option::Option::None; + } + + pub fn has_destination(&self) -> bool { + self.destination.is_some() + } + + // Param is passed by value, moved + pub fn set_destination(&mut self, v: ::std::string::String) { + self.destination = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_destination(&mut self) -> &mut ::std::string::String { + if self.destination.is_none() { + self.destination = ::std::option::Option::Some(::std::string::String::new()); + } + self.destination.as_mut().unwrap() + } + + // Take field + pub fn take_destination(&mut self) -> ::std::string::String { + self.destination.take().unwrap_or_else(|| ::std::string::String::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "token_id", + |m: &MintlayerChangeTokenAuthority| { &m.token_id }, + |m: &mut MintlayerChangeTokenAuthority| { &mut m.token_id }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "destination", + |m: &MintlayerChangeTokenAuthority| { &m.destination }, + |m: &mut MintlayerChangeTokenAuthority| { &mut m.destination }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerChangeTokenAuthority", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerChangeTokenAuthority { + const NAME: &'static str = "MintlayerChangeTokenAuthority"; + + fn is_initialized(&self) -> bool { + if self.token_id.is_none() { + return false; + } + if self.destination.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.token_id = ::std::option::Option::Some(is.read_string()?); + }, + 18 => { + self.destination = ::std::option::Option::Some(is.read_string()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.token_id.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.destination.as_ref() { + my_size += ::protobuf::rt::string_size(2, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.token_id.as_ref() { + os.write_string(1, v)?; + } + if let Some(v) = self.destination.as_ref() { + os.write_string(2, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerChangeTokenAuthority { + MintlayerChangeTokenAuthority::new() + } + + fn clear(&mut self) { + self.token_id = ::std::option::Option::None; + self.destination = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerChangeTokenAuthority { + static instance: MintlayerChangeTokenAuthority = MintlayerChangeTokenAuthority { + token_id: ::std::option::Option::None, + destination: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerChangeTokenAuthority { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerChangeTokenAuthority").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerChangeTokenAuthority { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerChangeTokenAuthority { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerConcludeOrder) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerConcludeOrder { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerConcludeOrder.order_id) + pub order_id: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerConcludeOrder.filled_ask_amount) + pub filled_ask_amount: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerConcludeOrder.give_balance) + pub give_balance: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerConcludeOrder.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerConcludeOrder { + fn default() -> &'a MintlayerConcludeOrder { + ::default_instance() + } +} + +impl MintlayerConcludeOrder { + pub fn new() -> MintlayerConcludeOrder { + ::std::default::Default::default() + } + + // required string order_id = 1; + + pub fn order_id(&self) -> &str { + match self.order_id.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_order_id(&mut self) { + self.order_id = ::std::option::Option::None; + } + + pub fn has_order_id(&self) -> bool { + self.order_id.is_some() + } + + // Param is passed by value, moved + pub fn set_order_id(&mut self, v: ::std::string::String) { + self.order_id = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_order_id(&mut self) -> &mut ::std::string::String { + if self.order_id.is_none() { + self.order_id = ::std::option::Option::Some(::std::string::String::new()); + } + self.order_id.as_mut().unwrap() + } + + // Take field + pub fn take_order_id(&mut self) -> ::std::string::String { + self.order_id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(3); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "order_id", + |m: &MintlayerConcludeOrder| { &m.order_id }, + |m: &mut MintlayerConcludeOrder| { &mut m.order_id }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerOutputValue>( + "filled_ask_amount", + |m: &MintlayerConcludeOrder| { &m.filled_ask_amount }, + |m: &mut MintlayerConcludeOrder| { &mut m.filled_ask_amount }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerOutputValue>( + "give_balance", + |m: &MintlayerConcludeOrder| { &m.give_balance }, + |m: &mut MintlayerConcludeOrder| { &mut m.give_balance }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerConcludeOrder", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerConcludeOrder { + const NAME: &'static str = "MintlayerConcludeOrder"; + + fn is_initialized(&self) -> bool { + if self.order_id.is_none() { + return false; + } + if self.filled_ask_amount.is_none() { + return false; + } + if self.give_balance.is_none() { + return false; + } + for v in &self.filled_ask_amount { + if !v.is_initialized() { + return false; + } + }; + for v in &self.give_balance { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.order_id = ::std::option::Option::Some(is.read_string()?); + }, + 18 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.filled_ask_amount)?; + }, + 26 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.give_balance)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.order_id.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.filled_ask_amount.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.give_balance.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.order_id.as_ref() { + os.write_string(1, v)?; + } + if let Some(v) = self.filled_ask_amount.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(2, v, os)?; + } + if let Some(v) = self.give_balance.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(3, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerConcludeOrder { + MintlayerConcludeOrder::new() + } + + fn clear(&mut self) { + self.order_id = ::std::option::Option::None; + self.filled_ask_amount.clear(); + self.give_balance.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerConcludeOrder { + static instance: MintlayerConcludeOrder = MintlayerConcludeOrder { + order_id: ::std::option::Option::None, + filled_ask_amount: ::protobuf::MessageField::none(), + give_balance: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerConcludeOrder { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerConcludeOrder").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerConcludeOrder { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerConcludeOrder { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerFillOrder) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerFillOrder { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerFillOrder.order_id) + pub order_id: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerFillOrder.amount) + pub amount: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerFillOrder.destination) + pub destination: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerFillOrder.ask_balance) + pub ask_balance: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerFillOrder.give_balance) + pub give_balance: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerFillOrder.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerFillOrder { + fn default() -> &'a MintlayerFillOrder { + ::default_instance() + } +} + +impl MintlayerFillOrder { + pub fn new() -> MintlayerFillOrder { + ::std::default::Default::default() + } + + // required string order_id = 1; + + pub fn order_id(&self) -> &str { + match self.order_id.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_order_id(&mut self) { + self.order_id = ::std::option::Option::None; + } + + pub fn has_order_id(&self) -> bool { + self.order_id.is_some() + } + + // Param is passed by value, moved + pub fn set_order_id(&mut self, v: ::std::string::String) { + self.order_id = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_order_id(&mut self) -> &mut ::std::string::String { + if self.order_id.is_none() { + self.order_id = ::std::option::Option::Some(::std::string::String::new()); + } + self.order_id.as_mut().unwrap() + } + + // Take field + pub fn take_order_id(&mut self) -> ::std::string::String { + self.order_id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required bytes amount = 2; + + pub fn amount(&self) -> &[u8] { + match self.amount.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_amount(&mut self) { + self.amount = ::std::option::Option::None; + } + + pub fn has_amount(&self) -> bool { + self.amount.is_some() + } + + // Param is passed by value, moved + pub fn set_amount(&mut self, v: ::std::vec::Vec) { + self.amount = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_amount(&mut self) -> &mut ::std::vec::Vec { + if self.amount.is_none() { + self.amount = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.amount.as_mut().unwrap() + } + + // Take field + pub fn take_amount(&mut self) -> ::std::vec::Vec { + self.amount.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // required string destination = 3; + + pub fn destination(&self) -> &str { + match self.destination.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_destination(&mut self) { + self.destination = ::std::option::Option::None; + } + + pub fn has_destination(&self) -> bool { + self.destination.is_some() + } + + // Param is passed by value, moved + pub fn set_destination(&mut self, v: ::std::string::String) { + self.destination = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_destination(&mut self) -> &mut ::std::string::String { + if self.destination.is_none() { + self.destination = ::std::option::Option::Some(::std::string::String::new()); + } + self.destination.as_mut().unwrap() + } + + // Take field + pub fn take_destination(&mut self) -> ::std::string::String { + self.destination.take().unwrap_or_else(|| ::std::string::String::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(5); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "order_id", + |m: &MintlayerFillOrder| { &m.order_id }, + |m: &mut MintlayerFillOrder| { &mut m.order_id }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "amount", + |m: &MintlayerFillOrder| { &m.amount }, + |m: &mut MintlayerFillOrder| { &mut m.amount }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "destination", + |m: &MintlayerFillOrder| { &m.destination }, + |m: &mut MintlayerFillOrder| { &mut m.destination }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerOutputValue>( + "ask_balance", + |m: &MintlayerFillOrder| { &m.ask_balance }, + |m: &mut MintlayerFillOrder| { &mut m.ask_balance }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerOutputValue>( + "give_balance", + |m: &MintlayerFillOrder| { &m.give_balance }, + |m: &mut MintlayerFillOrder| { &mut m.give_balance }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerFillOrder", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerFillOrder { + const NAME: &'static str = "MintlayerFillOrder"; + + fn is_initialized(&self) -> bool { + if self.order_id.is_none() { + return false; + } + if self.amount.is_none() { + return false; + } + if self.destination.is_none() { + return false; + } + if self.ask_balance.is_none() { + return false; + } + if self.give_balance.is_none() { + return false; + } + for v in &self.ask_balance { + if !v.is_initialized() { + return false; + } + }; + for v in &self.give_balance { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.order_id = ::std::option::Option::Some(is.read_string()?); + }, + 18 => { + self.amount = ::std::option::Option::Some(is.read_bytes()?); + }, + 26 => { + self.destination = ::std::option::Option::Some(is.read_string()?); + }, + 34 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.ask_balance)?; + }, + 42 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.give_balance)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.order_id.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.amount.as_ref() { + my_size += ::protobuf::rt::bytes_size(2, &v); + } + if let Some(v) = self.destination.as_ref() { + my_size += ::protobuf::rt::string_size(3, &v); + } + if let Some(v) = self.ask_balance.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.give_balance.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.order_id.as_ref() { + os.write_string(1, v)?; + } + if let Some(v) = self.amount.as_ref() { + os.write_bytes(2, v)?; + } + if let Some(v) = self.destination.as_ref() { + os.write_string(3, v)?; + } + if let Some(v) = self.ask_balance.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(4, v, os)?; + } + if let Some(v) = self.give_balance.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(5, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerFillOrder { + MintlayerFillOrder::new() + } + + fn clear(&mut self) { + self.order_id = ::std::option::Option::None; + self.amount = ::std::option::Option::None; + self.destination = ::std::option::Option::None; + self.ask_balance.clear(); + self.give_balance.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerFillOrder { + static instance: MintlayerFillOrder = MintlayerFillOrder { + order_id: ::std::option::Option::None, + amount: ::std::option::Option::None, + destination: ::std::option::Option::None, + ask_balance: ::protobuf::MessageField::none(), + give_balance: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerFillOrder { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerFillOrder").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerFillOrder { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerFillOrder { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerChangeTokenMetadataUri) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerChangeTokenMetadataUri { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerChangeTokenMetadataUri.token_id) + pub token_id: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerChangeTokenMetadataUri.metadata_uri) + pub metadata_uri: ::std::option::Option<::std::vec::Vec>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerChangeTokenMetadataUri.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerChangeTokenMetadataUri { + fn default() -> &'a MintlayerChangeTokenMetadataUri { + ::default_instance() + } +} + +impl MintlayerChangeTokenMetadataUri { + pub fn new() -> MintlayerChangeTokenMetadataUri { + ::std::default::Default::default() + } + + // required string token_id = 1; + + pub fn token_id(&self) -> &str { + match self.token_id.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_token_id(&mut self) { + self.token_id = ::std::option::Option::None; + } + + pub fn has_token_id(&self) -> bool { + self.token_id.is_some() + } + + // Param is passed by value, moved + pub fn set_token_id(&mut self, v: ::std::string::String) { + self.token_id = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_token_id(&mut self) -> &mut ::std::string::String { + if self.token_id.is_none() { + self.token_id = ::std::option::Option::Some(::std::string::String::new()); + } + self.token_id.as_mut().unwrap() + } + + // Take field + pub fn take_token_id(&mut self) -> ::std::string::String { + self.token_id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required bytes metadata_uri = 2; + + pub fn metadata_uri(&self) -> &[u8] { + match self.metadata_uri.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_metadata_uri(&mut self) { + self.metadata_uri = ::std::option::Option::None; + } + + pub fn has_metadata_uri(&self) -> bool { + self.metadata_uri.is_some() + } + + // Param is passed by value, moved + pub fn set_metadata_uri(&mut self, v: ::std::vec::Vec) { + self.metadata_uri = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_metadata_uri(&mut self) -> &mut ::std::vec::Vec { + if self.metadata_uri.is_none() { + self.metadata_uri = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.metadata_uri.as_mut().unwrap() + } + + // Take field + pub fn take_metadata_uri(&mut self) -> ::std::vec::Vec { + self.metadata_uri.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "token_id", + |m: &MintlayerChangeTokenMetadataUri| { &m.token_id }, + |m: &mut MintlayerChangeTokenMetadataUri| { &mut m.token_id }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "metadata_uri", + |m: &MintlayerChangeTokenMetadataUri| { &m.metadata_uri }, + |m: &mut MintlayerChangeTokenMetadataUri| { &mut m.metadata_uri }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerChangeTokenMetadataUri", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerChangeTokenMetadataUri { + const NAME: &'static str = "MintlayerChangeTokenMetadataUri"; + + fn is_initialized(&self) -> bool { + if self.token_id.is_none() { + return false; + } + if self.metadata_uri.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.token_id = ::std::option::Option::Some(is.read_string()?); + }, + 18 => { + self.metadata_uri = ::std::option::Option::Some(is.read_bytes()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.token_id.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.metadata_uri.as_ref() { + my_size += ::protobuf::rt::bytes_size(2, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.token_id.as_ref() { + os.write_string(1, v)?; + } + if let Some(v) = self.metadata_uri.as_ref() { + os.write_bytes(2, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerChangeTokenMetadataUri { + MintlayerChangeTokenMetadataUri::new() + } + + fn clear(&mut self) { + self.token_id = ::std::option::Option::None; + self.metadata_uri = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerChangeTokenMetadataUri { + static instance: MintlayerChangeTokenMetadataUri = MintlayerChangeTokenMetadataUri { + token_id: ::std::option::Option::None, + metadata_uri: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerChangeTokenMetadataUri { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerChangeTokenMetadataUri").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerChangeTokenMetadataUri { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerChangeTokenMetadataUri { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerTokenOutputValue) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerTokenOutputValue { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTokenOutputValue.token_id) + pub token_id: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTokenOutputValue.token_ticker) + pub token_ticker: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTokenOutputValue.number_of_decimals) + pub number_of_decimals: ::std::option::Option, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerTokenOutputValue.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerTokenOutputValue { + fn default() -> &'a MintlayerTokenOutputValue { + ::default_instance() + } +} + +impl MintlayerTokenOutputValue { + pub fn new() -> MintlayerTokenOutputValue { + ::std::default::Default::default() + } + + // required string token_id = 1; + + pub fn token_id(&self) -> &str { + match self.token_id.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_token_id(&mut self) { + self.token_id = ::std::option::Option::None; + } + + pub fn has_token_id(&self) -> bool { + self.token_id.is_some() + } + + // Param is passed by value, moved + pub fn set_token_id(&mut self, v: ::std::string::String) { + self.token_id = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_token_id(&mut self) -> &mut ::std::string::String { + if self.token_id.is_none() { + self.token_id = ::std::option::Option::Some(::std::string::String::new()); + } + self.token_id.as_mut().unwrap() + } + + // Take field + pub fn take_token_id(&mut self) -> ::std::string::String { + self.token_id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required bytes token_ticker = 2; + + pub fn token_ticker(&self) -> &[u8] { + match self.token_ticker.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_token_ticker(&mut self) { + self.token_ticker = ::std::option::Option::None; + } + + pub fn has_token_ticker(&self) -> bool { + self.token_ticker.is_some() + } + + // Param is passed by value, moved + pub fn set_token_ticker(&mut self, v: ::std::vec::Vec) { + self.token_ticker = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_token_ticker(&mut self) -> &mut ::std::vec::Vec { + if self.token_ticker.is_none() { + self.token_ticker = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.token_ticker.as_mut().unwrap() + } + + // Take field + pub fn take_token_ticker(&mut self) -> ::std::vec::Vec { + self.token_ticker.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // required uint32 number_of_decimals = 3; + + pub fn number_of_decimals(&self) -> u32 { + self.number_of_decimals.unwrap_or(0) + } + + pub fn clear_number_of_decimals(&mut self) { + self.number_of_decimals = ::std::option::Option::None; + } + + pub fn has_number_of_decimals(&self) -> bool { + self.number_of_decimals.is_some() + } + + // Param is passed by value, moved + pub fn set_number_of_decimals(&mut self, v: u32) { + self.number_of_decimals = ::std::option::Option::Some(v); + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(3); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "token_id", + |m: &MintlayerTokenOutputValue| { &m.token_id }, + |m: &mut MintlayerTokenOutputValue| { &mut m.token_id }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "token_ticker", + |m: &MintlayerTokenOutputValue| { &m.token_ticker }, + |m: &mut MintlayerTokenOutputValue| { &mut m.token_ticker }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "number_of_decimals", + |m: &MintlayerTokenOutputValue| { &m.number_of_decimals }, + |m: &mut MintlayerTokenOutputValue| { &mut m.number_of_decimals }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerTokenOutputValue", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerTokenOutputValue { + const NAME: &'static str = "MintlayerTokenOutputValue"; + + fn is_initialized(&self) -> bool { + if self.token_id.is_none() { + return false; + } + if self.token_ticker.is_none() { + return false; + } + if self.number_of_decimals.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.token_id = ::std::option::Option::Some(is.read_string()?); + }, + 18 => { + self.token_ticker = ::std::option::Option::Some(is.read_bytes()?); + }, + 24 => { + self.number_of_decimals = ::std::option::Option::Some(is.read_uint32()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.token_id.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.token_ticker.as_ref() { + my_size += ::protobuf::rt::bytes_size(2, &v); + } + if let Some(v) = self.number_of_decimals { + my_size += ::protobuf::rt::uint32_size(3, v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.token_id.as_ref() { + os.write_string(1, v)?; + } + if let Some(v) = self.token_ticker.as_ref() { + os.write_bytes(2, v)?; + } + if let Some(v) = self.number_of_decimals { + os.write_uint32(3, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerTokenOutputValue { + MintlayerTokenOutputValue::new() + } + + fn clear(&mut self) { + self.token_id = ::std::option::Option::None; + self.token_ticker = ::std::option::Option::None; + self.number_of_decimals = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerTokenOutputValue { + static instance: MintlayerTokenOutputValue = MintlayerTokenOutputValue { + token_id: ::std::option::Option::None, + token_ticker: ::std::option::Option::None, + number_of_decimals: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerTokenOutputValue { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerTokenOutputValue").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerTokenOutputValue { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerTokenOutputValue { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerOutputValue) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerOutputValue { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerOutputValue.amount) + pub amount: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerOutputValue.token) + pub token: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerOutputValue.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerOutputValue { + fn default() -> &'a MintlayerOutputValue { + ::default_instance() + } +} + +impl MintlayerOutputValue { + pub fn new() -> MintlayerOutputValue { + ::std::default::Default::default() + } + + // required bytes amount = 1; + + pub fn amount(&self) -> &[u8] { + match self.amount.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_amount(&mut self) { + self.amount = ::std::option::Option::None; + } + + pub fn has_amount(&self) -> bool { + self.amount.is_some() + } + + // Param is passed by value, moved + pub fn set_amount(&mut self, v: ::std::vec::Vec) { + self.amount = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_amount(&mut self) -> &mut ::std::vec::Vec { + if self.amount.is_none() { + self.amount = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.amount.as_mut().unwrap() + } + + // Take field + pub fn take_amount(&mut self) -> ::std::vec::Vec { + self.amount.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "amount", + |m: &MintlayerOutputValue| { &m.amount }, + |m: &mut MintlayerOutputValue| { &mut m.amount }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerTokenOutputValue>( + "token", + |m: &MintlayerOutputValue| { &m.token }, + |m: &mut MintlayerOutputValue| { &mut m.token }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerOutputValue", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerOutputValue { + const NAME: &'static str = "MintlayerOutputValue"; + + fn is_initialized(&self) -> bool { + if self.amount.is_none() { + return false; + } + for v in &self.token { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.amount = ::std::option::Option::Some(is.read_bytes()?); + }, + 18 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.token)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.amount.as_ref() { + my_size += ::protobuf::rt::bytes_size(1, &v); + } + if let Some(v) = self.token.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.amount.as_ref() { + os.write_bytes(1, v)?; + } + if let Some(v) = self.token.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(2, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerOutputValue { + MintlayerOutputValue::new() + } + + fn clear(&mut self) { + self.amount = ::std::option::Option::None; + self.token.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerOutputValue { + static instance: MintlayerOutputValue = MintlayerOutputValue { + amount: ::std::option::Option::None, + token: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerOutputValue { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerOutputValue").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerOutputValue { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerOutputValue { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerTransferTxOutput) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerTransferTxOutput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTransferTxOutput.address) + pub address: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTransferTxOutput.value) + pub value: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerTransferTxOutput.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerTransferTxOutput { + fn default() -> &'a MintlayerTransferTxOutput { + ::default_instance() + } +} + +impl MintlayerTransferTxOutput { + pub fn new() -> MintlayerTransferTxOutput { + ::std::default::Default::default() + } + + // required string address = 1; + + pub fn address(&self) -> &str { + match self.address.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_address(&mut self) { + self.address = ::std::option::Option::None; + } + + pub fn has_address(&self) -> bool { + self.address.is_some() + } + + // Param is passed by value, moved + pub fn set_address(&mut self, v: ::std::string::String) { + self.address = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_address(&mut self) -> &mut ::std::string::String { + if self.address.is_none() { + self.address = ::std::option::Option::Some(::std::string::String::new()); + } + self.address.as_mut().unwrap() + } + + // Take field + pub fn take_address(&mut self) -> ::std::string::String { + self.address.take().unwrap_or_else(|| ::std::string::String::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "address", + |m: &MintlayerTransferTxOutput| { &m.address }, + |m: &mut MintlayerTransferTxOutput| { &mut m.address }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerOutputValue>( + "value", + |m: &MintlayerTransferTxOutput| { &m.value }, + |m: &mut MintlayerTransferTxOutput| { &mut m.value }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerTransferTxOutput", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerTransferTxOutput { + const NAME: &'static str = "MintlayerTransferTxOutput"; + + fn is_initialized(&self) -> bool { + if self.address.is_none() { + return false; + } + if self.value.is_none() { + return false; + } + for v in &self.value { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.address = ::std::option::Option::Some(is.read_string()?); + }, + 18 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.value)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.address.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.value.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.address.as_ref() { + os.write_string(1, v)?; + } + if let Some(v) = self.value.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(2, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerTransferTxOutput { + MintlayerTransferTxOutput::new() + } + + fn clear(&mut self) { + self.address = ::std::option::Option::None; + self.value.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerTransferTxOutput { + static instance: MintlayerTransferTxOutput = MintlayerTransferTxOutput { + address: ::std::option::Option::None, + value: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerTransferTxOutput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerTransferTxOutput").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerTransferTxOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerTransferTxOutput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerOutputTimeLock) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerOutputTimeLock { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerOutputTimeLock.until_height) + pub until_height: ::std::option::Option, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerOutputTimeLock.until_time) + pub until_time: ::std::option::Option, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerOutputTimeLock.for_block_count) + pub for_block_count: ::std::option::Option, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerOutputTimeLock.for_seconds) + pub for_seconds: ::std::option::Option, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerOutputTimeLock.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerOutputTimeLock { + fn default() -> &'a MintlayerOutputTimeLock { + ::default_instance() + } +} + +impl MintlayerOutputTimeLock { + pub fn new() -> MintlayerOutputTimeLock { + ::std::default::Default::default() + } + + // optional uint64 until_height = 1; + + pub fn until_height(&self) -> u64 { + self.until_height.unwrap_or(0) + } + + pub fn clear_until_height(&mut self) { + self.until_height = ::std::option::Option::None; + } + + pub fn has_until_height(&self) -> bool { + self.until_height.is_some() + } + + // Param is passed by value, moved + pub fn set_until_height(&mut self, v: u64) { + self.until_height = ::std::option::Option::Some(v); + } + + // optional uint64 until_time = 2; + + pub fn until_time(&self) -> u64 { + self.until_time.unwrap_or(0) + } + + pub fn clear_until_time(&mut self) { + self.until_time = ::std::option::Option::None; + } + + pub fn has_until_time(&self) -> bool { + self.until_time.is_some() + } + + // Param is passed by value, moved + pub fn set_until_time(&mut self, v: u64) { + self.until_time = ::std::option::Option::Some(v); + } + + // optional uint64 for_block_count = 3; + + pub fn for_block_count(&self) -> u64 { + self.for_block_count.unwrap_or(0) + } + + pub fn clear_for_block_count(&mut self) { + self.for_block_count = ::std::option::Option::None; + } + + pub fn has_for_block_count(&self) -> bool { + self.for_block_count.is_some() + } + + // Param is passed by value, moved + pub fn set_for_block_count(&mut self, v: u64) { + self.for_block_count = ::std::option::Option::Some(v); + } + + // optional uint64 for_seconds = 4; + + pub fn for_seconds(&self) -> u64 { + self.for_seconds.unwrap_or(0) + } + + pub fn clear_for_seconds(&mut self) { + self.for_seconds = ::std::option::Option::None; + } + + pub fn has_for_seconds(&self) -> bool { + self.for_seconds.is_some() + } + + // Param is passed by value, moved + pub fn set_for_seconds(&mut self, v: u64) { + self.for_seconds = ::std::option::Option::Some(v); + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(4); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "until_height", + |m: &MintlayerOutputTimeLock| { &m.until_height }, + |m: &mut MintlayerOutputTimeLock| { &mut m.until_height }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "until_time", + |m: &MintlayerOutputTimeLock| { &m.until_time }, + |m: &mut MintlayerOutputTimeLock| { &mut m.until_time }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "for_block_count", + |m: &MintlayerOutputTimeLock| { &m.for_block_count }, + |m: &mut MintlayerOutputTimeLock| { &mut m.for_block_count }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "for_seconds", + |m: &MintlayerOutputTimeLock| { &m.for_seconds }, + |m: &mut MintlayerOutputTimeLock| { &mut m.for_seconds }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerOutputTimeLock", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerOutputTimeLock { + const NAME: &'static str = "MintlayerOutputTimeLock"; + + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 8 => { + self.until_height = ::std::option::Option::Some(is.read_uint64()?); + }, + 16 => { + self.until_time = ::std::option::Option::Some(is.read_uint64()?); + }, + 24 => { + self.for_block_count = ::std::option::Option::Some(is.read_uint64()?); + }, + 32 => { + self.for_seconds = ::std::option::Option::Some(is.read_uint64()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.until_height { + my_size += ::protobuf::rt::uint64_size(1, v); + } + if let Some(v) = self.until_time { + my_size += ::protobuf::rt::uint64_size(2, v); + } + if let Some(v) = self.for_block_count { + my_size += ::protobuf::rt::uint64_size(3, v); + } + if let Some(v) = self.for_seconds { + my_size += ::protobuf::rt::uint64_size(4, v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.until_height { + os.write_uint64(1, v)?; + } + if let Some(v) = self.until_time { + os.write_uint64(2, v)?; + } + if let Some(v) = self.for_block_count { + os.write_uint64(3, v)?; + } + if let Some(v) = self.for_seconds { + os.write_uint64(4, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerOutputTimeLock { + MintlayerOutputTimeLock::new() + } + + fn clear(&mut self) { + self.until_height = ::std::option::Option::None; + self.until_time = ::std::option::Option::None; + self.for_block_count = ::std::option::Option::None; + self.for_seconds = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerOutputTimeLock { + static instance: MintlayerOutputTimeLock = MintlayerOutputTimeLock { + until_height: ::std::option::Option::None, + until_time: ::std::option::Option::None, + for_block_count: ::std::option::Option::None, + for_seconds: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerOutputTimeLock { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerOutputTimeLock").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerOutputTimeLock { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerOutputTimeLock { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerLockThenTransferTxOutput) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerLockThenTransferTxOutput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerLockThenTransferTxOutput.address) + pub address: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerLockThenTransferTxOutput.value) + pub value: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerLockThenTransferTxOutput.lock) + pub lock: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerLockThenTransferTxOutput.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerLockThenTransferTxOutput { + fn default() -> &'a MintlayerLockThenTransferTxOutput { + ::default_instance() + } +} + +impl MintlayerLockThenTransferTxOutput { + pub fn new() -> MintlayerLockThenTransferTxOutput { + ::std::default::Default::default() + } + + // required string address = 1; + + pub fn address(&self) -> &str { + match self.address.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_address(&mut self) { + self.address = ::std::option::Option::None; + } + + pub fn has_address(&self) -> bool { + self.address.is_some() + } + + // Param is passed by value, moved + pub fn set_address(&mut self, v: ::std::string::String) { + self.address = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_address(&mut self) -> &mut ::std::string::String { + if self.address.is_none() { + self.address = ::std::option::Option::Some(::std::string::String::new()); + } + self.address.as_mut().unwrap() + } + + // Take field + pub fn take_address(&mut self) -> ::std::string::String { + self.address.take().unwrap_or_else(|| ::std::string::String::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(3); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "address", + |m: &MintlayerLockThenTransferTxOutput| { &m.address }, + |m: &mut MintlayerLockThenTransferTxOutput| { &mut m.address }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerOutputValue>( + "value", + |m: &MintlayerLockThenTransferTxOutput| { &m.value }, + |m: &mut MintlayerLockThenTransferTxOutput| { &mut m.value }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerOutputTimeLock>( + "lock", + |m: &MintlayerLockThenTransferTxOutput| { &m.lock }, + |m: &mut MintlayerLockThenTransferTxOutput| { &mut m.lock }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerLockThenTransferTxOutput", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerLockThenTransferTxOutput { + const NAME: &'static str = "MintlayerLockThenTransferTxOutput"; + + fn is_initialized(&self) -> bool { + if self.address.is_none() { + return false; + } + if self.value.is_none() { + return false; + } + if self.lock.is_none() { + return false; + } + for v in &self.value { + if !v.is_initialized() { + return false; + } + }; + for v in &self.lock { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.address = ::std::option::Option::Some(is.read_string()?); + }, + 18 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.value)?; + }, + 26 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.lock)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.address.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.value.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.lock.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.address.as_ref() { + os.write_string(1, v)?; + } + if let Some(v) = self.value.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(2, v, os)?; + } + if let Some(v) = self.lock.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(3, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerLockThenTransferTxOutput { + MintlayerLockThenTransferTxOutput::new() + } + + fn clear(&mut self) { + self.address = ::std::option::Option::None; + self.value.clear(); + self.lock.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerLockThenTransferTxOutput { + static instance: MintlayerLockThenTransferTxOutput = MintlayerLockThenTransferTxOutput { + address: ::std::option::Option::None, + value: ::protobuf::MessageField::none(), + lock: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerLockThenTransferTxOutput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerLockThenTransferTxOutput").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerLockThenTransferTxOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerLockThenTransferTxOutput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerBurnTxOutput) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerBurnTxOutput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerBurnTxOutput.value) + pub value: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerBurnTxOutput.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerBurnTxOutput { + fn default() -> &'a MintlayerBurnTxOutput { + ::default_instance() + } +} + +impl MintlayerBurnTxOutput { + pub fn new() -> MintlayerBurnTxOutput { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(1); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerOutputValue>( + "value", + |m: &MintlayerBurnTxOutput| { &m.value }, + |m: &mut MintlayerBurnTxOutput| { &mut m.value }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerBurnTxOutput", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerBurnTxOutput { + const NAME: &'static str = "MintlayerBurnTxOutput"; + + fn is_initialized(&self) -> bool { + if self.value.is_none() { + return false; + } + for v in &self.value { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.value)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.value.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.value.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(1, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerBurnTxOutput { + MintlayerBurnTxOutput::new() + } + + fn clear(&mut self) { + self.value.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerBurnTxOutput { + static instance: MintlayerBurnTxOutput = MintlayerBurnTxOutput { + value: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerBurnTxOutput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerBurnTxOutput").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerBurnTxOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerBurnTxOutput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerCreateStakePoolTxOutput) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerCreateStakePoolTxOutput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerCreateStakePoolTxOutput.pool_id) + pub pool_id: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerCreateStakePoolTxOutput.pledge) + pub pledge: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerCreateStakePoolTxOutput.staker) + pub staker: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerCreateStakePoolTxOutput.vrf_public_key) + pub vrf_public_key: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerCreateStakePoolTxOutput.decommission_key) + pub decommission_key: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerCreateStakePoolTxOutput.margin_ratio_per_thousand) + pub margin_ratio_per_thousand: ::std::option::Option, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerCreateStakePoolTxOutput.cost_per_block) + pub cost_per_block: ::std::option::Option<::std::vec::Vec>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerCreateStakePoolTxOutput.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerCreateStakePoolTxOutput { + fn default() -> &'a MintlayerCreateStakePoolTxOutput { + ::default_instance() + } +} + +impl MintlayerCreateStakePoolTxOutput { + pub fn new() -> MintlayerCreateStakePoolTxOutput { + ::std::default::Default::default() + } + + // required string pool_id = 1; + + pub fn pool_id(&self) -> &str { + match self.pool_id.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_pool_id(&mut self) { + self.pool_id = ::std::option::Option::None; + } + + pub fn has_pool_id(&self) -> bool { + self.pool_id.is_some() + } + + // Param is passed by value, moved + pub fn set_pool_id(&mut self, v: ::std::string::String) { + self.pool_id = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_pool_id(&mut self) -> &mut ::std::string::String { + if self.pool_id.is_none() { + self.pool_id = ::std::option::Option::Some(::std::string::String::new()); + } + self.pool_id.as_mut().unwrap() + } + + // Take field + pub fn take_pool_id(&mut self) -> ::std::string::String { + self.pool_id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required bytes pledge = 2; + + pub fn pledge(&self) -> &[u8] { + match self.pledge.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_pledge(&mut self) { + self.pledge = ::std::option::Option::None; + } + + pub fn has_pledge(&self) -> bool { + self.pledge.is_some() + } + + // Param is passed by value, moved + pub fn set_pledge(&mut self, v: ::std::vec::Vec) { + self.pledge = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_pledge(&mut self) -> &mut ::std::vec::Vec { + if self.pledge.is_none() { + self.pledge = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.pledge.as_mut().unwrap() + } + + // Take field + pub fn take_pledge(&mut self) -> ::std::vec::Vec { + self.pledge.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // required string staker = 3; + + pub fn staker(&self) -> &str { + match self.staker.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_staker(&mut self) { + self.staker = ::std::option::Option::None; + } + + pub fn has_staker(&self) -> bool { + self.staker.is_some() + } + + // Param is passed by value, moved + pub fn set_staker(&mut self, v: ::std::string::String) { + self.staker = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_staker(&mut self) -> &mut ::std::string::String { + if self.staker.is_none() { + self.staker = ::std::option::Option::Some(::std::string::String::new()); + } + self.staker.as_mut().unwrap() + } + + // Take field + pub fn take_staker(&mut self) -> ::std::string::String { + self.staker.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required string vrf_public_key = 4; + + pub fn vrf_public_key(&self) -> &str { + match self.vrf_public_key.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_vrf_public_key(&mut self) { + self.vrf_public_key = ::std::option::Option::None; + } + + pub fn has_vrf_public_key(&self) -> bool { + self.vrf_public_key.is_some() + } + + // Param is passed by value, moved + pub fn set_vrf_public_key(&mut self, v: ::std::string::String) { + self.vrf_public_key = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_vrf_public_key(&mut self) -> &mut ::std::string::String { + if self.vrf_public_key.is_none() { + self.vrf_public_key = ::std::option::Option::Some(::std::string::String::new()); + } + self.vrf_public_key.as_mut().unwrap() + } + + // Take field + pub fn take_vrf_public_key(&mut self) -> ::std::string::String { + self.vrf_public_key.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required string decommission_key = 5; + + pub fn decommission_key(&self) -> &str { + match self.decommission_key.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_decommission_key(&mut self) { + self.decommission_key = ::std::option::Option::None; + } + + pub fn has_decommission_key(&self) -> bool { + self.decommission_key.is_some() + } + + // Param is passed by value, moved + pub fn set_decommission_key(&mut self, v: ::std::string::String) { + self.decommission_key = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_decommission_key(&mut self) -> &mut ::std::string::String { + if self.decommission_key.is_none() { + self.decommission_key = ::std::option::Option::Some(::std::string::String::new()); + } + self.decommission_key.as_mut().unwrap() + } + + // Take field + pub fn take_decommission_key(&mut self) -> ::std::string::String { + self.decommission_key.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required uint32 margin_ratio_per_thousand = 6; + + pub fn margin_ratio_per_thousand(&self) -> u32 { + self.margin_ratio_per_thousand.unwrap_or(0) + } + + pub fn clear_margin_ratio_per_thousand(&mut self) { + self.margin_ratio_per_thousand = ::std::option::Option::None; + } + + pub fn has_margin_ratio_per_thousand(&self) -> bool { + self.margin_ratio_per_thousand.is_some() + } + + // Param is passed by value, moved + pub fn set_margin_ratio_per_thousand(&mut self, v: u32) { + self.margin_ratio_per_thousand = ::std::option::Option::Some(v); + } + + // required bytes cost_per_block = 7; + + pub fn cost_per_block(&self) -> &[u8] { + match self.cost_per_block.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_cost_per_block(&mut self) { + self.cost_per_block = ::std::option::Option::None; + } + + pub fn has_cost_per_block(&self) -> bool { + self.cost_per_block.is_some() + } + + // Param is passed by value, moved + pub fn set_cost_per_block(&mut self, v: ::std::vec::Vec) { + self.cost_per_block = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_cost_per_block(&mut self) -> &mut ::std::vec::Vec { + if self.cost_per_block.is_none() { + self.cost_per_block = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.cost_per_block.as_mut().unwrap() + } + + // Take field + pub fn take_cost_per_block(&mut self) -> ::std::vec::Vec { + self.cost_per_block.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(7); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "pool_id", + |m: &MintlayerCreateStakePoolTxOutput| { &m.pool_id }, + |m: &mut MintlayerCreateStakePoolTxOutput| { &mut m.pool_id }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "pledge", + |m: &MintlayerCreateStakePoolTxOutput| { &m.pledge }, + |m: &mut MintlayerCreateStakePoolTxOutput| { &mut m.pledge }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "staker", + |m: &MintlayerCreateStakePoolTxOutput| { &m.staker }, + |m: &mut MintlayerCreateStakePoolTxOutput| { &mut m.staker }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "vrf_public_key", + |m: &MintlayerCreateStakePoolTxOutput| { &m.vrf_public_key }, + |m: &mut MintlayerCreateStakePoolTxOutput| { &mut m.vrf_public_key }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "decommission_key", + |m: &MintlayerCreateStakePoolTxOutput| { &m.decommission_key }, + |m: &mut MintlayerCreateStakePoolTxOutput| { &mut m.decommission_key }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "margin_ratio_per_thousand", + |m: &MintlayerCreateStakePoolTxOutput| { &m.margin_ratio_per_thousand }, + |m: &mut MintlayerCreateStakePoolTxOutput| { &mut m.margin_ratio_per_thousand }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "cost_per_block", + |m: &MintlayerCreateStakePoolTxOutput| { &m.cost_per_block }, + |m: &mut MintlayerCreateStakePoolTxOutput| { &mut m.cost_per_block }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerCreateStakePoolTxOutput", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerCreateStakePoolTxOutput { + const NAME: &'static str = "MintlayerCreateStakePoolTxOutput"; + + fn is_initialized(&self) -> bool { + if self.pool_id.is_none() { + return false; + } + if self.pledge.is_none() { + return false; + } + if self.staker.is_none() { + return false; + } + if self.vrf_public_key.is_none() { + return false; + } + if self.decommission_key.is_none() { + return false; + } + if self.margin_ratio_per_thousand.is_none() { + return false; + } + if self.cost_per_block.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.pool_id = ::std::option::Option::Some(is.read_string()?); + }, + 18 => { + self.pledge = ::std::option::Option::Some(is.read_bytes()?); + }, + 26 => { + self.staker = ::std::option::Option::Some(is.read_string()?); + }, + 34 => { + self.vrf_public_key = ::std::option::Option::Some(is.read_string()?); + }, + 42 => { + self.decommission_key = ::std::option::Option::Some(is.read_string()?); + }, + 48 => { + self.margin_ratio_per_thousand = ::std::option::Option::Some(is.read_uint32()?); + }, + 58 => { + self.cost_per_block = ::std::option::Option::Some(is.read_bytes()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.pool_id.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.pledge.as_ref() { + my_size += ::protobuf::rt::bytes_size(2, &v); + } + if let Some(v) = self.staker.as_ref() { + my_size += ::protobuf::rt::string_size(3, &v); + } + if let Some(v) = self.vrf_public_key.as_ref() { + my_size += ::protobuf::rt::string_size(4, &v); + } + if let Some(v) = self.decommission_key.as_ref() { + my_size += ::protobuf::rt::string_size(5, &v); + } + if let Some(v) = self.margin_ratio_per_thousand { + my_size += ::protobuf::rt::uint32_size(6, v); + } + if let Some(v) = self.cost_per_block.as_ref() { + my_size += ::protobuf::rt::bytes_size(7, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.pool_id.as_ref() { + os.write_string(1, v)?; + } + if let Some(v) = self.pledge.as_ref() { + os.write_bytes(2, v)?; + } + if let Some(v) = self.staker.as_ref() { + os.write_string(3, v)?; + } + if let Some(v) = self.vrf_public_key.as_ref() { + os.write_string(4, v)?; + } + if let Some(v) = self.decommission_key.as_ref() { + os.write_string(5, v)?; + } + if let Some(v) = self.margin_ratio_per_thousand { + os.write_uint32(6, v)?; + } + if let Some(v) = self.cost_per_block.as_ref() { + os.write_bytes(7, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerCreateStakePoolTxOutput { + MintlayerCreateStakePoolTxOutput::new() + } + + fn clear(&mut self) { + self.pool_id = ::std::option::Option::None; + self.pledge = ::std::option::Option::None; + self.staker = ::std::option::Option::None; + self.vrf_public_key = ::std::option::Option::None; + self.decommission_key = ::std::option::Option::None; + self.margin_ratio_per_thousand = ::std::option::Option::None; + self.cost_per_block = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerCreateStakePoolTxOutput { + static instance: MintlayerCreateStakePoolTxOutput = MintlayerCreateStakePoolTxOutput { + pool_id: ::std::option::Option::None, + pledge: ::std::option::Option::None, + staker: ::std::option::Option::None, + vrf_public_key: ::std::option::Option::None, + decommission_key: ::std::option::Option::None, + margin_ratio_per_thousand: ::std::option::Option::None, + cost_per_block: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerCreateStakePoolTxOutput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerCreateStakePoolTxOutput").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerCreateStakePoolTxOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerCreateStakePoolTxOutput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerProduceBlockFromStakeTxOutput) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerProduceBlockFromStakeTxOutput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerProduceBlockFromStakeTxOutput.destination) + pub destination: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerProduceBlockFromStakeTxOutput.pool_id) + pub pool_id: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerProduceBlockFromStakeTxOutput.staker_balance) + pub staker_balance: ::std::option::Option<::std::vec::Vec>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerProduceBlockFromStakeTxOutput.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerProduceBlockFromStakeTxOutput { + fn default() -> &'a MintlayerProduceBlockFromStakeTxOutput { + ::default_instance() + } +} + +impl MintlayerProduceBlockFromStakeTxOutput { + pub fn new() -> MintlayerProduceBlockFromStakeTxOutput { + ::std::default::Default::default() + } + + // required string destination = 1; + + pub fn destination(&self) -> &str { + match self.destination.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_destination(&mut self) { + self.destination = ::std::option::Option::None; + } + + pub fn has_destination(&self) -> bool { + self.destination.is_some() + } + + // Param is passed by value, moved + pub fn set_destination(&mut self, v: ::std::string::String) { + self.destination = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_destination(&mut self) -> &mut ::std::string::String { + if self.destination.is_none() { + self.destination = ::std::option::Option::Some(::std::string::String::new()); + } + self.destination.as_mut().unwrap() + } + + // Take field + pub fn take_destination(&mut self) -> ::std::string::String { + self.destination.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required string pool_id = 2; + + pub fn pool_id(&self) -> &str { + match self.pool_id.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_pool_id(&mut self) { + self.pool_id = ::std::option::Option::None; + } + + pub fn has_pool_id(&self) -> bool { + self.pool_id.is_some() + } + + // Param is passed by value, moved + pub fn set_pool_id(&mut self, v: ::std::string::String) { + self.pool_id = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_pool_id(&mut self) -> &mut ::std::string::String { + if self.pool_id.is_none() { + self.pool_id = ::std::option::Option::Some(::std::string::String::new()); + } + self.pool_id.as_mut().unwrap() + } + + // Take field + pub fn take_pool_id(&mut self) -> ::std::string::String { + self.pool_id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required bytes staker_balance = 3; + + pub fn staker_balance(&self) -> &[u8] { + match self.staker_balance.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_staker_balance(&mut self) { + self.staker_balance = ::std::option::Option::None; + } + + pub fn has_staker_balance(&self) -> bool { + self.staker_balance.is_some() + } + + // Param is passed by value, moved + pub fn set_staker_balance(&mut self, v: ::std::vec::Vec) { + self.staker_balance = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_staker_balance(&mut self) -> &mut ::std::vec::Vec { + if self.staker_balance.is_none() { + self.staker_balance = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.staker_balance.as_mut().unwrap() + } + + // Take field + pub fn take_staker_balance(&mut self) -> ::std::vec::Vec { + self.staker_balance.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(3); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "destination", + |m: &MintlayerProduceBlockFromStakeTxOutput| { &m.destination }, + |m: &mut MintlayerProduceBlockFromStakeTxOutput| { &mut m.destination }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "pool_id", + |m: &MintlayerProduceBlockFromStakeTxOutput| { &m.pool_id }, + |m: &mut MintlayerProduceBlockFromStakeTxOutput| { &mut m.pool_id }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "staker_balance", + |m: &MintlayerProduceBlockFromStakeTxOutput| { &m.staker_balance }, + |m: &mut MintlayerProduceBlockFromStakeTxOutput| { &mut m.staker_balance }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerProduceBlockFromStakeTxOutput", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerProduceBlockFromStakeTxOutput { + const NAME: &'static str = "MintlayerProduceBlockFromStakeTxOutput"; + + fn is_initialized(&self) -> bool { + if self.destination.is_none() { + return false; + } + if self.pool_id.is_none() { + return false; + } + if self.staker_balance.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.destination = ::std::option::Option::Some(is.read_string()?); + }, + 18 => { + self.pool_id = ::std::option::Option::Some(is.read_string()?); + }, + 26 => { + self.staker_balance = ::std::option::Option::Some(is.read_bytes()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.destination.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.pool_id.as_ref() { + my_size += ::protobuf::rt::string_size(2, &v); + } + if let Some(v) = self.staker_balance.as_ref() { + my_size += ::protobuf::rt::bytes_size(3, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.destination.as_ref() { + os.write_string(1, v)?; + } + if let Some(v) = self.pool_id.as_ref() { + os.write_string(2, v)?; + } + if let Some(v) = self.staker_balance.as_ref() { + os.write_bytes(3, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerProduceBlockFromStakeTxOutput { + MintlayerProduceBlockFromStakeTxOutput::new() + } + + fn clear(&mut self) { + self.destination = ::std::option::Option::None; + self.pool_id = ::std::option::Option::None; + self.staker_balance = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerProduceBlockFromStakeTxOutput { + static instance: MintlayerProduceBlockFromStakeTxOutput = MintlayerProduceBlockFromStakeTxOutput { + destination: ::std::option::Option::None, + pool_id: ::std::option::Option::None, + staker_balance: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerProduceBlockFromStakeTxOutput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerProduceBlockFromStakeTxOutput").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerProduceBlockFromStakeTxOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerProduceBlockFromStakeTxOutput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerCreateDelegationIdTxOutput) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerCreateDelegationIdTxOutput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerCreateDelegationIdTxOutput.destination) + pub destination: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerCreateDelegationIdTxOutput.pool_id) + pub pool_id: ::std::option::Option<::std::string::String>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerCreateDelegationIdTxOutput.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerCreateDelegationIdTxOutput { + fn default() -> &'a MintlayerCreateDelegationIdTxOutput { + ::default_instance() + } +} + +impl MintlayerCreateDelegationIdTxOutput { + pub fn new() -> MintlayerCreateDelegationIdTxOutput { + ::std::default::Default::default() + } + + // required string destination = 1; + + pub fn destination(&self) -> &str { + match self.destination.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_destination(&mut self) { + self.destination = ::std::option::Option::None; + } + + pub fn has_destination(&self) -> bool { + self.destination.is_some() + } + + // Param is passed by value, moved + pub fn set_destination(&mut self, v: ::std::string::String) { + self.destination = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_destination(&mut self) -> &mut ::std::string::String { + if self.destination.is_none() { + self.destination = ::std::option::Option::Some(::std::string::String::new()); + } + self.destination.as_mut().unwrap() + } + + // Take field + pub fn take_destination(&mut self) -> ::std::string::String { + self.destination.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required string pool_id = 2; + + pub fn pool_id(&self) -> &str { + match self.pool_id.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_pool_id(&mut self) { + self.pool_id = ::std::option::Option::None; + } + + pub fn has_pool_id(&self) -> bool { + self.pool_id.is_some() + } + + // Param is passed by value, moved + pub fn set_pool_id(&mut self, v: ::std::string::String) { + self.pool_id = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_pool_id(&mut self) -> &mut ::std::string::String { + if self.pool_id.is_none() { + self.pool_id = ::std::option::Option::Some(::std::string::String::new()); + } + self.pool_id.as_mut().unwrap() + } + + // Take field + pub fn take_pool_id(&mut self) -> ::std::string::String { + self.pool_id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "destination", + |m: &MintlayerCreateDelegationIdTxOutput| { &m.destination }, + |m: &mut MintlayerCreateDelegationIdTxOutput| { &mut m.destination }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "pool_id", + |m: &MintlayerCreateDelegationIdTxOutput| { &m.pool_id }, + |m: &mut MintlayerCreateDelegationIdTxOutput| { &mut m.pool_id }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerCreateDelegationIdTxOutput", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerCreateDelegationIdTxOutput { + const NAME: &'static str = "MintlayerCreateDelegationIdTxOutput"; + + fn is_initialized(&self) -> bool { + if self.destination.is_none() { + return false; + } + if self.pool_id.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.destination = ::std::option::Option::Some(is.read_string()?); + }, + 18 => { + self.pool_id = ::std::option::Option::Some(is.read_string()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.destination.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.pool_id.as_ref() { + my_size += ::protobuf::rt::string_size(2, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.destination.as_ref() { + os.write_string(1, v)?; + } + if let Some(v) = self.pool_id.as_ref() { + os.write_string(2, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerCreateDelegationIdTxOutput { + MintlayerCreateDelegationIdTxOutput::new() + } + + fn clear(&mut self) { + self.destination = ::std::option::Option::None; + self.pool_id = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerCreateDelegationIdTxOutput { + static instance: MintlayerCreateDelegationIdTxOutput = MintlayerCreateDelegationIdTxOutput { + destination: ::std::option::Option::None, + pool_id: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerCreateDelegationIdTxOutput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerCreateDelegationIdTxOutput").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerCreateDelegationIdTxOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerCreateDelegationIdTxOutput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerDelegateStakingTxOutput) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerDelegateStakingTxOutput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerDelegateStakingTxOutput.amount) + pub amount: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerDelegateStakingTxOutput.delegation_id) + pub delegation_id: ::std::option::Option<::std::string::String>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerDelegateStakingTxOutput.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerDelegateStakingTxOutput { + fn default() -> &'a MintlayerDelegateStakingTxOutput { + ::default_instance() + } +} + +impl MintlayerDelegateStakingTxOutput { + pub fn new() -> MintlayerDelegateStakingTxOutput { + ::std::default::Default::default() + } + + // required bytes amount = 1; + + pub fn amount(&self) -> &[u8] { + match self.amount.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_amount(&mut self) { + self.amount = ::std::option::Option::None; + } + + pub fn has_amount(&self) -> bool { + self.amount.is_some() + } + + // Param is passed by value, moved + pub fn set_amount(&mut self, v: ::std::vec::Vec) { + self.amount = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_amount(&mut self) -> &mut ::std::vec::Vec { + if self.amount.is_none() { + self.amount = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.amount.as_mut().unwrap() + } + + // Take field + pub fn take_amount(&mut self) -> ::std::vec::Vec { + self.amount.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // required string delegation_id = 2; + + pub fn delegation_id(&self) -> &str { + match self.delegation_id.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_delegation_id(&mut self) { + self.delegation_id = ::std::option::Option::None; + } + + pub fn has_delegation_id(&self) -> bool { + self.delegation_id.is_some() + } + + // Param is passed by value, moved + pub fn set_delegation_id(&mut self, v: ::std::string::String) { + self.delegation_id = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_delegation_id(&mut self) -> &mut ::std::string::String { + if self.delegation_id.is_none() { + self.delegation_id = ::std::option::Option::Some(::std::string::String::new()); + } + self.delegation_id.as_mut().unwrap() + } + + // Take field + pub fn take_delegation_id(&mut self) -> ::std::string::String { + self.delegation_id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "amount", + |m: &MintlayerDelegateStakingTxOutput| { &m.amount }, + |m: &mut MintlayerDelegateStakingTxOutput| { &mut m.amount }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "delegation_id", + |m: &MintlayerDelegateStakingTxOutput| { &m.delegation_id }, + |m: &mut MintlayerDelegateStakingTxOutput| { &mut m.delegation_id }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerDelegateStakingTxOutput", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerDelegateStakingTxOutput { + const NAME: &'static str = "MintlayerDelegateStakingTxOutput"; + + fn is_initialized(&self) -> bool { + if self.amount.is_none() { + return false; + } + if self.delegation_id.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.amount = ::std::option::Option::Some(is.read_bytes()?); + }, + 18 => { + self.delegation_id = ::std::option::Option::Some(is.read_string()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.amount.as_ref() { + my_size += ::protobuf::rt::bytes_size(1, &v); + } + if let Some(v) = self.delegation_id.as_ref() { + my_size += ::protobuf::rt::string_size(2, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.amount.as_ref() { + os.write_bytes(1, v)?; + } + if let Some(v) = self.delegation_id.as_ref() { + os.write_string(2, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerDelegateStakingTxOutput { + MintlayerDelegateStakingTxOutput::new() + } + + fn clear(&mut self) { + self.amount = ::std::option::Option::None; + self.delegation_id = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerDelegateStakingTxOutput { + static instance: MintlayerDelegateStakingTxOutput = MintlayerDelegateStakingTxOutput { + amount: ::std::option::Option::None, + delegation_id: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerDelegateStakingTxOutput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerDelegateStakingTxOutput").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerDelegateStakingTxOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerDelegateStakingTxOutput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerTokenTotalSupply) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerTokenTotalSupply { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTokenTotalSupply.type) + pub type_: ::std::option::Option<::protobuf::EnumOrUnknown>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTokenTotalSupply.fixed_amount) + pub fixed_amount: ::std::option::Option<::std::vec::Vec>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerTokenTotalSupply.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerTokenTotalSupply { + fn default() -> &'a MintlayerTokenTotalSupply { + ::default_instance() + } +} + +impl MintlayerTokenTotalSupply { + pub fn new() -> MintlayerTokenTotalSupply { + ::std::default::Default::default() + } + + // required .hw.trezor.messages.mintlayer.MintlayerTokenTotalSupplyType type = 1; + + pub fn type_(&self) -> MintlayerTokenTotalSupplyType { + match self.type_ { + Some(e) => e.enum_value_or(MintlayerTokenTotalSupplyType::FIXED), + None => MintlayerTokenTotalSupplyType::FIXED, + } + } + + pub fn clear_type_(&mut self) { + self.type_ = ::std::option::Option::None; + } + + pub fn has_type(&self) -> bool { + self.type_.is_some() + } + + // Param is passed by value, moved + pub fn set_type(&mut self, v: MintlayerTokenTotalSupplyType) { + self.type_ = ::std::option::Option::Some(::protobuf::EnumOrUnknown::new(v)); + } + + // optional bytes fixed_amount = 2; + + pub fn fixed_amount(&self) -> &[u8] { + match self.fixed_amount.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_fixed_amount(&mut self) { + self.fixed_amount = ::std::option::Option::None; + } + + pub fn has_fixed_amount(&self) -> bool { + self.fixed_amount.is_some() + } + + // Param is passed by value, moved + pub fn set_fixed_amount(&mut self, v: ::std::vec::Vec) { + self.fixed_amount = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_fixed_amount(&mut self) -> &mut ::std::vec::Vec { + if self.fixed_amount.is_none() { + self.fixed_amount = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.fixed_amount.as_mut().unwrap() + } + + // Take field + pub fn take_fixed_amount(&mut self) -> ::std::vec::Vec { + self.fixed_amount.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "type", + |m: &MintlayerTokenTotalSupply| { &m.type_ }, + |m: &mut MintlayerTokenTotalSupply| { &mut m.type_ }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "fixed_amount", + |m: &MintlayerTokenTotalSupply| { &m.fixed_amount }, + |m: &mut MintlayerTokenTotalSupply| { &mut m.fixed_amount }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerTokenTotalSupply", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerTokenTotalSupply { + const NAME: &'static str = "MintlayerTokenTotalSupply"; + + fn is_initialized(&self) -> bool { + if self.type_.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 8 => { + self.type_ = ::std::option::Option::Some(is.read_enum_or_unknown()?); + }, + 18 => { + self.fixed_amount = ::std::option::Option::Some(is.read_bytes()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.type_ { + my_size += ::protobuf::rt::int32_size(1, v.value()); + } + if let Some(v) = self.fixed_amount.as_ref() { + my_size += ::protobuf::rt::bytes_size(2, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.type_ { + os.write_enum(1, ::protobuf::EnumOrUnknown::value(&v))?; + } + if let Some(v) = self.fixed_amount.as_ref() { + os.write_bytes(2, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerTokenTotalSupply { + MintlayerTokenTotalSupply::new() + } + + fn clear(&mut self) { + self.type_ = ::std::option::Option::None; + self.fixed_amount = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerTokenTotalSupply { + static instance: MintlayerTokenTotalSupply = MintlayerTokenTotalSupply { + type_: ::std::option::Option::None, + fixed_amount: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerTokenTotalSupply { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerTokenTotalSupply").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerTokenTotalSupply { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerTokenTotalSupply { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerIssueFungibleTokenTxOutput) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerIssueFungibleTokenTxOutput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerIssueFungibleTokenTxOutput.token_ticker) + pub token_ticker: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerIssueFungibleTokenTxOutput.number_of_decimals) + pub number_of_decimals: ::std::option::Option, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerIssueFungibleTokenTxOutput.metadata_uri) + pub metadata_uri: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerIssueFungibleTokenTxOutput.total_supply) + pub total_supply: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerIssueFungibleTokenTxOutput.authority) + pub authority: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerIssueFungibleTokenTxOutput.is_freezable) + pub is_freezable: ::std::option::Option, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerIssueFungibleTokenTxOutput.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerIssueFungibleTokenTxOutput { + fn default() -> &'a MintlayerIssueFungibleTokenTxOutput { + ::default_instance() + } +} + +impl MintlayerIssueFungibleTokenTxOutput { + pub fn new() -> MintlayerIssueFungibleTokenTxOutput { + ::std::default::Default::default() + } + + // required bytes token_ticker = 1; + + pub fn token_ticker(&self) -> &[u8] { + match self.token_ticker.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_token_ticker(&mut self) { + self.token_ticker = ::std::option::Option::None; + } + + pub fn has_token_ticker(&self) -> bool { + self.token_ticker.is_some() + } + + // Param is passed by value, moved + pub fn set_token_ticker(&mut self, v: ::std::vec::Vec) { + self.token_ticker = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_token_ticker(&mut self) -> &mut ::std::vec::Vec { + if self.token_ticker.is_none() { + self.token_ticker = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.token_ticker.as_mut().unwrap() + } + + // Take field + pub fn take_token_ticker(&mut self) -> ::std::vec::Vec { + self.token_ticker.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // required uint32 number_of_decimals = 2; + + pub fn number_of_decimals(&self) -> u32 { + self.number_of_decimals.unwrap_or(0) + } + + pub fn clear_number_of_decimals(&mut self) { + self.number_of_decimals = ::std::option::Option::None; + } + + pub fn has_number_of_decimals(&self) -> bool { + self.number_of_decimals.is_some() + } + + // Param is passed by value, moved + pub fn set_number_of_decimals(&mut self, v: u32) { + self.number_of_decimals = ::std::option::Option::Some(v); + } + + // required bytes metadata_uri = 3; + + pub fn metadata_uri(&self) -> &[u8] { + match self.metadata_uri.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_metadata_uri(&mut self) { + self.metadata_uri = ::std::option::Option::None; + } + + pub fn has_metadata_uri(&self) -> bool { + self.metadata_uri.is_some() + } + + // Param is passed by value, moved + pub fn set_metadata_uri(&mut self, v: ::std::vec::Vec) { + self.metadata_uri = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_metadata_uri(&mut self) -> &mut ::std::vec::Vec { + if self.metadata_uri.is_none() { + self.metadata_uri = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.metadata_uri.as_mut().unwrap() + } + + // Take field + pub fn take_metadata_uri(&mut self) -> ::std::vec::Vec { + self.metadata_uri.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // required string authority = 5; + + pub fn authority(&self) -> &str { + match self.authority.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_authority(&mut self) { + self.authority = ::std::option::Option::None; + } + + pub fn has_authority(&self) -> bool { + self.authority.is_some() + } + + // Param is passed by value, moved + pub fn set_authority(&mut self, v: ::std::string::String) { + self.authority = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_authority(&mut self) -> &mut ::std::string::String { + if self.authority.is_none() { + self.authority = ::std::option::Option::Some(::std::string::String::new()); + } + self.authority.as_mut().unwrap() + } + + // Take field + pub fn take_authority(&mut self) -> ::std::string::String { + self.authority.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required bool is_freezable = 6; + + pub fn is_freezable(&self) -> bool { + self.is_freezable.unwrap_or(false) + } + + pub fn clear_is_freezable(&mut self) { + self.is_freezable = ::std::option::Option::None; + } + + pub fn has_is_freezable(&self) -> bool { + self.is_freezable.is_some() + } + + // Param is passed by value, moved + pub fn set_is_freezable(&mut self, v: bool) { + self.is_freezable = ::std::option::Option::Some(v); + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(6); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "token_ticker", + |m: &MintlayerIssueFungibleTokenTxOutput| { &m.token_ticker }, + |m: &mut MintlayerIssueFungibleTokenTxOutput| { &mut m.token_ticker }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "number_of_decimals", + |m: &MintlayerIssueFungibleTokenTxOutput| { &m.number_of_decimals }, + |m: &mut MintlayerIssueFungibleTokenTxOutput| { &mut m.number_of_decimals }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "metadata_uri", + |m: &MintlayerIssueFungibleTokenTxOutput| { &m.metadata_uri }, + |m: &mut MintlayerIssueFungibleTokenTxOutput| { &mut m.metadata_uri }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerTokenTotalSupply>( + "total_supply", + |m: &MintlayerIssueFungibleTokenTxOutput| { &m.total_supply }, + |m: &mut MintlayerIssueFungibleTokenTxOutput| { &mut m.total_supply }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "authority", + |m: &MintlayerIssueFungibleTokenTxOutput| { &m.authority }, + |m: &mut MintlayerIssueFungibleTokenTxOutput| { &mut m.authority }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "is_freezable", + |m: &MintlayerIssueFungibleTokenTxOutput| { &m.is_freezable }, + |m: &mut MintlayerIssueFungibleTokenTxOutput| { &mut m.is_freezable }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerIssueFungibleTokenTxOutput", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerIssueFungibleTokenTxOutput { + const NAME: &'static str = "MintlayerIssueFungibleTokenTxOutput"; + + fn is_initialized(&self) -> bool { + if self.token_ticker.is_none() { + return false; + } + if self.number_of_decimals.is_none() { + return false; + } + if self.metadata_uri.is_none() { + return false; + } + if self.total_supply.is_none() { + return false; + } + if self.authority.is_none() { + return false; + } + if self.is_freezable.is_none() { + return false; + } + for v in &self.total_supply { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.token_ticker = ::std::option::Option::Some(is.read_bytes()?); + }, + 16 => { + self.number_of_decimals = ::std::option::Option::Some(is.read_uint32()?); + }, + 26 => { + self.metadata_uri = ::std::option::Option::Some(is.read_bytes()?); + }, + 34 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.total_supply)?; + }, + 42 => { + self.authority = ::std::option::Option::Some(is.read_string()?); + }, + 48 => { + self.is_freezable = ::std::option::Option::Some(is.read_bool()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.token_ticker.as_ref() { + my_size += ::protobuf::rt::bytes_size(1, &v); + } + if let Some(v) = self.number_of_decimals { + my_size += ::protobuf::rt::uint32_size(2, v); + } + if let Some(v) = self.metadata_uri.as_ref() { + my_size += ::protobuf::rt::bytes_size(3, &v); + } + if let Some(v) = self.total_supply.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.authority.as_ref() { + my_size += ::protobuf::rt::string_size(5, &v); + } + if let Some(v) = self.is_freezable { + my_size += 1 + 1; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.token_ticker.as_ref() { + os.write_bytes(1, v)?; + } + if let Some(v) = self.number_of_decimals { + os.write_uint32(2, v)?; + } + if let Some(v) = self.metadata_uri.as_ref() { + os.write_bytes(3, v)?; + } + if let Some(v) = self.total_supply.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(4, v, os)?; + } + if let Some(v) = self.authority.as_ref() { + os.write_string(5, v)?; + } + if let Some(v) = self.is_freezable { + os.write_bool(6, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerIssueFungibleTokenTxOutput { + MintlayerIssueFungibleTokenTxOutput::new() + } + + fn clear(&mut self) { + self.token_ticker = ::std::option::Option::None; + self.number_of_decimals = ::std::option::Option::None; + self.metadata_uri = ::std::option::Option::None; + self.total_supply.clear(); + self.authority = ::std::option::Option::None; + self.is_freezable = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerIssueFungibleTokenTxOutput { + static instance: MintlayerIssueFungibleTokenTxOutput = MintlayerIssueFungibleTokenTxOutput { + token_ticker: ::std::option::Option::None, + number_of_decimals: ::std::option::Option::None, + metadata_uri: ::std::option::Option::None, + total_supply: ::protobuf::MessageField::none(), + authority: ::std::option::Option::None, + is_freezable: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerIssueFungibleTokenTxOutput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerIssueFungibleTokenTxOutput").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerIssueFungibleTokenTxOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerIssueFungibleTokenTxOutput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerIssueNftTxOutput) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerIssueNftTxOutput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerIssueNftTxOutput.token_id) + pub token_id: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerIssueNftTxOutput.destination) + pub destination: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerIssueNftTxOutput.creator) + pub creator: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerIssueNftTxOutput.name) + pub name: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerIssueNftTxOutput.description) + pub description: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerIssueNftTxOutput.ticker) + pub ticker: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerIssueNftTxOutput.icon_uri) + pub icon_uri: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerIssueNftTxOutput.additional_metadata_uri) + pub additional_metadata_uri: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerIssueNftTxOutput.media_uri) + pub media_uri: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerIssueNftTxOutput.media_hash) + pub media_hash: ::std::option::Option<::std::vec::Vec>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerIssueNftTxOutput.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerIssueNftTxOutput { + fn default() -> &'a MintlayerIssueNftTxOutput { + ::default_instance() + } +} + +impl MintlayerIssueNftTxOutput { + pub fn new() -> MintlayerIssueNftTxOutput { + ::std::default::Default::default() + } + + // required string token_id = 1; + + pub fn token_id(&self) -> &str { + match self.token_id.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_token_id(&mut self) { + self.token_id = ::std::option::Option::None; + } + + pub fn has_token_id(&self) -> bool { + self.token_id.is_some() + } + + // Param is passed by value, moved + pub fn set_token_id(&mut self, v: ::std::string::String) { + self.token_id = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_token_id(&mut self) -> &mut ::std::string::String { + if self.token_id.is_none() { + self.token_id = ::std::option::Option::Some(::std::string::String::new()); + } + self.token_id.as_mut().unwrap() + } + + // Take field + pub fn take_token_id(&mut self) -> ::std::string::String { + self.token_id.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required string destination = 2; + + pub fn destination(&self) -> &str { + match self.destination.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_destination(&mut self) { + self.destination = ::std::option::Option::None; + } + + pub fn has_destination(&self) -> bool { + self.destination.is_some() + } + + // Param is passed by value, moved + pub fn set_destination(&mut self, v: ::std::string::String) { + self.destination = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_destination(&mut self) -> &mut ::std::string::String { + if self.destination.is_none() { + self.destination = ::std::option::Option::Some(::std::string::String::new()); + } + self.destination.as_mut().unwrap() + } + + // Take field + pub fn take_destination(&mut self) -> ::std::string::String { + self.destination.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // optional string creator = 3; + + pub fn creator(&self) -> &str { + match self.creator.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_creator(&mut self) { + self.creator = ::std::option::Option::None; + } + + pub fn has_creator(&self) -> bool { + self.creator.is_some() + } + + // Param is passed by value, moved + pub fn set_creator(&mut self, v: ::std::string::String) { + self.creator = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_creator(&mut self) -> &mut ::std::string::String { + if self.creator.is_none() { + self.creator = ::std::option::Option::Some(::std::string::String::new()); + } + self.creator.as_mut().unwrap() + } + + // Take field + pub fn take_creator(&mut self) -> ::std::string::String { + self.creator.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required bytes name = 4; + + pub fn name(&self) -> &[u8] { + match self.name.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_name(&mut self) { + self.name = ::std::option::Option::None; + } + + pub fn has_name(&self) -> bool { + self.name.is_some() + } + + // Param is passed by value, moved + pub fn set_name(&mut self, v: ::std::vec::Vec) { + self.name = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_name(&mut self) -> &mut ::std::vec::Vec { + if self.name.is_none() { + self.name = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.name.as_mut().unwrap() + } + + // Take field + pub fn take_name(&mut self) -> ::std::vec::Vec { + self.name.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // required bytes description = 5; + + pub fn description(&self) -> &[u8] { + match self.description.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_description(&mut self) { + self.description = ::std::option::Option::None; + } + + pub fn has_description(&self) -> bool { + self.description.is_some() + } + + // Param is passed by value, moved + pub fn set_description(&mut self, v: ::std::vec::Vec) { + self.description = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_description(&mut self) -> &mut ::std::vec::Vec { + if self.description.is_none() { + self.description = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.description.as_mut().unwrap() + } + + // Take field + pub fn take_description(&mut self) -> ::std::vec::Vec { + self.description.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // required bytes ticker = 6; + + pub fn ticker(&self) -> &[u8] { + match self.ticker.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_ticker(&mut self) { + self.ticker = ::std::option::Option::None; + } + + pub fn has_ticker(&self) -> bool { + self.ticker.is_some() + } + + // Param is passed by value, moved + pub fn set_ticker(&mut self, v: ::std::vec::Vec) { + self.ticker = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_ticker(&mut self) -> &mut ::std::vec::Vec { + if self.ticker.is_none() { + self.ticker = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.ticker.as_mut().unwrap() + } + + // Take field + pub fn take_ticker(&mut self) -> ::std::vec::Vec { + self.ticker.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // optional bytes icon_uri = 7; + + pub fn icon_uri(&self) -> &[u8] { + match self.icon_uri.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_icon_uri(&mut self) { + self.icon_uri = ::std::option::Option::None; + } + + pub fn has_icon_uri(&self) -> bool { + self.icon_uri.is_some() + } + + // Param is passed by value, moved + pub fn set_icon_uri(&mut self, v: ::std::vec::Vec) { + self.icon_uri = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_icon_uri(&mut self) -> &mut ::std::vec::Vec { + if self.icon_uri.is_none() { + self.icon_uri = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.icon_uri.as_mut().unwrap() + } + + // Take field + pub fn take_icon_uri(&mut self) -> ::std::vec::Vec { + self.icon_uri.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // optional bytes additional_metadata_uri = 8; + + pub fn additional_metadata_uri(&self) -> &[u8] { + match self.additional_metadata_uri.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_additional_metadata_uri(&mut self) { + self.additional_metadata_uri = ::std::option::Option::None; + } + + pub fn has_additional_metadata_uri(&self) -> bool { + self.additional_metadata_uri.is_some() + } + + // Param is passed by value, moved + pub fn set_additional_metadata_uri(&mut self, v: ::std::vec::Vec) { + self.additional_metadata_uri = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_additional_metadata_uri(&mut self) -> &mut ::std::vec::Vec { + if self.additional_metadata_uri.is_none() { + self.additional_metadata_uri = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.additional_metadata_uri.as_mut().unwrap() + } + + // Take field + pub fn take_additional_metadata_uri(&mut self) -> ::std::vec::Vec { + self.additional_metadata_uri.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // optional bytes media_uri = 9; + + pub fn media_uri(&self) -> &[u8] { + match self.media_uri.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_media_uri(&mut self) { + self.media_uri = ::std::option::Option::None; + } + + pub fn has_media_uri(&self) -> bool { + self.media_uri.is_some() + } + + // Param is passed by value, moved + pub fn set_media_uri(&mut self, v: ::std::vec::Vec) { + self.media_uri = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_media_uri(&mut self) -> &mut ::std::vec::Vec { + if self.media_uri.is_none() { + self.media_uri = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.media_uri.as_mut().unwrap() + } + + // Take field + pub fn take_media_uri(&mut self) -> ::std::vec::Vec { + self.media_uri.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // required bytes media_hash = 10; + + pub fn media_hash(&self) -> &[u8] { + match self.media_hash.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_media_hash(&mut self) { + self.media_hash = ::std::option::Option::None; + } + + pub fn has_media_hash(&self) -> bool { + self.media_hash.is_some() + } + + // Param is passed by value, moved + pub fn set_media_hash(&mut self, v: ::std::vec::Vec) { + self.media_hash = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_media_hash(&mut self) -> &mut ::std::vec::Vec { + if self.media_hash.is_none() { + self.media_hash = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.media_hash.as_mut().unwrap() + } + + // Take field + pub fn take_media_hash(&mut self) -> ::std::vec::Vec { + self.media_hash.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(10); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "token_id", + |m: &MintlayerIssueNftTxOutput| { &m.token_id }, + |m: &mut MintlayerIssueNftTxOutput| { &mut m.token_id }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "destination", + |m: &MintlayerIssueNftTxOutput| { &m.destination }, + |m: &mut MintlayerIssueNftTxOutput| { &mut m.destination }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "creator", + |m: &MintlayerIssueNftTxOutput| { &m.creator }, + |m: &mut MintlayerIssueNftTxOutput| { &mut m.creator }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "name", + |m: &MintlayerIssueNftTxOutput| { &m.name }, + |m: &mut MintlayerIssueNftTxOutput| { &mut m.name }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "description", + |m: &MintlayerIssueNftTxOutput| { &m.description }, + |m: &mut MintlayerIssueNftTxOutput| { &mut m.description }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "ticker", + |m: &MintlayerIssueNftTxOutput| { &m.ticker }, + |m: &mut MintlayerIssueNftTxOutput| { &mut m.ticker }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "icon_uri", + |m: &MintlayerIssueNftTxOutput| { &m.icon_uri }, + |m: &mut MintlayerIssueNftTxOutput| { &mut m.icon_uri }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "additional_metadata_uri", + |m: &MintlayerIssueNftTxOutput| { &m.additional_metadata_uri }, + |m: &mut MintlayerIssueNftTxOutput| { &mut m.additional_metadata_uri }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "media_uri", + |m: &MintlayerIssueNftTxOutput| { &m.media_uri }, + |m: &mut MintlayerIssueNftTxOutput| { &mut m.media_uri }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "media_hash", + |m: &MintlayerIssueNftTxOutput| { &m.media_hash }, + |m: &mut MintlayerIssueNftTxOutput| { &mut m.media_hash }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerIssueNftTxOutput", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerIssueNftTxOutput { + const NAME: &'static str = "MintlayerIssueNftTxOutput"; + + fn is_initialized(&self) -> bool { + if self.token_id.is_none() { + return false; + } + if self.destination.is_none() { + return false; + } + if self.name.is_none() { + return false; + } + if self.description.is_none() { + return false; + } + if self.ticker.is_none() { + return false; + } + if self.media_hash.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.token_id = ::std::option::Option::Some(is.read_string()?); + }, + 18 => { + self.destination = ::std::option::Option::Some(is.read_string()?); + }, + 26 => { + self.creator = ::std::option::Option::Some(is.read_string()?); + }, + 34 => { + self.name = ::std::option::Option::Some(is.read_bytes()?); + }, + 42 => { + self.description = ::std::option::Option::Some(is.read_bytes()?); + }, + 50 => { + self.ticker = ::std::option::Option::Some(is.read_bytes()?); + }, + 58 => { + self.icon_uri = ::std::option::Option::Some(is.read_bytes()?); + }, + 66 => { + self.additional_metadata_uri = ::std::option::Option::Some(is.read_bytes()?); + }, + 74 => { + self.media_uri = ::std::option::Option::Some(is.read_bytes()?); + }, + 82 => { + self.media_hash = ::std::option::Option::Some(is.read_bytes()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.token_id.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.destination.as_ref() { + my_size += ::protobuf::rt::string_size(2, &v); + } + if let Some(v) = self.creator.as_ref() { + my_size += ::protobuf::rt::string_size(3, &v); + } + if let Some(v) = self.name.as_ref() { + my_size += ::protobuf::rt::bytes_size(4, &v); + } + if let Some(v) = self.description.as_ref() { + my_size += ::protobuf::rt::bytes_size(5, &v); + } + if let Some(v) = self.ticker.as_ref() { + my_size += ::protobuf::rt::bytes_size(6, &v); + } + if let Some(v) = self.icon_uri.as_ref() { + my_size += ::protobuf::rt::bytes_size(7, &v); + } + if let Some(v) = self.additional_metadata_uri.as_ref() { + my_size += ::protobuf::rt::bytes_size(8, &v); + } + if let Some(v) = self.media_uri.as_ref() { + my_size += ::protobuf::rt::bytes_size(9, &v); + } + if let Some(v) = self.media_hash.as_ref() { + my_size += ::protobuf::rt::bytes_size(10, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.token_id.as_ref() { + os.write_string(1, v)?; + } + if let Some(v) = self.destination.as_ref() { + os.write_string(2, v)?; + } + if let Some(v) = self.creator.as_ref() { + os.write_string(3, v)?; + } + if let Some(v) = self.name.as_ref() { + os.write_bytes(4, v)?; + } + if let Some(v) = self.description.as_ref() { + os.write_bytes(5, v)?; + } + if let Some(v) = self.ticker.as_ref() { + os.write_bytes(6, v)?; + } + if let Some(v) = self.icon_uri.as_ref() { + os.write_bytes(7, v)?; + } + if let Some(v) = self.additional_metadata_uri.as_ref() { + os.write_bytes(8, v)?; + } + if let Some(v) = self.media_uri.as_ref() { + os.write_bytes(9, v)?; + } + if let Some(v) = self.media_hash.as_ref() { + os.write_bytes(10, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerIssueNftTxOutput { + MintlayerIssueNftTxOutput::new() + } + + fn clear(&mut self) { + self.token_id = ::std::option::Option::None; + self.destination = ::std::option::Option::None; + self.creator = ::std::option::Option::None; + self.name = ::std::option::Option::None; + self.description = ::std::option::Option::None; + self.ticker = ::std::option::Option::None; + self.icon_uri = ::std::option::Option::None; + self.additional_metadata_uri = ::std::option::Option::None; + self.media_uri = ::std::option::Option::None; + self.media_hash = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerIssueNftTxOutput { + static instance: MintlayerIssueNftTxOutput = MintlayerIssueNftTxOutput { + token_id: ::std::option::Option::None, + destination: ::std::option::Option::None, + creator: ::std::option::Option::None, + name: ::std::option::Option::None, + description: ::std::option::Option::None, + ticker: ::std::option::Option::None, + icon_uri: ::std::option::Option::None, + additional_metadata_uri: ::std::option::Option::None, + media_uri: ::std::option::Option::None, + media_hash: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerIssueNftTxOutput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerIssueNftTxOutput").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerIssueNftTxOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerIssueNftTxOutput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerDataDepositTxOutput) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerDataDepositTxOutput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerDataDepositTxOutput.data) + pub data: ::std::option::Option<::std::vec::Vec>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerDataDepositTxOutput.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerDataDepositTxOutput { + fn default() -> &'a MintlayerDataDepositTxOutput { + ::default_instance() + } +} + +impl MintlayerDataDepositTxOutput { + pub fn new() -> MintlayerDataDepositTxOutput { + ::std::default::Default::default() + } + + // required bytes data = 1; + + pub fn data(&self) -> &[u8] { + match self.data.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_data(&mut self) { + self.data = ::std::option::Option::None; + } + + pub fn has_data(&self) -> bool { + self.data.is_some() + } + + // Param is passed by value, moved + pub fn set_data(&mut self, v: ::std::vec::Vec) { + self.data = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_data(&mut self) -> &mut ::std::vec::Vec { + if self.data.is_none() { + self.data = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.data.as_mut().unwrap() + } + + // Take field + pub fn take_data(&mut self) -> ::std::vec::Vec { + self.data.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(1); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "data", + |m: &MintlayerDataDepositTxOutput| { &m.data }, + |m: &mut MintlayerDataDepositTxOutput| { &mut m.data }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerDataDepositTxOutput", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerDataDepositTxOutput { + const NAME: &'static str = "MintlayerDataDepositTxOutput"; + + fn is_initialized(&self) -> bool { + if self.data.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.data = ::std::option::Option::Some(is.read_bytes()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.data.as_ref() { + my_size += ::protobuf::rt::bytes_size(1, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.data.as_ref() { + os.write_bytes(1, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerDataDepositTxOutput { + MintlayerDataDepositTxOutput::new() + } + + fn clear(&mut self) { + self.data = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerDataDepositTxOutput { + static instance: MintlayerDataDepositTxOutput = MintlayerDataDepositTxOutput { + data: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerDataDepositTxOutput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerDataDepositTxOutput").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerDataDepositTxOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerDataDepositTxOutput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerHtlcTxOutput) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerHtlcTxOutput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerHtlcTxOutput.value) + pub value: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerHtlcTxOutput.secret_hash) + pub secret_hash: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerHtlcTxOutput.spend_key) + pub spend_key: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerHtlcTxOutput.refund_timelock) + pub refund_timelock: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerHtlcTxOutput.refund_key) + pub refund_key: ::std::option::Option<::std::string::String>, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerHtlcTxOutput.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerHtlcTxOutput { + fn default() -> &'a MintlayerHtlcTxOutput { + ::default_instance() + } +} + +impl MintlayerHtlcTxOutput { + pub fn new() -> MintlayerHtlcTxOutput { + ::std::default::Default::default() + } + + // required bytes secret_hash = 2; + + pub fn secret_hash(&self) -> &[u8] { + match self.secret_hash.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_secret_hash(&mut self) { + self.secret_hash = ::std::option::Option::None; + } + + pub fn has_secret_hash(&self) -> bool { + self.secret_hash.is_some() + } + + // Param is passed by value, moved + pub fn set_secret_hash(&mut self, v: ::std::vec::Vec) { + self.secret_hash = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_secret_hash(&mut self) -> &mut ::std::vec::Vec { + if self.secret_hash.is_none() { + self.secret_hash = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.secret_hash.as_mut().unwrap() + } + + // Take field + pub fn take_secret_hash(&mut self) -> ::std::vec::Vec { + self.secret_hash.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // required string spend_key = 3; + + pub fn spend_key(&self) -> &str { + match self.spend_key.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_spend_key(&mut self) { + self.spend_key = ::std::option::Option::None; + } + + pub fn has_spend_key(&self) -> bool { + self.spend_key.is_some() + } + + // Param is passed by value, moved + pub fn set_spend_key(&mut self, v: ::std::string::String) { + self.spend_key = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_spend_key(&mut self) -> &mut ::std::string::String { + if self.spend_key.is_none() { + self.spend_key = ::std::option::Option::Some(::std::string::String::new()); + } + self.spend_key.as_mut().unwrap() + } + + // Take field + pub fn take_spend_key(&mut self) -> ::std::string::String { + self.spend_key.take().unwrap_or_else(|| ::std::string::String::new()) + } + + // required string refund_key = 5; + + pub fn refund_key(&self) -> &str { + match self.refund_key.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_refund_key(&mut self) { + self.refund_key = ::std::option::Option::None; + } + + pub fn has_refund_key(&self) -> bool { + self.refund_key.is_some() + } + + // Param is passed by value, moved + pub fn set_refund_key(&mut self, v: ::std::string::String) { + self.refund_key = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_refund_key(&mut self) -> &mut ::std::string::String { + if self.refund_key.is_none() { + self.refund_key = ::std::option::Option::Some(::std::string::String::new()); + } + self.refund_key.as_mut().unwrap() + } + + // Take field + pub fn take_refund_key(&mut self) -> ::std::string::String { + self.refund_key.take().unwrap_or_else(|| ::std::string::String::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(5); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerOutputValue>( + "value", + |m: &MintlayerHtlcTxOutput| { &m.value }, + |m: &mut MintlayerHtlcTxOutput| { &mut m.value }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "secret_hash", + |m: &MintlayerHtlcTxOutput| { &m.secret_hash }, + |m: &mut MintlayerHtlcTxOutput| { &mut m.secret_hash }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "spend_key", + |m: &MintlayerHtlcTxOutput| { &m.spend_key }, + |m: &mut MintlayerHtlcTxOutput| { &mut m.spend_key }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerOutputTimeLock>( + "refund_timelock", + |m: &MintlayerHtlcTxOutput| { &m.refund_timelock }, + |m: &mut MintlayerHtlcTxOutput| { &mut m.refund_timelock }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "refund_key", + |m: &MintlayerHtlcTxOutput| { &m.refund_key }, + |m: &mut MintlayerHtlcTxOutput| { &mut m.refund_key }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerHtlcTxOutput", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerHtlcTxOutput { + const NAME: &'static str = "MintlayerHtlcTxOutput"; + + fn is_initialized(&self) -> bool { + if self.value.is_none() { + return false; + } + if self.secret_hash.is_none() { + return false; + } + if self.spend_key.is_none() { + return false; + } + if self.refund_timelock.is_none() { + return false; + } + if self.refund_key.is_none() { + return false; + } + for v in &self.value { + if !v.is_initialized() { + return false; + } + }; + for v in &self.refund_timelock { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.value)?; + }, + 18 => { + self.secret_hash = ::std::option::Option::Some(is.read_bytes()?); + }, + 26 => { + self.spend_key = ::std::option::Option::Some(is.read_string()?); + }, + 34 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.refund_timelock)?; + }, + 42 => { + self.refund_key = ::std::option::Option::Some(is.read_string()?); + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.value.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.secret_hash.as_ref() { + my_size += ::protobuf::rt::bytes_size(2, &v); + } + if let Some(v) = self.spend_key.as_ref() { + my_size += ::protobuf::rt::string_size(3, &v); + } + if let Some(v) = self.refund_timelock.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.refund_key.as_ref() { + my_size += ::protobuf::rt::string_size(5, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.value.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(1, v, os)?; + } + if let Some(v) = self.secret_hash.as_ref() { + os.write_bytes(2, v)?; + } + if let Some(v) = self.spend_key.as_ref() { + os.write_string(3, v)?; + } + if let Some(v) = self.refund_timelock.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(4, v, os)?; + } + if let Some(v) = self.refund_key.as_ref() { + os.write_string(5, v)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerHtlcTxOutput { + MintlayerHtlcTxOutput::new() + } + + fn clear(&mut self) { + self.value.clear(); + self.secret_hash = ::std::option::Option::None; + self.spend_key = ::std::option::Option::None; + self.refund_timelock.clear(); + self.refund_key = ::std::option::Option::None; + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerHtlcTxOutput { + static instance: MintlayerHtlcTxOutput = MintlayerHtlcTxOutput { + value: ::protobuf::MessageField::none(), + secret_hash: ::std::option::Option::None, + spend_key: ::std::option::Option::None, + refund_timelock: ::protobuf::MessageField::none(), + refund_key: ::std::option::Option::None, + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerHtlcTxOutput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerHtlcTxOutput").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerHtlcTxOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerHtlcTxOutput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerCreateOrderTxOutput) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerCreateOrderTxOutput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerCreateOrderTxOutput.conclude_key) + pub conclude_key: ::std::option::Option<::std::string::String>, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerCreateOrderTxOutput.ask) + pub ask: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerCreateOrderTxOutput.give) + pub give: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerCreateOrderTxOutput.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerCreateOrderTxOutput { + fn default() -> &'a MintlayerCreateOrderTxOutput { + ::default_instance() + } +} + +impl MintlayerCreateOrderTxOutput { + pub fn new() -> MintlayerCreateOrderTxOutput { + ::std::default::Default::default() + } + + // required string conclude_key = 1; + + pub fn conclude_key(&self) -> &str { + match self.conclude_key.as_ref() { + Some(v) => v, + None => "", + } + } + + pub fn clear_conclude_key(&mut self) { + self.conclude_key = ::std::option::Option::None; + } + + pub fn has_conclude_key(&self) -> bool { + self.conclude_key.is_some() + } + + // Param is passed by value, moved + pub fn set_conclude_key(&mut self, v: ::std::string::String) { + self.conclude_key = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_conclude_key(&mut self) -> &mut ::std::string::String { + if self.conclude_key.is_none() { + self.conclude_key = ::std::option::Option::Some(::std::string::String::new()); + } + self.conclude_key.as_mut().unwrap() + } + + // Take field + pub fn take_conclude_key(&mut self) -> ::std::string::String { + self.conclude_key.take().unwrap_or_else(|| ::std::string::String::new()) + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(3); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "conclude_key", + |m: &MintlayerCreateOrderTxOutput| { &m.conclude_key }, + |m: &mut MintlayerCreateOrderTxOutput| { &mut m.conclude_key }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerOutputValue>( + "ask", + |m: &MintlayerCreateOrderTxOutput| { &m.ask }, + |m: &mut MintlayerCreateOrderTxOutput| { &mut m.ask }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, MintlayerOutputValue>( + "give", + |m: &MintlayerCreateOrderTxOutput| { &m.give }, + |m: &mut MintlayerCreateOrderTxOutput| { &mut m.give }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerCreateOrderTxOutput", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerCreateOrderTxOutput { + const NAME: &'static str = "MintlayerCreateOrderTxOutput"; + + fn is_initialized(&self) -> bool { + if self.conclude_key.is_none() { + return false; + } + if self.ask.is_none() { + return false; + } + if self.give.is_none() { + return false; + } + for v in &self.ask { + if !v.is_initialized() { + return false; + } + }; + for v in &self.give { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + self.conclude_key = ::std::option::Option::Some(is.read_string()?); + }, + 18 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.ask)?; + }, + 26 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.give)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.conclude_key.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.ask.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.give.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.conclude_key.as_ref() { + os.write_string(1, v)?; + } + if let Some(v) = self.ask.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(2, v, os)?; + } + if let Some(v) = self.give.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(3, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerCreateOrderTxOutput { + MintlayerCreateOrderTxOutput::new() + } + + fn clear(&mut self) { + self.conclude_key = ::std::option::Option::None; + self.ask.clear(); + self.give.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerCreateOrderTxOutput { + static instance: MintlayerCreateOrderTxOutput = MintlayerCreateOrderTxOutput { + conclude_key: ::std::option::Option::None, + ask: ::protobuf::MessageField::none(), + give: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerCreateOrderTxOutput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerCreateOrderTxOutput").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerCreateOrderTxOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerCreateOrderTxOutput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +// @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerTxAck) +#[derive(PartialEq,Clone,Default,Debug)] +pub struct MintlayerTxAck { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxAck.input) + pub input: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxAck.output) + pub output: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerTxAck.special_fields) + pub special_fields: ::protobuf::SpecialFields, +} + +impl<'a> ::std::default::Default for &'a MintlayerTxAck { + fn default() -> &'a MintlayerTxAck { + ::default_instance() + } +} + +impl MintlayerTxAck { + pub fn new() -> MintlayerTxAck { + ::std::default::Default::default() + } + + fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(2); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, mintlayer_tx_ack::MintlayerTxInput>( + "input", + |m: &MintlayerTxAck| { &m.input }, + |m: &mut MintlayerTxAck| { &mut m.input }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, mintlayer_tx_ack::MintlayerTxOutput>( + "output", + |m: &MintlayerTxAck| { &m.output }, + |m: &mut MintlayerTxAck| { &mut m.output }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerTxAck", + fields, + oneofs, + ) + } +} + +impl ::protobuf::Message for MintlayerTxAck { + const NAME: &'static str = "MintlayerTxAck"; + + fn is_initialized(&self) -> bool { + for v in &self.input { + if !v.is_initialized() { + return false; + } + }; + for v in &self.output { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.input)?; + }, + 18 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.output)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.input.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.output.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.input.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(1, v, os)?; + } + if let Some(v) = self.output.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(2, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerTxAck { + MintlayerTxAck::new() + } + + fn clear(&mut self) { + self.input.clear(); + self.output.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerTxAck { + static instance: MintlayerTxAck = MintlayerTxAck { + input: ::protobuf::MessageField::none(), + output: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } +} + +impl ::protobuf::MessageFull for MintlayerTxAck { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().message_by_package_relative_name("MintlayerTxAck").unwrap()).clone() + } +} + +impl ::std::fmt::Display for MintlayerTxAck { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MintlayerTxAck { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; +} + +/// Nested message and enums of message `MintlayerTxAck` +pub mod mintlayer_tx_ack { + // @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxInput) + #[derive(PartialEq,Clone,Default,Debug)] + pub struct MintlayerTxInput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxInput.utxo) + pub utxo: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxInput.account) + pub account: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxInput.account_command) + pub account_command: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxInput.special_fields) + pub special_fields: ::protobuf::SpecialFields, + } + + impl<'a> ::std::default::Default for &'a MintlayerTxInput { + fn default() -> &'a MintlayerTxInput { + ::default_instance() + } + } + + impl MintlayerTxInput { + pub fn new() -> MintlayerTxInput { + ::std::default::Default::default() + } + + pub(in super) fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(3); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, super::MintlayerUtxoTxInput>( + "utxo", + |m: &MintlayerTxInput| { &m.utxo }, + |m: &mut MintlayerTxInput| { &mut m.utxo }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, super::MintlayerAccountTxInput>( + "account", + |m: &MintlayerTxInput| { &m.account }, + |m: &mut MintlayerTxInput| { &mut m.account }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, super::MintlayerAccountCommandTxInput>( + "account_command", + |m: &MintlayerTxInput| { &m.account_command }, + |m: &mut MintlayerTxInput| { &mut m.account_command }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerTxAck.MintlayerTxInput", + fields, + oneofs, + ) + } + } + + impl ::protobuf::Message for MintlayerTxInput { + const NAME: &'static str = "MintlayerTxInput"; + + fn is_initialized(&self) -> bool { + for v in &self.utxo { + if !v.is_initialized() { + return false; + } + }; + for v in &self.account { + if !v.is_initialized() { + return false; + } + }; + for v in &self.account_command { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.utxo)?; + }, + 18 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.account)?; + }, + 26 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.account_command)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.utxo.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.account.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.account_command.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.utxo.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(1, v, os)?; + } + if let Some(v) = self.account.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(2, v, os)?; + } + if let Some(v) = self.account_command.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(3, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerTxInput { + MintlayerTxInput::new() + } + + fn clear(&mut self) { + self.utxo.clear(); + self.account.clear(); + self.account_command.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerTxInput { + static instance: MintlayerTxInput = MintlayerTxInput { + utxo: ::protobuf::MessageField::none(), + account: ::protobuf::MessageField::none(), + account_command: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } + } + + impl ::protobuf::MessageFull for MintlayerTxInput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| super::file_descriptor().message_by_package_relative_name("MintlayerTxAck.MintlayerTxInput").unwrap()).clone() + } + } + + impl ::std::fmt::Display for MintlayerTxInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } + } + + impl ::protobuf::reflect::ProtobufValue for MintlayerTxInput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; + } + + // @@protoc_insertion_point(message:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxOutput) + #[derive(PartialEq,Clone,Default,Debug)] + pub struct MintlayerTxOutput { + // message fields + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxOutput.transfer) + pub transfer: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxOutput.lock_then_transfer) + pub lock_then_transfer: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxOutput.burn) + pub burn: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxOutput.create_stake_pool) + pub create_stake_pool: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxOutput.produce_block_from_stake) + pub produce_block_from_stake: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxOutput.create_delegation_id) + pub create_delegation_id: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxOutput.delegate_staking) + pub delegate_staking: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxOutput.issue_fungible_token) + pub issue_fungible_token: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxOutput.issue_nft) + pub issue_nft: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxOutput.data_deposit) + pub data_deposit: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxOutput.htlc) + pub htlc: ::protobuf::MessageField, + // @@protoc_insertion_point(field:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxOutput.create_order) + pub create_order: ::protobuf::MessageField, + // special fields + // @@protoc_insertion_point(special_field:hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxOutput.special_fields) + pub special_fields: ::protobuf::SpecialFields, + } + + impl<'a> ::std::default::Default for &'a MintlayerTxOutput { + fn default() -> &'a MintlayerTxOutput { + ::default_instance() + } + } + + impl MintlayerTxOutput { + pub fn new() -> MintlayerTxOutput { + ::std::default::Default::default() + } + + pub(in super) fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { + let mut fields = ::std::vec::Vec::with_capacity(12); + let mut oneofs = ::std::vec::Vec::with_capacity(0); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, super::MintlayerTransferTxOutput>( + "transfer", + |m: &MintlayerTxOutput| { &m.transfer }, + |m: &mut MintlayerTxOutput| { &mut m.transfer }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, super::MintlayerLockThenTransferTxOutput>( + "lock_then_transfer", + |m: &MintlayerTxOutput| { &m.lock_then_transfer }, + |m: &mut MintlayerTxOutput| { &mut m.lock_then_transfer }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, super::MintlayerBurnTxOutput>( + "burn", + |m: &MintlayerTxOutput| { &m.burn }, + |m: &mut MintlayerTxOutput| { &mut m.burn }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, super::MintlayerCreateStakePoolTxOutput>( + "create_stake_pool", + |m: &MintlayerTxOutput| { &m.create_stake_pool }, + |m: &mut MintlayerTxOutput| { &mut m.create_stake_pool }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, super::MintlayerProduceBlockFromStakeTxOutput>( + "produce_block_from_stake", + |m: &MintlayerTxOutput| { &m.produce_block_from_stake }, + |m: &mut MintlayerTxOutput| { &mut m.produce_block_from_stake }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, super::MintlayerCreateDelegationIdTxOutput>( + "create_delegation_id", + |m: &MintlayerTxOutput| { &m.create_delegation_id }, + |m: &mut MintlayerTxOutput| { &mut m.create_delegation_id }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, super::MintlayerDelegateStakingTxOutput>( + "delegate_staking", + |m: &MintlayerTxOutput| { &m.delegate_staking }, + |m: &mut MintlayerTxOutput| { &mut m.delegate_staking }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, super::MintlayerIssueFungibleTokenTxOutput>( + "issue_fungible_token", + |m: &MintlayerTxOutput| { &m.issue_fungible_token }, + |m: &mut MintlayerTxOutput| { &mut m.issue_fungible_token }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, super::MintlayerIssueNftTxOutput>( + "issue_nft", + |m: &MintlayerTxOutput| { &m.issue_nft }, + |m: &mut MintlayerTxOutput| { &mut m.issue_nft }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, super::MintlayerDataDepositTxOutput>( + "data_deposit", + |m: &MintlayerTxOutput| { &m.data_deposit }, + |m: &mut MintlayerTxOutput| { &mut m.data_deposit }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, super::MintlayerHtlcTxOutput>( + "htlc", + |m: &MintlayerTxOutput| { &m.htlc }, + |m: &mut MintlayerTxOutput| { &mut m.htlc }, + )); + fields.push(::protobuf::reflect::rt::v2::make_message_field_accessor::<_, super::MintlayerCreateOrderTxOutput>( + "create_order", + |m: &MintlayerTxOutput| { &m.create_order }, + |m: &mut MintlayerTxOutput| { &mut m.create_order }, + )); + ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( + "MintlayerTxAck.MintlayerTxOutput", + fields, + oneofs, + ) + } + } + + impl ::protobuf::Message for MintlayerTxOutput { + const NAME: &'static str = "MintlayerTxOutput"; + + fn is_initialized(&self) -> bool { + for v in &self.transfer { + if !v.is_initialized() { + return false; + } + }; + for v in &self.lock_then_transfer { + if !v.is_initialized() { + return false; + } + }; + for v in &self.burn { + if !v.is_initialized() { + return false; + } + }; + for v in &self.create_stake_pool { + if !v.is_initialized() { + return false; + } + }; + for v in &self.produce_block_from_stake { + if !v.is_initialized() { + return false; + } + }; + for v in &self.create_delegation_id { + if !v.is_initialized() { + return false; + } + }; + for v in &self.delegate_staking { + if !v.is_initialized() { + return false; + } + }; + for v in &self.issue_fungible_token { + if !v.is_initialized() { + return false; + } + }; + for v in &self.issue_nft { + if !v.is_initialized() { + return false; + } + }; + for v in &self.data_deposit { + if !v.is_initialized() { + return false; + } + }; + for v in &self.htlc { + if !v.is_initialized() { + return false; + } + }; + for v in &self.create_order { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::Result<()> { + while let Some(tag) = is.read_raw_tag_or_eof()? { + match tag { + 10 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.transfer)?; + }, + 18 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.lock_then_transfer)?; + }, + 26 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.burn)?; + }, + 34 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.create_stake_pool)?; + }, + 42 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.produce_block_from_stake)?; + }, + 50 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.create_delegation_id)?; + }, + 58 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.delegate_staking)?; + }, + 66 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.issue_fungible_token)?; + }, + 74 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.issue_nft)?; + }, + 82 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.data_deposit)?; + }, + 90 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.htlc)?; + }, + 98 => { + ::protobuf::rt::read_singular_message_into_field(is, &mut self.create_order)?; + }, + tag => { + ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u64 { + let mut my_size = 0; + if let Some(v) = self.transfer.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.lock_then_transfer.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.burn.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.create_stake_pool.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.produce_block_from_stake.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.create_delegation_id.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.delegate_staking.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.issue_fungible_token.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.issue_nft.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.data_deposit.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.htlc.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + if let Some(v) = self.create_order.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint64_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); + self.special_fields.cached_size().set(my_size as u32); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::Result<()> { + if let Some(v) = self.transfer.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(1, v, os)?; + } + if let Some(v) = self.lock_then_transfer.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(2, v, os)?; + } + if let Some(v) = self.burn.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(3, v, os)?; + } + if let Some(v) = self.create_stake_pool.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(4, v, os)?; + } + if let Some(v) = self.produce_block_from_stake.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(5, v, os)?; + } + if let Some(v) = self.create_delegation_id.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(6, v, os)?; + } + if let Some(v) = self.delegate_staking.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(7, v, os)?; + } + if let Some(v) = self.issue_fungible_token.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(8, v, os)?; + } + if let Some(v) = self.issue_nft.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(9, v, os)?; + } + if let Some(v) = self.data_deposit.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(10, v, os)?; + } + if let Some(v) = self.htlc.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(11, v, os)?; + } + if let Some(v) = self.create_order.as_ref() { + ::protobuf::rt::write_message_field_with_cached_size(12, v, os)?; + } + os.write_unknown_fields(self.special_fields.unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn special_fields(&self) -> &::protobuf::SpecialFields { + &self.special_fields + } + + fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields { + &mut self.special_fields + } + + fn new() -> MintlayerTxOutput { + MintlayerTxOutput::new() + } + + fn clear(&mut self) { + self.transfer.clear(); + self.lock_then_transfer.clear(); + self.burn.clear(); + self.create_stake_pool.clear(); + self.produce_block_from_stake.clear(); + self.create_delegation_id.clear(); + self.delegate_staking.clear(); + self.issue_fungible_token.clear(); + self.issue_nft.clear(); + self.data_deposit.clear(); + self.htlc.clear(); + self.create_order.clear(); + self.special_fields.clear(); + } + + fn default_instance() -> &'static MintlayerTxOutput { + static instance: MintlayerTxOutput = MintlayerTxOutput { + transfer: ::protobuf::MessageField::none(), + lock_then_transfer: ::protobuf::MessageField::none(), + burn: ::protobuf::MessageField::none(), + create_stake_pool: ::protobuf::MessageField::none(), + produce_block_from_stake: ::protobuf::MessageField::none(), + create_delegation_id: ::protobuf::MessageField::none(), + delegate_staking: ::protobuf::MessageField::none(), + issue_fungible_token: ::protobuf::MessageField::none(), + issue_nft: ::protobuf::MessageField::none(), + data_deposit: ::protobuf::MessageField::none(), + htlc: ::protobuf::MessageField::none(), + create_order: ::protobuf::MessageField::none(), + special_fields: ::protobuf::SpecialFields::new(), + }; + &instance + } + } + + impl ::protobuf::MessageFull for MintlayerTxOutput { + fn descriptor() -> ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| super::file_descriptor().message_by_package_relative_name("MintlayerTxAck.MintlayerTxOutput").unwrap()).clone() + } + } + + impl ::std::fmt::Display for MintlayerTxOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } + } + + impl ::protobuf::reflect::ProtobufValue for MintlayerTxOutput { + type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage; + } +} + +#[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)] +// @@protoc_insertion_point(enum:hw.trezor.messages.mintlayer.MintlayerChainType) +pub enum MintlayerChainType { + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerChainType.Mainnet) + Mainnet = 1, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerChainType.Testnet) + Testnet = 2, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerChainType.Regtest) + Regtest = 3, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerChainType.Signet) + Signet = 4, +} + +impl ::protobuf::Enum for MintlayerChainType { + const NAME: &'static str = "MintlayerChainType"; + + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 1 => ::std::option::Option::Some(MintlayerChainType::Mainnet), + 2 => ::std::option::Option::Some(MintlayerChainType::Testnet), + 3 => ::std::option::Option::Some(MintlayerChainType::Regtest), + 4 => ::std::option::Option::Some(MintlayerChainType::Signet), + _ => ::std::option::Option::None + } + } + + fn from_str(str: &str) -> ::std::option::Option { + match str { + "Mainnet" => ::std::option::Option::Some(MintlayerChainType::Mainnet), + "Testnet" => ::std::option::Option::Some(MintlayerChainType::Testnet), + "Regtest" => ::std::option::Option::Some(MintlayerChainType::Regtest), + "Signet" => ::std::option::Option::Some(MintlayerChainType::Signet), + _ => ::std::option::Option::None + } + } + + const VALUES: &'static [MintlayerChainType] = &[ + MintlayerChainType::Mainnet, + MintlayerChainType::Testnet, + MintlayerChainType::Regtest, + MintlayerChainType::Signet, + ]; +} + +impl ::protobuf::EnumFull for MintlayerChainType { + fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().enum_by_package_relative_name("MintlayerChainType").unwrap()).clone() + } + + fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor { + let index = match self { + MintlayerChainType::Mainnet => 0, + MintlayerChainType::Testnet => 1, + MintlayerChainType::Regtest => 2, + MintlayerChainType::Signet => 3, + }; + Self::enum_descriptor().value_by_index(index) + } +} + +// Note, `Default` is implemented although default value is not 0 +impl ::std::default::Default for MintlayerChainType { + fn default() -> Self { + MintlayerChainType::Mainnet + } +} + +impl MintlayerChainType { + fn generated_enum_descriptor_data() -> ::protobuf::reflect::GeneratedEnumDescriptorData { + ::protobuf::reflect::GeneratedEnumDescriptorData::new::("MintlayerChainType") + } +} + +#[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)] +// @@protoc_insertion_point(enum:hw.trezor.messages.mintlayer.MintlayerAddressType) +pub enum MintlayerAddressType { + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerAddressType.PUBLIC_KEY) + PUBLIC_KEY = 1, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerAddressType.PUBLIC_KEY_HASH) + PUBLIC_KEY_HASH = 2, +} + +impl ::protobuf::Enum for MintlayerAddressType { + const NAME: &'static str = "MintlayerAddressType"; + + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 1 => ::std::option::Option::Some(MintlayerAddressType::PUBLIC_KEY), + 2 => ::std::option::Option::Some(MintlayerAddressType::PUBLIC_KEY_HASH), + _ => ::std::option::Option::None + } + } + + fn from_str(str: &str) -> ::std::option::Option { + match str { + "PUBLIC_KEY" => ::std::option::Option::Some(MintlayerAddressType::PUBLIC_KEY), + "PUBLIC_KEY_HASH" => ::std::option::Option::Some(MintlayerAddressType::PUBLIC_KEY_HASH), + _ => ::std::option::Option::None + } + } + + const VALUES: &'static [MintlayerAddressType] = &[ + MintlayerAddressType::PUBLIC_KEY, + MintlayerAddressType::PUBLIC_KEY_HASH, + ]; +} + +impl ::protobuf::EnumFull for MintlayerAddressType { + fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().enum_by_package_relative_name("MintlayerAddressType").unwrap()).clone() + } + + fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor { + let index = match self { + MintlayerAddressType::PUBLIC_KEY => 0, + MintlayerAddressType::PUBLIC_KEY_HASH => 1, + }; + Self::enum_descriptor().value_by_index(index) + } +} + +// Note, `Default` is implemented although default value is not 0 +impl ::std::default::Default for MintlayerAddressType { + fn default() -> Self { + MintlayerAddressType::PUBLIC_KEY + } +} + +impl MintlayerAddressType { + fn generated_enum_descriptor_data() -> ::protobuf::reflect::GeneratedEnumDescriptorData { + ::protobuf::reflect::GeneratedEnumDescriptorData::new::("MintlayerAddressType") + } +} + +#[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)] +// @@protoc_insertion_point(enum:hw.trezor.messages.mintlayer.MintlayerUtxoType) +pub enum MintlayerUtxoType { + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerUtxoType.TRANSACTION) + TRANSACTION = 0, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerUtxoType.BLOCK) + BLOCK = 1, +} + +impl ::protobuf::Enum for MintlayerUtxoType { + const NAME: &'static str = "MintlayerUtxoType"; + + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 0 => ::std::option::Option::Some(MintlayerUtxoType::TRANSACTION), + 1 => ::std::option::Option::Some(MintlayerUtxoType::BLOCK), + _ => ::std::option::Option::None + } + } + + fn from_str(str: &str) -> ::std::option::Option { + match str { + "TRANSACTION" => ::std::option::Option::Some(MintlayerUtxoType::TRANSACTION), + "BLOCK" => ::std::option::Option::Some(MintlayerUtxoType::BLOCK), + _ => ::std::option::Option::None + } + } + + const VALUES: &'static [MintlayerUtxoType] = &[ + MintlayerUtxoType::TRANSACTION, + MintlayerUtxoType::BLOCK, + ]; +} + +impl ::protobuf::EnumFull for MintlayerUtxoType { + fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().enum_by_package_relative_name("MintlayerUtxoType").unwrap()).clone() + } + + fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor { + let index = *self as usize; + Self::enum_descriptor().value_by_index(index) + } +} + +impl ::std::default::Default for MintlayerUtxoType { + fn default() -> Self { + MintlayerUtxoType::TRANSACTION + } +} + +impl MintlayerUtxoType { + fn generated_enum_descriptor_data() -> ::protobuf::reflect::GeneratedEnumDescriptorData { + ::protobuf::reflect::GeneratedEnumDescriptorData::new::("MintlayerUtxoType") + } +} + +#[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)] +// @@protoc_insertion_point(enum:hw.trezor.messages.mintlayer.MintlayerTokenTotalSupplyType) +pub enum MintlayerTokenTotalSupplyType { + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerTokenTotalSupplyType.FIXED) + FIXED = 0, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerTokenTotalSupplyType.LOCKABLE) + LOCKABLE = 1, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerTokenTotalSupplyType.UNLIMITED) + UNLIMITED = 2, +} + +impl ::protobuf::Enum for MintlayerTokenTotalSupplyType { + const NAME: &'static str = "MintlayerTokenTotalSupplyType"; + + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 0 => ::std::option::Option::Some(MintlayerTokenTotalSupplyType::FIXED), + 1 => ::std::option::Option::Some(MintlayerTokenTotalSupplyType::LOCKABLE), + 2 => ::std::option::Option::Some(MintlayerTokenTotalSupplyType::UNLIMITED), + _ => ::std::option::Option::None + } + } + + fn from_str(str: &str) -> ::std::option::Option { + match str { + "FIXED" => ::std::option::Option::Some(MintlayerTokenTotalSupplyType::FIXED), + "LOCKABLE" => ::std::option::Option::Some(MintlayerTokenTotalSupplyType::LOCKABLE), + "UNLIMITED" => ::std::option::Option::Some(MintlayerTokenTotalSupplyType::UNLIMITED), + _ => ::std::option::Option::None + } + } + + const VALUES: &'static [MintlayerTokenTotalSupplyType] = &[ + MintlayerTokenTotalSupplyType::FIXED, + MintlayerTokenTotalSupplyType::LOCKABLE, + MintlayerTokenTotalSupplyType::UNLIMITED, + ]; +} + +impl ::protobuf::EnumFull for MintlayerTokenTotalSupplyType { + fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().enum_by_package_relative_name("MintlayerTokenTotalSupplyType").unwrap()).clone() + } + + fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor { + let index = *self as usize; + Self::enum_descriptor().value_by_index(index) + } +} + +impl ::std::default::Default for MintlayerTokenTotalSupplyType { + fn default() -> Self { + MintlayerTokenTotalSupplyType::FIXED + } +} + +impl MintlayerTokenTotalSupplyType { + fn generated_enum_descriptor_data() -> ::protobuf::reflect::GeneratedEnumDescriptorData { + ::protobuf::reflect::GeneratedEnumDescriptorData::new::("MintlayerTokenTotalSupplyType") + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\x18messages-mintlayer.proto\x12\x1chw.trezor.messages.mintlayer\"\xc2\ + \x01\n\x13MintlayerGetAddress\x12\x1b\n\taddress_n\x18\x01\x20\x03(\rR\ + \x08addressN\x12O\n\nchain_type\x18\x02\x20\x02(\x0e20.hw.trezor.message\ + s.mintlayer.MintlayerChainTypeR\tchainType\x12!\n\x0cshow_display\x18\ + \x03\x20\x01(\x08R\x0bshowDisplay\x12\x1a\n\x08chunkify\x18\x04\x20\x01(\ + \x08R\x08chunkify\",\n\x10MintlayerAddress\x12\x18\n\x07address\x18\x01\ + \x20\x02(\tR\x07address\"\xa8\x01\n\x15MintlayerGetPublicKey\x12\x1b\n\t\ + address_n\x18\x01\x20\x03(\rR\x08addressN\x12O\n\nchain_type\x18\x02\x20\ + \x02(\x0e20.hw.trezor.messages.mintlayer.MintlayerChainTypeR\tchainType\ + \x12!\n\x0cshow_display\x18\x03\x20\x01(\x08R\x0bshowDisplay\"R\n\x12Min\ + tlayerPublicKey\x12\x1d\n\npublic_key\x18\x01\x20\x02(\x0cR\tpublicKey\ + \x12\x1d\n\nchain_code\x18\x02\x20\x02(\x0cR\tchainCode\"\xf5\x01\n\x14M\ + intlayerSignMessage\x12\x1b\n\taddress_n\x18\x01\x20\x03(\rR\x08addressN\ + \x12O\n\nchain_type\x18\x02\x20\x02(\x0e20.hw.trezor.messages.mintlayer.\ + MintlayerChainTypeR\tchainType\x12U\n\x0caddress_type\x18\x03\x20\x02(\ + \x0e22.hw.trezor.messages.mintlayer.MintlayerAddressTypeR\x0baddressType\ + \x12\x18\n\x07message\x18\x04\x20\x02(\x0cR\x07message\"\xe3\x01\n\x0fMi\ + ntlayerSignTx\x12#\n\routputs_count\x18\x01\x20\x02(\rR\x0coutputsCount\ + \x12!\n\x0cinputs_count\x18\x02\x20\x02(\rR\x0binputsCount\x12O\n\nchain\ + _type\x18\x03\x20\x02(\x0e20.hw.trezor.messages.mintlayer.MintlayerChain\ + TypeR\tchainType\x12\x1b\n\x07version\x18\x04\x20\x01(\r:\x011R\x07versi\ + on\x12\x1a\n\x08chunkify\x18\x05\x20\x01(\x08R\x08chunkify\"\x87\x07\n\ + \x12MintlayerTxRequest\x12m\n\rinput_request\x18\x01\x20\x01(\x0b2H.hw.t\ + rezor.messages.mintlayer.MintlayerTxRequest.MintlayerTxInputRequestR\x0c\ + inputRequest\x12p\n\x0eoutput_request\x18\x02\x20\x01(\x0b2I.hw.trezor.m\ + essages.mintlayer.MintlayerTxRequest.MintlayerTxOutputRequestR\routputRe\ + quest\x12t\n\x10signing_finished\x18\x03\x20\x01(\x0b2I.hw.trezor.messag\ + es.mintlayer.MintlayerTxRequest.MintlayerTxSigningResultR\x0fsigningFini\ + shed\x1a:\n\x17MintlayerTxInputRequest\x12\x1f\n\x0binput_index\x18\x01\ + \x20\x02(\rR\ninputIndex\x1aV\n\x18MintlayerTxOutputRequest\x12!\n\x0cou\ + tput_index\x18\x01\x20\x02(\rR\x0boutputIndex\x12\x17\n\x07tx_hash\x18\ + \x02\x20\x01(\x0cR\x06txHash\x1aU\n\x12MintlayerSignature\x12\x1c\n\tsig\ + nature\x18\x01\x20\x02(\x0cR\tsignature\x12!\n\x0cmultisig_idx\x18\x02\ + \x20\x01(\rR\x0bmultisigIdx\x1a\xa3\x01\n\x1bMintlayerSignaturesForInput\ + \x12\x1f\n\x0binput_index\x18\x01\x20\x02(\rR\ninputIndex\x12c\n\nsignat\ + ures\x18\x02\x20\x03(\x0b2C.hw.trezor.messages.mintlayer.MintlayerTxRequ\ + est.MintlayerSignatureR\nsignatures\x1a\x88\x01\n\x18MintlayerTxSigningR\ + esult\x12l\n\nsignatures\x18\x01\x20\x03(\x0b2L.hw.trezor.messages.mintl\ + ayer.MintlayerTxRequest.MintlayerSignaturesForInputR\nsignatures\"V\n\ + \x14MintlayerAddressPath\x12\x1b\n\taddress_n\x18\x01\x20\x03(\rR\x08add\ + ressN\x12!\n\x0cmultisig_idx\x18\x02\x20\x01(\rR\x0bmultisigIdx\"\xe9\ + \x01\n\x14MintlayerUtxoTxInput\x12P\n\taddresses\x18\x01\x20\x03(\x0b22.\ + hw.trezor.messages.mintlayer.MintlayerAddressPathR\taddresses\x12\x1b\n\ + \tprev_hash\x18\x02\x20\x02(\x0cR\x08prevHash\x12\x1d\n\nprev_index\x18\ + \x03\x20\x02(\rR\tprevIndex\x12C\n\x04type\x18\x04\x20\x02(\x0e2/.hw.tre\ + zor.messages.mintlayer.MintlayerUtxoTypeR\x04type\"\xf9\x01\n\x17Mintlay\ + erAccountTxInput\x12P\n\taddresses\x18\x01\x20\x03(\x0b22.hw.trezor.mess\ + ages.mintlayer.MintlayerAddressPathR\taddresses\x12\x14\n\x05nonce\x18\ + \x02\x20\x02(\x04R\x05nonce\x12v\n\x12delegation_balance\x18\x03\x20\x01\ + (\x0b2G.hw.trezor.messages.mintlayer.MintlayerAccountSpendingDelegationB\ + alanceR\x11delegationBalance\"h\n)MintlayerAccountSpendingDelegationBala\ + nce\x12#\n\rdelegation_id\x18\x01\x20\x02(\tR\x0cdelegationId\x12\x16\n\ + \x06amount\x18\x02\x20\x02(\x0cR\x06amount\"\xcf\x07\n\x1eMintlayerAccou\ + ntCommandTxInput\x12P\n\taddresses\x18\x01\x20\x03(\x0b22.hw.trezor.mess\ + ages.mintlayer.MintlayerAddressPathR\taddresses\x12\x14\n\x05nonce\x18\ + \x02\x20\x02(\x04R\x05nonce\x12E\n\x04mint\x18\x03\x20\x01(\x0b21.hw.tre\ + zor.messages.mintlayer.MintlayerMintTokensR\x04mint\x12K\n\x06unmint\x18\ + \x04\x20\x01(\x0b23.hw.trezor.messages.mintlayer.MintlayerUnmintTokensR\ + \x06unmint\x12b\n\x11lock_token_supply\x18\x05\x20\x01(\x0b26.hw.trezor.\ + messages.mintlayer.MintlayerLockTokenSupplyR\x0flockTokenSupply\x12U\n\ + \x0cfreeze_token\x18\x06\x20\x01(\x0b22.hw.trezor.messages.mintlayer.Min\ + tlayerFreezeTokenR\x0bfreezeToken\x12[\n\x0eunfreeze_token\x18\x07\x20\ + \x01(\x0b24.hw.trezor.messages.mintlayer.MintlayerUnfreezeTokenR\runfree\ + zeToken\x12q\n\x16change_token_authority\x18\x08\x20\x01(\x0b2;.hw.trezo\ + r.messages.mintlayer.MintlayerChangeTokenAuthorityR\x14changeTokenAuthor\ + ity\x12[\n\x0econclude_order\x18\t\x20\x01(\x0b24.hw.trezor.messages.min\ + tlayer.MintlayerConcludeOrderR\rconcludeOrder\x12O\n\nfill_order\x18\n\ + \x20\x01(\x0b20.hw.trezor.messages.mintlayer.MintlayerFillOrderR\tfillOr\ + der\x12x\n\x19change_token_metadata_uri\x18\x0b\x20\x01(\x0b2=.hw.trezor\ + .messages.mintlayer.MintlayerChangeTokenMetadataUriR\x16changeTokenMetad\ + ataUri\"H\n\x13MintlayerMintTokens\x12\x19\n\x08token_id\x18\x01\x20\x02\ + (\tR\x07tokenId\x12\x16\n\x06amount\x18\x02\x20\x02(\x0cR\x06amount\"2\n\ + \x15MintlayerUnmintTokens\x12\x19\n\x08token_id\x18\x01\x20\x02(\tR\x07t\ + okenId\"5\n\x18MintlayerLockTokenSupply\x12\x19\n\x08token_id\x18\x01\ + \x20\x02(\tR\x07tokenId\"c\n\x14MintlayerFreezeToken\x12\x19\n\x08token_\ + id\x18\x01\x20\x02(\tR\x07tokenId\x120\n\x14is_token_unfreezable\x18\x02\ + \x20\x02(\x08R\x12isTokenUnfreezable\"3\n\x16MintlayerUnfreezeToken\x12\ + \x19\n\x08token_id\x18\x01\x20\x02(\tR\x07tokenId\"\\\n\x1dMintlayerChan\ + geTokenAuthority\x12\x19\n\x08token_id\x18\x01\x20\x02(\tR\x07tokenId\ + \x12\x20\n\x0bdestination\x18\x02\x20\x02(\tR\x0bdestination\"\xea\x01\n\ + \x16MintlayerConcludeOrder\x12\x19\n\x08order_id\x18\x01\x20\x02(\tR\x07\ + orderId\x12^\n\x11filled_ask_amount\x18\x02\x20\x02(\x0b22.hw.trezor.mes\ + sages.mintlayer.MintlayerOutputValueR\x0ffilledAskAmount\x12U\n\x0cgive_\ + balance\x18\x03\x20\x02(\x0b22.hw.trezor.messages.mintlayer.MintlayerOut\ + putValueR\x0bgiveBalance\"\x95\x02\n\x12MintlayerFillOrder\x12\x19\n\x08\ + order_id\x18\x01\x20\x02(\tR\x07orderId\x12\x16\n\x06amount\x18\x02\x20\ + \x02(\x0cR\x06amount\x12\x20\n\x0bdestination\x18\x03\x20\x02(\tR\x0bdes\ + tination\x12S\n\x0bask_balance\x18\x04\x20\x02(\x0b22.hw.trezor.messages\ + .mintlayer.MintlayerOutputValueR\naskBalance\x12U\n\x0cgive_balance\x18\ + \x05\x20\x02(\x0b22.hw.trezor.messages.mintlayer.MintlayerOutputValueR\ + \x0bgiveBalance\"_\n\x1fMintlayerChangeTokenMetadataUri\x12\x19\n\x08tok\ + en_id\x18\x01\x20\x02(\tR\x07tokenId\x12!\n\x0cmetadata_uri\x18\x02\x20\ + \x02(\x0cR\x0bmetadataUri\"\x87\x01\n\x19MintlayerTokenOutputValue\x12\ + \x19\n\x08token_id\x18\x01\x20\x02(\tR\x07tokenId\x12!\n\x0ctoken_ticker\ + \x18\x02\x20\x02(\x0cR\x0btokenTicker\x12,\n\x12number_of_decimals\x18\ + \x03\x20\x02(\rR\x10numberOfDecimals\"}\n\x14MintlayerOutputValue\x12\ + \x16\n\x06amount\x18\x01\x20\x02(\x0cR\x06amount\x12M\n\x05token\x18\x02\ + \x20\x01(\x0b27.hw.trezor.messages.mintlayer.MintlayerTokenOutputValueR\ + \x05token\"\x7f\n\x19MintlayerTransferTxOutput\x12\x18\n\x07address\x18\ + \x01\x20\x02(\tR\x07address\x12H\n\x05value\x18\x02\x20\x02(\x0b22.hw.tr\ + ezor.messages.mintlayer.MintlayerOutputValueR\x05value\"\xa4\x01\n\x17Mi\ + ntlayerOutputTimeLock\x12!\n\x0cuntil_height\x18\x01\x20\x01(\x04R\x0bun\ + tilHeight\x12\x1d\n\nuntil_time\x18\x02\x20\x01(\x04R\tuntilTime\x12&\n\ + \x0ffor_block_count\x18\x03\x20\x01(\x04R\rforBlockCount\x12\x1f\n\x0bfo\ + r_seconds\x18\x04\x20\x01(\x04R\nforSeconds\"\xd2\x01\n!MintlayerLockThe\ + nTransferTxOutput\x12\x18\n\x07address\x18\x01\x20\x02(\tR\x07address\ + \x12H\n\x05value\x18\x02\x20\x02(\x0b22.hw.trezor.messages.mintlayer.Min\ + tlayerOutputValueR\x05value\x12I\n\x04lock\x18\x03\x20\x02(\x0b25.hw.tre\ + zor.messages.mintlayer.MintlayerOutputTimeLockR\x04lock\"a\n\x15Mintlaye\ + rBurnTxOutput\x12H\n\x05value\x18\x01\x20\x02(\x0b22.hw.trezor.messages.\ + mintlayer.MintlayerOutputValueR\x05value\"\x9d\x02\n\x20MintlayerCreateS\ + takePoolTxOutput\x12\x17\n\x07pool_id\x18\x01\x20\x02(\tR\x06poolId\x12\ + \x16\n\x06pledge\x18\x02\x20\x02(\x0cR\x06pledge\x12\x16\n\x06staker\x18\ + \x03\x20\x02(\tR\x06staker\x12$\n\x0evrf_public_key\x18\x04\x20\x02(\tR\ + \x0cvrfPublicKey\x12)\n\x10decommission_key\x18\x05\x20\x02(\tR\x0fdecom\ + missionKey\x129\n\x19margin_ratio_per_thousand\x18\x06\x20\x02(\rR\x16ma\ + rginRatioPerThousand\x12$\n\x0ecost_per_block\x18\x07\x20\x02(\x0cR\x0cc\ + ostPerBlock\"\x8a\x01\n&MintlayerProduceBlockFromStakeTxOutput\x12\x20\n\ + \x0bdestination\x18\x01\x20\x02(\tR\x0bdestination\x12\x17\n\x07pool_id\ + \x18\x02\x20\x02(\tR\x06poolId\x12%\n\x0estaker_balance\x18\x03\x20\x02(\ + \x0cR\rstakerBalance\"`\n#MintlayerCreateDelegationIdTxOutput\x12\x20\n\ + \x0bdestination\x18\x01\x20\x02(\tR\x0bdestination\x12\x17\n\x07pool_id\ + \x18\x02\x20\x02(\tR\x06poolId\"_\n\x20MintlayerDelegateStakingTxOutput\ + \x12\x16\n\x06amount\x18\x01\x20\x02(\x0cR\x06amount\x12#\n\rdelegation_\ + id\x18\x02\x20\x02(\tR\x0cdelegationId\"\x8f\x01\n\x19MintlayerTokenTota\ + lSupply\x12O\n\x04type\x18\x01\x20\x02(\x0e2;.hw.trezor.messages.mintlay\ + er.MintlayerTokenTotalSupplyTypeR\x04type\x12!\n\x0cfixed_amount\x18\x02\ + \x20\x01(\x0cR\x0bfixedAmount\"\xb6\x02\n#MintlayerIssueFungibleTokenTxO\ + utput\x12!\n\x0ctoken_ticker\x18\x01\x20\x02(\x0cR\x0btokenTicker\x12,\n\ + \x12number_of_decimals\x18\x02\x20\x02(\rR\x10numberOfDecimals\x12!\n\ + \x0cmetadata_uri\x18\x03\x20\x02(\x0cR\x0bmetadataUri\x12Z\n\x0ctotal_su\ + pply\x18\x04\x20\x02(\x0b27.hw.trezor.messages.mintlayer.MintlayerTokenT\ + otalSupplyR\x0btotalSupply\x12\x1c\n\tauthority\x18\x05\x20\x02(\tR\taut\ + hority\x12!\n\x0cis_freezable\x18\x06\x20\x02(\x08R\x0bisFreezable\"\xcf\ + \x02\n\x19MintlayerIssueNftTxOutput\x12\x19\n\x08token_id\x18\x01\x20\ + \x02(\tR\x07tokenId\x12\x20\n\x0bdestination\x18\x02\x20\x02(\tR\x0bdest\ + ination\x12\x18\n\x07creator\x18\x03\x20\x01(\tR\x07creator\x12\x12\n\ + \x04name\x18\x04\x20\x02(\x0cR\x04name\x12\x20\n\x0bdescription\x18\x05\ + \x20\x02(\x0cR\x0bdescription\x12\x16\n\x06ticker\x18\x06\x20\x02(\x0cR\ + \x06ticker\x12\x19\n\x08icon_uri\x18\x07\x20\x01(\x0cR\x07iconUri\x126\n\ + \x17additional_metadata_uri\x18\x08\x20\x01(\x0cR\x15additionalMetadataU\ + ri\x12\x1b\n\tmedia_uri\x18\t\x20\x01(\x0cR\x08mediaUri\x12\x1d\n\nmedia\ + _hash\x18\n\x20\x02(\x0cR\tmediaHash\"2\n\x1cMintlayerDataDepositTxOutpu\ + t\x12\x12\n\x04data\x18\x01\x20\x02(\x0cR\x04data\"\x9e\x02\n\x15Mintlay\ + erHtlcTxOutput\x12H\n\x05value\x18\x01\x20\x02(\x0b22.hw.trezor.messages\ + .mintlayer.MintlayerOutputValueR\x05value\x12\x1f\n\x0bsecret_hash\x18\ + \x02\x20\x02(\x0cR\nsecretHash\x12\x1b\n\tspend_key\x18\x03\x20\x02(\tR\ + \x08spendKey\x12^\n\x0frefund_timelock\x18\x04\x20\x02(\x0b25.hw.trezor.\ + messages.mintlayer.MintlayerOutputTimeLockR\x0erefundTimelock\x12\x1d\n\ + \nrefund_key\x18\x05\x20\x02(\tR\trefundKey\"\xcf\x01\n\x1cMintlayerCrea\ + teOrderTxOutput\x12!\n\x0cconclude_key\x18\x01\x20\x02(\tR\x0bconcludeKe\ + y\x12D\n\x03ask\x18\x02\x20\x02(\x0b22.hw.trezor.messages.mintlayer.Mint\ + layerOutputValueR\x03ask\x12F\n\x04give\x18\x03\x20\x02(\x0b22.hw.trezor\ + .messages.mintlayer.MintlayerOutputValueR\x04give\"\x92\r\n\x0eMintlayer\ + TxAck\x12S\n\x05input\x18\x01\x20\x01(\x0b2=.hw.trezor.messages.mintlaye\ + r.MintlayerTxAck.MintlayerTxInputR\x05input\x12V\n\x06output\x18\x02\x20\ + \x01(\x0b2>.hw.trezor.messages.mintlayer.MintlayerTxAck.MintlayerTxOutpu\ + tR\x06output\x1a\x92\x02\n\x10MintlayerTxInput\x12F\n\x04utxo\x18\x01\ + \x20\x01(\x0b22.hw.trezor.messages.mintlayer.MintlayerUtxoTxInputR\x04ut\ + xo\x12O\n\x07account\x18\x02\x20\x01(\x0b25.hw.trezor.messages.mintlayer\ + .MintlayerAccountTxInputR\x07account\x12e\n\x0faccount_command\x18\x03\ + \x20\x01(\x0b2<.hw.trezor.messages.mintlayer.MintlayerAccountCommandTxIn\ + putR\x0eaccountCommand\x1a\xbd\t\n\x11MintlayerTxOutput\x12S\n\x08transf\ + er\x18\x01\x20\x01(\x0b27.hw.trezor.messages.mintlayer.MintlayerTransfer\ + TxOutputR\x08transfer\x12m\n\x12lock_then_transfer\x18\x02\x20\x01(\x0b2\ + ?.hw.trezor.messages.mintlayer.MintlayerLockThenTransferTxOutputR\x10loc\ + kThenTransfer\x12G\n\x04burn\x18\x03\x20\x01(\x0b23.hw.trezor.messages.m\ + intlayer.MintlayerBurnTxOutputR\x04burn\x12j\n\x11create_stake_pool\x18\ + \x04\x20\x01(\x0b2>.hw.trezor.messages.mintlayer.MintlayerCreateStakePoo\ + lTxOutputR\x0fcreateStakePool\x12}\n\x18produce_block_from_stake\x18\x05\ + \x20\x01(\x0b2D.hw.trezor.messages.mintlayer.MintlayerProduceBlockFromSt\ + akeTxOutputR\x15produceBlockFromStake\x12s\n\x14create_delegation_id\x18\ + \x06\x20\x01(\x0b2A.hw.trezor.messages.mintlayer.MintlayerCreateDelegati\ + onIdTxOutputR\x12createDelegationId\x12i\n\x10delegate_staking\x18\x07\ + \x20\x01(\x0b2>.hw.trezor.messages.mintlayer.MintlayerDelegateStakingTxO\ + utputR\x0fdelegateStaking\x12s\n\x14issue_fungible_token\x18\x08\x20\x01\ + (\x0b2A.hw.trezor.messages.mintlayer.MintlayerIssueFungibleTokenTxOutput\ + R\x12issueFungibleToken\x12T\n\tissue_nft\x18\t\x20\x01(\x0b27.hw.trezor\ + .messages.mintlayer.MintlayerIssueNftTxOutputR\x08issueNft\x12]\n\x0cdat\ + a_deposit\x18\n\x20\x01(\x0b2:.hw.trezor.messages.mintlayer.MintlayerDat\ + aDepositTxOutputR\x0bdataDeposit\x12G\n\x04htlc\x18\x0b\x20\x01(\x0b23.h\ + w.trezor.messages.mintlayer.MintlayerHtlcTxOutputR\x04htlc\x12]\n\x0ccre\ + ate_order\x18\x0c\x20\x01(\x0b2:.hw.trezor.messages.mintlayer.MintlayerC\ + reateOrderTxOutputR\x0bcreateOrder*G\n\x12MintlayerChainType\x12\x0b\n\ + \x07Mainnet\x10\x01\x12\x0b\n\x07Testnet\x10\x02\x12\x0b\n\x07Regtest\ + \x10\x03\x12\n\n\x06Signet\x10\x04*;\n\x14MintlayerAddressType\x12\x0e\n\ + \nPUBLIC_KEY\x10\x01\x12\x13\n\x0fPUBLIC_KEY_HASH\x10\x02*/\n\x11Mintlay\ + erUtxoType\x12\x0f\n\x0bTRANSACTION\x10\0\x12\t\n\x05BLOCK\x10\x01*G\n\ + \x1dMintlayerTokenTotalSupplyType\x12\t\n\x05FIXED\x10\0\x12\x0c\n\x08LO\ + CKABLE\x10\x01\x12\r\n\tUNLIMITED\x10\x02B=\n#com.satoshilabs.trezor.lib\ + .protobufB\x16TrezorMessageMintlayer\ +"; + +/// `FileDescriptorProto` object which was a source for this generated file +fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + static file_descriptor_proto_lazy: ::protobuf::rt::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::Lazy::new(); + file_descriptor_proto_lazy.get(|| { + ::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap() + }) +} + +/// `FileDescriptor` object which allows dynamic access to files +pub fn file_descriptor() -> &'static ::protobuf::reflect::FileDescriptor { + static generated_file_descriptor_lazy: ::protobuf::rt::Lazy<::protobuf::reflect::GeneratedFileDescriptor> = ::protobuf::rt::Lazy::new(); + static file_descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::FileDescriptor> = ::protobuf::rt::Lazy::new(); + file_descriptor.get(|| { + let generated_file_descriptor = generated_file_descriptor_lazy.get(|| { + let mut deps = ::std::vec::Vec::with_capacity(0); + let mut messages = ::std::vec::Vec::with_capacity(45); + messages.push(MintlayerGetAddress::generated_message_descriptor_data()); + messages.push(MintlayerAddress::generated_message_descriptor_data()); + messages.push(MintlayerGetPublicKey::generated_message_descriptor_data()); + messages.push(MintlayerPublicKey::generated_message_descriptor_data()); + messages.push(MintlayerSignMessage::generated_message_descriptor_data()); + messages.push(MintlayerSignTx::generated_message_descriptor_data()); + messages.push(MintlayerTxRequest::generated_message_descriptor_data()); + messages.push(MintlayerAddressPath::generated_message_descriptor_data()); + messages.push(MintlayerUtxoTxInput::generated_message_descriptor_data()); + messages.push(MintlayerAccountTxInput::generated_message_descriptor_data()); + messages.push(MintlayerAccountSpendingDelegationBalance::generated_message_descriptor_data()); + messages.push(MintlayerAccountCommandTxInput::generated_message_descriptor_data()); + messages.push(MintlayerMintTokens::generated_message_descriptor_data()); + messages.push(MintlayerUnmintTokens::generated_message_descriptor_data()); + messages.push(MintlayerLockTokenSupply::generated_message_descriptor_data()); + messages.push(MintlayerFreezeToken::generated_message_descriptor_data()); + messages.push(MintlayerUnfreezeToken::generated_message_descriptor_data()); + messages.push(MintlayerChangeTokenAuthority::generated_message_descriptor_data()); + messages.push(MintlayerConcludeOrder::generated_message_descriptor_data()); + messages.push(MintlayerFillOrder::generated_message_descriptor_data()); + messages.push(MintlayerChangeTokenMetadataUri::generated_message_descriptor_data()); + messages.push(MintlayerTokenOutputValue::generated_message_descriptor_data()); + messages.push(MintlayerOutputValue::generated_message_descriptor_data()); + messages.push(MintlayerTransferTxOutput::generated_message_descriptor_data()); + messages.push(MintlayerOutputTimeLock::generated_message_descriptor_data()); + messages.push(MintlayerLockThenTransferTxOutput::generated_message_descriptor_data()); + messages.push(MintlayerBurnTxOutput::generated_message_descriptor_data()); + messages.push(MintlayerCreateStakePoolTxOutput::generated_message_descriptor_data()); + messages.push(MintlayerProduceBlockFromStakeTxOutput::generated_message_descriptor_data()); + messages.push(MintlayerCreateDelegationIdTxOutput::generated_message_descriptor_data()); + messages.push(MintlayerDelegateStakingTxOutput::generated_message_descriptor_data()); + messages.push(MintlayerTokenTotalSupply::generated_message_descriptor_data()); + messages.push(MintlayerIssueFungibleTokenTxOutput::generated_message_descriptor_data()); + messages.push(MintlayerIssueNftTxOutput::generated_message_descriptor_data()); + messages.push(MintlayerDataDepositTxOutput::generated_message_descriptor_data()); + messages.push(MintlayerHtlcTxOutput::generated_message_descriptor_data()); + messages.push(MintlayerCreateOrderTxOutput::generated_message_descriptor_data()); + messages.push(MintlayerTxAck::generated_message_descriptor_data()); + messages.push(mintlayer_tx_request::MintlayerTxInputRequest::generated_message_descriptor_data()); + messages.push(mintlayer_tx_request::MintlayerTxOutputRequest::generated_message_descriptor_data()); + messages.push(mintlayer_tx_request::MintlayerSignature::generated_message_descriptor_data()); + messages.push(mintlayer_tx_request::MintlayerSignaturesForInput::generated_message_descriptor_data()); + messages.push(mintlayer_tx_request::MintlayerTxSigningResult::generated_message_descriptor_data()); + messages.push(mintlayer_tx_ack::MintlayerTxInput::generated_message_descriptor_data()); + messages.push(mintlayer_tx_ack::MintlayerTxOutput::generated_message_descriptor_data()); + let mut enums = ::std::vec::Vec::with_capacity(4); + enums.push(MintlayerChainType::generated_enum_descriptor_data()); + enums.push(MintlayerAddressType::generated_enum_descriptor_data()); + enums.push(MintlayerUtxoType::generated_enum_descriptor_data()); + enums.push(MintlayerTokenTotalSupplyType::generated_enum_descriptor_data()); + ::protobuf::reflect::GeneratedFileDescriptor::new_generated( + file_descriptor_proto(), + deps, + messages, + enums, + ) + }); + ::protobuf::reflect::FileDescriptor::new_generated_2(generated_file_descriptor) + }) +} diff --git a/rust/trezor-client/src/protos/generated/messages_mintlayer_enums.rs b/rust/trezor-client/src/protos/generated/messages_mintlayer_enums.rs new file mode 100644 index 0000000000..58f4ac190a --- /dev/null +++ b/rust/trezor-client/src/protos/generated/messages_mintlayer_enums.rs @@ -0,0 +1,238 @@ +// This file is generated by rust-protobuf 3.3.0. Do not edit +// .proto file is parsed by protoc 3.19.6 +// @generated + +// https://github.com/rust-lang/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![allow(unused_attributes)] +#![cfg_attr(rustfmt, rustfmt::skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unused_results)] +#![allow(unused_mut)] + +//! Generated file from `messages-mintlayer-enums.proto` + +/// Generated files are compatible only with the same version +/// of protobuf runtime. +const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_3_0; + +#[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)] +// @@protoc_insertion_point(enum:hw.trezor.messages.mintlayer.MintlayerAccountCommandType) +pub enum MintlayerAccountCommandType { + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerAccountCommandType.MINT_TOKENS) + MINT_TOKENS = 0, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerAccountCommandType.UNMINT_TOKENS) + UNMINT_TOKENS = 1, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerAccountCommandType.LOCK_TOKEN_SUPPLY) + LOCK_TOKEN_SUPPLY = 2, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerAccountCommandType.FREEZE_TOKEN) + FREEZE_TOKEN = 3, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerAccountCommandType.UNFREEZE_TOKEN) + UNFREEZE_TOKEN = 4, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerAccountCommandType.CHANGE_TOKEN_AUTHORITY) + CHANGE_TOKEN_AUTHORITY = 5, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerAccountCommandType.CONCLUDE_ORDER) + CONCLUDE_ORDER = 6, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerAccountCommandType.FILL_ORDER) + FILL_ORDER = 7, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerAccountCommandType.CHANGE_TOKEN_METADATA_URI) + CHANGE_TOKEN_METADATA_URI = 8, +} + +impl ::protobuf::Enum for MintlayerAccountCommandType { + const NAME: &'static str = "MintlayerAccountCommandType"; + + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 0 => ::std::option::Option::Some(MintlayerAccountCommandType::MINT_TOKENS), + 1 => ::std::option::Option::Some(MintlayerAccountCommandType::UNMINT_TOKENS), + 2 => ::std::option::Option::Some(MintlayerAccountCommandType::LOCK_TOKEN_SUPPLY), + 3 => ::std::option::Option::Some(MintlayerAccountCommandType::FREEZE_TOKEN), + 4 => ::std::option::Option::Some(MintlayerAccountCommandType::UNFREEZE_TOKEN), + 5 => ::std::option::Option::Some(MintlayerAccountCommandType::CHANGE_TOKEN_AUTHORITY), + 6 => ::std::option::Option::Some(MintlayerAccountCommandType::CONCLUDE_ORDER), + 7 => ::std::option::Option::Some(MintlayerAccountCommandType::FILL_ORDER), + 8 => ::std::option::Option::Some(MintlayerAccountCommandType::CHANGE_TOKEN_METADATA_URI), + _ => ::std::option::Option::None + } + } + + fn from_str(str: &str) -> ::std::option::Option { + match str { + "MINT_TOKENS" => ::std::option::Option::Some(MintlayerAccountCommandType::MINT_TOKENS), + "UNMINT_TOKENS" => ::std::option::Option::Some(MintlayerAccountCommandType::UNMINT_TOKENS), + "LOCK_TOKEN_SUPPLY" => ::std::option::Option::Some(MintlayerAccountCommandType::LOCK_TOKEN_SUPPLY), + "FREEZE_TOKEN" => ::std::option::Option::Some(MintlayerAccountCommandType::FREEZE_TOKEN), + "UNFREEZE_TOKEN" => ::std::option::Option::Some(MintlayerAccountCommandType::UNFREEZE_TOKEN), + "CHANGE_TOKEN_AUTHORITY" => ::std::option::Option::Some(MintlayerAccountCommandType::CHANGE_TOKEN_AUTHORITY), + "CONCLUDE_ORDER" => ::std::option::Option::Some(MintlayerAccountCommandType::CONCLUDE_ORDER), + "FILL_ORDER" => ::std::option::Option::Some(MintlayerAccountCommandType::FILL_ORDER), + "CHANGE_TOKEN_METADATA_URI" => ::std::option::Option::Some(MintlayerAccountCommandType::CHANGE_TOKEN_METADATA_URI), + _ => ::std::option::Option::None + } + } + + const VALUES: &'static [MintlayerAccountCommandType] = &[ + MintlayerAccountCommandType::MINT_TOKENS, + MintlayerAccountCommandType::UNMINT_TOKENS, + MintlayerAccountCommandType::LOCK_TOKEN_SUPPLY, + MintlayerAccountCommandType::FREEZE_TOKEN, + MintlayerAccountCommandType::UNFREEZE_TOKEN, + MintlayerAccountCommandType::CHANGE_TOKEN_AUTHORITY, + MintlayerAccountCommandType::CONCLUDE_ORDER, + MintlayerAccountCommandType::FILL_ORDER, + MintlayerAccountCommandType::CHANGE_TOKEN_METADATA_URI, + ]; +} + +impl ::protobuf::EnumFull for MintlayerAccountCommandType { + fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().enum_by_package_relative_name("MintlayerAccountCommandType").unwrap()).clone() + } + + fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor { + let index = *self as usize; + Self::enum_descriptor().value_by_index(index) + } +} + +impl ::std::default::Default for MintlayerAccountCommandType { + fn default() -> Self { + MintlayerAccountCommandType::MINT_TOKENS + } +} + +impl MintlayerAccountCommandType { + fn generated_enum_descriptor_data() -> ::protobuf::reflect::GeneratedEnumDescriptorData { + ::protobuf::reflect::GeneratedEnumDescriptorData::new::("MintlayerAccountCommandType") + } +} + +#[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)] +// @@protoc_insertion_point(enum:hw.trezor.messages.mintlayer.MintlayerOutputTimeLockType) +pub enum MintlayerOutputTimeLockType { + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerOutputTimeLockType.UNTIL_HEIGHT) + UNTIL_HEIGHT = 0, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerOutputTimeLockType.UNTIL_TIME) + UNTIL_TIME = 1, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerOutputTimeLockType.FOR_BLOCK_COUNT) + FOR_BLOCK_COUNT = 2, + // @@protoc_insertion_point(enum_value:hw.trezor.messages.mintlayer.MintlayerOutputTimeLockType.FOR_SECONDS) + FOR_SECONDS = 3, +} + +impl ::protobuf::Enum for MintlayerOutputTimeLockType { + const NAME: &'static str = "MintlayerOutputTimeLockType"; + + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 0 => ::std::option::Option::Some(MintlayerOutputTimeLockType::UNTIL_HEIGHT), + 1 => ::std::option::Option::Some(MintlayerOutputTimeLockType::UNTIL_TIME), + 2 => ::std::option::Option::Some(MintlayerOutputTimeLockType::FOR_BLOCK_COUNT), + 3 => ::std::option::Option::Some(MintlayerOutputTimeLockType::FOR_SECONDS), + _ => ::std::option::Option::None + } + } + + fn from_str(str: &str) -> ::std::option::Option { + match str { + "UNTIL_HEIGHT" => ::std::option::Option::Some(MintlayerOutputTimeLockType::UNTIL_HEIGHT), + "UNTIL_TIME" => ::std::option::Option::Some(MintlayerOutputTimeLockType::UNTIL_TIME), + "FOR_BLOCK_COUNT" => ::std::option::Option::Some(MintlayerOutputTimeLockType::FOR_BLOCK_COUNT), + "FOR_SECONDS" => ::std::option::Option::Some(MintlayerOutputTimeLockType::FOR_SECONDS), + _ => ::std::option::Option::None + } + } + + const VALUES: &'static [MintlayerOutputTimeLockType] = &[ + MintlayerOutputTimeLockType::UNTIL_HEIGHT, + MintlayerOutputTimeLockType::UNTIL_TIME, + MintlayerOutputTimeLockType::FOR_BLOCK_COUNT, + MintlayerOutputTimeLockType::FOR_SECONDS, + ]; +} + +impl ::protobuf::EnumFull for MintlayerOutputTimeLockType { + fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor { + static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::Lazy::new(); + descriptor.get(|| file_descriptor().enum_by_package_relative_name("MintlayerOutputTimeLockType").unwrap()).clone() + } + + fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor { + let index = *self as usize; + Self::enum_descriptor().value_by_index(index) + } +} + +impl ::std::default::Default for MintlayerOutputTimeLockType { + fn default() -> Self { + MintlayerOutputTimeLockType::UNTIL_HEIGHT + } +} + +impl MintlayerOutputTimeLockType { + fn generated_enum_descriptor_data() -> ::protobuf::reflect::GeneratedEnumDescriptorData { + ::protobuf::reflect::GeneratedEnumDescriptorData::new::("MintlayerOutputTimeLockType") + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\x1emessages-mintlayer-enums.proto\x12\x1chw.trezor.messages.mintlayer\ + *\xdd\x01\n\x1bMintlayerAccountCommandType\x12\x0f\n\x0bMINT_TOKENS\x10\ + \0\x12\x11\n\rUNMINT_TOKENS\x10\x01\x12\x15\n\x11LOCK_TOKEN_SUPPLY\x10\ + \x02\x12\x10\n\x0cFREEZE_TOKEN\x10\x03\x12\x12\n\x0eUNFREEZE_TOKEN\x10\ + \x04\x12\x1a\n\x16CHANGE_TOKEN_AUTHORITY\x10\x05\x12\x12\n\x0eCONCLUDE_O\ + RDER\x10\x06\x12\x0e\n\nFILL_ORDER\x10\x07\x12\x1d\n\x19CHANGE_TOKEN_MET\ + ADATA_URI\x10\x08*e\n\x1bMintlayerOutputTimeLockType\x12\x10\n\x0cUNTIL_\ + HEIGHT\x10\0\x12\x0e\n\nUNTIL_TIME\x10\x01\x12\x13\n\x0fFOR_BLOCK_COUNT\ + \x10\x02\x12\x0f\n\x0bFOR_SECONDS\x10\x03B=\n#com.satoshilabs.trezor.lib\ + .protobufB\x16TrezorMessageMintlayer\ +"; + +/// `FileDescriptorProto` object which was a source for this generated file +fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + static file_descriptor_proto_lazy: ::protobuf::rt::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::Lazy::new(); + file_descriptor_proto_lazy.get(|| { + ::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap() + }) +} + +/// `FileDescriptor` object which allows dynamic access to files +pub fn file_descriptor() -> &'static ::protobuf::reflect::FileDescriptor { + static generated_file_descriptor_lazy: ::protobuf::rt::Lazy<::protobuf::reflect::GeneratedFileDescriptor> = ::protobuf::rt::Lazy::new(); + static file_descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::FileDescriptor> = ::protobuf::rt::Lazy::new(); + file_descriptor.get(|| { + let generated_file_descriptor = generated_file_descriptor_lazy.get(|| { + let mut deps = ::std::vec::Vec::with_capacity(0); + let mut messages = ::std::vec::Vec::with_capacity(0); + let mut enums = ::std::vec::Vec::with_capacity(2); + enums.push(MintlayerAccountCommandType::generated_enum_descriptor_data()); + enums.push(MintlayerOutputTimeLockType::generated_enum_descriptor_data()); + ::protobuf::reflect::GeneratedFileDescriptor::new_generated( + file_descriptor_proto(), + deps, + messages, + enums, + ) + }); + ::protobuf::reflect::FileDescriptor::new_generated_2(generated_file_descriptor) + }) +} diff --git a/rust/trezor-client/src/protos/mod.rs b/rust/trezor-client/src/protos/mod.rs index 7dd8483f9c..9981354407 100644 --- a/rust/trezor-client/src/protos/mod.rs +++ b/rust/trezor-client/src/protos/mod.rs @@ -38,6 +38,8 @@ mod generated { "stellar" => messages_stellar "tezos" => messages_tezos "webauthn" => messages_webauthn + "mintlayer" => messages_mintlayer + "mintlayer" => messages_mintlayer_enums } } diff --git a/tests/REGISTERED_MARKERS b/tests/REGISTERED_MARKERS index fab4ec8b3a..bbc4a48c76 100644 --- a/tests/REGISTERED_MARKERS +++ b/tests/REGISTERED_MARKERS @@ -6,6 +6,7 @@ decred eos ethereum komodo +mintlayer monero multisig nem diff --git a/tests/device_tests/mintlayer/__init__.py b/tests/device_tests/mintlayer/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/device_tests/mintlayer/test_get_address.py b/tests/device_tests/mintlayer/test_get_address.py new file mode 100644 index 0000000000..60f0d09379 --- /dev/null +++ b/tests/device_tests/mintlayer/test_get_address.py @@ -0,0 +1,99 @@ +# This file is part of the Trezor project. +# +# Copyright (C) 2012-2019 SatoshiLabs and contributors +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the License along with this library. +# If not, see . + +import pytest + +from trezorlib import mintlayer +from trezorlib.debuglink import TrezorClientDebugLink as Client +from trezorlib.exceptions import TrezorFailure +from trezorlib.tools import parse_path + +GET_ADDRESS_VECTORS = [ + (1, "mtc1qyumjs84s5nqgcp6nw9kwde9mn7akph6hgtulsdk"), + (2, "tmt1qx5p4r2en7c99mpmg2tz9hucxfarf4k6dyyvsahr"), + (3, "rmt1qx5p4r2en7c99mpmg2tz9hucxfarf4k6dypq388a"), + (4, "smt1qx5p4r2en7c99mpmg2tz9hucxfarf4k6dy5zamcc"), +] + +CHAIN_TYPE_TO_COIN = {1: 19788, 2: 1, 3: 1, 4: 1} + + +@pytest.mark.altcoin +@pytest.mark.mintlayer +@pytest.mark.setup_client( + mnemonic="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" +) +@pytest.mark.parametrize("chain_type, address", GET_ADDRESS_VECTORS) +def test_mintlayer_get_address(client: Client, chain_type: int, address: str): + with client: + assert ( + mintlayer.get_address( + client, + chain_type=chain_type, + address_n=parse_path(f"m/44h/{CHAIN_TYPE_TO_COIN[chain_type]}h/0h/0/0"), + show_display=True, + ) + == address + ) + + +CHAIN_TYPES = [1, 2, 3, 4] + + +@pytest.mark.altcoin +@pytest.mark.mintlayer +@pytest.mark.setup_client( + mnemonic="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" +) +@pytest.mark.parametrize("chain_type", CHAIN_TYPES) +def test_mintlayer_get_address_forbidden_path(client: Client, chain_type: int): + coin = CHAIN_TYPE_TO_COIN[chain_type] + with client: + # invalid coin + with pytest.raises(TrezorFailure, match="Forbidden key path"): + mintlayer.get_address( + client, + chain_type=chain_type, + address_n=parse_path(f"m/44h/{coin + 1}h/0h/0/0"), + show_display=True, + ) + + # invalid bip44 + with pytest.raises(TrezorFailure, match="Forbidden key path"): + mintlayer.get_address( + client, + chain_type=chain_type, + address_n=parse_path(f"m/43h/{coin}h/0h/0/0"), + show_display=True, + ) + + # short path + with pytest.raises(TrezorFailure, match="Forbidden key path"): + mintlayer.get_address( + client, + chain_type=chain_type, + address_n=parse_path(f"m/44h/{coin}h"), + show_display=True, + ) + + # short path + with pytest.raises(TrezorFailure, match="Forbidden key path"): + mintlayer.get_address( + client, + chain_type=chain_type, + address_n=parse_path("m/44h"), + show_display=True, + ) diff --git a/tests/device_tests/mintlayer/test_get_public_key.py b/tests/device_tests/mintlayer/test_get_public_key.py new file mode 100644 index 0000000000..e87f65c2e2 --- /dev/null +++ b/tests/device_tests/mintlayer/test_get_public_key.py @@ -0,0 +1,125 @@ +# This file is part of the Trezor project. +# +# Copyright (C) 2012-2019 SatoshiLabs and contributors +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the License along with this library. +# If not, see . + +import pytest + +from trezorlib import messages, mintlayer +from trezorlib.debuglink import TrezorClientDebugLink as Client +from trezorlib.exceptions import TrezorFailure +from trezorlib.tools import parse_path + +from ...input_flows import InputFlowShowXpubQRCode + +GET_PUBLIC_KEY_VECTORS = [ + ( + 1, + "03bf6f8d52dade77f95e9c6c9488fd8492a99c09ff23095caffb2e6409d1746ade", + "0ae454a1024d0ddb9e10d23479cf8ef39fb400727fabd17844bd8362b1c70d7d", + ), + ( + 2, + "02a7451395735369f2ecdfc829c0f774e88ef1303dfe5b2f04dbaab30a535dfdd6", + "f33f3a6035684e404902a47c25cad7269a1afdba22c6b02167f43f09125f37f2", + ), + ( + 3, + "02a7451395735369f2ecdfc829c0f774e88ef1303dfe5b2f04dbaab30a535dfdd6", + "f33f3a6035684e404902a47c25cad7269a1afdba22c6b02167f43f09125f37f2", + ), + ( + 4, + "02a7451395735369f2ecdfc829c0f774e88ef1303dfe5b2f04dbaab30a535dfdd6", + "f33f3a6035684e404902a47c25cad7269a1afdba22c6b02167f43f09125f37f2", + ), +] + +CHAIN_TYPE_TO_COIN = {1: 19788, 2: 1, 3: 1, 4: 1} + + +@pytest.mark.altcoin +@pytest.mark.mintlayer +@pytest.mark.setup_client( + mnemonic="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" +) +@pytest.mark.parametrize("chain_type, pub_key, chain_code", GET_PUBLIC_KEY_VECTORS) +def test_mintlayer_get_public_key( + client: Client, chain_type: int, pub_key: str, chain_code: str +): + coin = CHAIN_TYPE_TO_COIN[chain_type] + with client: + IF = InputFlowShowXpubQRCode(client) + client.set_input_flow(IF.get()) + result = mintlayer.get_public_key( + client, + chain_type=1, + address_n=parse_path(f"m/44h/{coin}h/0h/0/0"), + show_display=True, + ) + if isinstance(result, messages.MintlayerPublicKey): + # m/44'/coin'/0'/0/0 for MNEMONIC + assert result.public_key.hex() == pub_key + assert result.chain_code.hex() == chain_code + else: + assert False + + +CHAIN_TYPES = [1, 2, 3, 4] + + +@pytest.mark.altcoin +@pytest.mark.mintlayer +@pytest.mark.setup_client( + mnemonic="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" +) +@pytest.mark.parametrize("chain_type", CHAIN_TYPES) +def test_mintlayer_get_public_key_forbidden_path(client: Client, chain_type: int): + coin = CHAIN_TYPE_TO_COIN[chain_type] + with client: + # invalid coin + with pytest.raises(TrezorFailure, match="Forbidden key path"): + mintlayer.get_public_key( + client, + chain_type=chain_type, + address_n=parse_path(f"m/44h/{coin + 1}h/0h/0/0"), + show_display=True, + ) + + # invalid bip44 + with pytest.raises(TrezorFailure, match="Forbidden key path"): + mintlayer.get_public_key( + client, + chain_type=chain_type, + address_n=parse_path(f"m/43h/{coin}h/0h/0/0"), + show_display=True, + ) + + # short path + with pytest.raises(TrezorFailure, match="Forbidden key path"): + mintlayer.get_public_key( + client, + chain_type=chain_type, + address_n=parse_path(f"m/44h/{coin}h"), + show_display=True, + ) + + # short path + with pytest.raises(TrezorFailure, match="Forbidden key path"): + mintlayer.get_public_key( + client, + chain_type=chain_type, + address_n=parse_path("m/44h"), + show_display=True, + ) diff --git a/tests/device_tests/mintlayer/test_sign_message.py b/tests/device_tests/mintlayer/test_sign_message.py new file mode 100644 index 0000000000..4dd7e0225c --- /dev/null +++ b/tests/device_tests/mintlayer/test_sign_message.py @@ -0,0 +1,116 @@ +import pytest +from construct import itertools + +from trezorlib import messages, mintlayer +from trezorlib.debuglink import TrezorClientDebugLink as Client +from trezorlib.exceptions import TrezorFailure +from trezorlib.tools import parse_path + +M_ADDRESS = "mtc1qyumjs84s5nqgcp6nw9kwde9mn7akph6hgtulsdk" +M_PK_ADDRESS = "mptc1qgpm7mud2tddualet6wxe9yglkzf92vup8ljxz2u4lajueqf696x4hs2ryf7j" +M_SIGNATURE = "7d8a743ada09e7ca8e76cf99429385a1651a9738d96a78c6b601c49a7cb20896d076e1c4d4e8a514ad73f4b88fe115cb30b61e1c04fc96d999baeabd32f82fb2" +T_ADDRESS = "tmt1qx5p4r2en7c99mpmg2tz9hucxfarf4k6dyyvsahr" +T_PK_ADDRESS = "tpmt1qgp2w3gnj4e4x60jan0us2wq7a6w3rh3xq7luke0qnd64vc22dwlm4s4hr3um" +T_SIGNATURE = "d85ce2bbad7e86626675b8d95a5f5c87d3a96f9fdf94b1ea0d017a86163998dc54a7e4fec66ee3f196a2275c81434e99a2d7eae669640ac4d05ab708aaa18dc1" +R_ADDRESS = "rmt1qx5p4r2en7c99mpmg2tz9hucxfarf4k6dypq388a" +R_PK_ADDRESS = "rpmt1qgp2w3gnj4e4x60jan0us2wq7a6w3rh3xq7luke0qnd64vc22dwlm4sy595zf" +S_ADDRESS = "smt1qx5p4r2en7c99mpmg2tz9hucxfarf4k6dy5zamcc" +S_PK_ADDRESS = "spmt1qgp2w3gnj4e4x60jan0us2wq7a6w3rh3xq7luke0qnd64vc22dwlm4shqyp8w" + +SIGN_TEST_VECTORS = [ + (1, "PUBLIC_KEY_HASH", M_ADDRESS, M_SIGNATURE), + (1, "PUBLIC_KEY", M_PK_ADDRESS, M_SIGNATURE), + (2, "PUBLIC_KEY_HASH", T_ADDRESS, T_SIGNATURE), + (2, "PUBLIC_KEY", T_PK_ADDRESS, T_SIGNATURE), + (3, "PUBLIC_KEY_HASH", R_ADDRESS, T_SIGNATURE), + (3, "PUBLIC_KEY", R_PK_ADDRESS, T_SIGNATURE), + (4, "PUBLIC_KEY_HASH", S_ADDRESS, T_SIGNATURE), + (4, "PUBLIC_KEY", S_PK_ADDRESS, T_SIGNATURE), +] + +CHAIN_TYPE_TO_COIN = {1: 19788, 2: 1, 3: 1, 4: 1} + + +@pytest.mark.altcoin +@pytest.mark.mintlayer +@pytest.mark.setup_client( + mnemonic="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" +) +@pytest.mark.parametrize( + "chain_type, addr_type, expected_address, expected_signature", SIGN_TEST_VECTORS +) +def test_mintlayer_sign_message( + client: Client, + chain_type: int, + addr_type: str, + expected_address: str, + expected_signature: str, +): + with client: + result = mintlayer.sign_message( + client, + chain_type=chain_type, + address_type=addr_type, + address_n=parse_path(f"m/44h/{CHAIN_TYPE_TO_COIN[chain_type]}h/0h/0/0"), + message="Message to sign".encode(), + ) + if isinstance(result, messages.MessageSignature): + assert result.signature.hex() == expected_signature + assert result.address == expected_address + + +INVALID_PATH_TEST_VECTORS = itertools.product( + [1, 2, 3, 4], ["PUBLIC_KEY", "PUBLIC_KEY_HASH"] +) + + +@pytest.mark.altcoin +@pytest.mark.mintlayer +@pytest.mark.setup_client( + mnemonic="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" +) +@pytest.mark.parametrize("chain_type, addr_type", INVALID_PATH_TEST_VECTORS) +def test_mintlayer_sign_message_error_path( + client: Client, chain_type: int, addr_type: str +): + coin = CHAIN_TYPE_TO_COIN[chain_type] + with client: + # invalid coin + with pytest.raises(TrezorFailure, match="Forbidden key path"): + mintlayer.sign_message( + client, + address_type=addr_type, + chain_type=chain_type, + address_n=parse_path(f"m/44h/{coin+1}h/0h/0/0"), + message="Message to sign".encode(), + ) + + # invalid bip44 + with pytest.raises(TrezorFailure, match="Forbidden key path"): + mintlayer.sign_message( + client, + address_type=addr_type, + chain_type=chain_type, + address_n=parse_path(f"m/43h/{coin}h/0h/0/0"), + message="Message to sign".encode(), + ) + + # short path + with pytest.raises(TrezorFailure, match="Forbidden key path"): + mintlayer.sign_message( + client, + address_type=addr_type, + chain_type=chain_type, + address_n=parse_path(f"m/44h/{coin}h"), + message="Message to sign".encode(), + ) + + # short path + with pytest.raises(TrezorFailure, match="Forbidden key path"): + mintlayer.sign_message( + client, + address_type=addr_type, + chain_type=chain_type, + address_n=parse_path("m/44h"), + message="Message to sign".encode(), + ) diff --git a/tests/device_tests/mintlayer/test_sign_tx.py b/tests/device_tests/mintlayer/test_sign_tx.py new file mode 100644 index 0000000000..5981a987b1 --- /dev/null +++ b/tests/device_tests/mintlayer/test_sign_tx.py @@ -0,0 +1,718 @@ +# This file is part of the Trezor project. +# +# Copyright (C) 2012-2019 SatoshiLabs and contributors +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the License along with this library. +# If not, see . + +import itertools +import random +from typing import Optional + +import pytest + +from trezorlib import messages, mintlayer +from trezorlib.debuglink import TrezorClientDebugLink as Client +from trezorlib.exceptions import TrezorFailure +from trezorlib.tools import parse_path + +B = messages.ButtonRequestType + + +def request_input(n: int) -> messages.MintlayerTxRequest: + return messages.MintlayerTxRequest( + input_request=messages.MintlayerTxInputRequest(input_index=n) + ) + + +def request_output( + n: int, tx_hash: Optional[bytes] = None +) -> messages.MintlayerTxRequest: + return messages.MintlayerTxRequest( + output_request=messages.MintlayerTxOutputRequest( + output_index=n, tx_hash=tx_hash + ) + ) + + +def request_finished() -> messages.MintlayerTxRequest: + return messages.MintlayerTxRequest( + signing_finished=messages.MintlayerTxSigningResult() + ) + + +SIGN_TX_VECTORS = [ + ( + 1, + "mmtc1q3plqylyzrj4mdemdfs39v8zy574rnztc5zpse0x", + "mdelg1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqut3aj8", + "mmltk1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqa3r2pu", + "mordr1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqacsnmg", + "mpool1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqd2ew4w", + "mvrfpk1qq7859x9n9zk9d8j3yfefr0l2vjmcsshzdm6ryz765pdmrufxmgsyh6z8a9", + # sigs ====================== + "0770b640bd217d130e2a654860f6ef0d2c1711871c2bc02f725da6a9c97b84863eac0483bfbb741e53f684d000c6968b628dead5f37c1c0dbb4d926e769bb7ce", + "0bc5ace472748f2fff8afe60152558fd84f6027081a06a45c0ba621e447b1e7f7481e442849a97a63d077fbc3347badfb03a61cdf5e74120c1e5f69b01e8535a", + ), + ( + 2, + "tmtc1qjn5ls4sz90ppcart66jf0vx0n0u8ndjluz8lpsy", + "tdelg1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqnu8zn4", + "tmltk1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqjx44qw", + "tordr1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj0xv66", + "tpool1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqza035u", + "tvrfpk1qregu4v895mchautf84u46nsf9xel2507a37ksaf3stmuw44y3m4vffs89t", + # sigs ====================== + "7ae7291601bd4a6a0069d91f2695b1a37faa4d42485e9cae047f3d080253d1fa827a4c2e38e004a2199adba7b0201a243856a9a3cf1c069ec856964570635ea2", + "abadf0c5f984c6b1f55a32a05cc7aa37aa5aae6b0b96544bb752c01ad8a29e7d9fe90124776699228f1843b1e033e5f27b081643b0c873e776e1142845aaa56c", + ), + ( + 3, + "rmtc1qjn5ls4sz90ppcart66jf0vx0n0u8ndjluu6nzuv", + "rdelg1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqf9m6ka", + "rmltk1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqglfd9x", + "rordr1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqgk65lj", + "rpool1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqcynf35", + "rvrfpk1qregu4v895mchautf84u46nsf9xel2507a37ksaf3stmuw44y3m4vc2kzme", + # sigs ====================== + "7ae7291601bd4a6a0069d91f2695b1a37faa4d42485e9cae047f3d080253d1fa827a4c2e38e004a2199adba7b0201a243856a9a3cf1c069ec856964570635ea2", + "abadf0c5f984c6b1f55a32a05cc7aa37aa5aae6b0b96544bb752c01ad8a29e7d9fe90124776699228f1843b1e033e5f27b081643b0c873e776e1142845aaa56c", + ), + ( + 4, + "smtc1qjn5ls4sz90ppcart66jf0vx0n0u8ndjluet3k7h", + "sdelg1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq4dx7rx", + "smltk1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq5h5fsa", + "sordr1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq578s2f", + "spool1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqyvwdy0", + "svrfpk1qregu4v895mchautf84u46nsf9xel2507a37ksaf3stmuw44y3m4vt7hh77", + # sigs ====================== + "7ae7291601bd4a6a0069d91f2695b1a37faa4d42485e9cae047f3d080253d1fa827a4c2e38e004a2199adba7b0201a243856a9a3cf1c069ec856964570635ea2", + "abadf0c5f984c6b1f55a32a05cc7aa37aa5aae6b0b96544bb752c01ad8a29e7d9fe90124776699228f1843b1e033e5f27b081643b0c873e776e1142845aaa56c", + ), +] + +CHAIN_TYPE_TO_COIN = {1: 19788, 2: 1, 3: 1, 4: 1} + + +@pytest.mark.altcoin +@pytest.mark.mintlayer +@pytest.mark.setup_client( + mnemonic="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" +) +@pytest.mark.parametrize( + "chain_type, multisig_addr, delegation_id, token_id, order_id, pool_id, vrf_public_key, sig1, sig2", + SIGN_TX_VECTORS, +) +def test_mintlayer_sign_tx( + client: Client, + chain_type: int, + multisig_addr: str, + delegation_id: str, + token_id: str, + order_id: str, + pool_id: str, + vrf_public_key: str, + sig1: str, + sig2: str, +): + coin = CHAIN_TYPE_TO_COIN[chain_type] + with client: + path = parse_path(f"m/44h/{coin}h/0h/0/0") + address_0 = messages.MintlayerAddressPath(address_n=path) + wallet_dest0 = mintlayer.get_address( + client, + chain_type=chain_type, + address_n=parse_path(f"m/44h/{coin}h/0h/0/0"), + show_display=True, + ) + prev_utxo_index = 1 + prev_utxo_index_token = 2 + + path = parse_path(f"m/44h/{coin}h/0h/0/0") + multisig0 = messages.MintlayerAddressPath(address_n=path, multisig_idx=0) + path = parse_path(f"m/44h/{coin}h/0h/0/1") + multisig2 = messages.MintlayerAddressPath(address_n=path, multisig_idx=2) + prev_multisig_utxo_index = 3 + + prev_hash = b"\x00" * 32 + # anyone_can_spend = wallet_dest0 + anyone_can_spend = "mxanyonecanspend1qqx4x7pk" + + token_ticker = "XXXX".encode() + number_of_decimals = 2 + uri = "http://uri.com".encode() + amount_10 = (10).to_bytes(16, byteorder="big") + value_10 = messages.MintlayerOutputValue(amount=amount_10) + amount_1 = (1).to_bytes(16, byteorder="big") + value_1 = messages.MintlayerOutputValue(amount=amount_1) + token_value_1 = messages.MintlayerOutputValue( + amount=amount_1, + token=messages.MintlayerTokenOutputValue( + token_id=token_id, + token_ticker=token_ticker, + number_of_decimals=number_of_decimals, + ), + ) + amount_0 = (0).to_bytes(16, byteorder="big") + value_0 = messages.MintlayerOutputValue(amount=amount_0) + + inputs = [ + # UTXO input + messages.MintlayerTxInput( + utxo=messages.MintlayerUtxoTxInput( + prev_hash=prev_hash, + prev_index=prev_utxo_index, + addresses=[address_0], + type=messages.MintlayerUtxoType.TRANSACTION, + ) + ), + # UTXO input wiht tokens + messages.MintlayerTxInput( + utxo=messages.MintlayerUtxoTxInput( + prev_hash=prev_hash, + prev_index=prev_utxo_index_token, + addresses=[address_0], + type=messages.MintlayerUtxoType.TRANSACTION, + ) + ), + # Multisig UTXO + messages.MintlayerTxInput( + utxo=messages.MintlayerUtxoTxInput( + prev_hash=prev_hash, + prev_index=prev_multisig_utxo_index, + addresses=[multisig0, multisig2], + type=messages.MintlayerUtxoType.TRANSACTION, + ) + ), + # Account inpput + messages.MintlayerTxInput( + account=messages.MintlayerAccountTxInput( + addresses=[address_0], + nonce=0, + delegation_balance=messages.MintlayerAccountSpendingDelegationBalance( + delegation_id=delegation_id, + amount=amount_1, + ), + ) + ), + # Account commands + messages.MintlayerTxInput( + account_command=messages.MintlayerAccountCommandTxInput( + addresses=[address_0], + nonce=0, + mint=messages.MintlayerMintTokens( + token_id=token_id, amount=amount_1 + ), + ) + ), + messages.MintlayerTxInput( + account_command=messages.MintlayerAccountCommandTxInput( + addresses=[address_0], + nonce=0, + unmint=messages.MintlayerUnmintTokens(token_id=token_id), + ) + ), + messages.MintlayerTxInput( + account_command=messages.MintlayerAccountCommandTxInput( + addresses=[address_0], + nonce=0, + lock_token_supply=messages.MintlayerLockTokenSupply( + token_id=token_id + ), + ) + ), + messages.MintlayerTxInput( + account_command=messages.MintlayerAccountCommandTxInput( + addresses=[address_0], + nonce=0, + freeze_token=messages.MintlayerFreezeToken( + token_id=token_id, is_token_unfreezeable=True + ), + ) + ), + messages.MintlayerTxInput( + account_command=messages.MintlayerAccountCommandTxInput( + addresses=[address_0], + nonce=0, + unfreeze_token=messages.MintlayerUnfreezeToken(token_id=token_id), + ) + ), + messages.MintlayerTxInput( + account_command=messages.MintlayerAccountCommandTxInput( + addresses=[address_0], + nonce=0, + change_token_authority=messages.MintlayerChangeTokenAuthority( + token_id=token_id, destination=anyone_can_spend + ), + ) + ), + messages.MintlayerTxInput( + account_command=messages.MintlayerAccountCommandTxInput( + addresses=[address_0], + nonce=0, + conclude_order=messages.MintlayerConcludeOrder( + order_id=order_id, + filled_ask_amount=value_0, + give_balance=value_1, + ), + ) + ), + messages.MintlayerTxInput( + account_command=messages.MintlayerAccountCommandTxInput( + addresses=[address_0], + nonce=0, + fill_order=messages.MintlayerFillOrder( + order_id=order_id, + amount=amount_1, + destination=anyone_can_spend, + ask_balance=value_1, + give_balance=value_1, + ), + ) + ), + messages.MintlayerTxInput( + account_command=messages.MintlayerAccountCommandTxInput( + addresses=[address_0], + nonce=0, + change_token_metadata_uri=messages.MintlayerChangeTokenMetadataUri( + token_id=token_id, metadata_uri=uri + ), + ) + ), + ] + + utxo = messages.MintlayerTransferTxOutput(address=wallet_dest0, value=value_10) + utxo_out = messages.MintlayerTxOutput(transfer=utxo) + utxo = messages.MintlayerTransferTxOutput( + address=wallet_dest0, value=token_value_1 + ) + utxo_out_token = messages.MintlayerTxOutput(transfer=utxo) + + utxo = messages.MintlayerTransferTxOutput(address=multisig_addr, value=value_1) + multisig_utxo = messages.MintlayerTxOutput(transfer=utxo) + prev_txs = { + prev_hash: { + prev_utxo_index: utxo_out, + prev_utxo_index_token: utxo_out_token, + prev_multisig_utxo_index: multisig_utxo, + } + } + + value_1 = messages.MintlayerOutputValue(amount=amount_1) + outputs = [ + messages.MintlayerTxOutput( + transfer=messages.MintlayerTransferTxOutput( + address=anyone_can_spend, value=token_value_1 + ) + ), + messages.MintlayerTxOutput( + transfer=messages.MintlayerTransferTxOutput( + address=anyone_can_spend, value=value_1 + ) + ), + messages.MintlayerTxOutput( + lock_then_transfer=messages.MintlayerLockThenTransferTxOutput( + address=anyone_can_spend, + value=value_1, + lock=messages.MintlayerOutputTimeLock(until_height=10), + ) + ), + messages.MintlayerTxOutput( + lock_then_transfer=messages.MintlayerLockThenTransferTxOutput( + address=anyone_can_spend, + value=value_1, + lock=messages.MintlayerOutputTimeLock(until_time=10), + ) + ), + messages.MintlayerTxOutput( + lock_then_transfer=messages.MintlayerLockThenTransferTxOutput( + address=anyone_can_spend, + value=value_1, + lock=messages.MintlayerOutputTimeLock(for_block_count=10), + ) + ), + messages.MintlayerTxOutput( + lock_then_transfer=messages.MintlayerLockThenTransferTxOutput( + address=anyone_can_spend, + value=value_1, + lock=messages.MintlayerOutputTimeLock(for_seconds=10), + ) + ), + messages.MintlayerTxOutput( + burn=messages.MintlayerBurnTxOutput( + value=value_1, + ) + ), + messages.MintlayerTxOutput( + create_stake_pool=messages.MintlayerCreateStakePoolTxOutput( + pool_id=pool_id, + pledge=amount_1, + staker=anyone_can_spend, + decommission_key=anyone_can_spend, + vrf_public_key=vrf_public_key, + margin_ratio_per_thousand=1, + cost_per_block=amount_1, + ) + ), + messages.MintlayerTxOutput( + create_delegation_id=messages.MintlayerCreateDelegationIdTxOutput( + destination=anyone_can_spend, + pool_id=pool_id, + ) + ), + messages.MintlayerTxOutput( + delegate_staking=messages.MintlayerDelegateStakingTxOutput( + amount=amount_1, + delegation_id=delegation_id, + ) + ), + messages.MintlayerTxOutput( + issue_fungible_token=messages.MintlayerIssueFungibleTokenTxOutput( + token_ticker="XXXX".encode(), + number_of_decimals=2, + metadata_uri=uri, + authority=anyone_can_spend, + is_freezable=True, + total_supply=messages.MintlayerTokenTotalSupply( + type=messages.MintlayerTokenTotalSupplyType.UNLIMITED + ), + ) + ), + messages.MintlayerTxOutput( + issue_nft=messages.MintlayerIssueNftTxOutput( + token_id=token_id, + destination=anyone_can_spend, + ticker="NFTX".encode(), + name="Name".encode(), + description="SomeNFT".encode(), + media_uri=uri, + media_hash="123456".encode(), + ) + ), + messages.MintlayerTxOutput( + data_deposit=messages.MintlayerDataDepositTxOutput( + data=bytes([1, 2, 3]) + ) + ), + messages.MintlayerTxOutput( + htlc=messages.MintlayerHtlcTxOutput( + value=value_1, + secret_hash=bytes([1] * 20), + spend_key=anyone_can_spend, + refund_timelock=messages.MintlayerOutputTimeLock(until_height=10), + refund_key=anyone_can_spend, + ) + ), + messages.MintlayerTxOutput( + create_order=messages.MintlayerCreateOrderTxOutput( + conclude_key=anyone_can_spend, + ask=value_1, + give=value_1, + ) + ), + ] + + client.set_expected_responses( + [ + # ===== inputs + # get First UTXO input + request_input(0), + # get First input's UTXO + request_output(prev_utxo_index), + # get Second token UTXO input + request_input(1), + # get Second token input's UTXO + request_output(prev_utxo_index_token), + # get Second UTXO input with multisig address + request_input(2), + # get Second input's UTXO + request_output(prev_multisig_utxo_index), + # account input + request_input(3), + # account command inputs + request_input(4), + request_input(5), + request_input(6), + request_input(7), + request_input(8), + request_input(9), + request_input(10), + request_input(11), + request_input(12), + # ===== outputs + # get First Output + request_output(0), + messages.ButtonRequest(code=B.ConfirmOutput), + messages.ButtonRequest(code=B.ConfirmOutput), + request_output(1), + messages.ButtonRequest(code=B.ConfirmOutput), + messages.ButtonRequest(code=B.ConfirmOutput), + request_output(2), + messages.ButtonRequest(code=B.ConfirmOutput), + messages.ButtonRequest(code=B.ConfirmOutput), + request_output(3), + messages.ButtonRequest(code=B.ConfirmOutput), + messages.ButtonRequest(code=B.ConfirmOutput), + request_output(4), + messages.ButtonRequest(code=B.ConfirmOutput), + messages.ButtonRequest(code=B.ConfirmOutput), + request_output(5), + messages.ButtonRequest(code=B.ConfirmOutput), + messages.ButtonRequest(code=B.ConfirmOutput), + request_output(6), + messages.ButtonRequest(code=B.ConfirmOutput), + messages.ButtonRequest(code=B.ConfirmOutput), + request_output(7), + messages.ButtonRequest(code=B.ConfirmOutput), + messages.ButtonRequest(code=B.ConfirmOutput), + request_output(8), + messages.ButtonRequest(code=B.ConfirmOutput), + request_output(9), + messages.ButtonRequest(code=B.ConfirmOutput), + messages.ButtonRequest(code=B.ConfirmOutput), + request_output(10), + messages.ButtonRequest(code=B.ConfirmOutput), + request_output(11), + messages.ButtonRequest(code=B.ConfirmOutput), + request_output(12), + messages.ButtonRequest(code=B.ConfirmOutput), + request_output(13), + messages.ButtonRequest(code=B.ConfirmOutput), + messages.ButtonRequest(code=B.ConfirmOutput), + request_output(14), + messages.ButtonRequest(code=B.ConfirmOutput), + # sign tx + messages.ButtonRequest(code=B.SignTx), + # sign tx for the tokens total + messages.ButtonRequest(code=B.SignTx), + request_finished(), + ] + ) + + results = mintlayer.sign_tx(client, chain_type, inputs, outputs, prev_txs) + + expected_multi_sigs = { + 0: sig1, + 2: sig2, + } + expected_sig = sig1 + + assert len(results) == len(inputs) + + for res in results: + for sig in res.signatures: + if sig.multisig_idx is not None: + assert sig.signature.hex() == expected_multi_sigs[sig.multisig_idx] + else: + assert sig.signature.hex() == expected_sig + + +@pytest.mark.altcoin +@pytest.mark.mintlayer +@pytest.mark.setup_client( + mnemonic="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" +) +def test_mintlayer_random_sign_tx(client: Client): + with client: + num_inputs = random.randint(1, 10) + + prev_txs = {} + inputs = [] + input_utxos = [] + total_inputs = 0 + for _ in range(num_inputs): + random_address = random.randint(0, 100) + random_account = random.randint(0, 100) + random_purpose = random.choice([0, 1]) + path = parse_path( + f"m/44h/19788h/{random_account}h/{random_purpose}/{random_address}" + ) + + prev_hash = bytes(random.getrandbits(8) for _ in range(32)) + + random_amount = random.randint(1, 10_000) + total_inputs += random_amount + address = messages.MintlayerAddressPath(address_n=path) + + prev_utxo_index = random.randint(0, 100) + inp = messages.MintlayerTxInput( + utxo=messages.MintlayerUtxoTxInput( + prev_hash=prev_hash, + prev_index=prev_utxo_index, + addresses=[address], + type=random.choice(list(messages.MintlayerUtxoType)), + ) + ) + + value = messages.MintlayerOutputValue( + amount=random_amount.to_bytes(16, byteorder="big") + ) + utxo = messages.MintlayerTransferTxOutput( + address="mxanyonecanspend1qqx4x7pk", value=value + ) + utxo_out = messages.MintlayerTxOutput(transfer=utxo) + + if prev_hash in prev_txs: + prev_txs[prev_hash][prev_utxo_index] = utxo_out + else: + prev_txs[prev_hash] = {prev_utxo_index: utxo_out} + inputs.append(inp) + input_utxos.append((prev_hash, prev_utxo_index)) + + num_outputs = random.randint(1, 10) + outputs = [] + for _ in range(num_outputs): + random_amount = random.randint(0, total_inputs // num_outputs) + value = messages.MintlayerOutputValue( + amount=random_amount.to_bytes(16, byteorder="big") + ) + output = messages.MintlayerTransferTxOutput( + address="mxanyonecanspend1qqx4x7pk", value=value + ) + out = messages.MintlayerTxOutput(transfer=output) + outputs.append(out) + + client.set_expected_responses( + list( + itertools.chain.from_iterable( + [ + [ + # get First input + request_input(input_idx), + # get First input's UTXO + request_output(prev_utxo_index, prev_hash), + ] + for ( + input_idx, + (prev_hash, prev_utxo_index), + ) in enumerate(input_utxos) + ] + + [ + [ + # get First Output + request_output(output_idx), + # confirm Output + messages.ButtonRequest(code=B.ConfirmOutput), + # confirm output + messages.ButtonRequest(code=B.ConfirmOutput), + ] + for output_idx in range(num_outputs) + ] + + [ + [ + # sign tx + messages.ButtonRequest(code=B.SignTx), + request_finished(), + ] + ] + ) + ) + ) + + result = mintlayer.sign_tx(client, 3, inputs, outputs, prev_txs) + + assert len(result) == num_inputs + + +CHAIN_TYPES = [1, 2, 3, 4] + + +@pytest.mark.altcoin +@pytest.mark.mintlayer +@pytest.mark.setup_client( + mnemonic="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" +) +@pytest.mark.parametrize("chain_type", CHAIN_TYPES) +def test_mintlayer_sign_tx_forbidden_path(client: Client, chain_type: int): + coin = CHAIN_TYPE_TO_COIN[chain_type] + + prev_hash = bytes(random.getrandbits(8) for _ in range(32)) + random_amount = random.randint(1, 10_000) + prev_utxo_index = random.randint(0, 100) + + value = messages.MintlayerOutputValue( + amount=random_amount.to_bytes(16, byteorder="big") + ) + + wallet_dest0 = mintlayer.get_address( + client, + chain_type=chain_type, + address_n=parse_path(f"m/44h/{coin}h/0h/0/0"), + show_display=True, + ) + + utxo = messages.MintlayerTransferTxOutput(address=wallet_dest0, value=value) + utxo_out = messages.MintlayerTxOutput(transfer=utxo) + + prev_txs = {prev_hash: {prev_utxo_index: utxo_out}} + + with client: + # invalid coin + with pytest.raises(TrezorFailure, match="Forbidden key path"): + path = parse_path(f"m/44h/{coin + 1}h/0h/0/0") + address = messages.MintlayerAddressPath(address_n=path) + + inp = messages.MintlayerTxInput( + utxo=messages.MintlayerUtxoTxInput( + prev_hash=prev_hash, + prev_index=prev_utxo_index, + addresses=[address], + type=random.choice(list(messages.MintlayerUtxoType)), + ) + ) + mintlayer.sign_tx(client, chain_type, [inp], [], prev_txs) + + # invalid bip44 + with pytest.raises(TrezorFailure, match="Forbidden key path"): + path = parse_path(f"m/43h/{coin}h/0h/0/0") + address = messages.MintlayerAddressPath(address_n=path) + + inp = messages.MintlayerTxInput( + utxo=messages.MintlayerUtxoTxInput( + prev_hash=prev_hash, + prev_index=prev_utxo_index, + addresses=[address], + type=random.choice(list(messages.MintlayerUtxoType)), + ) + ) + mintlayer.sign_tx(client, chain_type, [inp], [], prev_txs) + + # short path + with pytest.raises(TrezorFailure, match="Forbidden key path"): + path = parse_path(f"m/44h/{coin}h") + address = messages.MintlayerAddressPath(address_n=path) + + inp = messages.MintlayerTxInput( + utxo=messages.MintlayerUtxoTxInput( + prev_hash=prev_hash, + prev_index=prev_utxo_index, + addresses=[address], + type=random.choice(list(messages.MintlayerUtxoType)), + ) + ) + mintlayer.sign_tx(client, chain_type, [inp], [], prev_txs) + + # short path + with pytest.raises(TrezorFailure, match="Forbidden key path"): + path = parse_path("m/44h") + address = messages.MintlayerAddressPath(address_n=path) + + inp = messages.MintlayerTxInput( + utxo=messages.MintlayerUtxoTxInput( + prev_hash=prev_hash, + prev_index=prev_utxo_index, + addresses=[address], + type=random.choice(list(messages.MintlayerUtxoType)), + ) + ) + mintlayer.sign_tx(client, chain_type, [inp], [], prev_txs)