From 89ce7275485ecdd84d2aef907bfa21b907870197 Mon Sep 17 00:00:00 2001 From: Saleem Rashid Date: Tue, 30 May 2017 09:34:21 +0100 Subject: [PATCH] protob: Add NEMTransaction & NEMRequestAnnounce --- protob/messages.proto | 27 +++++++++ protob/types.proto | 134 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+) diff --git a/protob/messages.proto b/protob/messages.proto index 97a3fff477..5a521c14c0 100644 --- a/protob/messages.proto +++ b/protob/messages.proto @@ -78,6 +78,8 @@ enum MessageType { MessageType_EthereumMessageSignature = 66 [(wire_out) = true]; MessageType_NEMGetAddress = 67 [(wire_in) = true]; MessageType_NEMAddress = 68 [(wire_out) = true]; + MessageType_NEMTransaction = 69 [(wire_in) = true]; + MessageType_NEMRequestAnnounce = 70 [(wire_out) = true]; MessageType_DebugLinkDecision = 100 [(wire_debug_in) = true, (wire_tiny) = true]; MessageType_DebugLinkGetState = 101 [(wire_debug_in) = true]; MessageType_DebugLinkState = 102 [(wire_debug_out) = true]; @@ -838,6 +840,31 @@ message NEMAddress { required string address = 1; // NEM address in Base32 encoding } +/** + * Request: Ask device to sign transaction + * @next NEMRequestAnnounce + * @next Failure + */ +message NEMTransaction { + optional NEMTransactionCommon transaction = 1; // Common part of transaction + optional NEMTransactionCommon multisig = 2; // Common part of inner transaction for multisig transactions + optional NEMTransfer transfer = 3; // Transfer transaction part + optional bool cosigning = 4; // Whether cosigning or initiating the multisig transaction + optional NEMProvisionNamespace provision_namespace = 5; // Provision namespace part + optional NEMMosaicCreation mosaic_creation = 6; // Mosaic definition creation part + optional NEMMosaicSupplyChange supply_change = 7; // Mosaic supply change part + optional NEMAggregateModification aggregate_modification = 8; // Aggregate modification part +} + +/** + * Response: Contains NEM transaction data and signature + * @prev NEMTransaction + */ +message NEMRequestAnnounce { + optional bytes data = 1; // Transaction data + optional bytes signature = 2; // Signature for the transaction +} + ///////////////////////////////////////////////////////////// // Debug messages (only available if DebugLink is enabled) // ///////////////////////////////////////////////////////////// diff --git a/protob/types.proto b/protob/types.proto index ee15ab3d34..48091f0cf5 100644 --- a/protob/types.proto +++ b/protob/types.proto @@ -270,3 +270,137 @@ message IdentityType { optional string path = 5; // path part of URI optional uint32 index = 6 [default=0]; // identity index } + +/** + * Structure representing the common part for NEM transactions + * @used_in NEMTransaction + */ +message NEMTransactionCommon { + repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node + optional uint32 network = 2; // Network ID (0x68 = Mainnet, 0x98 = Testnet, 0x60 = Mijin) + optional uint32 timestamp = 3; // Number of seconds elapsed since the creation of the nemesis block + optional uint64 fee = 4; // Fee for the transaction + optional uint32 deadline = 5; // Deadline of the transaction + optional bytes signer = 6; // Public key of the account (for multisig transactions) +} + +/** + * Structure representing the transfer transaction part for NEM transactions + * @used_in NEMTransaction + */ +message NEMTransfer { + optional string recipient = 1; // Address of the recipient + optional uint64 amount = 2; // Amount of micro NEM that is transferred + optional bytes payload = 3; // Actual message data (unencrypted) + optional bytes public_key = 4; // Public key of the recipient (for encrypted payloads) + repeated NEMMosaic mosaics = 5; // Attached mosaics +} + +/** + * Structure representing the mosaic attachment for NEM transfer transactions + * @used_in NEMTransfer + */ +message NEMMosaic { + optional string namespace = 1; // Fully qualified name of the namespace + optional string mosaic = 2; // Name of the mosaic definition + optional uint64 quantity = 3; // Mosaic quantity, always given in smallest units +} + +/** + * Structure representing the provision namespace part for NEM transactions + * @used_in NEMTransaction + */ +message NEMProvisionNamespace { + optional string namespace = 1; // New part concatenated to the parent + optional string parent = 2; // Parent namespace (for child namespaces) + optional string sink = 3; // Rental fee sink address + optional uint64 fee = 4; // Rental fee +} + +/** + * Type of levy which will be used for mosaic + * @used_in NEMMosaicDefinition + */ +enum NEMMosaicLevy { + MosaicLevy_Absolute = 1; + MosaicLevy_Percentile = 2; +} + +/** + * Structure representing the mosaic definition creation part for NEM transactions + * @used_in NEMTransaction + */ +message NEMMosaicCreation { + optional NEMMosaicDefinition definition = 1; // Mosaic definition + optional string sink = 2; // Creation fee sink address + optional uint64 fee = 3; // Creation fee +} + +/** + * Structure representing a mosaic definition + * @used_in NEMMosaicCreation + */ +message NEMMosaicDefinition { + optional string name = 1; // User-friendly name of the mosaic (for whitelisted mosaics) + optional string ticker = 2; // Ticker of the mosaic (for whitelisted mosaics) + optional string namespace = 3; // Fully qualified name of the namespace + optional string mosaic = 4; // Name of the mosaic definition + optional uint32 divisibility = 5; // Number of decimal places that a mosaic can be divided into + optional NEMMosaicLevy levy = 6; // Levy type + optional uint64 fee = 7; // Levy fee (interpretation depends on levy type) + optional string levy_address = 8; // Levy address + optional string levy_namespace = 9; // Fully qualified name of the namespace of the levy mosaic + optional string levy_mosaic = 10; // Name of the levy mosaic + optional uint64 supply = 11; // Initial supply to create, always given in entire units + optional bool mutable_supply = 12; // Mutable supply + optional bool transferable = 13; // Mosaic allows transfers among accounts other than the creator + optional string description = 14; // Mosaic description + repeated uint32 networks = 15; // Networks that the mosaic is valid on (for whitelisted mosaics) +} + +/** + * Structure representing the mosaic supply change part for NEM transactions + * @used_in NEMTransaction + */ +message NEMMosaicSupplyChange { + optional string namespace = 1; // Fully qualified name of the namespace + optional string mosaic = 2; // Name of the mosaic definition + optional NEMSupplyChangeType type = 3; // Type of supply change + optional uint64 delta = 4; // Supply delta +} + +/** + * Type of supply change which will be applied to mosaic + * @used_in NEMMosaicSupplyChange + */ +enum NEMSupplyChangeType { + SupplyChange_Increase = 1; + SupplyChange_Decrease = 2; +} + +/** + * Structure representing the aggregate modification part for NEM transactions + * @used_in NEMTransaction + */ +message NEMAggregateModification { + repeated NEMCosignatoryModification modifications = 1; // Cosignatory modifications + optional sint32 relative_change = 2; // Relative change of the minimum cosignatories +} + +/** + * Structure representing the cosignatory modification for aggregate modification transactions + * @used_in NEMAggregateMdofiication + */ +message NEMCosignatoryModification { + optional NEMModificationType type = 1; // Type of cosignatory modification + optional bytes public_key = 2; // Public key of the cosignatory +} + +/** + * Type of cosignatory modification + * @used_in NEMCosignatoryModification + */ +enum NEMModificationType { + CosignatoryModification_Add = 1; + CosignatoryModification_Delete = 2; +}