From 2f8d68740564e6e701319875e0016db087d7461d Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Sat, 21 Nov 2020 12:24:10 +0100 Subject: [PATCH] feat(legacy): implement GetPublicKey.ignore_xpub_magic behaviour --- legacy/firmware/fsm_msg_coin.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/legacy/firmware/fsm_msg_coin.h b/legacy/firmware/fsm_msg_coin.h index be4b398d28..1cddd232fb 100644 --- a/legacy/firmware/fsm_msg_coin.h +++ b/legacy/firmware/fsm_msg_coin.h @@ -59,14 +59,24 @@ void fsm_msgGetPublicKey(const GetPublicKey *msg) { script_type == InputScriptType_SPENDMULTISIG)) { hdnode_serialize_public(node, fingerprint, coin->xpub_magic, resp->xpub, sizeof(resp->xpub)); - } else if (coin->has_segwit && coin->xpub_magic_segwit_p2sh && - script_type == InputScriptType_SPENDP2SHWITNESS) { + } else if (coin->has_segwit && + script_type == InputScriptType_SPENDP2SHWITNESS && + !msg->ignore_xpub_magic && coin->xpub_magic_segwit_p2sh) { hdnode_serialize_public(node, fingerprint, coin->xpub_magic_segwit_p2sh, resp->xpub, sizeof(resp->xpub)); - } else if (coin->has_segwit && coin->xpub_magic_segwit_native && - script_type == InputScriptType_SPENDWITNESS) { + } else if (coin->has_segwit && + script_type == InputScriptType_SPENDP2SHWITNESS && + msg->ignore_xpub_magic && coin->xpub_magic) { + hdnode_serialize_public(node, fingerprint, coin->xpub_magic, resp->xpub, + sizeof(resp->xpub)); + } else if (coin->has_segwit && script_type == InputScriptType_SPENDWITNESS && + !msg->ignore_xpub_magic && coin->xpub_magic_segwit_native) { hdnode_serialize_public(node, fingerprint, coin->xpub_magic_segwit_native, resp->xpub, sizeof(resp->xpub)); + } else if (coin->has_segwit && script_type == InputScriptType_SPENDWITNESS && + msg->ignore_xpub_magic && coin->xpub_magic) { + hdnode_serialize_public(node, fingerprint, coin->xpub_magic, resp->xpub, + sizeof(resp->xpub)); } else { fsm_sendFailure(FailureType_Failure_DataError, _("Invalid combination of coin and script_type"));