mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 23:48:12 +00:00
Merge pull request #223 from saleemrashid/nem-importance-transfer
NEM Importance Transfer Transaction Support
This commit is contained in:
commit
4b87e50e1c
@ -1160,7 +1160,8 @@ void fsm_msgNEMSignTx(NEMSignTx *msg) {
|
||||
msg->has_provision_namespace +
|
||||
msg->has_mosaic_creation +
|
||||
msg->has_supply_change +
|
||||
msg->has_aggregate_modification;
|
||||
msg->has_aggregate_modification +
|
||||
msg->has_importance_transfer;
|
||||
CHECK_PARAM(provided != 0, _("No transaction provided"));
|
||||
CHECK_PARAM(provided == 1, _("More than one transaction provided"));
|
||||
|
||||
@ -1170,6 +1171,7 @@ void fsm_msgNEMSignTx(NEMSignTx *msg) {
|
||||
NEM_CHECK_PARAM_WHEN(msg->has_mosaic_creation, nem_validate_mosaic_creation(&msg->mosaic_creation, msg->transaction.network));
|
||||
NEM_CHECK_PARAM_WHEN(msg->has_supply_change, nem_validate_supply_change(&msg->supply_change));
|
||||
NEM_CHECK_PARAM_WHEN(msg->has_aggregate_modification, nem_validate_aggregate_modification(&msg->aggregate_modification, !msg->has_multisig));
|
||||
NEM_CHECK_PARAM_WHEN(msg->has_importance_transfer, nem_validate_importance_transfer(&msg->importance_transfer));
|
||||
|
||||
bool cosigning = msg->has_cosigning && msg->cosigning;
|
||||
if (msg->has_multisig) {
|
||||
@ -1242,6 +1244,12 @@ void fsm_msgNEMSignTx(NEMSignTx *msg) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg->has_importance_transfer && !nem_askImportanceTransfer(common, &msg->importance_transfer, network)) {
|
||||
fsm_sendFailure(FailureType_Failure_ActionCancelled, _("Signing cancelled by user"));
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
|
||||
nem_transaction_ctx context;
|
||||
nem_transaction_start(&context, &node->public_key[1], resp->data.bytes, sizeof(resp->data.bytes));
|
||||
|
||||
@ -1276,6 +1284,11 @@ void fsm_msgNEMSignTx(NEMSignTx *msg) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg->has_importance_transfer && !nem_fsmImportanceTransfer(&inner, &msg->multisig, &msg->importance_transfer)) {
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!nem_fsmMultisig(&context, &msg->transaction, &inner, cosigning)) {
|
||||
layoutHome();
|
||||
return;
|
||||
@ -1305,6 +1318,11 @@ void fsm_msgNEMSignTx(NEMSignTx *msg) {
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg->has_importance_transfer && !nem_fsmImportanceTransfer(&context, &msg->transaction, &msg->importance_transfer)) {
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
resp->has_data = true;
|
||||
|
@ -155,6 +155,14 @@ const char *nem_validate_aggregate_modification(const NEMAggregateModification *
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *nem_validate_importance_transfer(const NEMImportanceTransfer *importance_transfer) {
|
||||
if (!importance_transfer->has_mode) return _("No mode provided");
|
||||
if (!importance_transfer->has_public_key) return _("No remote account provided");
|
||||
if (importance_transfer->public_key.size != 32) return _("Invalid remote account provided");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool nem_askTransfer(const NEMTransactionCommon *common, const NEMTransfer *transfer, const char *desc) {
|
||||
if (transfer->mosaics_count) {
|
||||
const NEMMosaic *xem = NULL;
|
||||
@ -608,6 +616,40 @@ bool nem_fsmAggregateModification(nem_transaction_ctx *context, const NEMTransac
|
||||
return true;
|
||||
}
|
||||
|
||||
bool nem_askImportanceTransfer(const NEMTransactionCommon *common, const NEMImportanceTransfer *importance_transfer, const char *desc) {
|
||||
layoutDialogSwipe(&bmp_icon_question,
|
||||
_("Cancel"),
|
||||
_("Next"),
|
||||
desc,
|
||||
importance_transfer->mode == NEMImportanceTransferMode_ImportanceTransfer_Activate ? _("Activate remote") : _("Deactivate remote"),
|
||||
_("harvesting?"),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
layoutNEMNetworkFee(desc, true, _("Confirm network fee"), common->fee, NULL, 0);
|
||||
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool nem_fsmImportanceTransfer(nem_transaction_ctx *context, const NEMTransactionCommon *common, const NEMImportanceTransfer *importance_transfer) {
|
||||
return nem_transaction_create_importance_transfer(context,
|
||||
common->network,
|
||||
common->timestamp,
|
||||
NULL,
|
||||
common->fee,
|
||||
common->deadline,
|
||||
importance_transfer->mode,
|
||||
importance_transfer->public_key.bytes);
|
||||
}
|
||||
|
||||
bool nem_askMultisig(const char *address, const char *desc, bool cosigning, uint64_t fee) {
|
||||
layoutNEMDialog(&bmp_icon_question,
|
||||
_("Cancel"),
|
||||
|
@ -34,6 +34,7 @@ const char *nem_validate_provision_namespace(const NEMProvisionNamespace *provis
|
||||
const char *nem_validate_mosaic_creation(const NEMMosaicCreation *mosaic_creation, uint8_t network);
|
||||
const char *nem_validate_supply_change(const NEMMosaicSupplyChange *supply_change);
|
||||
const char *nem_validate_aggregate_modification(const NEMAggregateModification *aggregate_modification, bool creation);
|
||||
const char *nem_validate_importance_transfer(const NEMImportanceTransfer *importance_transfer);
|
||||
|
||||
bool nem_askTransfer(const NEMTransactionCommon *common, const NEMTransfer *transfer, const char *desc);
|
||||
bool nem_fsmTransfer(nem_transaction_ctx *context, const HDNode *node, const NEMTransactionCommon *common, const NEMTransfer *transfer);
|
||||
@ -50,6 +51,9 @@ bool nem_fsmSupplyChange(nem_transaction_ctx *context, const NEMTransactionCommo
|
||||
bool nem_askAggregateModification(const NEMTransactionCommon *common, const NEMAggregateModification *aggregate_modification, const char *desc, bool creation);
|
||||
bool nem_fsmAggregateModification(nem_transaction_ctx *context, const NEMTransactionCommon *common, const NEMAggregateModification *aggregate_modification);
|
||||
|
||||
bool nem_askImportanceTransfer(const NEMTransactionCommon *common, const NEMImportanceTransfer *importance_transfer, const char *desc);
|
||||
bool nem_fsmImportanceTransfer(nem_transaction_ctx *context, const NEMTransactionCommon *common, const NEMImportanceTransfer *importance_transfer);
|
||||
|
||||
bool nem_askMultisig(const char *address, const char *desc, bool cosigning, uint64_t fee);
|
||||
bool nem_fsmMultisig(nem_transaction_ctx *context, const NEMTransactionCommon *common, const nem_transaction_ctx *inner, bool cosigning);
|
||||
|
||||
|
@ -70,3 +70,5 @@ NEMMosaicSupplyChange.mosaic max_size:33
|
||||
NEMAggregateModification.modifications max_count:16
|
||||
|
||||
NEMCosignatoryModification.public_key max_size:32
|
||||
|
||||
NEMImportanceTransfer.public_key max_size:32
|
||||
|
2
vendor/trezor-common
vendored
2
vendor/trezor-common
vendored
@ -1 +1 @@
|
||||
Subproject commit c20bb1c567ac0c1ddabf74354f204043eeacad10
|
||||
Subproject commit b9a2a9c3defd8a4b84d674116cbae2cf46b6080b
|
2
vendor/trezor-crypto
vendored
2
vendor/trezor-crypto
vendored
@ -1 +1 @@
|
||||
Subproject commit 9c919856747a6a519e5a553cc9b67f1c408337af
|
||||
Subproject commit 636320da585ddb5f5c26257cfb724efd34cde50b
|
Loading…
Reference in New Issue
Block a user